dom-render 1.0.91 → 1.0.92
Sign up to get free protection for your applications and to get access to all the features.
- package/DomRender.js +5 -1
- package/DomRenderProxy.d.ts +1 -1
- package/DomRenderProxy.js +121 -63
- package/README.MD +14 -2
- package/configs/TargetElement.d.ts +1 -1
- package/dist/bundle.js +1189 -835
- package/events/EventManager.js +1 -0
- package/operators/Dr.d.ts +1 -1
- package/operators/Dr.js +58 -17
- package/operators/DrAppender.d.ts +1 -1
- package/operators/DrAppender.js +61 -21
- package/operators/DrFor.d.ts +1 -1
- package/operators/DrFor.js +58 -17
- package/operators/DrForOf.d.ts +1 -1
- package/operators/DrForOf.js +61 -20
- package/operators/DrForm.d.ts +1 -1
- package/operators/DrForm.js +87 -46
- package/operators/DrIf.d.ts +1 -1
- package/operators/DrIf.js +62 -23
- package/operators/DrInnerHTML.d.ts +1 -1
- package/operators/DrInnerHTML.js +56 -15
- package/operators/DrInnerText.d.ts +1 -1
- package/operators/DrInnerText.js +54 -13
- package/operators/DrPre.d.ts +1 -1
- package/operators/DrPre.js +41 -1
- package/operators/DrRepeat.d.ts +1 -1
- package/operators/DrRepeat.js +58 -17
- package/operators/DrTargetAttr.d.ts +1 -1
- package/operators/DrTargetAttr.js +64 -23
- package/operators/DrTargetElement.d.ts +1 -1
- package/operators/DrTargetElement.js +78 -34
- package/operators/DrThis.d.ts +1 -1
- package/operators/DrThis.js +73 -23
- package/operators/OperatorExecuter.d.ts +3 -2
- package/operators/OperatorExecuter.js +60 -14
- package/operators/OperatorExecuterAttrRequire.d.ts +2 -2
- package/operators/OperatorExecuterAttrRequire.js +48 -24
- package/package.json +1 -1
- package/rawsets/RawSet.d.ts +3 -3
- package/rawsets/RawSet.js +458 -315
- package/routers/HashRouter.js +1 -1
- package/routers/PathRouter.js +1 -1
- package/routers/Router.d.ts +3 -0
- package/routers/Router.js +10 -0
package/operators/DrRepeat.js
CHANGED
@@ -25,6 +25,42 @@ var __assign = (this && this.__assign) || function () {
|
|
25
25
|
};
|
26
26
|
return __assign.apply(this, arguments);
|
27
27
|
};
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
35
|
+
});
|
36
|
+
};
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
41
|
+
function step(op) {
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
43
|
+
while (_) try {
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
46
|
+
switch (op[0]) {
|
47
|
+
case 0: case 1: t = op; break;
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
51
|
+
default:
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
56
|
+
if (t[2]) _.ops.pop();
|
57
|
+
_.trys.pop(); continue;
|
58
|
+
}
|
59
|
+
op = body.call(thisArg, _);
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
62
|
+
}
|
63
|
+
};
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
65
|
exports.DrRepeat = void 0;
|
30
66
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -41,23 +77,28 @@ var DrRepeat = /** @class */ (function (_super) {
|
|
41
77
|
return _this;
|
42
78
|
}
|
43
79
|
DrRepeat.prototype.executeAttrRequire = function (attr) {
|
44
|
-
var _a;
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
80
|
+
var _a, _b, _c, _d;
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
82
|
+
var itRandom, vars, newTemp, tempalte, rr;
|
83
|
+
var _e;
|
84
|
+
return __generator(this, function (_f) {
|
85
|
+
itRandom = RawSet_1.RawSet.drItOtherEncoding(this.elementSource.element);
|
86
|
+
vars = RawSet_1.RawSet.drVarEncoding(this.elementSource.element, (_a = this.elementSource.attrs.drVarOption) !== null && _a !== void 0 ? _a : '');
|
87
|
+
newTemp = this.source.config.window.document.createElement('temp');
|
88
|
+
ScriptUtils_1.ScriptUtils.eval("\n ".concat(this.render.bindScript, "\n ").concat((_b = this.elementSource.attrs.drBeforeOption) !== null && _b !== void 0 ? _b : '', "\n var i = 0; \n const repeat = ").concat(attr, ";\n const repeatStr = `").concat(attr, "`;\n let range = repeat;\n if (typeof repeat === 'number') {\n range = ").concat(EventManager_1.EventManager.RANGE_VARNAME, "(repeat);\n } \n for(const it of range) {\n var destIt = it;\n if (range.isRange) {\n destIt = it;\n } else {\n destIt = repeatStr + '[' + i +']'\n }\n const n = this.__render.element.cloneNode(true);\n n.getAttributeNames().forEach(it => n.setAttribute(it, n.getAttribute(it).replace(/\\#it\\#/g, destIt).replace(/\\#nearRangeIt\\#/g, destIt).replace(/\\#nearRangeIndex\\#/g, destIt)))\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt).replace(/\\#index\\#/g, destIt);\n \n if (this.__render.drStripOption === 'true') {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }\n ").concat((_c = this.elementSource.attrs.drAfterOption) !== null && _c !== void 0 ? _c : '', "\n "), Object.assign(this.source.obj, {
|
89
|
+
__render: Object.freeze(__assign({ fag: newTemp, drStripOption: this.elementSource.attrs.drStripOption }, this.render))
|
90
|
+
}));
|
91
|
+
RawSet_1.RawSet.drVarDecoding(newTemp, vars);
|
92
|
+
RawSet_1.RawSet.drItOtherDecoding(newTemp, itRandom);
|
93
|
+
tempalte = this.source.config.window.document.createElement('template');
|
94
|
+
tempalte.innerHTML = newTemp.innerHTML;
|
95
|
+
this.returnContainer.fag.append(tempalte.content);
|
96
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
97
|
+
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
98
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
99
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
100
|
+
});
|
101
|
+
});
|
61
102
|
};
|
62
103
|
return DrRepeat;
|
63
104
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
@@ -3,5 +3,5 @@ import { AfterCallBack, ElementSource, ExecuteState, OperatorExecuter, ReturnCon
|
|
3
3
|
import { Render } from '../rawsets/Render';
|
4
4
|
export declare class DrTargetAttr extends OperatorExecuter<void> {
|
5
5
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
6
|
-
execute(): ExecuteState
|
6
|
+
execute(): Promise<ExecuteState>;
|
7
7
|
}
|
@@ -14,6 +14,42 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrTargetAttr = void 0;
|
19
55
|
var RawSet_1 = require("../rawsets/RawSet");
|
@@ -27,30 +63,35 @@ var DrTargetAttr = /** @class */ (function (_super) {
|
|
27
63
|
return _this;
|
28
64
|
}
|
29
65
|
DrTargetAttr.prototype.execute = function () {
|
30
|
-
var _a;
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
66
|
+
var _a, _b, _c, _d;
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
68
|
+
var attributeNames, targetAttr, attrName, attrValue, documentFragment, rr;
|
69
|
+
var _e;
|
70
|
+
return __generator(this, function (_f) {
|
71
|
+
attributeNames = this.elementSource.element.getAttributeNames();
|
72
|
+
targetAttr = (_b = (_a = this.source.config) === null || _a === void 0 ? void 0 : _a.targetAttrs) === null || _b === void 0 ? void 0 : _b.find(function (it) { return attributeNames.includes(it.name); });
|
73
|
+
if (targetAttr) {
|
74
|
+
attrName = targetAttr.name;
|
75
|
+
attrValue = this.rawSet.getAttributeAndDelete(this.elementSource.element, attrName);
|
76
|
+
if (attrValue && attrName && (!this.elementSource.attrs.drForOf && !this.elementSource.attrs.drFor && !this.elementSource.attrs.drRepeat)) {
|
77
|
+
documentFragment = targetAttr.callBack(this.elementSource.element, attrValue, this.source.obj, this.rawSet);
|
78
|
+
if (documentFragment) {
|
79
|
+
rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
|
80
|
+
(_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(documentFragment, this.elementSource.element);
|
81
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
82
|
+
this.afterCallBack.onAttrInitCallBacks.push({
|
83
|
+
attrName: attrName,
|
84
|
+
attrValue: attrValue,
|
85
|
+
obj: this.source.obj
|
86
|
+
});
|
87
|
+
(_d = targetAttr === null || targetAttr === void 0 ? void 0 : targetAttr.complete) === null || _d === void 0 ? void 0 : _d.call(targetAttr, this.elementSource.element, attrValue, this.source.obj, this.rawSet);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
49
91
|
}
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
return OperatorExecuter_1.ExecuteState.NO_EXECUTE;
|
92
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.NO_EXECUTE];
|
93
|
+
});
|
94
|
+
});
|
54
95
|
};
|
55
96
|
return DrTargetAttr;
|
56
97
|
}(OperatorExecuter_1.OperatorExecuter));
|
@@ -3,5 +3,5 @@ import { AfterCallBack, ElementSource, ExecuteState, OperatorExecuter, ReturnCon
|
|
3
3
|
import { Render } from '../rawsets/Render';
|
4
4
|
export declare class DrTargetElement extends OperatorExecuter<void> {
|
5
5
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack);
|
6
|
-
execute(): ExecuteState
|
6
|
+
execute(): Promise<ExecuteState>;
|
7
7
|
}
|
@@ -14,6 +14,42 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrTargetElement = void 0;
|
19
55
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
@@ -28,42 +64,50 @@ var DrTargetElement = /** @class */ (function (_super) {
|
|
28
64
|
return _this;
|
29
65
|
}
|
30
66
|
DrTargetElement.prototype.execute = function () {
|
31
|
-
var _a;
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
67
|
+
var _a, _b, _c, _d;
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
69
|
+
var targetElement, documentFragment, detectAction_1, render_1, rr;
|
70
|
+
var _e;
|
71
|
+
var _this = this;
|
72
|
+
return __generator(this, function (_f) {
|
73
|
+
switch (_f.label) {
|
74
|
+
case 0:
|
75
|
+
targetElement = (_b = (_a = this.source.config) === null || _a === void 0 ? void 0 : _a.targetElements) === null || _b === void 0 ? void 0 : _b.find(function (it) { return it.name.toLowerCase() === _this.elementSource.element.tagName.toLowerCase(); });
|
76
|
+
if (!targetElement) return [3 /*break*/, 2];
|
77
|
+
return [4 /*yield*/, targetElement.callBack(this.elementSource.element, this.source.obj, this.rawSet, this.elementSource.attrs, this.source.config)];
|
78
|
+
case 1:
|
79
|
+
documentFragment = _f.sent();
|
80
|
+
if (documentFragment) {
|
81
|
+
detectAction_1 = this.elementSource.element.getAttribute(RawSet_1.RawSet.DR_DETECT_NAME);
|
82
|
+
render_1 = documentFragment.render;
|
83
|
+
this.rawSet.fragment = documentFragment;
|
84
|
+
this.rawSet.data = render_1.component;
|
85
|
+
if (detectAction_1 && render_1) {
|
86
|
+
this.rawSet.detect = {
|
87
|
+
action: function () {
|
88
|
+
var script = "var $component = this.__render.component; var $element = this.__render.element; var $innerHTML = this.__render.innerHTML; var $attribute = this.__render.attribute; ".concat(detectAction_1, " ");
|
89
|
+
ScriptUtils_1.ScriptUtils.eval(script, Object.assign(_this.source.obj, {
|
90
|
+
__render: render_1
|
91
|
+
}));
|
92
|
+
}
|
93
|
+
};
|
94
|
+
}
|
95
|
+
rr = RawSet_1.RawSet.checkPointCreates(documentFragment, this.source.obj, this.source.config);
|
96
|
+
(_c = this.elementSource.element.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(documentFragment, this.elementSource.element);
|
97
|
+
(_e = this.returnContainer.raws).push.apply(_e, rr);
|
98
|
+
this.afterCallBack.onElementInitCallBacks.push({
|
99
|
+
name: targetElement.name.toLowerCase(),
|
100
|
+
obj: this.source.obj,
|
101
|
+
targetElement: targetElement,
|
102
|
+
creatorMetaData: targetElement.__creatorMetaData
|
103
|
+
});
|
104
|
+
(_d = targetElement === null || targetElement === void 0 ? void 0 : targetElement.complete) === null || _d === void 0 ? void 0 : _d.call(targetElement, this.elementSource.element, this.source.obj, this.rawSet);
|
49
105
|
}
|
50
|
-
|
106
|
+
return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
107
|
+
case 2: return [2 /*return*/, OperatorExecuter_1.ExecuteState.NO_EXECUTE];
|
51
108
|
}
|
52
|
-
|
53
|
-
|
54
|
-
(_d = this.elementSource.element.parentNode) === null || _d === void 0 ? void 0 : _d.replaceChild(documentFragment, this.elementSource.element);
|
55
|
-
(_a = this.returnContainer.raws).push.apply(_a, rr);
|
56
|
-
this.afterCallBack.onElementInitCallBacks.push({
|
57
|
-
name: targetElement.name.toLowerCase(),
|
58
|
-
obj: this.source.obj,
|
59
|
-
targetElement: targetElement,
|
60
|
-
creatorMetaData: targetElement.__creatorMetaData
|
61
|
-
});
|
62
|
-
(_e = targetElement === null || targetElement === void 0 ? void 0 : targetElement.complete) === null || _e === void 0 ? void 0 : _e.call(targetElement, this.elementSource.element, this.source.obj, this.rawSet);
|
63
|
-
}
|
64
|
-
return OperatorExecuter_1.ExecuteState.EXECUTE;
|
65
|
-
}
|
66
|
-
return OperatorExecuter_1.ExecuteState.NO_EXECUTE;
|
109
|
+
});
|
110
|
+
});
|
67
111
|
};
|
68
112
|
return DrTargetElement;
|
69
113
|
}(OperatorExecuter_1.OperatorExecuter));
|
package/operators/DrThis.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { OperatorExecuterAttrRequire } from './OperatorExecuterAttrRequire';
|
2
2
|
import { ExecuteState } from './OperatorExecuter';
|
3
3
|
export declare class DrThis extends OperatorExecuterAttrRequire<string> {
|
4
|
-
executeAttrRequire(attr: any): ExecuteState
|
4
|
+
executeAttrRequire(attr: any): Promise<ExecuteState>;
|
5
5
|
}
|
package/operators/DrThis.js
CHANGED
@@ -14,6 +14,42 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (_) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
17
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
54
|
exports.DrThis = void 0;
|
19
55
|
var OperatorExecuterAttrRequire_1 = require("./OperatorExecuterAttrRequire");
|
@@ -26,30 +62,44 @@ var DrThis = /** @class */ (function (_super) {
|
|
26
62
|
return _super !== null && _super.apply(this, arguments) || this;
|
27
63
|
}
|
28
64
|
DrThis.prototype.executeAttrRequire = function (attr) {
|
29
|
-
var _a;
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
65
|
+
var _a, _b, _c, _d, _e;
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
67
|
+
var destroyOptions, componentBody, _f, _g, rr;
|
68
|
+
var _h;
|
69
|
+
return __generator(this, function (_j) {
|
70
|
+
switch (_j.label) {
|
71
|
+
case 0:
|
72
|
+
if (!(attr && this.elementSource.attrs.drThis)) return [3 /*break*/, 5];
|
73
|
+
if (!(attr instanceof ComponentSet_1.ComponentSet)) return [3 /*break*/, 2];
|
74
|
+
if (this.rawSet.data) {
|
75
|
+
destroyOptions = (_b = (_a = this.elementSource.attrs.drDestroyOption) === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : [];
|
76
|
+
RawSet_1.RawSet.destroy(this.rawSet.data.obj, [], this.source.config, destroyOptions);
|
77
|
+
}
|
78
|
+
this.rawSet.data = attr;
|
79
|
+
return [4 /*yield*/, RawSet_1.RawSet.drThisCreate(this.rawSet, this.elementSource.element, "".concat(this.elementSource.attrs.drThis).concat(attr.config.objPath ? ('.' + attr.config.objPath) : ''), (_c = this.elementSource.attrs.drVarOption) !== null && _c !== void 0 ? _c : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config, attr)];
|
80
|
+
case 1:
|
81
|
+
componentBody = _j.sent();
|
82
|
+
this.returnContainer.fag.append(componentBody);
|
83
|
+
this.afterCallBack.onThisComponentSetCallBacks.push(attr);
|
84
|
+
return [3 /*break*/, 4];
|
85
|
+
case 2:
|
86
|
+
_g = (_f = this.returnContainer.fag).append;
|
87
|
+
return [4 /*yield*/, RawSet_1.RawSet.drThisCreate(this.rawSet, this.elementSource.element, this.elementSource.attrs.drThis, (_d = this.elementSource.attrs.drVarOption) !== null && _d !== void 0 ? _d : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config)];
|
88
|
+
case 3:
|
89
|
+
_g.apply(_f, [_j.sent()]);
|
90
|
+
_j.label = 4;
|
91
|
+
case 4:
|
92
|
+
rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
93
|
+
(_e = this.elementSource.element.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
94
|
+
(_h = this.returnContainer.raws).push.apply(_h, rr);
|
95
|
+
return [3 /*break*/, 6];
|
96
|
+
case 5:
|
97
|
+
this.elementSource.element.remove();
|
98
|
+
_j.label = 6;
|
99
|
+
case 6: return [2 /*return*/, OperatorExecuter_1.ExecuteState.EXECUTE];
|
36
100
|
}
|
37
|
-
|
38
|
-
|
39
|
-
this.returnContainer.fag.append(componentBody);
|
40
|
-
this.afterCallBack.onThisComponentSetCallBacks.push(attr);
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
this.returnContainer.fag.append(RawSet_1.RawSet.drThisCreate(this.rawSet, this.elementSource.element, this.elementSource.attrs.drThis, (_e = this.elementSource.attrs.drVarOption) !== null && _e !== void 0 ? _e : '', this.elementSource.attrs.drStripOption, this.source.obj, this.source.config));
|
44
|
-
}
|
45
|
-
var rr = RawSet_1.RawSet.checkPointCreates(this.returnContainer.fag, this.source.obj, this.source.config);
|
46
|
-
(_f = this.elementSource.element.parentNode) === null || _f === void 0 ? void 0 : _f.replaceChild(this.returnContainer.fag, this.elementSource.element);
|
47
|
-
(_a = this.returnContainer.raws).push.apply(_a, rr);
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
this.elementSource.element.remove();
|
51
|
-
}
|
52
|
-
return OperatorExecuter_1.ExecuteState.EXECUTE;
|
101
|
+
});
|
102
|
+
});
|
53
103
|
};
|
54
104
|
return DrThis;
|
55
105
|
}(OperatorExecuterAttrRequire_1.OperatorExecuterAttrRequire));
|
@@ -28,6 +28,7 @@ export declare type ElementSource = {
|
|
28
28
|
element: Element;
|
29
29
|
attrs: Attrs;
|
30
30
|
attr?: string | null;
|
31
|
+
attrName?: string | undefined;
|
31
32
|
};
|
32
33
|
export declare type Source = {
|
33
34
|
config: Config;
|
@@ -43,6 +44,6 @@ export declare abstract class OperatorExecuter<T = any> {
|
|
43
44
|
afterCallBack: AfterCallBack;
|
44
45
|
startingExecute: boolean;
|
45
46
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack, startingExecute?: boolean);
|
46
|
-
start(): ExecuteState
|
47
|
-
abstract execute(value: T): ExecuteState
|
47
|
+
start(): Promise<ExecuteState>;
|
48
|
+
abstract execute(value: T): Promise<ExecuteState>;
|
48
49
|
}
|
@@ -1,4 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (_) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
39
|
exports.OperatorExecuter = exports.ExecuteState = void 0;
|
4
40
|
var ScriptUtils_1 = require("../utils/script/ScriptUtils");
|
@@ -22,20 +58,30 @@ var OperatorExecuter = /** @class */ (function () {
|
|
22
58
|
;
|
23
59
|
OperatorExecuter.prototype.start = function () {
|
24
60
|
var _a, _b, _c, _d, _e, _f;
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
62
|
+
var attrValue, r, state;
|
63
|
+
return __generator(this, function (_g) {
|
64
|
+
switch (_g.label) {
|
65
|
+
case 0:
|
66
|
+
attrValue = this.elementSource.attr;
|
67
|
+
if ((_a = this.source.operatorAround) === null || _a === void 0 ? void 0 : _a.beforeAttr) {
|
68
|
+
attrValue = (_b = this.source.operatorAround.beforeAttr(attrValue, this)) !== null && _b !== void 0 ? _b : '';
|
69
|
+
}
|
70
|
+
r = attrValue;
|
71
|
+
if (r && this.startingExecute) {
|
72
|
+
r = ScriptUtils_1.ScriptUtils.eval(" ".concat(this.render.bindScript, "; return ").concat(attrValue), Object.assign(this.source.obj, { __render: this.render }));
|
73
|
+
}
|
74
|
+
if ((_c = this.source.operatorAround) === null || _c === void 0 ? void 0 : _c.before) {
|
75
|
+
r = (_d = this.source.operatorAround) === null || _d === void 0 ? void 0 : _d.before(r, this);
|
76
|
+
}
|
77
|
+
return [4 /*yield*/, this.execute(r)];
|
78
|
+
case 1:
|
79
|
+
state = _g.sent();
|
80
|
+
(_f = (_e = this.source.operatorAround) === null || _e === void 0 ? void 0 : _e.after) === null || _f === void 0 ? void 0 : _f.call(_e, r, this);
|
81
|
+
return [2 /*return*/, state];
|
82
|
+
}
|
83
|
+
});
|
84
|
+
});
|
39
85
|
};
|
40
86
|
;
|
41
87
|
return OperatorExecuter;
|
@@ -3,6 +3,6 @@ import { Render } from '../rawsets/Render';
|
|
3
3
|
import { AfterCallBack, ElementSource, ExecuteState, OperatorExecuter, ReturnContainer, Source } from './OperatorExecuter';
|
4
4
|
export declare abstract class OperatorExecuterAttrRequire<T> extends OperatorExecuter<T> {
|
5
5
|
constructor(rawSet: RawSet, render: Render, returnContainer: ReturnContainer, elementSource: ElementSource, source: Source, afterCallBack: AfterCallBack, startingExecute?: boolean);
|
6
|
-
execute(data: T): ExecuteState
|
7
|
-
protected abstract executeAttrRequire(attr: T): ExecuteState
|
6
|
+
execute(data: T): Promise<ExecuteState>;
|
7
|
+
protected abstract executeAttrRequire(attr: T): Promise<ExecuteState>;
|
8
8
|
}
|