dom-render 1.0.75 → 1.0.78

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.
@@ -14,7 +14,7 @@ export declare class DomRenderProxy<T extends object> implements ProxyHandler<T>
14
14
  run(objProxy: T): void;
15
15
  initRender(target: Node): void;
16
16
  getRawSets(): RawSet[];
17
- render(raws?: RawSet[] | string): void;
17
+ render(raws?: RawSet[] | string, fullPathStr?: string): void;
18
18
  root(paths: string[], value?: any, lastDoneExecute?: boolean): string[];
19
19
  set(target: T, p: string | symbol, value: any, receiver: T): boolean;
20
20
  get(target: T, p: string | symbol, receiver: any): any;
package/DomRenderProxy.js CHANGED
@@ -28,9 +28,9 @@ var DomRenderProxy = /** @class */ (function () {
28
28
  };
29
29
  DomRenderProxy.prototype.run = function (objProxy) {
30
30
  var _this = this;
31
- var _a;
31
+ var _a, _b;
32
32
  this._domRender_proxy = objProxy;
33
- (_a = objProxy === null || objProxy === void 0 ? void 0 : objProxy.onProxyDomRender) === null || _a === void 0 ? void 0 : _a.call(objProxy, this.config);
33
+ (_b = (_a = objProxy) === null || _a === void 0 ? void 0 : _a.onProxyDomRender) === null || _b === void 0 ? void 0 : _b.call(_a, this.config);
34
34
  var obj = objProxy._DomRender_origin;
35
35
  if (obj) {
36
36
  Object.keys(obj).forEach(function (it) {
@@ -56,8 +56,8 @@ var DomRenderProxy = /** @class */ (function () {
56
56
  DomRenderProxy.prototype.initRender = function (target) {
57
57
  var _this = this;
58
58
  var _a, _b, _c, _d, _e, _f, _g;
59
- var onCreate = (_b = (_a = target).getAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, 'dr-on-create');
60
- var createParam = undefined;
59
+ var onCreate = (_b = (_a = target).getAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, "".concat(EventManager_1.EventManager.attrPrefix, "on-create"));
60
+ var createParam;
61
61
  if (onCreate) {
62
62
  createParam = ScriptUtils_1.ScriptUtils.evalReturn(onCreate, this._domRender_proxy);
63
63
  }
@@ -65,6 +65,8 @@ var DomRenderProxy = /** @class */ (function () {
65
65
  var innerHTML = (_e = target.innerHTML) !== null && _e !== void 0 ? _e : '';
66
66
  this._targets.add(target);
67
67
  var rawSets = RawSet_1.RawSet.checkPointCreates(target, this.config);
68
+ // console.log('initRender -------rawSet', rawSets)
69
+ // 중요 초기에 한번 튕겨줘야함.
68
70
  EventManager_1.eventManager.applyEvent(this._domRender_proxy, EventManager_1.eventManager.findAttrElements(target, this.config), this.config);
69
71
  rawSets.forEach(function (it) {
70
72
  var variables = it.getUsingTriggerVariables(_this.config);
@@ -93,7 +95,8 @@ var DomRenderProxy = /** @class */ (function () {
93
95
  });
94
96
  return Array.from(set);
95
97
  };
96
- DomRenderProxy.prototype.render = function (raws) {
98
+ // 중요 important
99
+ DomRenderProxy.prototype.render = function (raws, fullPathStr) {
97
100
  var _this = this;
98
101
  if (typeof raws === 'string') {
99
102
  var iter = this._rawSets.get(raws);
@@ -106,15 +109,40 @@ var DomRenderProxy = /** @class */ (function () {
106
109
  }
107
110
  var removeRawSets = [];
108
111
  (raws !== null && raws !== void 0 ? raws : this.getRawSets()).forEach(function (it) {
109
- var _a;
112
+ var _a, _b, _c;
110
113
  it.getUsingTriggerVariables(_this.config).forEach(function (path) { return _this.addRawSet(path, it); });
111
- // console.log('------->', it, it.isConnected)
114
+ // console.log('------->', it, it.isConnected);
112
115
  if (it.isConnected) {
113
- if ((_a = it.detect) === null || _a === void 0 ? void 0 : _a.action) {
116
+ // 중요 render될때 targetAttribute 체크 해야함.
117
+ var targetAttrMap = (_b = (_a = it.point.node) === null || _a === void 0 ? void 0 : _a.getAttribute) === null || _b === void 0 ? void 0 : _b.call(_a, EventManager_1.EventManager.normalAttrMapAttrName);
118
+ if ((_c = it.detect) === null || _c === void 0 ? void 0 : _c.action) {
114
119
  it.detect.action();
115
120
  }
121
+ else if (it.type === RawSet_1.RawSetType.TARGET_ELEMENT && it.data && fullPathStr && targetAttrMap && it.fragment.render) {
122
+ new Map(JSON.parse(targetAttrMap)).forEach(function (v, k) {
123
+ // it?.data.onChangeAttrRender(k, null, v);
124
+ var isUsing = EventManager_1.EventManager.isUsingThisVar(v, "this.".concat(fullPathStr));
125
+ if (isUsing) {
126
+ var render = it.fragment.render;
127
+ // console.log('render-->', (it.fragment as any).render)
128
+ var script = "".concat(render.renderScript, " return ").concat(v, " ");
129
+ var cval = ScriptUtils_1.ScriptUtils.eval(script, Object.assign(_this._domRender_proxy, { __render: render }));
130
+ it.data.onChangeAttrRender(k, cval);
131
+ }
132
+ // console.log('---?', v, fullPathStr, isUsing);
133
+ });
134
+ // ------------------->
135
+ }
116
136
  else {
117
137
  var rawSets = it.render(_this._domRender_proxy, _this.config);
138
+ // 대상 attribute 있으면
139
+ // const targetAttrs = (it.point.node as Element).getAttribute(EventManager.normalAttrMapAttrName);
140
+ // if (it?.data.onChangeAttrRender && it.type === RawSetType.TARGET_ELEMENT && targetAttrs) {
141
+ // new Map<string, string>(JSON.parse(targetAttrs)).forEach((v, k) => {
142
+ // it?.data.onChangeAttrRender(k, null, v);
143
+ // });
144
+ // }
145
+ // 그외 자식들 render
118
146
  if (rawSets && rawSets.length > 0) {
119
147
  _this.render(rawSets);
120
148
  }
@@ -157,6 +185,7 @@ var DomRenderProxy = /** @class */ (function () {
157
185
  var fullPathStr_1 = strings.map(function (it) { return isNaN(Number(it)) ? '.' + it : "[".concat(it, "]"); }).join('').slice(1);
158
186
  if (lastDoneExecute) {
159
187
  var iterable = this._rawSets.get(fullPathStr_1);
188
+ // console.log('----->', iterable);
160
189
  // array check
161
190
  var front = strings.slice(0, strings.length - 1).map(function (it) { return isNaN(Number(it)) ? '.' + it : "[".concat(it, "]"); }).join('');
162
191
  var last = strings[strings.length - 1];
@@ -168,11 +197,14 @@ var DomRenderProxy = /** @class */ (function () {
168
197
  }
169
198
  }
170
199
  else if (iterable) {
171
- this.render(Array.from(iterable));
200
+ this.render(Array.from(iterable), fullPathStr_1);
172
201
  }
173
202
  this._targets.forEach(function (it) {
203
+ // console.log('target------->,', it)
204
+ // return;
174
205
  if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
175
206
  var targets = EventManager_1.eventManager.findAttrElements(it, _this.config);
207
+ // console.log('------>', targets);
176
208
  EventManager_1.eventManager.changeVar(_this._domRender_proxy, targets, "this.".concat(fullPathStr_1), _this.config);
177
209
  }
178
210
  });
@@ -182,7 +214,7 @@ var DomRenderProxy = /** @class */ (function () {
182
214
  return fullPaths;
183
215
  };
184
216
  DomRenderProxy.prototype.set = function (target, p, value, receiver) {
185
- var _a, _b;
217
+ var _a, _b, _c;
186
218
  if (typeof p === 'string' && p !== '__domrender_components' && excludeGetSetPropertys.includes(p)) {
187
219
  target[p] = value;
188
220
  return true;
@@ -203,12 +235,12 @@ var DomRenderProxy = /** @class */ (function () {
203
235
  }
204
236
  // console.log('full path:', fullPath);
205
237
  if (('onBeforeReturnSet' in receiver) && typeof p === 'string' && !((_a = this.config.proxyExcludeOnBeforeReturnSets) !== null && _a !== void 0 ? _a : []).concat(excludeGetSetPropertys).includes(p)) {
206
- (_b = receiver === null || receiver === void 0 ? void 0 : receiver.onBeforeReturnSet) === null || _b === void 0 ? void 0 : _b.call(receiver, p, value, fullPath);
238
+ (_c = (_b = receiver) === null || _b === void 0 ? void 0 : _b.onBeforeReturnSet) === null || _c === void 0 ? void 0 : _c.call(_b, p, value, fullPath);
207
239
  }
208
240
  return true;
209
241
  };
210
242
  DomRenderProxy.prototype.get = function (target, p, receiver) {
211
- var _a, _b;
243
+ var _a, _b, _c;
212
244
  // console.log('get-->', target, p, receiver);
213
245
  if (p === '_DomRender_origin') {
214
246
  return this._domRender_origin;
@@ -239,7 +271,7 @@ var DomRenderProxy = /** @class */ (function () {
239
271
  it_1 = it_1._DomRender_origin;
240
272
  }
241
273
  if (('onBeforeReturnGet' in receiver) && typeof p === 'string' && !((_a = this.config.proxyExcludeOnBeforeReturnGets) !== null && _a !== void 0 ? _a : []).concat(excludeGetSetPropertys).includes(p)) {
242
- (_b = receiver === null || receiver === void 0 ? void 0 : receiver.onBeforeReturnGet) === null || _b === void 0 ? void 0 : _b.call(receiver, p, it_1, this.root([p], it_1, false));
274
+ (_c = (_b = receiver) === null || _b === void 0 ? void 0 : _b.onBeforeReturnGet) === null || _c === void 0 ? void 0 : _c.call(_b, p, it_1, this.root([p], it_1, false));
243
275
  }
244
276
  return it_1;
245
277
  }
@@ -279,7 +311,7 @@ var DomRenderProxy = /** @class */ (function () {
279
311
  };
280
312
  DomRenderProxy.prototype.addRawSet = function (path, rawSet) {
281
313
  var _a;
282
- // console.log('addRawSet-->', path, rawSet)
314
+ // console.log('addRawSet--> path:', path, 'rawSet:', rawSet)
283
315
  if (!this._rawSets.get(path)) {
284
316
  this._rawSets.set(path, new Set());
285
317
  }
package/README.MD CHANGED
@@ -7,7 +7,7 @@ DOM-RENDER
7
7
 
8
8
  # 🚀 Quick start
9
9
  ```html
10
- <script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.75/dist/bundle.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/dom-render@1.0.78/dist/bundle.js"></script>
11
11
  ```
12
12
  ```html
13
13
  <!DOCTYPE html>
@@ -54,6 +54,32 @@ ${this.name}$ <!-- outout: <i>my name is dom-render</i> -->
54
54
 
55
55
  # dom-render attributes
56
56
 
57
+
58
+ ## attribute change, bind
59
+ <details>
60
+ <summary>attribute<strong>🔻(click)</strong></summary>
61
+
62
+ ### attribute
63
+ ```html
64
+ <body id="app">
65
+ <input type="text" value="${this.name}$" style="${'color: '+this.color}$">
66
+ <button dr-event-click="this.changeData();">change</button>
67
+ </body>
68
+ ```
69
+ ```typescript
70
+ class Data {
71
+ name = 'my name is dom-render';
72
+ color = '#ff0000';
73
+
74
+ changeData() {
75
+ this.name = RandomUtils.getRandomString(10);
76
+ this.color = RandomUtils.getRandomColor();
77
+ }
78
+ }
79
+ const data = DomRender.run(new Data(), document.querySelector('#app')!);
80
+ ```
81
+ </details>
82
+
57
83
  ## control, print Statement
58
84
  <details>
59
85
  <summary>dr-if<strong>🔻(click)</strong></summary>
@@ -73,6 +99,10 @@ ${this.name}$ <!-- outout: <i>my name is dom-render</i> -->
73
99
  ```
74
100
  </details>
75
101
 
102
+
103
+
104
+
105
+
76
106
  <details>
77
107
  <summary>dr-for, dr-for-of<strong>🔻(click)</strong></summary>
78
108
 
package/RawSet.d.ts CHANGED
@@ -47,6 +47,12 @@ export declare type ElementInitCallBack = {
47
47
  targetElement: TargetElement;
48
48
  creatorMetaData: CreatorMetaData;
49
49
  };
50
+ export declare enum RawSetType {
51
+ TEXT = "TEXT",
52
+ TARGET_ELEMENT = "TARGET_ELEMENT",
53
+ TARGET_ATTR = "TARGET_ATTR",
54
+ UNKOWN = "UNKOWN"
55
+ }
50
56
  export declare type Render = {
51
57
  rawset?: RawSet;
52
58
  scripts?: {
@@ -63,8 +69,10 @@ export declare type Render = {
63
69
  };
64
70
  export declare class RawSet {
65
71
  uuid: string;
72
+ type: RawSetType;
66
73
  point: {
67
74
  start: Comment;
75
+ node: Node;
68
76
  end: Comment;
69
77
  thisVariableName?: string | null;
70
78
  };
@@ -72,7 +80,7 @@ export declare class RawSet {
72
80
  detect?: {
73
81
  action: Function;
74
82
  } | undefined;
75
- data: any;
83
+ data?: any;
76
84
  static readonly DR = "dr";
77
85
  static readonly DR_IF_NAME = "dr-if";
78
86
  static readonly DR_FOR_NAME = "dr-for";
@@ -96,8 +104,9 @@ export declare class RawSet {
96
104
  static readonly drAttrsOriginName: Attrs;
97
105
  static readonly DR_TAGS: never[];
98
106
  static readonly DR_ATTRIBUTES: string[];
99
- constructor(uuid: string, point: {
107
+ constructor(uuid: string, type: RawSetType, point: {
100
108
  start: Comment;
109
+ node: Node;
101
110
  end: Comment;
102
111
  thisVariableName?: string | null;
103
112
  }, fragment: DocumentFragment, detect?: {
@@ -133,7 +142,8 @@ export declare class RawSet {
133
142
  static drThisCreate(element: Element, drThis: string, drVarOption: string, drStripOption: boolean | string | null, obj: any, config: Config, set?: ComponentSet): DocumentFragment;
134
143
  static createComponentTargetAttribute(name: string, getThisObj: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => any, factory: (element: Element, attrValue: string, obj: any, rawSet: RawSet) => DocumentFragment): TargetAttr;
135
144
  static createComponentTargetElement(name: string, objFactory: (element: Element, obj: any, rawSet: RawSet, counstructorParam: any[]) => any, template: string | undefined, styles: string[] | undefined, styleLocale: boolean, config: Config): TargetElement;
136
- static exporesionGrouops(data: string): RegExpExecArray[];
145
+ static isExporesion(data: string | null): boolean;
146
+ static exporesionGrouops(data: string | null): RegExpExecArray[];
137
147
  static styleTransformLocal(styleBody: string | string[], id: string, styleTagWrap?: boolean, locale?: boolean): string;
138
148
  static destroy(obj: any | undefined, parameter: any[], config: Config, destroyOptions?: (DestroyOptionType | string)[]): void;
139
149
  }
package/RawSet.js CHANGED
@@ -20,7 +20,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  return to.concat(ar || Array.prototype.slice.call(from));
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.RawSet = exports.DestroyOptionType = void 0;
23
+ exports.RawSet = exports.RawSetType = exports.DestroyOptionType = void 0;
24
24
  var RandomUtils_1 = require("./utils/random/RandomUtils");
25
25
  var StringUtils_1 = require("./utils/string/StringUtils");
26
26
  var ScriptUtils_1 = require("./utils/script/ScriptUtils");
@@ -47,14 +47,22 @@ var DestroyOptionType;
47
47
  DestroyOptionType["NO_DESTROY"] = "NO_DESTROY";
48
48
  DestroyOptionType["NO_MESSENGER_DESTROY"] = "NO_MESSENGER_DESTROY";
49
49
  })(DestroyOptionType = exports.DestroyOptionType || (exports.DestroyOptionType = {}));
50
+ var RawSetType;
51
+ (function (RawSetType) {
52
+ RawSetType["TEXT"] = "TEXT";
53
+ RawSetType["TARGET_ELEMENT"] = "TARGET_ELEMENT";
54
+ RawSetType["TARGET_ATTR"] = "TARGET_ATTR";
55
+ RawSetType["UNKOWN"] = "UNKOWN";
56
+ })(RawSetType = exports.RawSetType || (exports.RawSetType = {}));
50
57
  var RawSet = /** @class */ (function () {
51
- function RawSet(uuid, point, fragment, detect, data) {
52
- if (data === void 0) { data = {}; }
58
+ function RawSet(uuid, type, point, fragment, detect, data) {
53
59
  this.uuid = uuid;
60
+ this.type = type;
54
61
  this.point = point;
55
62
  this.fragment = fragment;
56
63
  this.detect = detect;
57
64
  this.data = data;
65
+ // console.log('rawset constructor->', (this.point.node as Element).getAttributeNames());
58
66
  }
59
67
  Object.defineProperty(RawSet.prototype, "isConnected", {
60
68
  get: function () {
@@ -63,6 +71,7 @@ var RawSet = /** @class */ (function () {
63
71
  enumerable: false,
64
72
  configurable: true
65
73
  });
74
+ // 중요
66
75
  RawSet.prototype.getUsingTriggerVariables = function (config) {
67
76
  var usingTriggerVariables = new Set();
68
77
  this.fragment.childNodes.forEach(function (cNode, key) {
@@ -70,11 +79,28 @@ var RawSet = /** @class */ (function () {
70
79
  var script = '';
71
80
  if (cNode.nodeType === Node.TEXT_NODE) {
72
81
  script = "`".concat((_a = cNode.textContent) !== null && _a !== void 0 ? _a : '', "`");
82
+ // console.log('???????', script)
73
83
  }
74
84
  else if (cNode.nodeType === Node.ELEMENT_NODE) {
75
85
  var element_1 = cNode;
76
- 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);
77
- script = targetAttrNames.map(function (it) { return (element_1.getAttribute(it)); }).filter(function (it) { return it; }).join(';');
86
+ 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); // .concat(EventManager.normalAttrMapAttrName);
87
+ var targetScripts_1 = targetAttrNames.map(function (it) { return element_1.getAttribute(it); }).filter(function (it) { return it; });
88
+ var targetAttrMap = element_1.getAttribute(EventManager_1.EventManager.normalAttrMapAttrName);
89
+ if (targetAttrMap) {
90
+ // console.log('----->', targetAttr);
91
+ new Map(JSON.parse(targetAttrMap)).forEach(function (v, k) {
92
+ targetScripts_1.push(v);
93
+ });
94
+ }
95
+ script = targetScripts_1.join(';');
96
+ // attribute쪽 체크하는거 추가
97
+ // console.log('----!!!!!-->', targetAttrNames)
98
+ // const otherAttrs = element.getAttributeNames()
99
+ // .filter(it => !targetAttrNames.includes(it.toLowerCase()) && RawSet.isExporesion(element.getAttribute(it)))
100
+ // .map(it => {
101
+ // return `\`${element.getAttribute(it) ?? ''}\``;
102
+ // }).join(';');
103
+ // script += ';' + otherAttrs
78
104
  }
79
105
  if (script) {
80
106
  // script = script.replace('}$','}');
@@ -92,6 +118,7 @@ var RawSet = /** @class */ (function () {
92
118
  // console.log('usingTriggerVariable----------->', usingTriggerVariables)
93
119
  return usingTriggerVariables;
94
120
  };
121
+ // 중요 render
95
122
  RawSet.prototype.render = function (obj, config) {
96
123
  var _this = this;
97
124
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -121,7 +148,7 @@ var RawSet = /** @class */ (function () {
121
148
  if (cNode.nodeType === Node.TEXT_NODE && cNode.textContent) {
122
149
  var textContent = cNode.textContent;
123
150
  var runText = RawSet.exporesionGrouops(textContent)[0][1];
124
- // console.log('--->', textContent,runText, runText[0][1])
151
+ // console.log('--->', RawSet.exporesionGrouops(textContent), textContent,runText, runText[0][1])
125
152
  var n = void 0;
126
153
  if (textContent === null || textContent === void 0 ? void 0 : textContent.startsWith('#')) {
127
154
  var r = ScriptUtils_1.ScriptUtils.eval("".concat(__render.bindScript, " return ").concat(runText), Object.assign(obj, { __render: __render }));
@@ -137,6 +164,7 @@ var RawSet = /** @class */ (function () {
137
164
  }
138
165
  else if (cNode.nodeType === Node.ELEMENT_NODE) {
139
166
  var element = cNode;
167
+ // console.log('target-->', element)
140
168
  var drAttr = {
141
169
  dr: this.getAttributeAndDelete(element, RawSet.DR),
142
170
  drIf: this.getAttributeAndDelete(element, RawSet.DR_IF_NAME),
@@ -222,8 +250,8 @@ var RawSet = /** @class */ (function () {
222
250
  var rawSet = domrenderComponentNew === null || domrenderComponentNew === void 0 ? void 0 : domrenderComponentNew.rawSet;
223
251
  var drAttrs = domrenderComponentNew === null || domrenderComponentNew === void 0 ? void 0 : domrenderComponentNew.drAttrs;
224
252
  if (rawSet && !rawSet.isConnected) {
225
- var domrenderComponent = obj.__domrender_components[key];
226
- console.log('component destroy--->', key, rawSet, rawSet.isConnected, domrenderComponent.name, domrenderComponent);
253
+ // const domrenderComponent = obj.__domrender_components[key];
254
+ // console.log('component destroy--->', key, rawSet, rawSet.isConnected, domrenderComponent.name, domrenderComponent);
227
255
  var destroyOptions = (_c = (_b = drAttrs === null || drAttrs === void 0 ? void 0 : drAttrs.drDestroyOption) === null || _b === void 0 ? void 0 : _b.split(',')) !== null && _c !== void 0 ? _c : [];
228
256
  RawSet.destroy(obj.__domrender_components[key], [domrenderComponentNew], config, destroyOptions);
229
257
  delete obj.__domrender_components[key];
@@ -274,8 +302,9 @@ var RawSet = /** @class */ (function () {
274
302
  this.childAllRemove();
275
303
  (_a = this.point.start.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(genNode, this.point.start.nextSibling);
276
304
  };
305
+ // 중요 important
277
306
  RawSet.checkPointCreates = function (element, config) {
278
- var _a, _b, _c, _d;
307
+ var _a, _b, _c, _d, _e, _f, _g, _h;
279
308
  var thisVariableName = element.__domrender_this_variable_name;
280
309
  // console.log('checkPointCreates thisVariableName', thisVariableName);
281
310
  var nodeIterator = config.window.document.createNodeIterator(element, NodeFilter.SHOW_ALL, {
@@ -284,7 +313,7 @@ var RawSet = /** @class */ (function () {
284
313
  if (node.nodeType === Node.TEXT_NODE) {
285
314
  // console.log('????????', node.parentElement, node.parentElement?.getAttribute('dr-pre'));
286
315
  // console.log('???????/',node.textContent, node.parentElement?.getAttribute('dr-pre'))
287
- // 나중에
316
+ // TODO: 나중에
288
317
  // const between = StringUtils.betweenRegexpStr('[$#]\\{', '\\}', StringUtils.deleteEnter((node as Text).data ?? ''))
289
318
  var between = RawSet.exporesionGrouops(StringUtils_1.StringUtils.deleteEnter((_a = node.data) !== null && _a !== void 0 ? _a : ''));
290
319
  // console.log('bbbb', between)
@@ -294,9 +323,23 @@ var RawSet = /** @class */ (function () {
294
323
  }
295
324
  else if (node.nodeType === Node.ELEMENT_NODE) {
296
325
  var element_2 = node;
326
+ // console.log('------>', element);
297
327
  var isElement = ((_c = (_b = config.targetElements) === null || _b === void 0 ? void 0 : _b.map(function (it) { return it.name.toLowerCase(); })) !== null && _c !== void 0 ? _c : []).includes(element_2.tagName.toLowerCase());
298
328
  var targetAttrNames_1 = ((_e = (_d = config.targetAttrs) === null || _d === void 0 ? void 0 : _d.map(function (it) { return it.name; })) !== null && _e !== void 0 ? _e : []).concat(RawSet.DR_ATTRIBUTES);
299
- var isAttr = element_2.getAttributeNames().filter(function (it) { return targetAttrNames_1.includes(it.toLowerCase()); }).length > 0;
329
+ var normalAttrs_1 = new Map();
330
+ var isAttr = element_2.getAttributeNames().filter(function (it) {
331
+ var value = element_2.getAttribute(it);
332
+ if (value && RawSet.isExporesion(value)) {
333
+ normalAttrs_1.set(it, RawSet.exporesionGrouops(value)[0][1]);
334
+ }
335
+ // console.log(element.getAttribute(it), attrExpresion);
336
+ var isTargetAttr = targetAttrNames_1.includes(it.toLowerCase());
337
+ return isTargetAttr;
338
+ }).length > 0;
339
+ // 기본 attribute를 처리하기위해
340
+ if (normalAttrs_1.size) {
341
+ element_2.setAttribute(EventManager_1.EventManager.normalAttrMapAttrName, JSON.stringify(Array.from(normalAttrs_1.entries())));
342
+ }
300
343
  return (isAttr || isElement) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
301
344
  }
302
345
  return NodeFilter.FILTER_REJECT;
@@ -307,52 +350,53 @@ var RawSet = /** @class */ (function () {
307
350
  var _loop_1 = function () {
308
351
  if (currentNode.nodeType === Node.TEXT_NODE) {
309
352
  var text = (_a = currentNode.textContent) !== null && _a !== void 0 ? _a : '';
310
- var template_1 = config.window.document.createElement('template');
353
+ var template = config.window.document.createElement('template');
311
354
  // const a = StringUtils.regexExec(/\$\{.*?\}/g, text);
312
355
  // const a = StringUtils.regexExec(/[$#]\{.*?\}/g, text);
313
- // const a = StringUtils.betweenRegexpStr('[$#]\\{', '\\}', text); // <--나중에..
314
- var a = RawSet.exporesionGrouops(text); // <--나중에..
315
- var map = a.map(function (it) {
316
- return {
317
- uuid: RandomUtils_1.RandomUtils.uuid(),
318
- content: it[0],
319
- regexArr: it
320
- };
321
- });
322
- var lasterIndex_1 = 0;
323
- map.forEach(function (it) {
324
- var regexArr = it.regexArr;
325
- var preparedText = regexArr.input.substring(lasterIndex_1, regexArr.index);
326
- var start = config.window.document.createComment("start text ".concat(it.uuid));
327
- var end = config.window.document.createComment("end text ".concat(it.uuid));
356
+ // const a = StringUtils.betweenRegexpStr('[$#]\\{', '\\}', text); // <--TODO: 나중에..
357
+ var groups = RawSet.exporesionGrouops(text);
358
+ var map = groups.map(function (it) { return ({ uuid: RandomUtils_1.RandomUtils.uuid(), content: it[0], regexArr: it }); });
359
+ var lasterIndex = 0;
360
+ for (var i = 0; i < map.length; i++) {
361
+ var it_4 = map[i];
362
+ var regexArr = it_4.regexArr;
363
+ var preparedText = regexArr.input.substring(lasterIndex, regexArr.index);
364
+ var start = config.window.document.createComment("start text ".concat(it_4.uuid));
365
+ var end = config.window.document.createComment("end text ".concat(it_4.uuid));
328
366
  // layout setting
329
- template_1.content.append(document.createTextNode(preparedText)); // 사이사이값.
330
- template_1.content.append(start);
331
- template_1.content.append(end);
367
+ template.content.append(document.createTextNode(preparedText)); // 사이사이값.
368
+ template.content.append(start);
369
+ template.content.append(end);
332
370
  // content
333
371
  var fragment = config.window.document.createDocumentFragment();
334
- fragment.append(config.window.document.createTextNode(it.content));
335
- pars.push(new RawSet(it.uuid, {
372
+ fragment.append(config.window.document.createTextNode(it_4.content));
373
+ pars.push(new RawSet(it_4.uuid, RawSetType.TEXT, {
336
374
  start: start,
375
+ node: currentNode,
337
376
  end: end,
338
377
  thisVariableName: thisVariableName
339
378
  }, fragment));
340
- lasterIndex_1 = regexArr.index + it.content.length;
341
- });
342
- template_1.content.append(config.window.document.createTextNode(text.substring(lasterIndex_1, text.length)));
343
- (_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template_1.content, currentNode);
379
+ lasterIndex = regexArr.index + it_4.content.length;
380
+ }
381
+ template.content.append(config.window.document.createTextNode(text.substring(lasterIndex, text.length)));
382
+ (_b = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _b === void 0 ? void 0 : _b.replaceChild(template.content, currentNode);
344
383
  }
345
- else {
384
+ else if (currentNode.nodeType === Node.ELEMENT_NODE) {
346
385
  var uuid = RandomUtils_1.RandomUtils.uuid();
386
+ var element_3 = currentNode;
347
387
  var fragment = config.window.document.createDocumentFragment();
348
388
  var start = config.window.document.createComment("start ".concat(uuid));
349
389
  var end = config.window.document.createComment("end ".concat(uuid));
350
390
  // console.log('start--', uuid)
351
- (_c = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _c === void 0 ? void 0 : _c.insertBefore(start, currentNode);
352
- (_d = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _d === void 0 ? void 0 : _d.insertBefore(end, currentNode.nextSibling);
391
+ var isElement = ((_d = (_c = config.targetElements) === null || _c === void 0 ? void 0 : _c.map(function (it) { return it.name.toLowerCase(); })) !== null && _d !== void 0 ? _d : []).includes(element_3.tagName.toLowerCase());
392
+ var targetAttrNames_2 = ((_f = (_e = config.targetAttrs) === null || _e === void 0 ? void 0 : _e.map(function (it) { return it.name; })) !== null && _f !== void 0 ? _f : []).concat(RawSet.DR_ATTRIBUTES);
393
+ var isAttr = element_3.getAttributeNames().filter(function (it) { return targetAttrNames_2.includes(it.toLowerCase()); }).length > 0;
394
+ (_g = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _g === void 0 ? void 0 : _g.insertBefore(start, currentNode);
395
+ (_h = currentNode === null || currentNode === void 0 ? void 0 : currentNode.parentNode) === null || _h === void 0 ? void 0 : _h.insertBefore(end, currentNode.nextSibling);
353
396
  fragment.append(currentNode);
354
- pars.push(new RawSet(uuid, {
397
+ pars.push(new RawSet(uuid, isElement ? RawSetType.TARGET_ELEMENT : (isAttr ? RawSetType.TARGET_ATTR : RawSetType.UNKOWN), {
355
398
  start: start,
399
+ node: currentNode,
356
400
  end: end,
357
401
  thisVariableName: thisVariableName
358
402
  }, fragment));
@@ -430,8 +474,8 @@ var RawSet = /** @class */ (function () {
430
474
  var nodeIterator = config.window.document.createNodeIterator(subElement, NodeFilter.SHOW_ELEMENT, {
431
475
  acceptNode: function (node) {
432
476
  if (node.nodeType === Node.ELEMENT_NODE) {
433
- var element_3 = node;
434
- return element_3.hasAttribute(as) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
477
+ var element_4 = node;
478
+ return element_4.hasAttribute(as) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
435
479
  }
436
480
  else {
437
481
  return NodeFilter.FILTER_REJECT;
@@ -441,9 +485,9 @@ var RawSet = /** @class */ (function () {
441
485
  var node;
442
486
  // eslint-disable-next-line no-cond-assign
443
487
  while (node = nodeIterator.nextNode()) {
444
- var element_4 = node;
445
- element_4.setAttribute(to, (_a = element_4.getAttribute(as)) !== null && _a !== void 0 ? _a : '');
446
- element_4.removeAttribute(as);
488
+ var element_5 = node;
489
+ element_5.setAttribute(to, (_a = element_5.getAttribute(as)) !== null && _a !== void 0 ? _a : '');
490
+ element_5.removeAttribute(as);
447
491
  }
448
492
  });
449
493
  };
@@ -553,7 +597,7 @@ var RawSet = /** @class */ (function () {
553
597
  template: template,
554
598
  callBack: function (element, obj, rawSet, attrs) {
555
599
  var _a, _b, _c, _d;
556
- // console.log('callback------->')
600
+ // console.log('callback------->', element)
557
601
  if (!obj.__domrender_components) {
558
602
  obj.__domrender_components = {};
559
603
  }
@@ -562,6 +606,7 @@ var RawSet = /** @class */ (function () {
562
606
  var attribute = DomUtils_1.DomUtils.getAttributeToObject(element);
563
607
  var renderScript = 'var $component = this.__render.component; var $element = this.__render.element; var $router = this.__render.router; var $innerHTML = this.__render.innerHTML; var $attribute = this.__render.attribute; var $creatorMetaData = this.__render.creatorMetaData;';
564
608
  var render = Object.freeze({
609
+ renderScript: renderScript,
565
610
  element: element,
566
611
  innerHTML: element.innerHTML,
567
612
  attribute: attribute,
@@ -597,6 +642,16 @@ var RawSet = /** @class */ (function () {
597
642
  i.creator = new Proxy(rawSet.point.thisVariableName ? ScriptUtils_1.ScriptUtils.evalReturn(rawSet.point.thisVariableName, obj) : obj, new Types_1.DomRenderFinalProxy());
598
643
  this.__creatorMetaData = i;
599
644
  render = __assign({ component: instance, creatorMetaData: i }, render);
645
+ // 중요 dr-normal-attr-map
646
+ var normalAttrMap = element.getAttribute(EventManager_1.EventManager.normalAttrMapAttrName);
647
+ if (instance.onChangeAttrRender && normalAttrMap) {
648
+ new Map(JSON.parse(normalAttrMap)).forEach(function (value, key) {
649
+ var script = "".concat(renderScript, " return ").concat(value, " ");
650
+ var cval = ScriptUtils_1.ScriptUtils.eval(script, Object.assign(obj, { __render: render }));
651
+ // element.setAttribute(key, cval);
652
+ instance.onChangeAttrRender(key, cval);
653
+ });
654
+ }
600
655
  // dr-on-create onCreateRender
601
656
  var onCreate = element.getAttribute("".concat(EventManager_1.EventManager.attrPrefix, "on-create"));
602
657
  this.__render = render;
@@ -634,10 +689,10 @@ var RawSet = /** @class */ (function () {
634
689
  var data = RawSet.drThisCreate(element, "this.__domrender_components.".concat(componentKey), '', true, obj, config);
635
690
  // 넘어온 innerHTML에 this가 있는걸 다시 복호화해서 제대로 작동하도록한다.
636
691
  if (innerHTMLThisRandom) {
637
- var template_2 = config.window.document.createElement('template');
638
- template_2.content.append(data);
639
- template_2.innerHTML = template_2.innerHTML.replace(RegExp(innerHTMLThisRandom, 'g'), 'this.');
640
- data = template_2.content;
692
+ var template_1 = config.window.document.createElement('template');
693
+ template_1.content.append(data);
694
+ template_1.innerHTML = template_1.innerHTML.replace(RegExp(innerHTMLThisRandom, 'g'), 'this.');
695
+ data = template_1.content;
641
696
  }
642
697
  data.render = render;
643
698
  return data;
@@ -646,10 +701,14 @@ var RawSet = /** @class */ (function () {
646
701
  };
647
702
  return targetElement;
648
703
  };
704
+ RawSet.isExporesion = function (data) {
705
+ var reg = /(?:[$#]\{(?:(([$#]\{)??[^$#]?[^{]*?)\}[$#]))/g;
706
+ return reg.test(data !== null && data !== void 0 ? data : '');
707
+ };
649
708
  RawSet.exporesionGrouops = function (data) {
650
709
  // const reg = /(?:[$#]\{(?:(([$#]\{)??[^$#]*?)\}[$#]))/g;
651
710
  var reg = /(?:[$#]\{(?:(([$#]\{)??[^$#]?[^{]*?)\}[$#]))/g;
652
- return StringUtils_1.StringUtils.regexExec(reg, data);
711
+ return StringUtils_1.StringUtils.regexExec(reg, data !== null && data !== void 0 ? data : '');
653
712
  };
654
713
  RawSet.styleTransformLocal = function (styleBody, id, styleTagWrap, locale) {
655
714
  if (styleTagWrap === void 0) { styleTagWrap = true; }