dom-render 1.0.37 → 1.0.41

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