dom-render 1.0.38 → 1.0.42

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,1111 +1,1113 @@
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 = [
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;
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;
421
421
  }())();
422
422
 
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;
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;
873
873
  }());
874
874
 
875
- var Shield = (function () {
876
- function Shield() {
877
- }
878
- return Shield;
875
+ var Shield = (function () {
876
+ function Shield() {
877
+ }
878
+ return Shield;
879
879
  }());
880
880
 
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;
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
+ it.getUsingTriggerVariables(_this.config).forEach(function (path) { return _this.addRawSet(path, it); });
954
+ if (it.point.start.isConnected && it.point.start.isConnected) {
955
+ var rawSets = it.render(_this._domRender_proxy, _this.config);
956
+ _this.render(rawSets);
957
+ }
958
+ else {
959
+ _this.removeRawSet(it);
960
+ }
961
+ });
962
+ };
963
+ DomRenderProxy.prototype.root = function (paths, value) {
964
+ var _this = this;
965
+ if (this._domRender_ref.size > 0) {
966
+ this._domRender_ref.forEach(function (it, key) {
967
+ if ('_DomRender_isProxy' in key) {
968
+ it.forEach(function (sit) {
969
+ var _a;
970
+ (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value);
971
+ });
972
+ }
973
+ });
974
+ }
975
+ else {
976
+ var strings = paths.reverse();
977
+ var fullPathStr_1 = strings.join('.');
978
+ var iterable = this._rawSets.get(fullPathStr_1);
979
+ var front = strings.slice(0, strings.length - 1).join('.');
980
+ var last = strings[strings.length - 1];
981
+ if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn('this.' + front, this._domRender_proxy))) {
982
+ var aIterable = this._rawSets.get(front);
983
+ if (aIterable) {
984
+ this.render(Array.from(aIterable));
985
+ }
986
+ }
987
+ else if (iterable) {
988
+ this.render(Array.from(iterable));
989
+ }
990
+ this._targets.forEach(function (it) {
991
+ if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
992
+ var targets = eventManager.findAttrElements(it, _this.config);
993
+ eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
994
+ }
995
+ });
996
+ }
997
+ };
998
+ DomRenderProxy.prototype.set = function (target, p, value, receiver) {
999
+ if (typeof p === 'string') {
1000
+ value = this.proxy(target, value, p);
1001
+ }
1002
+ target[p] = value;
1003
+ if (typeof p === 'string') {
1004
+ this.root([p], value);
1005
+ }
1006
+ return true;
1007
+ };
1008
+ DomRenderProxy.prototype.get = function (target, p, receiver) {
1009
+ if (p === '_DomRender_origin') {
1010
+ return this._domRender_origin;
1011
+ }
1012
+ else if (p === '_DomRender_ref') {
1013
+ return this._domRender_ref;
1014
+ }
1015
+ else if (p === '_DomRender_proxy') {
1016
+ return this;
1017
+ }
1018
+ else {
1019
+ var it_1 = target[p];
1020
+ if (it_1 && typeof it_1 === 'object' && ('_DomRender_isProxy' in it_1) && Object.prototype.toString.call(it_1._DomRender_origin) === '[object Date]') {
1021
+ return it_1._DomRender_origin;
1022
+ }
1023
+ else {
1024
+ return it_1;
1025
+ }
1026
+ }
1027
+ };
1028
+ DomRenderProxy.prototype.has = function (target, p) {
1029
+ return p === '_DomRender_isProxy' || p in target;
1030
+ };
1031
+ DomRenderProxy.prototype.proxy = function (parentProxy, obj, p) {
1032
+ var _a, _b, _c;
1033
+ 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;
1034
+ if (proxyTarget && obj !== undefined && obj !== null && typeof obj === 'object' && !('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
1035
+ var domRender = new DomRenderProxy(obj, undefined, this.config);
1036
+ domRender.addRef(parentProxy, p);
1037
+ var proxy = new Proxy(obj, domRender);
1038
+ domRender.run(proxy);
1039
+ return proxy;
1040
+ }
1041
+ if (proxyTarget && obj !== undefined && obj !== null && typeof obj === 'object' && ('_DomRender_isProxy' in obj) && !DomRenderProxy.isFinal(obj) && !Object.isFrozen(obj) && !(obj instanceof Shield)) {
1042
+ var d = obj._DomRender_proxy;
1043
+ d.addRef(this._domRender_proxy, p);
1044
+ return obj;
1045
+ }
1046
+ else {
1047
+ return obj;
1048
+ }
1049
+ };
1050
+ DomRenderProxy.prototype.addRef = function (parent, path) {
1051
+ var _a;
1052
+ if (!this._domRender_ref.get(parent)) {
1053
+ this._domRender_ref.set(parent, new Set());
1054
+ }
1055
+ (_a = this._domRender_ref.get(parent)) === null || _a === void 0 ? void 0 : _a.add(path);
1056
+ };
1057
+ DomRenderProxy.prototype.addRawSetAndRender = function (path, rawSet) {
1058
+ this.addRawSet(path, rawSet);
1059
+ this.render([rawSet]);
1060
+ };
1061
+ DomRenderProxy.prototype.addRawSet = function (path, rawSet) {
1062
+ var _a;
1063
+ if (!this._rawSets.get(path)) {
1064
+ this._rawSets.set(path, new Set());
1065
+ }
1066
+ (_a = this._rawSets.get(path)) === null || _a === void 0 ? void 0 : _a.add(rawSet);
1067
+ };
1068
+ DomRenderProxy.prototype.removeRawSet = function (raws) {
1069
+ this._rawSets.forEach(function (it) {
1070
+ it.delete(raws);
1071
+ });
1072
+ this.garbageRawSet();
1073
+ };
1074
+ DomRenderProxy.prototype.garbageRawSet = function () {
1075
+ var _this = this;
1076
+ this._targets.forEach(function (it) {
1077
+ if (!it.isConnected) {
1078
+ _this._targets.delete(it);
1079
+ }
1080
+ });
1081
+ this._rawSets.forEach(function (it) {
1082
+ it.forEach(function (sit) {
1083
+ if (!sit.isConnected) {
1084
+ it.delete(sit);
1085
+ }
1086
+ });
1087
+ });
1088
+ };
1089
+ return DomRenderProxy;
1089
1090
  }());
1090
1091
 
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;
1092
+ var DomRender = (function () {
1093
+ function DomRender() {
1094
+ }
1095
+ DomRender.run = function (obj, target, config) {
1096
+ if ('_DomRender_isProxy' in obj) {
1097
+ if (target) {
1098
+ obj._DomRender_proxy.initRender(target);
1099
+ }
1100
+ return obj;
1101
+ }
1102
+ else {
1103
+ var domRender = new DomRenderProxy(obj, target, config);
1104
+ var dest = new Proxy(obj, domRender);
1105
+ domRender.run(dest);
1106
+ return dest;
1107
+ }
1108
+ };
1109
+ return DomRender;
1109
1110
  }());
1110
1111
 
1111
1112
  exports.DomRender = DomRender;
1113
+ //# sourceMappingURL=bundle.js.map