dom-render 1.0.35 → 1.0.39

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.
@@ -1,1047 +1,1112 @@
1
1
  'use strict';
2
2
  try{if(!exports) {var exports = {}}}catch (e) {var exports = {}} Object.defineProperty(exports, '__esModule', { value: true });
3
- var ValidUtils = (function () {
4
- function ValidUtils() {
5
- }
6
- ValidUtils.isNullOrUndefined = function (data) {
7
- if (data == null || undefined === data) {
8
- return true;
9
- }
10
- else {
11
- return false;
12
- }
13
- };
14
- ValidUtils.isNull = function (data) {
15
- if (data == null) {
16
- return true;
17
- }
18
- else {
19
- return false;
20
- }
21
- };
22
- ValidUtils.isArray = function (object_o) {
23
- if (ValidUtils.isNullOrUndefined(object_o)) {
24
- return false;
25
- }
26
- else {
27
- return Object.prototype.toString.call(object_o).trim() === '[object Array]';
28
- }
29
- };
30
- ValidUtils.isNumber = function (object_o) {
31
- if (ValidUtils.isNullOrUndefined(object_o)) {
32
- return false;
33
- }
34
- else {
35
- return Object.prototype.toString.call(object_o).trim() === '[object Number]';
36
- }
37
- };
38
- ValidUtils.isString = function (object_o) {
39
- if (ValidUtils.isNullOrUndefined(object_o)) {
40
- return false;
41
- }
42
- else {
43
- return Object.prototype.toString.call(object_o).trim() === '[object String]';
44
- }
45
- };
46
- ValidUtils.isFunction = function (object_o) {
47
- if (ValidUtils.isNullOrUndefined(object_o)) {
48
- return false;
49
- }
50
- else {
51
- return Object.prototype.toString.call(object_o).trim() === '[object Function]';
52
- }
53
- };
54
- ValidUtils.isObject = function (object_o) {
55
- if (ValidUtils.isNullOrUndefined(object_o)) {
56
- return false;
57
- }
58
- else {
59
- return Object.prototype.toString.call(object_o).trim() === '[object Object]';
60
- }
61
- };
62
- ValidUtils.isMap = function (object_o) {
63
- if (ValidUtils.isNullOrUndefined(object_o)) {
64
- return false;
65
- }
66
- else {
67
- return Object.prototype.toString.call(object_o).trim() === '[object Map]';
68
- }
69
- };
70
- return ValidUtils;
3
+ var ValidUtils = (function () {
4
+ function ValidUtils() {
5
+ }
6
+ ValidUtils.isNullOrUndefined = function (data) {
7
+ if (data == null || undefined === data) {
8
+ return true;
9
+ }
10
+ else {
11
+ return false;
12
+ }
13
+ };
14
+ ValidUtils.isNull = function (data) {
15
+ if (data == null) {
16
+ return true;
17
+ }
18
+ else {
19
+ return false;
20
+ }
21
+ };
22
+ ValidUtils.isArray = function (object_o) {
23
+ if (ValidUtils.isNullOrUndefined(object_o)) {
24
+ return false;
25
+ }
26
+ else {
27
+ return Object.prototype.toString.call(object_o).trim() === '[object Array]';
28
+ }
29
+ };
30
+ ValidUtils.isNumber = function (object_o) {
31
+ if (ValidUtils.isNullOrUndefined(object_o)) {
32
+ return false;
33
+ }
34
+ else {
35
+ return Object.prototype.toString.call(object_o).trim() === '[object Number]';
36
+ }
37
+ };
38
+ ValidUtils.isString = function (object_o) {
39
+ if (ValidUtils.isNullOrUndefined(object_o)) {
40
+ return false;
41
+ }
42
+ else {
43
+ return Object.prototype.toString.call(object_o).trim() === '[object String]';
44
+ }
45
+ };
46
+ ValidUtils.isFunction = function (object_o) {
47
+ if (ValidUtils.isNullOrUndefined(object_o)) {
48
+ return false;
49
+ }
50
+ else {
51
+ return Object.prototype.toString.call(object_o).trim() === '[object Function]';
52
+ }
53
+ };
54
+ ValidUtils.isObject = function (object_o) {
55
+ if (ValidUtils.isNullOrUndefined(object_o)) {
56
+ return false;
57
+ }
58
+ else {
59
+ return Object.prototype.toString.call(object_o).trim() === '[object Object]';
60
+ }
61
+ };
62
+ ValidUtils.isMap = function (object_o) {
63
+ if (ValidUtils.isNullOrUndefined(object_o)) {
64
+ return false;
65
+ }
66
+ else {
67
+ return Object.prototype.toString.call(object_o).trim() === '[object Map]';
68
+ }
69
+ };
70
+ return ValidUtils;
71
71
  }());
72
72
 
73
- var RandomUtils = (function () {
74
- function RandomUtils() {
75
- }
76
- RandomUtils.random = function (min, max) {
77
- if (ValidUtils.isNullOrUndefined(min)) {
78
- return Math.random();
79
- }
80
- else if (!ValidUtils.isNullOrUndefined(min) && ValidUtils.isNullOrUndefined(max)) {
81
- return Math.random() * (min || 0);
82
- }
83
- else {
84
- return Math.random() * ((max || 0) - (min || 0)) + (min || 0);
85
- }
86
- };
87
- RandomUtils.uuid = function (format) {
88
- if (format === void 0) { format = 'xxxx-xxxx-xxxx-xxxx'; }
89
- return format.replace(/[xy]/g, function (c) {
90
- var r = Math.random() * 16 | 0;
91
- var v = c === 'x' ? r : (r & 0x3 | 0x8);
92
- return v.toString(16);
93
- });
94
- };
95
- RandomUtils.getRandomColor = function () {
96
- var letters = '0123456789ABCDEF'.split('');
97
- var color = '#';
98
- for (var i = 0; i < 6; i++) {
99
- color += letters[Math.floor(Math.random() * 16)];
100
- }
101
- return color;
102
- };
103
- RandomUtils.getRandomString = function (len) {
104
- var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
105
- var color = '';
106
- for (var i = 0; i < len; i++) {
107
- color += letters[Math.floor(Math.random() * letters.length)];
108
- }
109
- return color;
110
- };
111
- RandomUtils.d = '';
112
- return RandomUtils;
73
+ var RandomUtils = (function () {
74
+ function RandomUtils() {
75
+ }
76
+ RandomUtils.random = function (min, max) {
77
+ if (ValidUtils.isNullOrUndefined(min)) {
78
+ return Math.random();
79
+ }
80
+ else if (!ValidUtils.isNullOrUndefined(min) && ValidUtils.isNullOrUndefined(max)) {
81
+ return Math.random() * (min || 0);
82
+ }
83
+ else {
84
+ return Math.random() * ((max || 0) - (min || 0)) + (min || 0);
85
+ }
86
+ };
87
+ RandomUtils.uuid = function (format) {
88
+ if (format === void 0) { format = 'xxxx-xxxx-xxxx-xxxx'; }
89
+ return format.replace(/[xy]/g, function (c) {
90
+ var r = Math.random() * 16 | 0;
91
+ var v = c === 'x' ? r : (r & 0x3 | 0x8);
92
+ return v.toString(16);
93
+ });
94
+ };
95
+ RandomUtils.getRandomColor = function () {
96
+ var letters = '0123456789ABCDEF'.split('');
97
+ var color = '#';
98
+ for (var i = 0; i < 6; i++) {
99
+ color += letters[Math.floor(Math.random() * 16)];
100
+ }
101
+ return color;
102
+ };
103
+ RandomUtils.getRandomString = function (len) {
104
+ var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
105
+ var color = '';
106
+ for (var i = 0; i < len; i++) {
107
+ color += letters[Math.floor(Math.random() * letters.length)];
108
+ }
109
+ return color;
110
+ };
111
+ RandomUtils.d = '';
112
+ return RandomUtils;
113
113
  }());
114
114
 
115
- var StringUtils = (function () {
116
- function StringUtils() {
117
- }
118
- StringUtils.deleteEnter = function (data) {
119
- return data.replace(/\r?\n/g, '');
120
- };
121
- StringUtils.regexExec = function (regex, text) {
122
- var varExec = regex.exec(text);
123
- var usingVars = [];
124
- while (varExec) {
125
- usingVars.push(varExec);
126
- varExec = regex.exec(varExec.input);
127
- }
128
- return usingVars;
129
- };
130
- return StringUtils;
115
+ var StringUtils = (function () {
116
+ function StringUtils() {
117
+ }
118
+ StringUtils.deleteEnter = function (data) {
119
+ return data.replace(/\r?\n/g, '');
120
+ };
121
+ StringUtils.regexExec = function (regex, text) {
122
+ var varExec = regex.exec(text);
123
+ var usingVars = [];
124
+ while (varExec) {
125
+ usingVars.push(varExec);
126
+ varExec = regex.exec(varExec.input);
127
+ }
128
+ return usingVars;
129
+ };
130
+ return StringUtils;
131
131
  }());
132
132
 
133
- var ScriptUtils = (function () {
134
- function ScriptUtils() {
135
- }
136
- ScriptUtils.getVariablePaths = function (script) {
137
- var usingVars = new Set();
138
- var GetDetectProxy = (function () {
139
- function GetDetectProxy(prefix) {
140
- this.prefix = prefix;
141
- this.usingVars = usingVars;
142
- }
143
- GetDetectProxy.prototype.set = function (target, p, value, receiver) {
144
- return true;
145
- };
146
- GetDetectProxy.prototype.get = function (target, p, receiver) {
147
- var items;
148
- if (typeof p === 'string') {
149
- items = this.prefix ? this.prefix + '.' + p : p;
150
- this.usingVars.add(items);
151
- }
152
- return new Proxy(function () {
153
- }, new GetDetectProxy(items));
154
- };
155
- return GetDetectProxy;
156
- }());
157
- var destUser = new Proxy(function () {
158
- }, new GetDetectProxy());
159
- try {
160
- Function("\"use strict\"; " + script + "; ").bind(destUser)();
161
- }
162
- catch (e) {
163
- console.error(e);
164
- }
165
- return usingVars;
166
- };
167
- ScriptUtils.evalReturn = function (script, thisTarget) {
168
- return this.eval('return ' + script + ';', thisTarget);
169
- };
170
- ScriptUtils.eval = function (script, thisTarget) {
171
- return Function("\"use strict\"; " + script + " ").bind(thisTarget)();
172
- };
173
- ScriptUtils.loadElement = function (name, attribute, target) {
174
- if (target === void 0) { target = document.head; }
175
- return new Promise(function (resolve, reject) {
176
- var tag = document.createElement(name);
177
- tag.onload = resolve;
178
- tag.onerror = reject;
179
- for (var _i = 0, _a = Object.entries(attribute); _i < _a.length; _i++) {
180
- var _b = _a[_i], key = _b[0], value = _b[1];
181
- tag.setAttribute(key, value);
182
- }
183
- target.append(tag);
184
- });
185
- };
186
- ScriptUtils.loadStyleSheet = function (href, attribute) {
187
- if (attribute === void 0) { attribute = {}; }
188
- attribute.type = 'text/css';
189
- attribute.rel = 'stylesheet';
190
- attribute.href = href;
191
- return ScriptUtils.loadElement('link', attribute);
192
- };
193
- ScriptUtils.loadScript = function (src, attribute) {
194
- if (attribute === void 0) { attribute = {}; }
195
- attribute.type = 'text/javascript';
196
- attribute.src = src;
197
- return ScriptUtils.loadElement('script', attribute);
198
- };
199
- return ScriptUtils;
133
+ var ScriptUtils = (function () {
134
+ function ScriptUtils() {
135
+ }
136
+ ScriptUtils.getVariablePaths = function (script) {
137
+ var usingVars = new Set();
138
+ var GetDetectProxy = (function () {
139
+ function GetDetectProxy(prefix) {
140
+ this.prefix = prefix;
141
+ this.usingVars = usingVars;
142
+ }
143
+ GetDetectProxy.prototype.set = function (target, p, value, receiver) {
144
+ return true;
145
+ };
146
+ GetDetectProxy.prototype.get = function (target, p, receiver) {
147
+ var items;
148
+ if (typeof p === 'string') {
149
+ items = this.prefix ? this.prefix + '.' + p : p;
150
+ this.usingVars.add(items);
151
+ }
152
+ return new Proxy(function () {
153
+ }, new GetDetectProxy(items));
154
+ };
155
+ return GetDetectProxy;
156
+ }());
157
+ var destUser = new Proxy(function () {
158
+ }, new GetDetectProxy());
159
+ try {
160
+ Function("\"use strict\"; " + script + "; ").bind(destUser)();
161
+ }
162
+ catch (e) {
163
+ console.error(e);
164
+ }
165
+ return usingVars;
166
+ };
167
+ ScriptUtils.evalReturn = function (script, thisTarget) {
168
+ return this.eval('return ' + script + ';', thisTarget);
169
+ };
170
+ ScriptUtils.eval = function (script, thisTarget) {
171
+ return Function("\"use strict\"; " + script + " ").bind(thisTarget)();
172
+ };
173
+ ScriptUtils.loadElement = function (name, attribute, target) {
174
+ if (target === void 0) { target = document.head; }
175
+ return new Promise(function (resolve, reject) {
176
+ var tag = document.createElement(name);
177
+ tag.onload = resolve;
178
+ tag.onerror = reject;
179
+ for (var _i = 0, _a = Object.entries(attribute); _i < _a.length; _i++) {
180
+ var _b = _a[_i], key = _b[0], value = _b[1];
181
+ tag.setAttribute(key, value);
182
+ }
183
+ target.append(tag);
184
+ });
185
+ };
186
+ ScriptUtils.loadStyleSheet = function (href, attribute) {
187
+ if (attribute === void 0) { attribute = {}; }
188
+ attribute.type = 'text/css';
189
+ attribute.rel = 'stylesheet';
190
+ attribute.href = href;
191
+ return ScriptUtils.loadElement('link', attribute);
192
+ };
193
+ ScriptUtils.loadScript = function (src, attribute) {
194
+ if (attribute === void 0) { attribute = {}; }
195
+ attribute.type = 'text/javascript';
196
+ attribute.src = src;
197
+ return ScriptUtils.loadElement('script', attribute);
198
+ };
199
+ return ScriptUtils;
200
200
  }());
201
201
 
202
- var eventManager = new (function () {
203
- function class_1() {
204
- var _this = this;
205
- this.attrPrefix = 'dr-';
206
- this.eventNames = ['click', 'change', 'keyup', 'keydown', 'input', 'submit'];
207
- this.attrNames = [
208
- this.attrPrefix + 'value',
209
- this.attrPrefix + 'value-link',
210
- this.attrPrefix + 'attr',
211
- this.attrPrefix + 'style',
212
- this.attrPrefix + 'class',
213
- this.attrPrefix + 'window-event-popstate',
214
- this.attrPrefix + 'on-init'
215
- ];
216
- this.eventNames.forEach(function (it) {
217
- _this.attrNames.push(_this.attrPrefix + 'event-' + it);
218
- });
219
- window.addEventListener('popstate', function (e) {
220
- document.querySelectorAll('[dr-window-event-popstate]').forEach(function (it) {
221
- var _a;
222
- var script = it.getAttribute('dr-window-event-popstate');
223
- if (script) {
224
- (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, it.obj))()) !== null && _a !== void 0 ? _a : {};
225
- }
226
- });
227
- });
228
- }
229
- class_1.prototype.findAttrElements = function (fragment, config) {
230
- var _a, _b;
231
- var elements = new Set();
232
- var addAttributes = (_b = (_a = config === null || config === void 0 ? void 0 : config.applyEvents) === null || _a === void 0 ? void 0 : _a.map(function (it) { return it.attrName; })) !== null && _b !== void 0 ? _b : [];
233
- addAttributes.concat(this.attrNames).forEach(function (attrName) {
234
- fragment === null || fragment === void 0 ? void 0 : fragment.querySelectorAll("[" + attrName + "]").forEach(function (it) {
235
- elements.add(it);
236
- });
237
- });
238
- return elements;
239
- };
240
- class_1.prototype.applyEvent = function (obj, childNodes, config) {
241
- var _this = this;
242
- this.eventNames.forEach(function (it) {
243
- _this.addDrEvent(obj, it, childNodes);
244
- });
245
- this.procAttr(childNodes, this.attrPrefix + 'value', function (it, attribute) {
246
- var script = attribute;
247
- if (script) {
248
- var data = ScriptUtils.evalReturn(script, obj);
249
- if (it.value !== data) {
250
- it.value = data;
251
- }
252
- }
253
- });
254
- this.procAttr(childNodes, this.attrPrefix + 'window-event-popstate', function (it, attribute) {
255
- it.obj = obj;
256
- });
257
- this.procAttr(childNodes, this.attrPrefix + 'on-init', function (it, varName) {
258
- if (varName) {
259
- if (typeof _this.getValue(obj, varName) === 'function') {
260
- _this.getValue(obj, varName)(it);
261
- }
262
- else {
263
- _this.setValue(obj, varName, it);
264
- }
265
- }
266
- });
267
- this.procAttr(childNodes, this.attrPrefix + 'value-link', function (it, varName) {
268
- if (varName) {
269
- var value = _this.getValue(obj, varName);
270
- if (typeof value === 'function' && value) {
271
- value(it.value);
272
- }
273
- else {
274
- _this.setValue(obj, varName, it.value);
275
- }
276
- it.addEventListener('input', function (eit) {
277
- if (typeof _this.getValue(obj, varName) === 'function') {
278
- _this.getValue(obj, varName)(it.value, eit);
279
- }
280
- else {
281
- _this.setValue(obj, varName, it.value);
282
- }
283
- });
284
- }
285
- });
286
- this.changeVar(obj, childNodes, undefined);
287
- var elements = Array.from(childNodes).filter(function (it) { return it.nodeType === 1; }).map(function (it) { return it; });
288
- elements.forEach(function (it) {
289
- var _a;
290
- (_a = config === null || config === void 0 ? void 0 : config.applyEvents) === null || _a === void 0 ? void 0 : _a.filter(function (ta) { return it.getAttribute(ta.attrName); }).forEach(function (ta) { return ta.callBack(it, it.getAttribute(ta.attrName), obj); });
291
- });
292
- };
293
- class_1.prototype.changeVar = function (obj, elements, varName) {
294
- var _this = this;
295
- this.procAttr(elements, this.attrPrefix + 'value-link', function (it, attribute) {
296
- if (attribute && attribute === varName) {
297
- if (typeof _this.getValue(obj, attribute) === 'function') {
298
- _this.getValue(obj, attribute)(it.value);
299
- }
300
- else {
301
- var value = _this.getValue(obj, attribute);
302
- if (value !== undefined && value !== null) {
303
- it.value = value;
304
- }
305
- }
306
- }
307
- });
308
- this.procAttr(elements, this.attrPrefix + 'attr', function (it, attribute) {
309
- var _a;
310
- var script = attribute;
311
- if (script) {
312
- script = 'return ' + script;
313
- }
314
- if (_this.isUsingThisVar(script, varName) || varName === undefined) {
315
- var data = (_a = Function("\"use strict\"; const $target=this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
316
- for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
317
- var _c = _b[_i], key = _c[0], value = _c[1];
318
- it.setAttribute(key, String(value));
319
- }
320
- }
321
- });
322
- this.procAttr(elements, this.attrPrefix + 'style', function (it, attribute) {
323
- var _a;
324
- var script = attribute;
325
- if (script) {
326
- script = 'return ' + script;
327
- }
328
- if (_this.isUsingThisVar(script, varName) || varName === undefined) {
329
- var data = (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
330
- for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
331
- var _c = _b[_i], key = _c[0], value = _c[1];
332
- if (it instanceof HTMLElement) {
333
- it.style[key] = String(value);
334
- }
335
- }
336
- }
337
- });
338
- this.procAttr(elements, this.attrPrefix + 'class', function (it, attribute) {
339
- var _a;
340
- var script = attribute;
341
- if (script) {
342
- script = 'return ' + script;
343
- }
344
- if (_this.isUsingThisVar(script, varName) || varName === undefined) {
345
- var data = (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
346
- for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
347
- var _c = _b[_i], key = _c[0], value = _c[1];
348
- if (it instanceof HTMLElement) {
349
- if (value) {
350
- it.classList.add(key);
351
- }
352
- else {
353
- it.classList.remove(key);
354
- }
355
- }
356
- }
357
- }
358
- });
359
- };
360
- class_1.prototype.addDrEvent = function (obj, eventName, elements) {
361
- var attr = this.attrPrefix + 'event-' + eventName;
362
- this.procAttr(elements, attr, function (it, attribute) {
363
- var script = attribute;
364
- it.addEventListener(eventName, function (event) {
365
- var _a;
366
- var f = Function("\"use strict\"; const $target=event.target; const $event=event; " + script + " ");
367
- (_a = f.bind(Object.assign(obj))()) !== null && _a !== void 0 ? _a : {};
368
- });
369
- });
370
- };
371
- class_1.prototype.procAttr = function (elements, attrName, callBack) {
372
- if (elements === void 0) { elements = new Set(); }
373
- var sets = new Set();
374
- elements.forEach(function (it) {
375
- if (!it) {
376
- return;
377
- }
378
- if (it.nodeType === 1) {
379
- var e = it;
380
- sets.add(e);
381
- e.querySelectorAll("[" + attrName + "]").forEach(function (it) {
382
- sets.add(it);
383
- });
384
- }
385
- });
386
- sets.forEach(function (it) {
387
- var attr = it.getAttribute(attrName);
388
- if (attr) {
389
- callBack(it, attr);
390
- }
391
- });
392
- };
393
- class_1.prototype.getValue = function (obj, name, value) {
394
- var r = ScriptUtils.evalReturn(name, obj);
395
- if (typeof r === 'function') {
396
- r = r.bind(obj);
397
- }
398
- return r;
399
- };
400
- class_1.prototype.setValue = function (obj, name, value) {
401
- ScriptUtils.eval("this." + name + " = this.value", {
402
- this: obj,
403
- value: value
404
- });
405
- };
406
- class_1.prototype.isUsingThisVar = function (raws, varName) {
407
- if (varName && raws) {
408
- if (varName.startsWith('this.')) {
409
- varName = varName.replace(/this\./, '');
410
- }
411
- var variablePaths = ScriptUtils.getVariablePaths(raws !== null && raws !== void 0 ? raws : '');
412
- return variablePaths.has(varName);
413
- }
414
- return false;
415
- };
416
- return class_1;
202
+ var eventManager = new (function () {
203
+ function class_1() {
204
+ var _this = this;
205
+ this.attrPrefix = 'dr-';
206
+ this.eventNames = [
207
+ 'click', 'mousedown', 'mouseup', 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mouseenter', 'mouseleave', 'contextmenu',
208
+ 'keyup', 'keydown', 'keypress',
209
+ 'change', 'input', 'submit', 'resize'
210
+ ];
211
+ this.attrNames = [
212
+ this.attrPrefix + 'value',
213
+ this.attrPrefix + 'value-link',
214
+ this.attrPrefix + 'attr',
215
+ this.attrPrefix + 'style',
216
+ this.attrPrefix + 'class',
217
+ this.attrPrefix + 'window-event-popstate',
218
+ this.attrPrefix + 'on-init'
219
+ ];
220
+ this.eventNames.forEach(function (it) {
221
+ _this.attrNames.push(_this.attrPrefix + 'event-' + it);
222
+ });
223
+ window.addEventListener('popstate', function (e) {
224
+ document.querySelectorAll('[dr-window-event-popstate]').forEach(function (it) {
225
+ var _a;
226
+ var script = it.getAttribute('dr-window-event-popstate');
227
+ if (script) {
228
+ (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, it.obj))()) !== null && _a !== void 0 ? _a : {};
229
+ }
230
+ });
231
+ });
232
+ }
233
+ class_1.prototype.findAttrElements = function (fragment, config) {
234
+ var _a, _b;
235
+ var elements = new Set();
236
+ var addAttributes = (_b = (_a = config === null || config === void 0 ? void 0 : config.applyEvents) === null || _a === void 0 ? void 0 : _a.map(function (it) { return it.attrName; })) !== null && _b !== void 0 ? _b : [];
237
+ addAttributes.concat(this.attrNames).forEach(function (attrName) {
238
+ fragment === null || fragment === void 0 ? void 0 : fragment.querySelectorAll("[" + attrName + "]").forEach(function (it) {
239
+ elements.add(it);
240
+ });
241
+ });
242
+ return elements;
243
+ };
244
+ class_1.prototype.applyEvent = function (obj, childNodes, config) {
245
+ var _this = this;
246
+ this.eventNames.forEach(function (it) {
247
+ _this.addDrEvent(obj, it, childNodes);
248
+ });
249
+ this.procAttr(childNodes, this.attrPrefix + 'value', function (it, attribute) {
250
+ var script = attribute;
251
+ if (script) {
252
+ var data = ScriptUtils.evalReturn(script, obj);
253
+ if (it.value !== data) {
254
+ it.value = data;
255
+ }
256
+ }
257
+ });
258
+ this.procAttr(childNodes, this.attrPrefix + 'window-event-popstate', function (it, attribute) {
259
+ it.obj = obj;
260
+ });
261
+ this.procAttr(childNodes, this.attrPrefix + 'on-init', function (it, varName) {
262
+ if (varName) {
263
+ if (typeof _this.getValue(obj, varName) === 'function') {
264
+ _this.getValue(obj, varName)(it);
265
+ }
266
+ else {
267
+ _this.setValue(obj, varName, it);
268
+ }
269
+ }
270
+ });
271
+ this.procAttr(childNodes, this.attrPrefix + 'value-link', function (it, varName) {
272
+ if (varName) {
273
+ var value = _this.getValue(obj, varName);
274
+ if (typeof value === 'function' && value) {
275
+ value(it.value);
276
+ }
277
+ else {
278
+ _this.setValue(obj, varName, it.value);
279
+ }
280
+ it.addEventListener('input', function (eit) {
281
+ if (typeof _this.getValue(obj, varName) === 'function') {
282
+ _this.getValue(obj, varName)(it.value, eit);
283
+ }
284
+ else {
285
+ _this.setValue(obj, varName, it.value);
286
+ }
287
+ });
288
+ }
289
+ });
290
+ this.changeVar(obj, childNodes, undefined);
291
+ var elements = Array.from(childNodes).filter(function (it) { return it.nodeType === 1; }).map(function (it) { return it; });
292
+ elements.forEach(function (it) {
293
+ var _a;
294
+ (_a = config === null || config === void 0 ? void 0 : config.applyEvents) === null || _a === void 0 ? void 0 : _a.filter(function (ta) { return it.getAttribute(ta.attrName); }).forEach(function (ta) { return ta.callBack(it, it.getAttribute(ta.attrName), obj); });
295
+ });
296
+ };
297
+ class_1.prototype.changeVar = function (obj, elements, varName) {
298
+ var _this = this;
299
+ this.procAttr(elements, this.attrPrefix + 'value-link', function (it, attribute) {
300
+ if (attribute && attribute === varName) {
301
+ if (typeof _this.getValue(obj, attribute) === 'function') {
302
+ _this.getValue(obj, attribute)(it.value);
303
+ }
304
+ else {
305
+ var value = _this.getValue(obj, attribute);
306
+ if (value !== undefined && value !== null) {
307
+ it.value = value;
308
+ }
309
+ }
310
+ }
311
+ });
312
+ this.procAttr(elements, this.attrPrefix + 'attr', function (it, attribute) {
313
+ var _a;
314
+ var script = attribute;
315
+ if (script) {
316
+ script = 'return ' + script;
317
+ }
318
+ if (_this.isUsingThisVar(script, varName) || varName === undefined) {
319
+ var data = (_a = Function("\"use strict\"; const $target=this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
320
+ for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
321
+ var _c = _b[_i], key = _c[0], value = _c[1];
322
+ it.setAttribute(key, String(value));
323
+ }
324
+ }
325
+ });
326
+ this.procAttr(elements, this.attrPrefix + 'style', function (it, attribute) {
327
+ var _a;
328
+ var script = attribute;
329
+ if (script) {
330
+ script = 'return ' + script;
331
+ }
332
+ if (_this.isUsingThisVar(script, varName) || varName === undefined) {
333
+ var data = (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
334
+ for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
335
+ var _c = _b[_i], key = _c[0], value = _c[1];
336
+ if (it instanceof HTMLElement) {
337
+ it.style[key] = String(value);
338
+ }
339
+ }
340
+ }
341
+ });
342
+ this.procAttr(elements, this.attrPrefix + 'class', function (it, attribute) {
343
+ var _a;
344
+ var script = attribute;
345
+ if (script) {
346
+ script = 'return ' + script;
347
+ }
348
+ if (_this.isUsingThisVar(script, varName) || varName === undefined) {
349
+ var data = (_a = Function("\"use strict\"; const $target = this.$target; " + script + " ").bind(Object.assign({ $target: it }, obj))()) !== null && _a !== void 0 ? _a : {};
350
+ for (var _i = 0, _b = Object.entries(data); _i < _b.length; _i++) {
351
+ var _c = _b[_i], key = _c[0], value = _c[1];
352
+ if (it instanceof HTMLElement) {
353
+ if (value) {
354
+ it.classList.add(key);
355
+ }
356
+ else {
357
+ it.classList.remove(key);
358
+ }
359
+ }
360
+ }
361
+ }
362
+ });
363
+ };
364
+ class_1.prototype.addDrEvent = function (obj, eventName, elements) {
365
+ var attr = this.attrPrefix + 'event-' + eventName;
366
+ this.procAttr(elements, attr, function (it, attribute) {
367
+ var script = attribute;
368
+ it.addEventListener(eventName, function (event) {
369
+ var _a;
370
+ var f = Function("\"use strict\"; const $target=event.target; const $event=event; " + script + " ");
371
+ (_a = f.bind(Object.assign(obj))()) !== null && _a !== void 0 ? _a : {};
372
+ });
373
+ });
374
+ };
375
+ class_1.prototype.procAttr = function (elements, attrName, callBack) {
376
+ if (elements === void 0) { elements = new Set(); }
377
+ var sets = new Set();
378
+ elements.forEach(function (it) {
379
+ if (!it) {
380
+ return;
381
+ }
382
+ if (it.nodeType === 1) {
383
+ var e = it;
384
+ sets.add(e);
385
+ e.querySelectorAll("[" + attrName + "]").forEach(function (it) {
386
+ sets.add(it);
387
+ });
388
+ }
389
+ });
390
+ sets.forEach(function (it) {
391
+ var attr = it.getAttribute(attrName);
392
+ if (attr) {
393
+ callBack(it, attr);
394
+ }
395
+ });
396
+ };
397
+ class_1.prototype.getValue = function (obj, name, value) {
398
+ var r = ScriptUtils.evalReturn(name, obj);
399
+ if (typeof r === 'function') {
400
+ r = r.bind(obj);
401
+ }
402
+ return r;
403
+ };
404
+ class_1.prototype.setValue = function (obj, name, value) {
405
+ ScriptUtils.eval("this." + name + " = this.value", {
406
+ this: obj,
407
+ value: value
408
+ });
409
+ };
410
+ class_1.prototype.isUsingThisVar = function (raws, varName) {
411
+ if (varName && raws) {
412
+ if (varName.startsWith('this.')) {
413
+ varName = varName.replace(/this\./, '');
414
+ }
415
+ var variablePaths = ScriptUtils.getVariablePaths(raws !== null && raws !== void 0 ? raws : '');
416
+ return variablePaths.has(varName);
417
+ }
418
+ return false;
419
+ };
420
+ return class_1;
417
421
  }())();
418
422
 
419
- var RawSet = (function () {
420
- function RawSet(uuid, point, fragment, data) {
421
- if (data === void 0) { data = {}; }
422
- this.uuid = uuid;
423
- this.point = point;
424
- this.fragment = fragment;
425
- this.data = data;
426
- }
427
- Object.defineProperty(RawSet.prototype, "isConnected", {
428
- get: function () {
429
- return this.point.start.isConnected && this.point.end.isConnected;
430
- },
431
- enumerable: false,
432
- configurable: true
433
- });
434
- RawSet.prototype.getUsingTriggerVariables = function (config) {
435
- var usingTriggerVariables = new Set();
436
- this.fragment.childNodes.forEach(function (cNode, key) {
437
- var _a, _b, _c;
438
- if (cNode.nodeType === Node.TEXT_NODE) {
439
- ScriptUtils.getVariablePaths("`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`").forEach(function (it) { return usingTriggerVariables.add(it); });
440
- }
441
- else if (cNode.nodeType === Node.ELEMENT_NODE) {
442
- var element_1 = cNode;
443
- var targetAttrNames = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name; })) !== null && _c !== void 0 ? _c : []).concat(RawSet.DR_ATTRIBUTES);
444
- ScriptUtils.getVariablePaths(targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';')).forEach(function (it) { return usingTriggerVariables.add(it); });
445
- }
446
- });
447
- return usingTriggerVariables;
448
- };
449
- RawSet.prototype.render = function (obj, config) {
450
- var _this = this;
451
- var genNode = document.importNode(this.fragment, true);
452
- var raws = [];
453
- var onAttrInitCallBack = [];
454
- var onElementInitCallBack = [];
455
- genNode.childNodes.forEach(function (cNode, key) {
456
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
457
- var fag = document.createDocumentFragment();
458
- if (cNode.nodeType === Node.TEXT_NODE) {
459
- var textContent = cNode.textContent;
460
- var n = document.createTextNode(ScriptUtils.eval("return `" + textContent + "`", obj));
461
- (_a = cNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(n, cNode);
462
- }
463
- else if (cNode.nodeType === Node.ELEMENT_NODE) {
464
- var element_2 = cNode;
465
- var drAttr = {
466
- dr: _this.getAttributeAndDelete(element_2, RawSet.DR),
467
- drIf: _this.getAttributeAndDelete(element_2, RawSet.DR_IF_NAME),
468
- drFor: _this.getAttributeAndDelete(element_2, RawSet.DR_FOR_NAME),
469
- drForOf: _this.getAttributeAndDelete(element_2, RawSet.DR_FOR_OF_NAME),
470
- drThis: _this.getAttributeAndDelete(element_2, RawSet.DR_THIS_NAME),
471
- drInnerHTML: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERHTML_NAME),
472
- drInnerText: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERTEXT_NAME),
473
- drItOption: _this.getAttributeAndDelete(element_2, RawSet.DR_IT_OPTIONNAME),
474
- drVarOption: _this.getAttributeAndDelete(element_2, RawSet.DR_VAR_OPTIONNAME),
475
- drStripOption: _this.getAttributeAndDelete(element_2, RawSet.DR_STRIP_OPTIONNAME) === 'true'
476
- };
477
- if (drAttr.dr !== null && drAttr.dr.length >= 0) {
478
- var itRandom = RawSet.drItOtherEncoding(element_2);
479
- var vars = RawSet.drVarEncoding(element_2, (_b = drAttr.drVarOption) !== null && _b !== void 0 ? _b : '');
480
- var newTemp = document.createElement('temp');
481
- ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }", Object.assign({
482
- __fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
483
- }, obj));
484
- RawSet.drVarDecoding(newTemp, vars);
485
- RawSet.drItOtherDecoding(newTemp, itRandom);
486
- var tempalte = document.createElement('template');
487
- tempalte.innerHTML = newTemp.innerHTML;
488
- fag.append(tempalte.content);
489
- var rr = RawSet.checkPointCreates(fag, config);
490
- (_c = element_2.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(fag, element_2);
491
- raws.push.apply(raws, rr);
492
- }
493
- if (drAttr.drIf) {
494
- var itRandom = RawSet.drItOtherEncoding(element_2);
495
- var vars = RawSet.drVarEncoding(element_2, (_d = drAttr.drVarOption) !== null && _d !== void 0 ? _d : '');
496
- var newTemp = document.createElement('temp');
497
- ScriptUtils.eval("\n if(" + drAttr.drIf + ") {\n const n = this.__element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n }", Object.assign({
498
- __fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
499
- }, obj));
500
- RawSet.drVarDecoding(newTemp, vars);
501
- RawSet.drItOtherDecoding(newTemp, itRandom);
502
- var tempalte = document.createElement('template');
503
- tempalte.innerHTML = newTemp.innerHTML;
504
- fag.append(tempalte.content);
505
- var rr = RawSet.checkPointCreates(fag, config);
506
- (_e = element_2.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(fag, element_2);
507
- raws.push.apply(raws, rr);
508
- }
509
- if (drAttr.drThis) {
510
- var r = ScriptUtils.evalReturn(drAttr.drThis, obj);
511
- if (r) {
512
- fag.append(RawSet.drThisCreate(element_2, drAttr.drThis, (_f = drAttr.drVarOption) !== null && _f !== void 0 ? _f : '', drAttr.drStripOption, obj));
513
- var rr = RawSet.checkPointCreates(fag, config);
514
- (_g = element_2.parentNode) === null || _g === void 0 ? void 0 : _g.replaceChild(fag, element_2);
515
- raws.push.apply(raws, rr);
516
- }
517
- else {
518
- cNode.remove();
519
- }
520
- }
521
- if (drAttr.drInnerText) {
522
- var data = ScriptUtils.evalReturn(drAttr.drInnerText, obj);
523
- var newTemp = document.createElement('temp');
524
- ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerText = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({
525
- __fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2
526
- }, obj));
527
- var tempalte = document.createElement('template');
528
- tempalte.innerHTML = newTemp.innerHTML;
529
- fag.append(tempalte.content);
530
- var rr = RawSet.checkPointCreates(fag, config);
531
- (_h = element_2.parentNode) === null || _h === void 0 ? void 0 : _h.replaceChild(fag, element_2);
532
- raws.push.apply(raws, rr);
533
- }
534
- if (drAttr.drInnerHTML) {
535
- var data = ScriptUtils.evalReturn(drAttr.drInnerHTML, obj);
536
- var newTemp = document.createElement('temp');
537
- ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerHTML = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({
538
- __fag: newTemp, __drStripOption: drAttr.drStripOption, __data: data, __element: element_2
539
- }, obj));
540
- var tempalte = document.createElement('template');
541
- tempalte.innerHTML = newTemp.innerHTML;
542
- fag.append(tempalte.content);
543
- var rr = RawSet.checkPointCreates(fag, config);
544
- (_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2);
545
- raws.push.apply(raws, rr);
546
- }
547
- if (drAttr.drFor) {
548
- var itRandom = RawSet.drItOtherEncoding(element_2);
549
- var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : '');
550
- var newTemp = document.createElement('temp');
551
- ScriptUtils.eval("\n for(" + drAttr.drFor + ") {\n const n = this.__element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n }", Object.assign({
552
- __fag: newTemp, __drStripOption: drAttr.drStripOption, __element: element_2
553
- }, obj));
554
- RawSet.drVarDecoding(newTemp, vars);
555
- RawSet.drItOtherDecoding(newTemp, itRandom);
556
- var tempalte = document.createElement('template');
557
- tempalte.innerHTML = newTemp.innerHTML;
558
- fag.append(tempalte.content);
559
- var rr = RawSet.checkPointCreates(fag, config);
560
- (_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2);
561
- raws.push.apply(raws, rr);
562
- }
563
- if (drAttr.drForOf) {
564
- var itRandom = RawSet.drItOtherEncoding(element_2);
565
- var vars = RawSet.drVarEncoding(element_2, (_m = drAttr.drVarOption) !== null && _m !== void 0 ? _m : '');
566
- var newTemp = document.createElement('temp');
567
- ScriptUtils.eval("var i = 0; for(const it of " + drAttr.drForOf + ") {\n //alert(1)\n var destIt = it;\n var forOfStr = `" + drAttr.drForOf + "`;\n if (/,/g.test(forOfStr)) {\n if (typeof it === 'string') {\n destIt = it;\n } else {\n destIt = forOfStr.substring(1, forOfStr.length-1).split(',')[i];\n }\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n \n const n = this.__element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n i++;\n }", Object.assign({
568
- __drStripOption: drAttr.drStripOption,
569
- __fag: newTemp,
570
- __element: element_2
571
- }, obj));
572
- RawSet.drVarDecoding(newTemp, vars);
573
- RawSet.drItOtherDecoding(newTemp, itRandom);
574
- var tempalte = document.createElement('template');
575
- tempalte.innerHTML = newTemp.innerHTML;
576
- fag.append(tempalte.content);
577
- var rr = RawSet.checkPointCreates(fag, config);
578
- (_o = element_2.parentNode) === null || _o === void 0 ? void 0 : _o.replaceChild(fag, element_2);
579
- raws.push.apply(raws, rr);
580
- }
581
- (_p = config === null || config === void 0 ? void 0 : config.targetElements) === null || _p === void 0 ? void 0 : _p.forEach(function (it) {
582
- var _a, _b;
583
- var name = it.name;
584
- if (name.toLowerCase() === element_2.tagName.toLowerCase()) {
585
- var documentFragment = it.callBack(element_2, obj, _this);
586
- if (documentFragment) {
587
- fag.append(documentFragment);
588
- var rr = RawSet.checkPointCreates(fag, config);
589
- (_a = element_2.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fag, element_2);
590
- var onInit = element_2.getAttribute('dr-on-init-component');
591
- if (onInit) {
592
- ScriptUtils.evalReturn(onInit, obj)(obj === null || obj === void 0 ? void 0 : obj.__componentInstances[_this.uuid], _this);
593
- }
594
- raws.push.apply(raws, rr);
595
- onElementInitCallBack.push({ name: name, obj: obj });
596
- (_b = it === null || it === void 0 ? void 0 : it.complete) === null || _b === void 0 ? void 0 : _b.call(it, element_2, obj, _this);
597
- }
598
- }
599
- });
600
- (_q = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _q === void 0 ? void 0 : _q.forEach(function (it) {
601
- var _a, _b;
602
- var attrName = it.name;
603
- var attrValue = _this.getAttributeAndDelete(element_2, attrName);
604
- if (attrValue && attrName) {
605
- var documentFragment = it.callBack(element_2, attrValue, obj, _this);
606
- if (documentFragment) {
607
- fag.append(documentFragment);
608
- var rr = RawSet.checkPointCreates(fag, config);
609
- (_a = element_2.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fag, element_2);
610
- raws.push.apply(raws, rr);
611
- onAttrInitCallBack.push({ attrName: attrName, attrValue: attrValue, obj: obj });
612
- (_b = it === null || it === void 0 ? void 0 : it.complete) === null || _b === void 0 ? void 0 : _b.call(it, element_2, attrValue, obj, _this);
613
- }
614
- }
615
- });
616
- }
617
- });
618
- this.applyEvent(obj, genNode, config);
619
- this.replaceBody(genNode);
620
- onElementInitCallBack.forEach(function (it) { var _a; return (_a = config === null || config === void 0 ? void 0 : config.onElementInit) === null || _a === void 0 ? void 0 : _a.call(config, it.name, obj, _this); });
621
- onAttrInitCallBack.forEach(function (it) { var _a; return (_a = config === null || config === void 0 ? void 0 : config.onAttrInit) === null || _a === void 0 ? void 0 : _a.call(config, it.attrName, it.attrValue, obj, _this); });
622
- return raws;
623
- };
624
- RawSet.prototype.applyEvent = function (obj, fragment, config) {
625
- if (fragment === void 0) { fragment = this.fragment; }
626
- eventManager.applyEvent(obj, eventManager.findAttrElements(fragment, config), config);
627
- };
628
- RawSet.prototype.getAttributeAndDelete = function (element, attr) {
629
- var data = element.getAttribute(attr);
630
- element.removeAttribute(attr);
631
- return data;
632
- };
633
- RawSet.prototype.replaceBody = function (genNode) {
634
- var _a;
635
- this.childAllRemove();
636
- (_a = this.point.start.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(genNode, this.point.start.nextSibling);
637
- };
638
- RawSet.checkPointCreates = function (element, config) {
639
- var _a, _b, _c, _d;
640
- var nodeIterator = document.createNodeIterator(element, NodeFilter.SHOW_ALL, {
641
- acceptNode: function (node) {
642
- var _a, _b, _c, _d, _e;
643
- if (node.nodeType === Node.TEXT_NODE) {
644
- return /\$\{.*?\}/g.test(StringUtils.deleteEnter((_a = node.data) !== null && _a !== void 0 ? _a : '')) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
645
- }
646
- else if (node.nodeType === Node.ELEMENT_NODE) {
647
- var element_3 = node;
648
- var isElement = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetElements) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name.toLowerCase(); })) !== null && _c !== void 0 ? _c : []).includes(element_3.tagName.toLowerCase());
649
- var targetAttrNames_1 = ((_e = (_d = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _d === void 0 ? void 0 : _d.map(function (it) { return it.name; })) !== null && _e !== void 0 ? _e : []).concat(RawSet.DR_ATTRIBUTES);
650
- var isAttr = element_3.getAttributeNames().filter(function (it) { return targetAttrNames_1.includes(it.toLowerCase()); }).length > 0;
651
- return (isAttr || isElement) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
652
- }
653
- return NodeFilter.FILTER_REJECT;
654
- }
655
- });
656
- var pars = [];
657
- var currentNode;
658
- var _loop_1 = function () {
659
- if (currentNode.nodeType === Node.TEXT_NODE) {
660
- var text_1 = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
661
- var template_1 = document.createElement('template');
662
- var a = StringUtils.regexExec(/\$\{.*?\}/g, text_1);
663
- var map = a.reverse().map(function (it) { return { uuid: '', content: '', regexArr: it }; });
664
- map.forEach(function (it) {
665
- var uuid = RandomUtils.uuid();
666
- it.uuid = uuid;
667
- it.content = it.regexArr[0];
668
- text_1 = text_1.substr(0, it.regexArr.index) + text_1.substr(it.regexArr.index).replace(it.regexArr[0], "<!--start text " + uuid + "--><!--end text " + uuid + "-->");
669
- });
670
- template_1.innerHTML = text_1;
671
- map.forEach(function (it) {
672
- var _a, _b;
673
- var subNodeIterator = document.createNodeIterator(template_1.content, NodeFilter.SHOW_COMMENT, {
674
- acceptNode: function (node) {
675
- var text = node.textContent;
676
- return (text === "start text " + it.uuid || text === "end text " + it.uuid) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
677
- }
678
- });
679
- var start;
680
- var end;
681
- var subNode;
682
- while (subNode = subNodeIterator.nextNode()) {
683
- if (((_a = subNode.textContent) !== null && _a !== void 0 ? _a : '').startsWith('start')) {
684
- start = subNode;
685
- }
686
- if (((_b = subNode.textContent) !== null && _b !== void 0 ? _b : '').startsWith('end')) {
687
- end = subNode;
688
- }
689
- }
690
- if (start && end) {
691
- var fragment = document.createDocumentFragment();
692
- fragment.append(document.createTextNode(it.content));
693
- pars.push(new RawSet(it.uuid, { start: start, end: end }, fragment));
694
- }
695
- });
696
- (_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template_1.content, currentNode);
697
- }
698
- else {
699
- var uuid = RandomUtils.uuid();
700
- var fragment = document.createDocumentFragment();
701
- var start = document.createComment("start " + uuid);
702
- var end = document.createComment("end " + uuid);
703
- (_c = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(start, currentNode);
704
- (_d = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _d === void 0 ? void 0 : _d.insertBefore(end, currentNode.nextSibling);
705
- fragment.append(currentNode);
706
- pars.push(new RawSet(uuid, { start: start, end: end }, fragment));
707
- }
708
- };
709
- while (currentNode = nodeIterator.nextNode()) {
710
- _loop_1();
711
- }
712
- return pars;
713
- };
714
- RawSet.prototype.childAllRemove = function () {
715
- var next = this.point.start.nextSibling;
716
- while (next) {
717
- if (next === this.point.end) {
718
- break;
719
- }
720
- next.remove();
721
- next = this.point.start.nextSibling;
722
- }
723
- };
724
- RawSet.drItOtherEncoding = function (element) {
725
- var random = RandomUtils.uuid();
726
- var regex = /#it#/g;
727
- element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
728
- it.innerHTML = it.innerHTML.replace(regex, random);
729
- });
730
- return random;
731
- };
732
- RawSet.drItOtherDecoding = function (element, random) {
733
- element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
734
- it.innerHTML = it.innerHTML.replace(RegExp(random, 'g'), '#it#');
735
- });
736
- };
737
- RawSet.drThisEncoding = function (element, drThis) {
738
- var thisRandom = RandomUtils.uuid();
739
- element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
740
- var message = it.innerHTML;
741
- StringUtils.regexExec(/([^(dr\-)])?this(?=.?)/g, message).reverse().forEach(function (it) {
742
- var _a;
743
- message = message.substr(0, it.index) + message.substr(it.index).replace(it[0], "" + ((_a = it[1]) !== null && _a !== void 0 ? _a : '') + drThis);
744
- });
745
- it.innerHTML = message;
746
- });
747
- var message = element.innerHTML;
748
- StringUtils.regexExec(/([^(dr\-)])?this(?=.?)/g, message).reverse().forEach(function (it) {
749
- var _a;
750
- message = message.substr(0, it.index) + message.substr(it.index).replace(it[0], "" + ((_a = it[1]) !== null && _a !== void 0 ? _a : '') + drThis);
751
- });
752
- element.innerHTML = message;
753
- return thisRandom;
754
- };
755
- RawSet.drThisDecoding = function (element, thisRandom) {
756
- element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
757
- it.innerHTML = it.innerHTML.replace(RegExp(thisRandom, 'g'), 'this');
758
- });
759
- };
760
- RawSet.drVarEncoding = function (element, drVarOption) {
761
- var _a;
762
- var vars = ((_a = drVarOption === null || drVarOption === void 0 ? void 0 : drVarOption.split(',')) !== null && _a !== void 0 ? _a : []).map(function (it) {
763
- var s = it.trim().split('=');
764
- return {
765
- name: s[0],
766
- value: s[1],
767
- regex: RegExp('var\\.' + s[0] + '(?=.?)', 'g'),
768
- random: RandomUtils.uuid()
769
- };
770
- });
771
- element.querySelectorAll("[" + RawSet.DR_VAR_OPTIONNAME + "]").forEach(function (it) {
772
- vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
773
- it.innerHTML = it.innerHTML.replace(vit.regex, vit.random);
774
- });
775
- });
776
- vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
777
- element.innerHTML = element.innerHTML.replace(vit.regex, vit.value);
778
- });
779
- return vars;
780
- };
781
- RawSet.drVarDecoding = function (element, vars) {
782
- element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
783
- vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
784
- it.innerHTML = it.innerHTML.replace(RegExp(vit.random, 'g'), vit.value);
785
- });
786
- });
787
- };
788
- RawSet.drThisCreate = function (element, drThis, drVarOption, drStripOption, obj) {
789
- var fag = document.createDocumentFragment();
790
- var n = element.cloneNode(true);
791
- var thisRandom = this.drThisEncoding(n, drThis);
792
- var vars = this.drVarEncoding(n, drVarOption);
793
- this.drVarDecoding(n, vars);
794
- this.drThisDecoding(n, thisRandom);
795
- if (drStripOption) {
796
- Array.from(n.childNodes).forEach(function (it) { return fag.append(it); });
797
- }
798
- else {
799
- fag.append(n);
800
- }
801
- return fag;
802
- };
803
- RawSet.DR = 'dr';
804
- RawSet.DR_IF_NAME = 'dr-if';
805
- RawSet.DR_FOR_OF_NAME = 'dr-for-of';
806
- RawSet.DR_FOR_NAME = 'dr-for';
807
- RawSet.DR_THIS_NAME = 'dr-this';
808
- RawSet.DR_INNERHTML_NAME = 'dr-inner-html';
809
- RawSet.DR_INNERTEXT_NAME = 'dr-inner-text';
810
- RawSet.DR_TAGS = [];
811
- RawSet.DR_IT_OPTIONNAME = 'dr-it';
812
- RawSet.DR_VAR_OPTIONNAME = 'dr-var';
813
- RawSet.DR_STRIP_OPTIONNAME = 'dr-strip';
814
- RawSet.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME];
815
- return RawSet;
423
+ var RawSet = (function () {
424
+ function RawSet(uuid, point, fragment, data) {
425
+ if (data === void 0) { data = {}; }
426
+ this.uuid = uuid;
427
+ this.point = point;
428
+ this.fragment = fragment;
429
+ this.data = data;
430
+ }
431
+ Object.defineProperty(RawSet.prototype, "isConnected", {
432
+ get: function () {
433
+ return this.point.start.isConnected && this.point.end.isConnected;
434
+ },
435
+ enumerable: false,
436
+ configurable: true
437
+ });
438
+ RawSet.prototype.getUsingTriggerVariables = function (config) {
439
+ var usingTriggerVariables = new Set();
440
+ this.fragment.childNodes.forEach(function (cNode, key) {
441
+ var _a, _b, _c;
442
+ var script = '';
443
+ if (cNode.nodeType === Node.TEXT_NODE) {
444
+ script = "`" + ((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '') + "`";
445
+ }
446
+ else if (cNode.nodeType === Node.ELEMENT_NODE) {
447
+ var element_1 = cNode;
448
+ var targetAttrNames = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name; })) !== null && _c !== void 0 ? _c : []).concat(RawSet.DR_ATTRIBUTES);
449
+ script = targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';');
450
+ }
451
+ if (script) {
452
+ script = script.replace(RegExp(RawSet.SCRIPTS_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.SCRIPTS_VARNAME);
453
+ script = script.replace(RegExp(RawSet.RAWSET_VARNAME.replace('$', '\\$'), 'g'), "this?.___" + RawSet.RAWSET_VARNAME);
454
+ Array.from(ScriptUtils.getVariablePaths(script)).filter(function (it) { return !it.startsWith("___" + RawSet.SCRIPTS_VARNAME) && !it.startsWith("___" + RawSet.SCRIPTS_VARNAME); }).forEach(function (it) { return usingTriggerVariables.add(it); });
455
+ }
456
+ });
457
+ return usingTriggerVariables;
458
+ };
459
+ RawSet.prototype.render = function (obj, config) {
460
+ var _this = this;
461
+ var genNode = document.importNode(this.fragment, true);
462
+ var raws = [];
463
+ var onAttrInitCallBack = [];
464
+ var onElementInitCallBack = [];
465
+ genNode.childNodes.forEach(function (cNode, key) {
466
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
467
+ var fag = document.createDocumentFragment();
468
+ if (cNode.nodeType === Node.TEXT_NODE) {
469
+ var textContent = cNode.textContent;
470
+ var n = document.createTextNode(ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n return `" + textContent + "`\n ", Object.assign(obj, {
471
+ __render: Object.freeze({
472
+ rawset: _this,
473
+ scripts: _this.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
474
+ })
475
+ })));
476
+ (_a = cNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(n, cNode);
477
+ }
478
+ else if (cNode.nodeType === Node.ELEMENT_NODE) {
479
+ var element_2 = cNode;
480
+ var drAttr = {
481
+ dr: _this.getAttributeAndDelete(element_2, RawSet.DR),
482
+ drIf: _this.getAttributeAndDelete(element_2, RawSet.DR_IF_NAME),
483
+ drFor: _this.getAttributeAndDelete(element_2, RawSet.DR_FOR_NAME),
484
+ drForOf: _this.getAttributeAndDelete(element_2, RawSet.DR_FOR_OF_NAME),
485
+ drThis: _this.getAttributeAndDelete(element_2, RawSet.DR_THIS_NAME),
486
+ drInnerHTML: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERHTML_NAME),
487
+ drInnerText: _this.getAttributeAndDelete(element_2, RawSet.DR_INNERTEXT_NAME),
488
+ drItOption: _this.getAttributeAndDelete(element_2, RawSet.DR_IT_OPTIONNAME),
489
+ drVarOption: _this.getAttributeAndDelete(element_2, RawSet.DR_VAR_OPTIONNAME),
490
+ drStripOption: _this.getAttributeAndDelete(element_2, RawSet.DR_STRIP_OPTIONNAME) === 'true'
491
+ };
492
+ if (drAttr.dr !== null && drAttr.dr.length >= 0) {
493
+ var itRandom = RawSet.drItOtherEncoding(element_2);
494
+ var vars = RawSet.drVarEncoding(element_2, (_b = drAttr.drVarOption) !== null && _b !== void 0 ? _b : '');
495
+ var newTemp = document.createElement('temp');
496
+ ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__render.fag.append(n);\n }", Object.assign(obj, {
497
+ __render: Object.freeze({
498
+ fag: newTemp,
499
+ drStripOption: drAttr.drStripOption,
500
+ element: element_2,
501
+ rawset: _this,
502
+ scripts: _this.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
503
+ })
504
+ }));
505
+ RawSet.drVarDecoding(newTemp, vars);
506
+ RawSet.drItOtherDecoding(newTemp, itRandom);
507
+ var tempalte = document.createElement('template');
508
+ tempalte.innerHTML = newTemp.innerHTML;
509
+ fag.append(tempalte.content);
510
+ var rr = RawSet.checkPointCreates(fag, config);
511
+ (_c = element_2.parentNode) === null || _c === void 0 ? void 0 : _c.replaceChild(fag, element_2);
512
+ raws.push.apply(raws, rr);
513
+ }
514
+ if (drAttr.drIf) {
515
+ var itRandom = RawSet.drItOtherEncoding(element_2);
516
+ var vars = RawSet.drVarEncoding(element_2, (_d = drAttr.drVarOption) !== null && _d !== void 0 ? _d : '');
517
+ var newTemp = document.createElement('temp');
518
+ ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n const " + RawSet.RAWSET_VARNAME + " = this.__render.rawset;\n if(" + drAttr.drIf + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, {
519
+ __render: Object.freeze({
520
+ fag: newTemp,
521
+ drStripOption: drAttr.drStripOption,
522
+ element: element_2,
523
+ rawset: _this,
524
+ scripts: _this.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
525
+ })
526
+ }));
527
+ RawSet.drVarDecoding(newTemp, vars);
528
+ RawSet.drItOtherDecoding(newTemp, itRandom);
529
+ var tempalte = document.createElement('template');
530
+ tempalte.innerHTML = newTemp.innerHTML;
531
+ fag.append(tempalte.content);
532
+ var rr = RawSet.checkPointCreates(fag, config);
533
+ (_e = element_2.parentNode) === null || _e === void 0 ? void 0 : _e.replaceChild(fag, element_2);
534
+ raws.push.apply(raws, rr);
535
+ }
536
+ if (drAttr.drThis) {
537
+ var r = ScriptUtils.evalReturn(drAttr.drThis, obj);
538
+ if (r) {
539
+ fag.append(RawSet.drThisCreate(element_2, drAttr.drThis, (_f = drAttr.drVarOption) !== null && _f !== void 0 ? _f : '', drAttr.drStripOption, obj));
540
+ var rr = RawSet.checkPointCreates(fag, config);
541
+ (_g = element_2.parentNode) === null || _g === void 0 ? void 0 : _g.replaceChild(fag, element_2);
542
+ raws.push.apply(raws, rr);
543
+ }
544
+ else {
545
+ cNode.remove();
546
+ }
547
+ }
548
+ if (drAttr.drInnerText) {
549
+ var data = ScriptUtils.evalReturn(drAttr.drInnerText, obj);
550
+ var newTemp = document.createElement('temp');
551
+ ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerText = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({
552
+ __fag: newTemp,
553
+ __drStripOption: drAttr.drStripOption,
554
+ __data: data,
555
+ __element: element_2
556
+ }, obj));
557
+ var tempalte = document.createElement('template');
558
+ tempalte.innerHTML = newTemp.innerHTML;
559
+ fag.append(tempalte.content);
560
+ var rr = RawSet.checkPointCreates(fag, config);
561
+ (_h = element_2.parentNode) === null || _h === void 0 ? void 0 : _h.replaceChild(fag, element_2);
562
+ raws.push.apply(raws, rr);
563
+ }
564
+ if (drAttr.drInnerHTML) {
565
+ var data = ScriptUtils.evalReturn(drAttr.drInnerHTML, obj);
566
+ var newTemp = document.createElement('temp');
567
+ ScriptUtils.eval("\n const n = this.__element.cloneNode(true);\n n.innerHTML = this.__data;\n if (this.__drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__fag.append(it));\n } else {\n this.__fag.append(n);\n }\n ", Object.assign({
568
+ __fag: newTemp,
569
+ __drStripOption: drAttr.drStripOption,
570
+ __data: data,
571
+ __element: element_2
572
+ }, obj));
573
+ var tempalte = document.createElement('template');
574
+ tempalte.innerHTML = newTemp.innerHTML;
575
+ fag.append(tempalte.content);
576
+ var rr = RawSet.checkPointCreates(fag, config);
577
+ (_j = element_2.parentNode) === null || _j === void 0 ? void 0 : _j.replaceChild(fag, element_2);
578
+ raws.push.apply(raws, rr);
579
+ }
580
+ if (drAttr.drFor) {
581
+ var itRandom = RawSet.drItOtherEncoding(element_2);
582
+ var vars = RawSet.drVarEncoding(element_2, (_k = drAttr.drVarOption) !== null && _k !== void 0 ? _k : '');
583
+ var newTemp = document.createElement('temp');
584
+ ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n for(" + drAttr.drFor + ") {\n const n = this.__render.element.cloneNode(true);\n var destIt = " + drAttr.drItOption + ";\n if (destIt !== undefined) {\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n }\n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n }", Object.assign(obj, {
585
+ __render: Object.freeze({
586
+ fag: newTemp,
587
+ drStripOption: drAttr.drStripOption,
588
+ element: element_2,
589
+ scripts: _this.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
590
+ })
591
+ }));
592
+ RawSet.drVarDecoding(newTemp, vars);
593
+ RawSet.drItOtherDecoding(newTemp, itRandom);
594
+ var tempalte = document.createElement('template');
595
+ tempalte.innerHTML = newTemp.innerHTML;
596
+ fag.append(tempalte.content);
597
+ var rr = RawSet.checkPointCreates(fag, config);
598
+ (_l = element_2.parentNode) === null || _l === void 0 ? void 0 : _l.replaceChild(fag, element_2);
599
+ raws.push.apply(raws, rr);
600
+ }
601
+ if (drAttr.drForOf) {
602
+ var itRandom = RawSet.drItOtherEncoding(element_2);
603
+ var vars = RawSet.drVarEncoding(element_2, (_m = drAttr.drVarOption) !== null && _m !== void 0 ? _m : '');
604
+ var newTemp = document.createElement('temp');
605
+ ScriptUtils.eval("\n const " + RawSet.SCRIPTS_VARNAME + " = this.__render.scripts;\n var i = 0; \n for(const it of " + drAttr.drForOf + ") {\n var destIt = it;\n var forOfStr = `" + drAttr.drForOf + "`;\n if (/,/g.test(forOfStr)) {\n if (typeof it === 'string') {\n destIt = it;\n } else {\n destIt = forOfStr.substring(1, forOfStr.length-1).split(',')[i];\n }\n } else {\n destIt = forOfStr + '[' + i +']'\n }\n \n const n = this.__render.element.cloneNode(true);\n n.innerHTML = n.innerHTML.replace(/\\#it\\#/g, destIt);\n \n if (this.__render.drStripOption) {\n Array.from(n.childNodes).forEach(it => this.__render.fag.append(it));\n } else {\n this.__render.fag.append(n);\n }\n i++;\n }", Object.assign(obj, {
606
+ __render: Object.freeze({
607
+ drStripOption: drAttr.drStripOption,
608
+ fag: newTemp,
609
+ element: element_2,
610
+ scripts: _this.setBindProperty(config === null || config === void 0 ? void 0 : config.scripts, obj)
611
+ })
612
+ }));
613
+ RawSet.drVarDecoding(newTemp, vars);
614
+ RawSet.drItOtherDecoding(newTemp, itRandom);
615
+ var tempalte = document.createElement('template');
616
+ tempalte.innerHTML = newTemp.innerHTML;
617
+ fag.append(tempalte.content);
618
+ var rr = RawSet.checkPointCreates(fag, config);
619
+ (_o = element_2.parentNode) === null || _o === void 0 ? void 0 : _o.replaceChild(fag, element_2);
620
+ raws.push.apply(raws, rr);
621
+ }
622
+ (_p = config === null || config === void 0 ? void 0 : config.targetElements) === null || _p === void 0 ? void 0 : _p.forEach(function (it) {
623
+ var _a, _b;
624
+ var name = it.name;
625
+ if (name.toLowerCase() === element_2.tagName.toLowerCase()) {
626
+ var documentFragment = it.callBack(element_2, obj, _this);
627
+ if (documentFragment) {
628
+ fag.append(documentFragment);
629
+ var rr = RawSet.checkPointCreates(fag, config);
630
+ (_a = element_2.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fag, element_2);
631
+ var onInit = element_2.getAttribute('dr-on-init-component');
632
+ if (onInit) {
633
+ ScriptUtils.evalReturn(onInit, obj)(obj === null || obj === void 0 ? void 0 : obj.__componentInstances[_this.uuid], _this);
634
+ }
635
+ raws.push.apply(raws, rr);
636
+ onElementInitCallBack.push({
637
+ name: name,
638
+ obj: obj
639
+ });
640
+ (_b = it === null || it === void 0 ? void 0 : it.complete) === null || _b === void 0 ? void 0 : _b.call(it, element_2, obj, _this);
641
+ }
642
+ }
643
+ });
644
+ (_q = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _q === void 0 ? void 0 : _q.forEach(function (it) {
645
+ var _a, _b;
646
+ var attrName = it.name;
647
+ var attrValue = _this.getAttributeAndDelete(element_2, attrName);
648
+ if (attrValue && attrName) {
649
+ var documentFragment = it.callBack(element_2, attrValue, obj, _this);
650
+ if (documentFragment) {
651
+ fag.append(documentFragment);
652
+ var rr = RawSet.checkPointCreates(fag, config);
653
+ (_a = element_2.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(fag, element_2);
654
+ raws.push.apply(raws, rr);
655
+ onAttrInitCallBack.push({
656
+ attrName: attrName,
657
+ attrValue: attrValue,
658
+ obj: obj
659
+ });
660
+ (_b = it === null || it === void 0 ? void 0 : it.complete) === null || _b === void 0 ? void 0 : _b.call(it, element_2, attrValue, obj, _this);
661
+ }
662
+ }
663
+ });
664
+ }
665
+ });
666
+ this.applyEvent(obj, genNode, config);
667
+ this.replaceBody(genNode);
668
+ onElementInitCallBack.forEach(function (it) { var _a; return (_a = config === null || config === void 0 ? void 0 : config.onElementInit) === null || _a === void 0 ? void 0 : _a.call(config, it.name, obj, _this); });
669
+ onAttrInitCallBack.forEach(function (it) { var _a; return (_a = config === null || config === void 0 ? void 0 : config.onAttrInit) === null || _a === void 0 ? void 0 : _a.call(config, it.attrName, it.attrValue, obj, _this); });
670
+ return raws;
671
+ };
672
+ RawSet.prototype.applyEvent = function (obj, fragment, config) {
673
+ if (fragment === void 0) { fragment = this.fragment; }
674
+ eventManager.applyEvent(obj, eventManager.findAttrElements(fragment, config), config);
675
+ };
676
+ RawSet.prototype.getAttributeAndDelete = function (element, attr) {
677
+ var data = element.getAttribute(attr);
678
+ element.removeAttribute(attr);
679
+ return data;
680
+ };
681
+ RawSet.prototype.replaceBody = function (genNode) {
682
+ var _a;
683
+ this.childAllRemove();
684
+ (_a = this.point.start.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(genNode, this.point.start.nextSibling);
685
+ };
686
+ RawSet.checkPointCreates = function (element, config) {
687
+ var _a, _b, _c, _d;
688
+ var nodeIterator = document.createNodeIterator(element, NodeFilter.SHOW_ALL, {
689
+ acceptNode: function (node) {
690
+ var _a, _b, _c, _d, _e;
691
+ if (node.nodeType === Node.TEXT_NODE) {
692
+ return /\$\{.*?\}/g.test(StringUtils.deleteEnter((_a = node.data) !== null && _a !== void 0 ? _a : '')) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
693
+ }
694
+ else if (node.nodeType === Node.ELEMENT_NODE) {
695
+ var element_3 = node;
696
+ var isElement = ((_c = (_b = config === null || config === void 0 ? void 0 : config.targetElements) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name.toLowerCase(); })) !== null && _c !== void 0 ? _c : []).includes(element_3.tagName.toLowerCase());
697
+ var targetAttrNames_1 = ((_e = (_d = config === null || config === void 0 ? void 0 : config.targetAttrs) === null || _d === void 0 ? void 0 : _d.map(function (it) { return it.name; })) !== null && _e !== void 0 ? _e : []).concat(RawSet.DR_ATTRIBUTES);
698
+ var isAttr = element_3.getAttributeNames().filter(function (it) { return targetAttrNames_1.includes(it.toLowerCase()); }).length > 0;
699
+ return (isAttr || isElement) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
700
+ }
701
+ return NodeFilter.FILTER_REJECT;
702
+ }
703
+ });
704
+ var pars = [];
705
+ var currentNode;
706
+ var _loop_1 = function () {
707
+ if (currentNode.nodeType === Node.TEXT_NODE) {
708
+ var text = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
709
+ var template_1 = document.createElement('template');
710
+ var a = StringUtils.regexExec(/\$\{.*?\}/g, text);
711
+ var map = a.map(function (it) {
712
+ return {
713
+ uuid: RandomUtils.uuid(),
714
+ content: it[0],
715
+ regexArr: it
716
+ };
717
+ });
718
+ var lasterIndex_1 = 0;
719
+ map.forEach(function (it) {
720
+ var regexArr = it.regexArr;
721
+ var preparedText = regexArr.input.substring(lasterIndex_1, regexArr.index);
722
+ var start = document.createComment("start text " + it.uuid);
723
+ var end = document.createComment("end text " + it.uuid);
724
+ template_1.content.append(document.createTextNode(preparedText));
725
+ template_1.content.append(start);
726
+ template_1.content.append(end);
727
+ var fragment = document.createDocumentFragment();
728
+ fragment.append(document.createTextNode(it.content));
729
+ pars.push(new RawSet(it.uuid, {
730
+ start: start,
731
+ end: end
732
+ }, fragment));
733
+ lasterIndex_1 = regexArr.index + it.content.length;
734
+ });
735
+ template_1.content.append(document.createTextNode(text.substring(lasterIndex_1, text.length)));
736
+ (_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template_1.content, currentNode);
737
+ }
738
+ else {
739
+ var uuid = RandomUtils.uuid();
740
+ var fragment = document.createDocumentFragment();
741
+ var start = document.createComment("start " + uuid);
742
+ var end = document.createComment("end " + uuid);
743
+ (_c = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(start, currentNode);
744
+ (_d = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _d === void 0 ? void 0 : _d.insertBefore(end, currentNode.nextSibling);
745
+ fragment.append(currentNode);
746
+ pars.push(new RawSet(uuid, {
747
+ start: start,
748
+ end: end
749
+ }, fragment));
750
+ }
751
+ };
752
+ while (currentNode = nodeIterator.nextNode()) {
753
+ _loop_1();
754
+ }
755
+ return pars;
756
+ };
757
+ RawSet.prototype.childAllRemove = function () {
758
+ var next = this.point.start.nextSibling;
759
+ while (next) {
760
+ if (next === this.point.end) {
761
+ break;
762
+ }
763
+ next.remove();
764
+ next = this.point.start.nextSibling;
765
+ }
766
+ };
767
+ RawSet.drItOtherEncoding = function (element) {
768
+ var random = RandomUtils.uuid();
769
+ var regex = /#it#/g;
770
+ element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
771
+ it.innerHTML = it.innerHTML.replace(regex, random);
772
+ });
773
+ return random;
774
+ };
775
+ RawSet.drItOtherDecoding = function (element, random) {
776
+ element.querySelectorAll("[" + RawSet.DR_IT_OPTIONNAME + "], [" + RawSet.DR_FOR_OF_NAME + "]").forEach(function (it) {
777
+ it.innerHTML = it.innerHTML.replace(RegExp(random, 'g'), '#it#');
778
+ });
779
+ };
780
+ RawSet.drThisEncoding = function (element, drThis) {
781
+ var thisRandom = RandomUtils.uuid();
782
+ element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
783
+ var message = it.innerHTML;
784
+ StringUtils.regexExec(/([^(dr\-)])?this(?=.?)/g, message).reverse().forEach(function (it) {
785
+ var _a;
786
+ message = message.substr(0, it.index) + message.substr(it.index).replace(it[0], "" + ((_a = it[1]) !== null && _a !== void 0 ? _a : '') + drThis);
787
+ });
788
+ it.innerHTML = message;
789
+ });
790
+ var message = element.innerHTML;
791
+ StringUtils.regexExec(/([^(dr\-)])?this(?=.?)/g, message).reverse().forEach(function (it) {
792
+ var _a;
793
+ message = message.substr(0, it.index) + message.substr(it.index).replace(it[0], "" + ((_a = it[1]) !== null && _a !== void 0 ? _a : '') + drThis);
794
+ });
795
+ element.innerHTML = message;
796
+ return thisRandom;
797
+ };
798
+ RawSet.drThisDecoding = function (element, thisRandom) {
799
+ element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
800
+ it.innerHTML = it.innerHTML.replace(RegExp(thisRandom, 'g'), 'this');
801
+ });
802
+ };
803
+ RawSet.drVarEncoding = function (element, drVarOption) {
804
+ var _a;
805
+ var vars = ((_a = drVarOption === null || drVarOption === void 0 ? void 0 : drVarOption.split(',')) !== null && _a !== void 0 ? _a : []).map(function (it) {
806
+ var s = it.trim().split('=');
807
+ return {
808
+ name: s[0],
809
+ value: s[1],
810
+ regex: RegExp('var\\.' + s[0] + '(?=.?)', 'g'),
811
+ random: RandomUtils.uuid()
812
+ };
813
+ });
814
+ element.querySelectorAll("[" + RawSet.DR_VAR_OPTIONNAME + "]").forEach(function (it) {
815
+ vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
816
+ it.innerHTML = it.innerHTML.replace(vit.regex, vit.random);
817
+ });
818
+ });
819
+ vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
820
+ element.innerHTML = element.innerHTML.replace(vit.regex, vit.value);
821
+ });
822
+ return vars;
823
+ };
824
+ RawSet.drVarDecoding = function (element, vars) {
825
+ element.querySelectorAll("[" + RawSet.DR_THIS_NAME + "]").forEach(function (it) {
826
+ vars.filter(function (vit) { return vit.value && vit.name; }).forEach(function (vit) {
827
+ it.innerHTML = it.innerHTML.replace(RegExp(vit.random, 'g'), vit.value);
828
+ });
829
+ });
830
+ };
831
+ RawSet.drThisCreate = function (element, drThis, drVarOption, drStripOption, obj) {
832
+ var fag = document.createDocumentFragment();
833
+ var n = element.cloneNode(true);
834
+ var thisRandom = this.drThisEncoding(n, drThis);
835
+ var vars = this.drVarEncoding(n, drVarOption);
836
+ this.drVarDecoding(n, vars);
837
+ this.drThisDecoding(n, thisRandom);
838
+ if (drStripOption) {
839
+ Array.from(n.childNodes).forEach(function (it) { return fag.append(it); });
840
+ }
841
+ else {
842
+ fag.append(n);
843
+ }
844
+ return fag;
845
+ };
846
+ RawSet.prototype.setBindProperty = function (scripts, obj) {
847
+ if (scripts) {
848
+ var newScripts = Object.assign({}, scripts);
849
+ for (var _i = 0, _a = Object.entries(newScripts); _i < _a.length; _i++) {
850
+ var _b = _a[_i], key = _b[0], value = _b[1];
851
+ if (typeof value === 'function') {
852
+ newScripts[key] = value.bind(obj);
853
+ }
854
+ }
855
+ return newScripts;
856
+ }
857
+ };
858
+ RawSet.DR = 'dr';
859
+ RawSet.DR_IF_NAME = 'dr-if';
860
+ RawSet.DR_FOR_OF_NAME = 'dr-for-of';
861
+ RawSet.DR_FOR_NAME = 'dr-for';
862
+ RawSet.DR_THIS_NAME = 'dr-this';
863
+ RawSet.DR_INNERHTML_NAME = 'dr-inner-html';
864
+ RawSet.DR_INNERTEXT_NAME = 'dr-inner-text';
865
+ RawSet.DR_TAGS = [];
866
+ RawSet.DR_IT_OPTIONNAME = 'dr-it';
867
+ RawSet.DR_VAR_OPTIONNAME = 'dr-var';
868
+ RawSet.DR_STRIP_OPTIONNAME = 'dr-strip';
869
+ RawSet.DR_ATTRIBUTES = [RawSet.DR, RawSet.DR_IF_NAME, RawSet.DR_FOR_OF_NAME, RawSet.DR_FOR_NAME, RawSet.DR_THIS_NAME, RawSet.DR_INNERHTML_NAME, RawSet.DR_INNERTEXT_NAME];
870
+ RawSet.SCRIPTS_VARNAME = '$scripts';
871
+ RawSet.RAWSET_VARNAME = '$rawset';
872
+ return RawSet;
816
873
  }());
817
874
 
818
- var Shield = (function () {
819
- function Shield() {
820
- }
821
- return Shield;
875
+ var Shield = (function () {
876
+ function Shield() {
877
+ }
878
+ return Shield;
822
879
  }());
823
880
 
824
- var DomRenderProxy = (function () {
825
- function DomRenderProxy(_domRender_origin, target, config) {
826
- this._domRender_origin = _domRender_origin;
827
- this.config = config;
828
- this._domRender_ref = new Map();
829
- this._rawSets = new Map();
830
- this._targets = new Set();
831
- if (target) {
832
- this._targets.add(target);
833
- }
834
- }
835
- DomRenderProxy.final = function (obj) {
836
- return new Proxy(obj, {
837
- has: function (target, p) {
838
- return p === '_DomRender_isFinal' || p in target;
839
- }
840
- });
841
- };
842
- DomRenderProxy.isFinal = function (obj) {
843
- return '_DomRender_isFinal' in obj;
844
- };
845
- DomRenderProxy.prototype.run = function (objProxy) {
846
- var _this = this;
847
- this._domRender_proxy = objProxy;
848
- var obj = objProxy._DomRender_origin;
849
- if (obj) {
850
- Object.keys(obj).forEach(function (it) {
851
- var _a, _b, _c;
852
- var target = obj[it];
853
- if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target) && !(obj instanceof Shield)) {
854
- var filter = (_c = (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeTyps) === null || _b === void 0 ? void 0 : _b.filter(function (it) { return target instanceof it; })) !== null && _c !== void 0 ? _c : [];
855
- if (filter.length === 0) {
856
- var proxyAfter = _this.proxy(objProxy, target, it);
857
- obj[it] = proxyAfter;
858
- }
859
- }
860
- });
861
- }
862
- this._targets.forEach(function (target) {
863
- _this.initRender(target);
864
- });
865
- };
866
- DomRenderProxy.prototype.initRender = function (target) {
867
- var _this = this;
868
- var _a, _b;
869
- this._targets.add(target);
870
- var rawSets = RawSet.checkPointCreates(target, this.config);
871
- eventManager.applyEvent(this._domRender_proxy, eventManager.findAttrElements(target, this.config), this.config);
872
- rawSets.forEach(function (it) {
873
- var strings = it.getUsingTriggerVariables(_this.config);
874
- if (strings.size <= 0) {
875
- _this.addRawSet('', it);
876
- }
877
- else {
878
- strings.forEach(function (sit) {
879
- _this.addRawSet(sit, it);
880
- });
881
- }
882
- });
883
- this._rawSets.forEach(function (v, k) {
884
- _this.render(Array.from(v));
885
- });
886
- (_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
887
- };
888
- DomRenderProxy.prototype.render = function (raws) {
889
- var _this = this;
890
- raws.forEach(function (it) {
891
- if (it.point.start.isConnected && it.point.start.isConnected) {
892
- var rawSets = it.render(_this._domRender_proxy, _this.config);
893
- _this.render(rawSets);
894
- }
895
- else {
896
- _this.removeRawSet(it);
897
- }
898
- });
899
- };
900
- DomRenderProxy.prototype.root = function (paths, value) {
901
- var _this = this;
902
- if (this._domRender_ref.size > 0) {
903
- this._domRender_ref.forEach(function (it, key) {
904
- if ('_DomRender_isProxy' in key) {
905
- it.forEach(function (sit) {
906
- var _a;
907
- (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value);
908
- });
909
- }
910
- });
911
- }
912
- else {
913
- var strings = paths.reverse();
914
- var fullPathStr_1 = strings.join('.');
915
- var iterable = this._rawSets.get(fullPathStr_1);
916
- var front = strings.slice(0, strings.length - 1).join('.');
917
- var last = strings[strings.length - 1];
918
- if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn(front, this._domRender_proxy))) {
919
- var aIterable = this._rawSets.get(front);
920
- if (aIterable) {
921
- this.render(Array.from(aIterable));
922
- }
923
- }
924
- else if (iterable) {
925
- this.render(Array.from(iterable));
926
- }
927
- this._targets.forEach(function (it) {
928
- if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
929
- var targets = eventManager.findAttrElements(it, _this.config);
930
- eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
931
- }
932
- });
933
- }
934
- };
935
- DomRenderProxy.prototype.set = function (target, p, value, receiver) {
936
- if (typeof p === 'string') {
937
- value = this.proxy(target, value, p);
938
- }
939
- target[p] = value;
940
- if (typeof p === 'string') {
941
- this.root([p], value);
942
- }
943
- return true;
944
- };
945
- DomRenderProxy.prototype.get = function (target, p, receiver) {
946
- if (p === '_DomRender_origin') {
947
- return this._domRender_origin;
948
- }
949
- else if (p === '_DomRender_ref') {
950
- return this._domRender_ref;
951
- }
952
- else if (p === '_DomRender_proxy') {
953
- return this;
954
- }
955
- else {
956
- var it_1 = target[p];
957
- if (it_1 && typeof it_1 === 'object' && ('_DomRender_isProxy' in it_1) && Object.prototype.toString.call(it_1._DomRender_origin) === '[object Date]') {
958
- return it_1._DomRender_origin;
959
- }
960
- else {
961
- return it_1;
962
- }
963
- }
964
- };
965
- DomRenderProxy.prototype.has = function (target, p) {
966
- return p === '_DomRender_isProxy' || p in target;
967
- };
968
- DomRenderProxy.prototype.proxy = function (parentProxy, obj, p) {
969
- if (obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
970
- var domRender = new DomRenderProxy(obj, undefined, this.config);
971
- domRender.addRef(parentProxy, p);
972
- var proxy = new Proxy(obj, domRender);
973
- domRender.run(proxy);
974
- return proxy;
975
- }
976
- if (obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
977
- var d = obj._DomRender_proxy;
978
- d.addRef(this._domRender_proxy, p);
979
- return obj;
980
- }
981
- else {
982
- return obj;
983
- }
984
- };
985
- DomRenderProxy.prototype.addRef = function (parent, path) {
986
- var _a;
987
- if (!this._domRender_ref.get(parent)) {
988
- this._domRender_ref.set(parent, new Set());
989
- }
990
- (_a = this._domRender_ref.get(parent)) === null || _a === void 0 ? void 0 : _a.add(path);
991
- };
992
- DomRenderProxy.prototype.addRawSetAndRender = function (path, rawSet) {
993
- this.addRawSet(path, rawSet);
994
- this.render([rawSet]);
995
- };
996
- DomRenderProxy.prototype.addRawSet = function (path, rawSet) {
997
- var _a;
998
- if (!this._rawSets.get(path)) {
999
- this._rawSets.set(path, new Set());
1000
- }
1001
- (_a = this._rawSets.get(path)) === null || _a === void 0 ? void 0 : _a.add(rawSet);
1002
- };
1003
- DomRenderProxy.prototype.removeRawSet = function (raws) {
1004
- this._rawSets.forEach(function (it) {
1005
- it.delete(raws);
1006
- });
1007
- this.garbageRawSet();
1008
- };
1009
- DomRenderProxy.prototype.garbageRawSet = function () {
1010
- var _this = this;
1011
- this._targets.forEach(function (it) {
1012
- if (!it.isConnected) {
1013
- _this._targets.delete(it);
1014
- }
1015
- });
1016
- this._rawSets.forEach(function (it) {
1017
- it.forEach(function (sit) {
1018
- if (!sit.isConnected) {
1019
- it.delete(sit);
1020
- }
1021
- });
1022
- });
1023
- };
1024
- return DomRenderProxy;
881
+ var DomRenderProxy = (function () {
882
+ function DomRenderProxy(_domRender_origin, target, config) {
883
+ this._domRender_origin = _domRender_origin;
884
+ this.config = config;
885
+ this._domRender_ref = new Map();
886
+ this._rawSets = new Map();
887
+ this._targets = new Set();
888
+ if (target) {
889
+ this._targets.add(target);
890
+ }
891
+ }
892
+ DomRenderProxy.final = function (obj) {
893
+ return new Proxy(obj, {
894
+ has: function (target, p) {
895
+ return p === '_DomRender_isFinal' || p in target;
896
+ }
897
+ });
898
+ };
899
+ DomRenderProxy.isFinal = function (obj) {
900
+ return '_DomRender_isFinal' in obj;
901
+ };
902
+ DomRenderProxy.prototype.run = function (objProxy) {
903
+ var _this = this;
904
+ this._domRender_proxy = objProxy;
905
+ var obj = objProxy._DomRender_origin;
906
+ if (obj) {
907
+ Object.keys(obj).forEach(function (it) {
908
+ var _a, _b, _c;
909
+ var target = obj[it];
910
+ if (target !== undefined && target !== null && typeof target === 'object' && !DomRenderProxy.isFinal(target) && !Object.isFrozen(target) && !(obj instanceof Shield)) {
911
+ var filter = (_c = (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeTyps) === null || _b === void 0 ? void 0 : _b.filter(function (it) { return target instanceof it; })) !== null && _c !== void 0 ? _c : [];
912
+ if (filter.length === 0) {
913
+ var proxyAfter = _this.proxy(objProxy, target, it);
914
+ obj[it] = proxyAfter;
915
+ }
916
+ }
917
+ });
918
+ }
919
+ this._targets.forEach(function (target) {
920
+ _this.initRender(target);
921
+ });
922
+ };
923
+ DomRenderProxy.prototype.initRender = function (target) {
924
+ var _this = this;
925
+ var _a, _b;
926
+ this._targets.add(target);
927
+ var rawSets = RawSet.checkPointCreates(target, this.config);
928
+ eventManager.applyEvent(this._domRender_proxy, eventManager.findAttrElements(target, this.config), this.config);
929
+ rawSets.forEach(function (it) {
930
+ var strings = it.getUsingTriggerVariables(_this.config);
931
+ if (strings.size <= 0) {
932
+ _this.addRawSet('', it);
933
+ }
934
+ else {
935
+ strings.forEach(function (sit) {
936
+ _this.addRawSet(sit, it);
937
+ });
938
+ }
939
+ });
940
+ this.render(this.getRawSets());
941
+ (_b = (_a = this._domRender_proxy) === null || _a === void 0 ? void 0 : _a.onInitRender) === null || _b === void 0 ? void 0 : _b.call(_a);
942
+ };
943
+ DomRenderProxy.prototype.getRawSets = function () {
944
+ var set = new Set();
945
+ this._rawSets.forEach(function (v, k) {
946
+ v.forEach(function (it) { return set.add(it); });
947
+ });
948
+ return Array.from(set);
949
+ };
950
+ DomRenderProxy.prototype.render = function (raws) {
951
+ var _this = this;
952
+ (raws !== null && raws !== void 0 ? raws : this.getRawSets()).forEach(function (it) {
953
+ if (it.point.start.isConnected && it.point.start.isConnected) {
954
+ var rawSets = it.render(_this._domRender_proxy, _this.config);
955
+ _this.render(rawSets);
956
+ }
957
+ else {
958
+ _this.removeRawSet(it);
959
+ }
960
+ });
961
+ };
962
+ DomRenderProxy.prototype.root = function (paths, value) {
963
+ var _this = this;
964
+ if (this._domRender_ref.size > 0) {
965
+ this._domRender_ref.forEach(function (it, key) {
966
+ if ('_DomRender_isProxy' in key) {
967
+ it.forEach(function (sit) {
968
+ var _a;
969
+ (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value);
970
+ });
971
+ }
972
+ });
973
+ }
974
+ else {
975
+ var strings = paths.reverse();
976
+ var fullPathStr_1 = strings.join('.');
977
+ var iterable = this._rawSets.get(fullPathStr_1);
978
+ var front = strings.slice(0, strings.length - 1).join('.');
979
+ var last = strings[strings.length - 1];
980
+ if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn(front, this._domRender_proxy))) {
981
+ var aIterable = this._rawSets.get(front);
982
+ if (aIterable) {
983
+ this.render(Array.from(aIterable));
984
+ }
985
+ }
986
+ else if (iterable) {
987
+ this.render(Array.from(iterable));
988
+ }
989
+ this._targets.forEach(function (it) {
990
+ if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
991
+ var targets = eventManager.findAttrElements(it, _this.config);
992
+ eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
993
+ }
994
+ });
995
+ }
996
+ };
997
+ DomRenderProxy.prototype.set = function (target, p, value, receiver) {
998
+ if (typeof p === 'string') {
999
+ value = this.proxy(target, value, p);
1000
+ }
1001
+ target[p] = value;
1002
+ if (typeof p === 'string') {
1003
+ this.root([p], value);
1004
+ }
1005
+ return true;
1006
+ };
1007
+ DomRenderProxy.prototype.get = function (target, p, receiver) {
1008
+ if (p === '_DomRender_origin') {
1009
+ return this._domRender_origin;
1010
+ }
1011
+ else if (p === '_DomRender_ref') {
1012
+ return this._domRender_ref;
1013
+ }
1014
+ else if (p === '_DomRender_proxy') {
1015
+ return this;
1016
+ }
1017
+ else {
1018
+ var it_1 = target[p];
1019
+ if (it_1 && typeof it_1 === 'object' && ('_DomRender_isProxy' in it_1) && Object.prototype.toString.call(it_1._DomRender_origin) === '[object Date]') {
1020
+ return it_1._DomRender_origin;
1021
+ }
1022
+ else {
1023
+ return it_1;
1024
+ }
1025
+ }
1026
+ };
1027
+ DomRenderProxy.prototype.has = function (target, p) {
1028
+ return p === '_DomRender_isProxy' || p in target;
1029
+ };
1030
+ DomRenderProxy.prototype.proxy = function (parentProxy, obj, p) {
1031
+ var _a, _b, _c;
1032
+ var proxyTarget = ((_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeTyps) === null || _b === void 0 ? void 0 : _b.filter(function (it) { return obj instanceof it; })) !== null && _c !== void 0 ? _c : []).length <= 0;
1033
+ if (proxyTarget && obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
1034
+ var domRender = new DomRenderProxy(obj, undefined, this.config);
1035
+ domRender.addRef(parentProxy, p);
1036
+ var proxy = new Proxy(obj, domRender);
1037
+ domRender.run(proxy);
1038
+ return proxy;
1039
+ }
1040
+ if (proxyTarget && obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
1041
+ var d = obj._DomRender_proxy;
1042
+ d.addRef(this._domRender_proxy, p);
1043
+ return obj;
1044
+ }
1045
+ else {
1046
+ return obj;
1047
+ }
1048
+ };
1049
+ DomRenderProxy.prototype.addRef = function (parent, path) {
1050
+ var _a;
1051
+ if (!this._domRender_ref.get(parent)) {
1052
+ this._domRender_ref.set(parent, new Set());
1053
+ }
1054
+ (_a = this._domRender_ref.get(parent)) === null || _a === void 0 ? void 0 : _a.add(path);
1055
+ };
1056
+ DomRenderProxy.prototype.addRawSetAndRender = function (path, rawSet) {
1057
+ this.addRawSet(path, rawSet);
1058
+ this.render([rawSet]);
1059
+ };
1060
+ DomRenderProxy.prototype.addRawSet = function (path, rawSet) {
1061
+ var _a;
1062
+ if (!this._rawSets.get(path)) {
1063
+ this._rawSets.set(path, new Set());
1064
+ }
1065
+ (_a = this._rawSets.get(path)) === null || _a === void 0 ? void 0 : _a.add(rawSet);
1066
+ };
1067
+ DomRenderProxy.prototype.removeRawSet = function (raws) {
1068
+ this._rawSets.forEach(function (it) {
1069
+ it.delete(raws);
1070
+ });
1071
+ this.garbageRawSet();
1072
+ };
1073
+ DomRenderProxy.prototype.garbageRawSet = function () {
1074
+ var _this = this;
1075
+ this._targets.forEach(function (it) {
1076
+ if (!it.isConnected) {
1077
+ _this._targets.delete(it);
1078
+ }
1079
+ });
1080
+ this._rawSets.forEach(function (it) {
1081
+ it.forEach(function (sit) {
1082
+ if (!sit.isConnected) {
1083
+ it.delete(sit);
1084
+ }
1085
+ });
1086
+ });
1087
+ };
1088
+ return DomRenderProxy;
1025
1089
  }());
1026
1090
 
1027
- var DomRender = (function () {
1028
- function DomRender() {
1029
- }
1030
- DomRender.run = function (obj, target, config) {
1031
- if ('_DomRender_isProxy' in obj) {
1032
- if (target) {
1033
- obj._DomRender_proxy.initRender(target);
1034
- }
1035
- return obj;
1036
- }
1037
- else {
1038
- var domRender = new DomRenderProxy(obj, target, config);
1039
- var dest = new Proxy(obj, domRender);
1040
- domRender.run(dest);
1041
- return dest;
1042
- }
1043
- };
1044
- return DomRender;
1091
+ var DomRender = (function () {
1092
+ function DomRender() {
1093
+ }
1094
+ DomRender.run = function (obj, target, config) {
1095
+ if ('_DomRender_isProxy' in obj) {
1096
+ if (target) {
1097
+ obj._DomRender_proxy.initRender(target);
1098
+ }
1099
+ return obj;
1100
+ }
1101
+ else {
1102
+ var domRender = new DomRenderProxy(obj, target, config);
1103
+ var dest = new Proxy(obj, domRender);
1104
+ domRender.run(dest);
1105
+ return dest;
1106
+ }
1107
+ };
1108
+ return DomRender;
1045
1109
  }());
1046
1110
 
1047
1111
  exports.DomRender = DomRender;
1112
+ //# sourceMappingURL=bundle.js.map