@dooboostore/simple-web-component 1.0.38 → 1.0.40

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.
Files changed (91) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +88 -871
  3. package/dist/cjs/SwcAppEngine.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +194 -111
  5. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  6. package/dist/cjs/decorators/applyNode.js +82 -80
  7. package/dist/cjs/decorators/applyNode.js.map +2 -2
  8. package/dist/cjs/decorators/applyProperty.js +213 -0
  9. package/dist/cjs/decorators/applyProperty.js.map +7 -0
  10. package/dist/cjs/decorators/applySlot.js +93 -82
  11. package/dist/cjs/decorators/applySlot.js.map +3 -3
  12. package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
  13. package/dist/cjs/decorators/elementDefine.js +14 -34
  14. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  15. package/dist/cjs/decorators/index.js +2 -2
  16. package/dist/cjs/decorators/index.js.map +2 -2
  17. package/dist/cjs/decorators/lifecycles.js +4 -4
  18. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  19. package/dist/cjs/decorators/state.js +0 -1
  20. package/dist/cjs/decorators/state.js.map +2 -2
  21. package/dist/cjs/elements/SwcApp.js.map +2 -2
  22. package/dist/cjs/types/index.js.map +1 -1
  23. package/dist/esm/SwcAppEngine.js.map +2 -2
  24. package/dist/esm/decorators/applyAttribute.js +196 -113
  25. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  26. package/dist/esm/decorators/applyNode.js +82 -80
  27. package/dist/esm/decorators/applyNode.js.map +2 -2
  28. package/dist/esm/decorators/applyProperty.js +194 -0
  29. package/dist/esm/decorators/applyProperty.js.map +7 -0
  30. package/dist/esm/decorators/applySlot.js +93 -82
  31. package/dist/esm/decorators/applySlot.js.map +3 -3
  32. package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
  33. package/dist/esm/decorators/elementDefine.js +14 -34
  34. package/dist/esm/decorators/elementDefine.js.map +2 -2
  35. package/dist/esm/decorators/index.js +2 -2
  36. package/dist/esm/decorators/index.js.map +1 -1
  37. package/dist/esm/decorators/lifecycles.js +4 -4
  38. package/dist/esm/decorators/lifecycles.js.map +2 -2
  39. package/dist/esm/decorators/state.js +0 -1
  40. package/dist/esm/decorators/state.js.map +2 -2
  41. package/dist/esm/elements/SwcApp.js.map +2 -2
  42. package/dist/esm/types/index.js.map +1 -1
  43. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +525 -513
  44. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  45. package/dist/types/SwcAppEngine.d.ts.map +1 -1
  46. package/dist/types/decorators/applyAttribute.d.ts +56 -15
  47. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  48. package/dist/types/decorators/applyNode.d.ts +28 -24
  49. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  50. package/dist/types/decorators/applyProperty.d.ts +61 -0
  51. package/dist/types/decorators/applyProperty.d.ts.map +1 -0
  52. package/dist/types/decorators/applySlot.d.ts +17 -15
  53. package/dist/types/decorators/applySlot.d.ts.map +1 -1
  54. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  55. package/dist/types/decorators/index.d.ts +2 -2
  56. package/dist/types/decorators/index.d.ts.map +1 -1
  57. package/dist/types/decorators/lifecycles.d.ts +4 -4
  58. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  59. package/dist/types/decorators/state.d.ts.map +1 -1
  60. package/dist/types/elements/SwcApp.d.ts.map +1 -1
  61. package/dist/types/types/index.d.ts +1 -6
  62. package/dist/types/types/index.d.ts.map +1 -1
  63. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +525 -513
  64. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  65. package/package.json +1 -1
  66. package/src/SwcAppEngine.ts +1 -0
  67. package/src/decorators/applyAttribute.ts +311 -126
  68. package/src/decorators/applyNode.ts +108 -105
  69. package/src/decorators/applyProperty.ts +302 -0
  70. package/src/decorators/applySlot.ts +112 -94
  71. package/src/decorators/changedAttributeThis.ts +1 -1
  72. package/src/decorators/elementDefine.ts +44 -33
  73. package/src/decorators/index.ts +2 -3
  74. package/src/decorators/lifecycles.ts +6 -6
  75. package/src/decorators/state.ts +0 -1
  76. package/src/elements/SwcApp.ts +0 -1
  77. package/src/types/index.ts +7 -7
  78. package/dist/cjs/decorators/attribute.js +0 -187
  79. package/dist/cjs/decorators/attribute.js.map +0 -7
  80. package/dist/cjs/decorators/setProperty.js +0 -109
  81. package/dist/cjs/decorators/setProperty.js.map +0 -7
  82. package/dist/esm/decorators/attribute.js +0 -168
  83. package/dist/esm/decorators/attribute.js.map +0 -7
  84. package/dist/esm/decorators/setProperty.js +0 -90
  85. package/dist/esm/decorators/setProperty.js.map +0 -7
  86. package/dist/types/decorators/attribute.d.ts +0 -31
  87. package/dist/types/decorators/attribute.d.ts.map +0 -1
  88. package/dist/types/decorators/setProperty.d.ts +0 -17
  89. package/dist/types/decorators/setProperty.d.ts.map +0 -1
  90. package/src/decorators/attribute.ts +0 -223
  91. package/src/decorators/setProperty.ts +0 -112
@@ -4,56 +4,42 @@ import { SwcUtils } from "../utils/Utils.js";
4
4
  import { findAllStateMetadata } from "./state.js";
5
5
  import { ElementApply } from "@dooboostore/core-web";
6
6
  const APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
7
- const normalizeNodes = (res, doc) => {
8
- const items = Array.isArray(res) ? res : [res];
9
- return items.map((it) => {
10
- if (it instanceof Node) return it;
11
- return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
12
- });
13
- };
14
7
  const applyToDom = (currentThis, targetEl, res, pos, win, host) => {
15
8
  if (!targetEl) return;
16
9
  const doc = win.document;
17
10
  const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);
18
11
  const id = currentThis._swcId;
19
- try {
20
- if (typeof res === "string") {
21
- const processed = SwcUtils.projectProcessHtml(id, res, doc);
22
- if (processed !== void 0) res = processed;
23
- } else if (res) {
24
- SwcUtils.projectProcessHtml(id, res, doc);
25
- }
26
- } catch (e) {
27
- }
28
- if (pos === "innerHtml") {
29
- targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
30
- return;
12
+ const nodes = [];
13
+ if (typeof res === "string" && pos === "innerHtml") {
14
+ const t = win.document.createElement("template");
15
+ t.innerHTML = res;
16
+ nodes.push(...Array.from(t.content.childNodes));
17
+ } else if (typeof res === "string" && pos === "innerText") {
18
+ nodes.push(win.document.createTextNode(res));
31
19
  }
32
- if (pos === "innerText") {
33
- if (targetEl.innerText !== void 0) {
34
- targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
35
- }
36
- return;
37
- }
38
- const stateContext = { ...hostSet };
39
- findAllStateMetadata(currentThis).forEach((it) => {
40
- stateContext[it.name] = currentThis[it.propertyKey];
41
- });
42
- new ElementApply(currentThis, { id: currentThis._swcId }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
20
+ SwcUtils.projectProcessHtml(id, nodes, doc);
43
21
  const isShadowRoot = targetEl instanceof win.ShadowRoot;
44
- const nodes = normalizeNodes(res, doc);
45
22
  if (pos === "replace") {
46
23
  if (!isShadowRoot) targetEl.replaceWith(...nodes);
24
+ } else if (pos === "innerHtml") {
25
+ targetEl.replaceChildren(...nodes);
26
+ } else if (pos === "innerText") {
27
+ targetEl.replaceChildren(...nodes);
47
28
  } else if (pos === "replaceChildren") {
48
29
  targetEl.replaceChildren(...nodes);
49
30
  } else {
50
31
  if (pos === "beforeEnd") {
51
- console.log("tarbbbbbbbbbbbbbb");
52
32
  targetEl.append(...nodes);
53
33
  } else if (pos === "afterBegin") targetEl.prepend(...nodes);
54
34
  else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
55
35
  else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
56
36
  }
37
+ const stateContext = { ...hostSet };
38
+ findAllStateMetadata(currentThis).forEach((it) => {
39
+ stateContext[it.name] = currentThis[it.propertyKey];
40
+ });
41
+ new ElementApply(targetEl, { id }).apply({ target: "noInitialized", context: stateContext, bind: currentThis });
42
+ return nodes;
57
43
  };
58
44
  function applyNode(selector, options = { position: "replaceChildren" }) {
59
45
  return (targetObj, propertyKey, descriptor) => {
@@ -90,7 +76,6 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
90
76
  const targetRoot = applyRoot(this);
91
77
  return targetRoot ? targetRoot.querySelector(selector) : null;
92
78
  };
93
- console.log("fffffffffff");
94
79
  const targetEl = getTarget();
95
80
  const res = original.apply(this, args);
96
81
  const runApply = (target, val) => {
@@ -100,13 +85,14 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
100
85
  applyToDom(this, target, processedVal, pos, currentWin);
101
86
  }
102
87
  };
88
+ const fallbackNodes = [];
89
+ if (targetEl && options.fallback) {
90
+ const loadingRes = options.fallback.call(this, hostSet);
91
+ fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || "beforeEnd", currentWin));
92
+ }
103
93
  if (res instanceof Promise) {
104
- if (targetEl && options.fallback) {
105
- const loadingRes = options.fallback.call(this, hostSet);
106
- applyToDom(this, targetEl, loadingRes, options.position || "beforeEnd", currentWin);
107
- }
108
94
  return res.then((finalRes) => {
109
- console.log("amnkj");
95
+ fallbackNodes.forEach((it) => it.remove());
110
96
  if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
111
97
  return finalRes;
112
98
  });
@@ -117,108 +103,124 @@ function applyNode(selector, options = { position: "replaceChildren" }) {
117
103
  };
118
104
  };
119
105
  }
120
- const findAllApplyNodeMetadata = (target) => {
121
- const result = /* @__PURE__ */ new Map();
122
- const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
123
- maps.forEach((map) => {
124
- if (map instanceof Map) {
125
- map.forEach((v, k) => result.set(k, v));
126
- }
127
- });
128
- return result;
129
- };
130
106
  function applyNodeThis(targetOrOptions, propertyKey, descriptor) {
131
107
  const option = { position: "replaceChildren" };
132
108
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
133
109
  const opt = targetOrOptions || {};
134
110
  return applyNode("$this", { ...option, ...opt });
135
111
  }
136
- function applyNodeThisReplaceChildren(targetOrOptions, propertyKey, descriptor) {
112
+ function replaceChildrenNodeThis(targetOrOptions, propertyKey, descriptor) {
137
113
  const option = { position: "replaceChildren" };
138
114
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
139
115
  const opt = targetOrOptions || {};
140
116
  return applyNode("$this", { ...opt, ...option });
141
117
  }
142
- function applyNodeThisReplaceChildrenLightDom(targetOrOptions, propertyKey, descriptor) {
143
- const options = { position: "replaceChildren", root: "light" };
144
- if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
145
- const opt = targetOrOptions || {};
146
- return applyNode("$this", { ...opt, ...options });
147
- }
148
- function applyNodeThisBeforeEnd(targetOrOptions, propertyKey, descriptor) {
118
+ function beforeEndNodeThis(targetOrOptions, propertyKey, descriptor) {
149
119
  const options = { position: "beforeEnd" };
150
120
  if (propertyKey !== void 0) return applyNode("$this", options)(targetOrOptions, propertyKey, descriptor);
151
121
  const opt = targetOrOptions || {};
152
122
  return applyNode("$this", { ...opt, ...options });
153
123
  }
154
- function applyNodeThisBeforeEndLightDom(targetOrOptions, propertyKey, descriptor) {
124
+ function beforeEndLightNodeThis(targetOrOptions, propertyKey, descriptor) {
155
125
  const option = { position: "beforeEnd", root: "light" };
156
126
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
157
127
  const opt = targetOrOptions || {};
158
128
  return applyNode("$this", { ...opt, ...option });
159
129
  }
160
- function applyNodeThisBeforeEndShadow(targetOrOptions, propertyKey, descriptor) {
130
+ function beforeEndShadowNodeThis(targetOrOptions, propertyKey, descriptor) {
161
131
  const option = { position: "beforeEnd", root: "shadow" };
162
132
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
163
133
  const opt = targetOrOptions || {};
164
134
  return applyNode("$this", { ...opt, ...option });
165
135
  }
166
- function applyNodeThisAfterBegin(targetOrOptions, propertyKey, descriptor) {
136
+ function afterBeginNodeThis(targetOrOptions, propertyKey, descriptor) {
167
137
  const option = { position: "afterBegin" };
168
138
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
169
139
  const opt = targetOrOptions || {};
170
140
  return applyNode("$this", { ...opt, ...option });
171
141
  }
172
- function applyNodeThisAfterBeginLightDom(targetOrOptions, propertyKey, descriptor) {
142
+ function afterBeginLightNodeThis(targetOrOptions, propertyKey, descriptor) {
173
143
  const option = { position: "afterBegin", root: "light" };
174
144
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
175
145
  const opt = targetOrOptions || {};
176
146
  return applyNode("$this", { ...opt, ...option });
177
147
  }
178
- function applyThisInnerHtmlNode(targetOrOptions, propertyKey, descriptor) {
148
+ function innerHtmlNodeThis(targetOrOptions, propertyKey, descriptor) {
179
149
  const option = { position: "innerHtml" };
180
150
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
181
151
  const opt = targetOrOptions || {};
182
152
  return applyNode("$this", { ...opt, ...option });
183
153
  }
184
- function applyThisInnerHtmlNodeLightDom(targetOrOptions, propertyKey, descriptor) {
154
+ function innerTextNodeThis(targetOrOptions, propertyKey, descriptor) {
155
+ const option = { position: "innerText" };
156
+ if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
157
+ const opt = targetOrOptions || {};
158
+ return applyNode("$this", { ...opt, ...option });
159
+ }
160
+ function innerHtmlLightNodeThis(targetOrOptions, propertyKey, descriptor) {
185
161
  const option = { position: "innerHtml", root: "light" };
186
162
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
187
163
  const opt = targetOrOptions || {};
188
164
  return applyNode("$this", { ...opt, ...option });
189
165
  }
190
- function applyThisReplaceChildrenNodeLightDom(targetOrOptions, propertyKey, descriptor) {
166
+ function replaceChildrenLightNodeThis(targetOrOptions, propertyKey, descriptor) {
191
167
  const option = { position: "replaceChildren", root: "light" };
192
168
  if (propertyKey !== void 0) return applyNode("$this", option)(targetOrOptions, propertyKey, descriptor);
193
169
  const opt = targetOrOptions || {};
194
170
  return applyNode("$this", { ...opt, ...option });
195
171
  }
196
- function applyNodeReplaceChildren(selector, options = {}) {
172
+ function replaceChildrenNode(selector, options = {}) {
197
173
  return applyNode(selector, { ...options, position: "replaceChildren" });
198
174
  }
199
- function applyNodeInnerHtml(selector, options = {}) {
175
+ function innerHtmlNode(selector, options = {}) {
200
176
  return applyNode(selector, { ...options, position: "innerHtml" });
201
177
  }
202
- function applyNodeInnerText(selector, options = {}) {
178
+ function innerHtmlLightNode(selector, options = {}) {
179
+ return applyNode(selector, { ...options, position: "innerHtml", root: "light" });
180
+ }
181
+ function innerHtmlShadowNode(selector, options = {}) {
182
+ return applyNode(selector, { ...options, position: "innerHtml", root: "shadow" });
183
+ }
184
+ function innerTextNode(selector, options = {}) {
203
185
  return applyNode(selector, { ...options, position: "innerText" });
204
186
  }
187
+ function innerTextLightNode(selector, options = {}) {
188
+ return applyNode(selector, { ...options, position: "innerText", root: "light" });
189
+ }
190
+ function innerTextShadowNode(selector, options = {}) {
191
+ return applyNode(selector, { ...options, position: "innerText", root: "shadow" });
192
+ }
193
+ const findAllApplyNodeMetadata = (target) => {
194
+ const result = /* @__PURE__ */ new Map();
195
+ const maps = ReflectUtils.findAllMetadata(APPLY_NODE_METADATA_KEY, target);
196
+ maps.forEach((map) => {
197
+ if (map instanceof Map) {
198
+ map.forEach((v, k) => result.set(k, v));
199
+ }
200
+ });
201
+ return result;
202
+ };
205
203
  export {
206
204
  APPLY_NODE_METADATA_KEY,
205
+ afterBeginLightNodeThis,
206
+ afterBeginNodeThis,
207
207
  applyNode,
208
- applyNodeInnerHtml,
209
- applyNodeInnerText,
210
- applyNodeReplaceChildren,
211
208
  applyNodeThis,
212
- applyNodeThisAfterBegin,
213
- applyNodeThisAfterBeginLightDom,
214
- applyNodeThisBeforeEnd,
215
- applyNodeThisBeforeEndLightDom,
216
- applyNodeThisBeforeEndShadow,
217
- applyNodeThisReplaceChildren,
218
- applyNodeThisReplaceChildrenLightDom,
219
- applyThisInnerHtmlNode,
220
- applyThisInnerHtmlNodeLightDom,
221
- applyThisReplaceChildrenNodeLightDom,
222
- findAllApplyNodeMetadata
209
+ beforeEndLightNodeThis,
210
+ beforeEndNodeThis,
211
+ beforeEndShadowNodeThis,
212
+ findAllApplyNodeMetadata,
213
+ innerHtmlLightNode,
214
+ innerHtmlLightNodeThis,
215
+ innerHtmlNode,
216
+ innerHtmlNodeThis,
217
+ innerHtmlShadowNode,
218
+ innerTextLightNode,
219
+ innerTextNode,
220
+ innerTextNodeThis,
221
+ innerTextShadowNode,
222
+ replaceChildrenLightNodeThis,
223
+ replaceChildrenNode,
224
+ replaceChildrenNodeThis
223
225
  };
224
226
  //# sourceMappingURL=applyNode.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/applyNode.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\nconst normalizeNodes = (res: any, doc: Document): Node[] => {\n const items = Array.isArray(res) ? res : [res];\n return items.map(it => {\n if (it instanceof Node) return it;\n return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n });\n};\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: any, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n\n // console.log('------------',currentThis.tagName, res)\n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n // Allow processHtml to run here so all DOM insertions go through a single\n // processing point. processHtml may mutate Node[] in-place or return a\n // transformed string result for text processing.\n try {\n if (typeof res === 'string') {\n const processed = SwcUtils.projectProcessHtml(id, res as string, doc);\n if (processed !== undefined) res = processed;\n } else if (res) {\n SwcUtils.projectProcessHtml(id, res, doc);\n }\n } catch (e) {\n // swallow and proceed with original res\n }\n\n if (pos === 'innerHtml') {\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n return;\n }\n\n if (pos === 'innerText') {\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n return;\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(currentThis, {id: currentThis._swcId}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n console.log('tarbbbbbbbbbbbbbb')\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = {position: 'replaceChildren'}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n\n console.log('fffffffffff')\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin);\n }\n\n return res.then(finalRes => {\n console.log('amnkj')\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...option, ...opt});\n}\n\nexport function applyNodeThisReplaceChildren(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisReplaceChildren(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisReplaceChildren(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisReplaceChildrenLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisReplaceChildrenLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisReplaceChildrenLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function applyNodeThisBeforeEnd(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisBeforeEnd(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEnd(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'beforeEnd'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function applyNodeThisBeforeEndLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisBeforeEndLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEndLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\nexport function applyNodeThisBeforeEndShadow(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisBeforeEndShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisBeforeEndShadow(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'shadow'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisAfterBegin(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyNodeThisAfterBegin(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisAfterBegin(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeThisAfterBeginLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyNodeThisAfterBeginLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThisAfterBeginLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyThisInnerHtmlNode(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function applyThisInnerHtmlNode(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisInnerHtmlNode(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyThisInnerHtmlNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyThisInnerHtmlNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisInnerHtmlNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyThisReplaceChildrenNodeLightDom(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function applyThisReplaceChildrenNodeLightDom(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyThisReplaceChildrenNodeLightDom(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function applyNodeReplaceChildren(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'replaceChildren'});\n}\n\nexport function applyNodeInnerHtml(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml'});\n}\n\n// export function applyNodeInnerHtmlLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n// return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});\n// }\n\nexport function applyNodeInnerText(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText'});\n}\n\n// export function applyNodeInnerTextLightDom(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n// return applyNode(selector, {...options, position: 'innerText', root: 'light'});\n// }\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AACxB,SAAQ,4BAA2B;AACnC,SAAQ,oBAAmB;AAgCpB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAEnF,MAAM,iBAAiB,CAAC,KAAU,QAA0B;AAC1D,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAM;AACrB,QAAI,cAAc,KAAM,QAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;AAAA,EAC7E,CAAC;AACH;AAEA,MAAM,aAAa,CAAC,aAAkB,UAAuB,KAAU,KAAwB,KAAa,SAAe;AACzH,MAAI,CAAC,SAAU;AAGf,QAAM,MAAM,IAAI;AAChB,QAAM,UAAU,SAAS,oBAAoB,KAAK,WAAW;AAC7D,QAAM,KAAK,YAAY;AAIvB,MAAI;AACF,QAAI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AG,KAAK,GAAG,OAAM,CAAC;AAC/C;AAIO,SAAS,qCAAqC,iBAAuB,aAA+B,YAAsC;AAC/I,QAAM,SAA2B,EAAC,UAAU,mBAAmB,MAAM,QAAO;AAC5E,MAAI,gBAAgB,OAAW,QAAO,UAAU,SAAS,MAAM,EAAE,iBAAiB,aAAa,UAAU;AACzG,QAAM,MAAM,mBAAmB,CAAC;AAChC,SAAO,UAAU,SAAS,EAAC,GAAG,KAAK,GAAG,OAAM,CAAC;AAC/C;AAEO,SAAS,yBAAyB,UAAkB,UAA8C,CAAC,GAAoB;AAC5H,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,kBAAiB,CAAC;AACtE;AAEO,SAAS,mBAAmB,UAAkB,UAA8C,CAAC,GAAoB;AACtH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;AAMO,SAAS,mBAAmB,UAAkB,UAA8C,CAAC,GAAoB;AACtH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport {SpecialSelector, SwcQueryOptions, HelperHostSet, SwcRootType} from '../types';\nimport { SwcUtils} from \"../utils/Utils\";\nimport {findAllStateMetadata} from \"./state\";\nimport {ElementApply} from \"@dooboostore/core-web\";\n/*\n<!-- beforebegin -->\n<p> <-- it's me\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n</p>\n<!-- afterend -->\n */\nexport type ApplyNodePosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd' | 'replace' | 'replaceChildren' | 'innerHtml' | 'innerText' | 'remove';\n\nexport interface ApplyNodeOptions {\n position?: ApplyNodePosition;\n root?: SwcRootType;\n /**\n * Filter function to determine whether to perform DOM operation.\n * If it returns false, the operation is skipped.\n */\n filter?: (target: HTMLElement | ShadowRoot, newValue: any, meta: { currentThis: any, helper: HelperHostSet }) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n fallback?: (helper: HelperHostSet) => any;\n}\n\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol.for('simple-web-component:apply-node');\n\n// const normalizeNodes = (res: any, doc: Document): Node[] => {\n// const items = Array.isArray(res) ? res : [res];\n// return items.map(it => {\n// if (it instanceof Node) return it;\n// return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');\n// });\n// };\n\nconst applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string, pos: ApplyNodePosition, win: Window, host?: any) => {\n if (!targetEl) return;\n const doc = win.document;\n const hostSet = SwcUtils.getHelperAndHostSet(win, currentThis);\n const id = currentThis._swcId;\n\n\n const nodes: Node[] = [];\n\n if (typeof res === 'string' && pos === 'innerHtml') {\n const t = win.document.createElement('template');\n t.innerHTML = res;\n nodes.push(...Array.from(t.content.childNodes));\n } else if (typeof res === 'string' && pos === 'innerText') {\n nodes.push(win.document.createTextNode(res));\n }\n\n SwcUtils.projectProcessHtml(id, nodes, doc);\n\n\n\n const isShadowRoot = targetEl instanceof win.ShadowRoot;\n // const nodes = normalizeNodes(res, doc);\n if (pos === 'replace') {\n if (!isShadowRoot) targetEl.replaceWith(...nodes);\n } else if (pos === 'innerHtml') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerText') {\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'replaceChildren') {\n targetEl.replaceChildren(...nodes);\n } else {\n if (pos === 'beforeEnd') {\n targetEl.append(...nodes)\n }\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin' && !isShadowRoot) targetEl.before(...nodes);\n else if (pos === 'afterEnd' && !isShadowRoot) targetEl.after(...nodes);\n }\n\n const stateContext: any = {...hostSet};\n findAllStateMetadata(currentThis).forEach(it => {\n stateContext[it.name] = currentThis[it.propertyKey]\n })\n new ElementApply(targetEl, {id: id}).apply({target: 'noInitialized', context: stateContext, bind: currentThis});\n return nodes;\n};\n\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = {position: 'replaceChildren'}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor) as Map<string | symbol, ApplyNodeMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ApplyNodeMetadata>();\n ReflectUtils.defineMetadata(APPLY_NODE_METADATA_KEY, metaList, constructor);\n }\n metaList.set(propertyKey, {propertyKey, selector, options});\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n\n const conf = getElementConfig(this);\n const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);\n const currentDoc = currentWin.document;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n const getTarget = () => {\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t) return t;\n if (r === 'auto') return t.shadowRoot || t;\n if (r === 'shadow') return t.shadowRoot;\n if (r === 'light') return t;\n if (r === 'all') return t.shadowRoot || t;\n return t;\n };\n\n if (selector === '$this') return applyRoot(this);\n if (selector === '$host') return applyRoot(hostSet.$host);\n if (selector === '$parentHost') return applyRoot(hostSet.$parentHost);\n if (selector === '$appHost') return applyRoot(hostSet.$appHost);\n if (selector === '$firstHost') return applyRoot(hostSet.$firstHost);\n if (selector === '$lastHost') return applyRoot(hostSet.$lastHost);\n\n const targetRoot = applyRoot(this);\n return targetRoot ? targetRoot.querySelector(selector) : null;\n };\n\n const targetEl = getTarget();\n const res = original.apply(this, args);\n\n const runApply = (target: any, val: any) => {\n const pos = options.position || 'beforeEnd';\n // Delegate HTML/node processing to applyToDom which centralizes\n // processing. runApply should not call processHtml itself to avoid\n // duplicate processing.\n const processedVal = val;\n\n // \uC0AC\uC6A9\uC790\uAC00 filter\uB97C \uBA85\uC2DC\uD558\uBA74 \uADF8 \uC870\uAC74\uC73C\uB85C, \uC544\uB2C8\uBA74 \uD56D\uC0C1 \uC801\uC6A9\n if (!options.filter || options.filter(target, processedVal, {currentThis: this, helper: hostSet})) {\n applyToDom(this, target, processedVal, pos, currentWin);\n }\n };\n\n\n const fallbackNodes: Node[] = [];\n if (targetEl && options.fallback) {\n const loadingRes = options.fallback.call(this, hostSet);\n // applyToDom expects a Window as the 4th argument\n fallbackNodes.push(...applyToDom(this, targetEl, loadingRes, options.position || 'beforeEnd', currentWin));\n }\n\n if (res instanceof Promise) {\n return res.then(finalRes => {\n fallbackNodes.forEach((it: any)=>it.remove());\n if (finalRes !== undefined && targetEl) runApply(targetEl, finalRes);\n return finalRes;\n });\n } else {\n if (res !== undefined && targetEl) runApply(targetEl, res);\n return res;\n }\n };\n };\n}\n\nexport function applyNodeThis(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...option, ...opt});\n}\n\nexport function replaceChildrenNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function replaceChildrenNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function replaceChildrenNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\n\n\nexport function beforeEndNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function beforeEndNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const options: ApplyNodeOptions = {position: 'beforeEnd'};\n if (propertyKey !== undefined) return applyNode('$this', options)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...options});\n}\n\nexport function beforeEndLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function beforeEndLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function beforeEndShadowNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function beforeEndShadowNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function beforeEndShadowNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'beforeEnd', root: 'shadow'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function afterBeginNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function afterBeginNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function afterBeginNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function afterBeginLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function afterBeginLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function afterBeginLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'afterBegin', root: 'light'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerHtmlNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerHtmlNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerHtmlNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerTextNodeThis(options: Omit<ApplyNodeOptions, 'position'>): MethodDecorator;\nexport function innerTextNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerTextNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerText'}\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function innerHtmlLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function innerHtmlLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function innerHtmlLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'innerHtml', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function replaceChildrenLightNodeThis(options: Omit<ApplyNodeOptions, 'position' | 'root'>): MethodDecorator;\nexport function replaceChildrenLightNodeThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function replaceChildrenLightNodeThis(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n const option: ApplyNodeOptions = {position: 'replaceChildren', root: 'light'};\n if (propertyKey !== undefined) return applyNode('$this', option)(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode('$this', {...opt, ...option});\n}\n\nexport function replaceChildrenNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'replaceChildren'});\n}\n\nexport function innerHtmlNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml'});\n}\n\nexport function innerHtmlLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml', root: 'light'});\n}\n\nexport function innerHtmlShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerHtml', root: 'shadow'});\n}\n\nexport function innerTextNode(selector: string, options: Omit<ApplyNodeOptions, 'position'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText'});\n}\n\nexport function innerTextLightNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText', root: 'light'});\n}\n\nexport function innerTextShadowNode(selector: string, options: Omit<ApplyNodeOptions, 'position' | 'root'> = {}): MethodDecorator {\n return applyNode(selector, {...options, position: 'innerText', root: 'shadow'});\n}\n\n\n\nexport const findAllApplyNodeMetadata = (target: any): Map<string | symbol, ApplyNodeMetadata> => {\n const result = new Map<string | symbol, ApplyNodeMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ApplyNodeMetadata>>(APPLY_NODE_METADATA_KEY, target);\n maps.forEach(map => {\n if (map instanceof Map) {\n map.forEach((v, k) => result.set(k, v));\n }\n });\n return result;\n};"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAe;AACxB,SAAQ,4BAA2B;AACnC,SAAQ,oBAAmB;AAgCpB,MAAM,0BAA0B,OAAO,IAAI,iCAAiC;AAUnF,MAAM,aAAa,CAAC,aAAkB,UAAuB,KAAoB,KAAwB,KAAa,SAAe;AACnI,MAAI,CAAC,SAAU;AACf,QAAM,MAAM,IAAI;AAChB,QAAM,UAAU,SAAS,oBAAoB,KAAK,WAAW;AAC7D,QAAM,KAAK,YAAY;AAGvB,QAAM,QAAgB,CAAC;AAEvB,MAAI,OAAO,QAAQ,YAAY,QAAQ,aAAa;AAClD,UAAM,IAAI,IAAI,SAAS,cAAc,UAAU;AAC/C,MAAE,YAAY;AACd,UAAM,KAAK,GAAG,MAAM,KAAK,EAAE,QAAQ,UAAU,CAAC;AAAA,EAChD,WAAW,OAAO,QAAQ,YAAY,QAAQ,aAAa;AACzD,UAAM,KAAK,IAAI,SAAS,eAAe,GAAG,CAAC;AAAA,EAC7C;AAEA,WAAS,mBAAmB,IAAI,OAAO,GAAG;AAI1C,QAAM,eAAe,oBAAoB,IAAI;AAE7C,MAAI,QAAQ,WAAW;AACrB,QAAI,CAAC,aAAc,UAAS,YAAY,GAAG,KAAK;AAAA,EAClD,WAAW,QAAQ,aAAa;AAC9B,aAAS,gBAAgB,GAAG,KAAK;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,UAAkB,UAA8C,CAAC,GAAoB;AACjH,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,YAAW,CAAC;AAChE;AAEO,SAAS,mBAAmB,UAAkB,UAAuD,CAAC,GAAoB;AAC/H,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,aAAa,MAAM,QAAO,CAAC;AAC/E;AAEO,SAAS,oBAAoB,UAAkB,UAAuD,CAAC,GAAoB;AAChI,SAAO,UAAU,UAAU,EAAC,GAAG,SAAS,UAAU,aAAa,MAAM,SAAQ,CAAC;AAChF;AAIO,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,SAAS,oBAAI,IAAwC;AAC3D,QAAM,OAAO,aAAa,gBAAyD,yBAAyB,MAAM;AAClH,OAAK,QAAQ,SAAO;AAClB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,194 @@
1
+ import { ReflectUtils } from "@dooboostore/core";
2
+ import { ensureInit, getElementConfig } from "./elementDefine.js";
3
+ import { SwcUtils } from "../utils/Utils.js";
4
+ const PROPERTY_METADATA_KEY = Symbol.for("simple-web-component:property");
5
+ const resolvePropertyTargets = (inst, selector, options) => {
6
+ const conf = getElementConfig(inst);
7
+ const currentWin = conf.window;
8
+ const r = options.root || "auto";
9
+ const results = [];
10
+ const applyRoot = (target) => {
11
+ if (!target) return;
12
+ if (r === "auto") {
13
+ results.push(target);
14
+ } else {
15
+ if (r === "light" || r === "all") results.push(target);
16
+ if ((r === "shadow" || r === "all") && target.shadowRoot) results.push(target.shadowRoot);
17
+ }
18
+ };
19
+ if (selector === "$this" || !selector) {
20
+ applyRoot(inst);
21
+ } else if (selector === "$window") {
22
+ results.push(currentWin);
23
+ } else if (selector === "$document") {
24
+ results.push(currentWin.document);
25
+ } else {
26
+ const hostSet = SwcUtils.getHostSet(inst);
27
+ if (selector === "$host") applyRoot(hostSet.$host);
28
+ else if (selector === "$parentHost") applyRoot(hostSet.$parentHost);
29
+ else if (selector === "$appHost") applyRoot(hostSet.$appHost);
30
+ else if (selector === "$firstHost") applyRoot(hostSet.$firstHost);
31
+ else if (selector === "$lastHost") applyRoot(hostSet.$lastHost);
32
+ else if (selector === "$firstAppHost") applyRoot(hostSet.$firstAppHost);
33
+ else if (selector === "$lastAppHost") applyRoot(hostSet.$lastAppHost);
34
+ else if (selector === "$hosts") hostSet.$hosts.forEach(applyRoot);
35
+ else if (selector === "$appHosts") hostSet.$appHosts.forEach(applyRoot);
36
+ else {
37
+ if (r === "shadow") {
38
+ const found = inst.shadowRoot?.querySelectorAll(selector);
39
+ if (found) results.push(...found);
40
+ } else if (r === "light") {
41
+ const found = inst.querySelectorAll(selector);
42
+ if (found) results.push(...found);
43
+ } else if (r === "all") {
44
+ const sMatch = inst.shadowRoot?.querySelectorAll(selector);
45
+ const lMatch = inst.querySelectorAll(selector);
46
+ if (sMatch) results.push(...sMatch);
47
+ if (lMatch) results.push(...lMatch);
48
+ } else {
49
+ const found = (inst.shadowRoot || inst).querySelectorAll(selector);
50
+ if (found) results.push(...found);
51
+ }
52
+ }
53
+ }
54
+ return results;
55
+ };
56
+ function applyProperty(selector, targetPropertyKeyOrOptions, options) {
57
+ return (target, propertyKey, descriptor) => {
58
+ const constructor = target.constructor;
59
+ const metaType = descriptor && typeof descriptor.value === "function" ? "method" : "property";
60
+ let finalOptions = {};
61
+ let targetPropertyKey;
62
+ if (typeof targetPropertyKeyOrOptions === "string" || typeof targetPropertyKeyOrOptions === "symbol") {
63
+ targetPropertyKey = targetPropertyKeyOrOptions;
64
+ finalOptions = options || {};
65
+ } else if (targetPropertyKeyOrOptions) {
66
+ finalOptions = targetPropertyKeyOrOptions;
67
+ targetPropertyKey = finalOptions.name || propertyKey;
68
+ } else {
69
+ targetPropertyKey = propertyKey;
70
+ }
71
+ let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor);
72
+ if (!metaList) {
73
+ metaList = [];
74
+ ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);
75
+ }
76
+ metaList.push({
77
+ propertyKey,
78
+ selector,
79
+ targetPropertyKey,
80
+ options: finalOptions,
81
+ type: metaType
82
+ });
83
+ const applyValueToTargets = (inst, resolvedValue) => {
84
+ if (resolvedValue === void 0) return resolvedValue;
85
+ const targetEls = resolvePropertyTargets(inst, selector, finalOptions);
86
+ const conf = getElementConfig(inst);
87
+ const currentWin = conf.window;
88
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);
89
+ targetEls.forEach((targetEl) => {
90
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {
91
+ return;
92
+ }
93
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
94
+ targetEl[targetPropertyKey] = resolvedRes;
95
+ });
96
+ return resolvedValue;
97
+ };
98
+ if (descriptor && typeof descriptor.value === "function") {
99
+ const original = descriptor.value;
100
+ descriptor.value = function(...args) {
101
+ ensureInit(this);
102
+ const res = original.apply(this, args);
103
+ if (res instanceof Promise) {
104
+ return res.then((v) => {
105
+ applyValueToTargets(this, v);
106
+ return v;
107
+ });
108
+ } else {
109
+ applyValueToTargets(this, res);
110
+ return res;
111
+ }
112
+ };
113
+ return;
114
+ }
115
+ Object.defineProperty(target, propertyKey, {
116
+ configurable: true,
117
+ enumerable: true,
118
+ get() {
119
+ ensureInit(this);
120
+ const targetEls = resolvePropertyTargets(this, selector, finalOptions);
121
+ const conf = getElementConfig(this);
122
+ const currentWin = conf.window;
123
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
124
+ const filtered = targetEls.filter((el) => {
125
+ if (finalOptions.filter && !finalOptions.filter(el, el[targetPropertyKey], { currentThis: this, helper: hostSet })) {
126
+ return false;
127
+ }
128
+ return true;
129
+ });
130
+ const values = filtered.map((el) => el[targetPropertyKey]);
131
+ return values.length === 1 ? values[0] : values;
132
+ },
133
+ set(value) {
134
+ ensureInit(this);
135
+ applyValueToTargets(this, value);
136
+ }
137
+ });
138
+ };
139
+ }
140
+ function property(selector, targetPropertyKeyOrOptions, options) {
141
+ return applyProperty(selector, targetPropertyKeyOrOptions, options);
142
+ }
143
+ function propertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
144
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
145
+ return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
146
+ }
147
+ if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
148
+ return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
149
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
150
+ return applyProperty("$this", void 0, targetOrOptions);
151
+ } else {
152
+ return applyProperty("$this", void 0, {});
153
+ }
154
+ }
155
+ function setProperty(selector, targetPropertyKeyOrOptions, options) {
156
+ return applyProperty(selector, targetPropertyKeyOrOptions, options);
157
+ }
158
+ function setPropertyThis(targetOrOptions, propertyKeyOrOptions, descriptor) {
159
+ if (typeof targetOrOptions === "object" && targetOrOptions !== null && !Array.isArray(targetOrOptions) && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
160
+ return applyProperty("$this", void 0, {})(targetOrOptions, propertyKeyOrOptions, descriptor);
161
+ }
162
+ if (typeof targetOrOptions === "string" || typeof targetOrOptions === "symbol") {
163
+ return applyProperty("$this", targetOrOptions, propertyKeyOrOptions);
164
+ } else if (targetOrOptions && typeof targetOrOptions === "object") {
165
+ return applyProperty("$this", void 0, targetOrOptions);
166
+ } else {
167
+ return applyProperty("$this", void 0, {});
168
+ }
169
+ }
170
+ const findAllPropertyMetadata = (target) => {
171
+ const actualTarget = target instanceof Function ? target : target.constructor;
172
+ return ReflectUtils.findAllMetadata(PROPERTY_METADATA_KEY, actualTarget).flat();
173
+ };
174
+ const findAllPropertyApplyMetadata = (target) => {
175
+ const result = /* @__PURE__ */ new Map();
176
+ findAllPropertyMetadata(target).forEach((meta) => {
177
+ result.set(meta.propertyKey, meta);
178
+ });
179
+ return result;
180
+ };
181
+ var applyProperty_default = applyProperty;
182
+ export {
183
+ PROPERTY_METADATA_KEY,
184
+ applyProperty,
185
+ applyProperty_default as default,
186
+ findAllPropertyApplyMetadata,
187
+ findAllPropertyMetadata,
188
+ property,
189
+ propertyThis,
190
+ resolvePropertyTargets,
191
+ setProperty,
192
+ setPropertyThis
193
+ };
194
+ //# sourceMappingURL=applyProperty.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/applyProperty.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface PropertyOptions extends SwcQueryOptions {\n name?: string | symbol;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface PropertyMetadata {\n propertyKey: string | symbol;\n selector: string;\n targetPropertyKey: string | symbol;\n options: PropertyOptions;\n type: 'property' | 'method';\n}\n\nexport const PROPERTY_METADATA_KEY = Symbol.for('simple-web-component:property');\n\n// ============================================\n// Utilities\n// ============================================\n\n/**\n * Resolve target elements based on selector and options\n * Handles special selectors ($this, $host, etc.) and CSS selectors\n * Returns HTMLElement[] but can include Window and Document for property access\n */\nexport const resolvePropertyTargets = (inst: any, selector: string, options: PropertyOptions): any[] => {\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const r = options.root || 'auto';\n const results: any[] = [];\n\n const applyRoot = (target: any) => {\n if (!target) return;\n if (r === 'auto') {\n results.push(target);\n } else {\n if (r === 'light' || r === 'all') results.push(target);\n if ((r === 'shadow' || r === 'all') && target.shadowRoot) results.push(target.shadowRoot);\n }\n };\n\n if (selector === '$this' || !selector) {\n applyRoot(inst);\n } else if (selector === '$window') {\n results.push(currentWin);\n } else if (selector === '$document') {\n results.push(currentWin.document);\n } else {\n const hostSet = SwcUtils.getHostSet(inst);\n if (selector === '$host') applyRoot(hostSet.$host);\n else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);\n else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);\n else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);\n else if (selector === '$hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === '$appHosts') hostSet.$appHosts.forEach(applyRoot);\n else {\n if (r === 'shadow') {\n const found = inst.shadowRoot?.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'light') {\n const found = inst.querySelectorAll(selector);\n if (found) results.push(...found);\n } else if (r === 'all') {\n const sMatch = inst.shadowRoot?.querySelectorAll(selector);\n const lMatch = inst.querySelectorAll(selector);\n if (sMatch) results.push(...sMatch);\n if (lMatch) results.push(...lMatch);\n } else {\n const found = (inst.shadowRoot || inst).querySelectorAll(selector);\n if (found) results.push(...found);\n }\n }\n }\n return results;\n};\n\n/**\n * @applyProperty decorator - set/get element properties\n * \n * Usage:\n * - @applyProperty('selector', 'propertyName') - Set property with explicit name\n * - @applyProperty('selector') - Use property name as target property name\n * - @applyProperty('selector', { name: 'propertyName' }) - Set property via options\n * - Return null/undefined to skip setting\n */\nexport function applyProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: string, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function applyProperty(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n // ensureInit(target as any);\n \n const constructor = target.constructor;\n const metaType: 'property' | 'method' = descriptor && typeof descriptor.value === 'function' ? 'method' : 'property';\n \n // Parse arguments\n let finalOptions: PropertyOptions = {};\n let targetPropertyKey: string | symbol;\n \n if (typeof targetPropertyKeyOrOptions === 'string' || typeof targetPropertyKeyOrOptions === 'symbol') {\n // applyProperty('selector', 'propertyName', options?)\n targetPropertyKey = targetPropertyKeyOrOptions;\n finalOptions = options || {};\n } else if (targetPropertyKeyOrOptions) {\n // applyProperty('selector', options)\n finalOptions = targetPropertyKeyOrOptions;\n targetPropertyKey = finalOptions.name || propertyKey;\n } else {\n // applyProperty('selector')\n targetPropertyKey = propertyKey;\n }\n\n // Store metadata\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_METADATA_KEY, constructor) as PropertyMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(PROPERTY_METADATA_KEY, metaList, constructor);\n }\n metaList.push({\n propertyKey,\n selector,\n targetPropertyKey,\n options: finalOptions,\n type: metaType\n });\n\n // Helper: apply resolved value to targets\n const applyValueToTargets = (inst: any, resolvedValue: any) => {\n if (resolvedValue === undefined) return resolvedValue;\n\n const targetEls = resolvePropertyTargets(inst, selector, finalOptions);\n const conf = getElementConfig(inst);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, inst);\n\n targetEls.forEach(targetEl => {\n // Apply filter if provided\n if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: inst, helper: hostSet })) {\n return;\n }\n\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n (targetEl as any)[targetPropertyKey] = resolvedRes;\n });\n\n return resolvedValue;\n };\n\n // Method decorator: wrap method to apply its return value to properties\n if (descriptor && typeof descriptor.value === 'function') {\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n if (res instanceof Promise) {\n return res.then((v: any) => { applyValueToTargets(this, v); return v; });\n } else {\n applyValueToTargets(this, res);\n return res;\n }\n };\n return;\n }\n\n // Property decorator: define getter/setter to proxy to element properties\n Object.defineProperty(target, propertyKey, {\n configurable: true,\n enumerable: true,\n get(this: any) {\n ensureInit(this);\n // Read from matched elements\n const targetEls = resolvePropertyTargets(this, selector, finalOptions);\n const conf = getElementConfig(this);\n const currentWin = conf.window;\n const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);\n\n // Apply filter\n const filtered = targetEls.filter(el => {\n if (finalOptions.filter && !finalOptions.filter(el, (el as any)[targetPropertyKey], { currentThis: this, helper: hostSet })) {\n return false;\n }\n return true;\n });\n\n const values = filtered.map(el => (el as any)[targetPropertyKey]);\n return values.length === 1 ? values[0] : values;\n },\n set(this: any, value: any) {\n ensureInit(this);\n applyValueToTargets(this, value);\n }\n });\n };\n}\n\n// ============================================\n// Convenience Aliases\n// ============================================\n\n/**\n * @property - Alias for @applyProperty\n */\nexport function property(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function property(selector: string, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function property(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator & PropertyDecorator {\n return applyProperty(selector, targetPropertyKeyOrOptions as any, options);\n}\n\n/**\n * @propertyThis - Apply property on $this element\n * Can be used as: @propertyThis or @propertyThis('propertyName') or @propertyThis({ name: 'propertyName' })\n */\nexport function propertyThis(target: Object, propertyKey: string | symbol): void;\nexport function propertyThis(targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function propertyThis(options?: PropertyOptions): MethodDecorator & PropertyDecorator;\nexport function propertyThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @propertyThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) && \n (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n // Called as @propertyThis (target, propertyKey)\n return applyProperty('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n \n // Called with parameters\n if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'symbol') {\n // @propertyThis('propertyName', options?)\n return applyProperty('$this', targetOrOptions, propertyKeyOrOptions);\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @propertyThis({ name: 'propertyName' })\n return applyProperty('$this', undefined as any, targetOrOptions);\n } else {\n // @propertyThis() or @propertyThis\n return applyProperty('$this', undefined as any, {});\n }\n}\n\n/**\n * @setProperty - Alias for @applyProperty (method-decorator semantics)\n */\nexport function setProperty(selector: string, targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selector: string, options?: PropertyOptions): MethodDecorator;\nexport function setProperty(selector: string, targetPropertyKeyOrOptions?: string | symbol | PropertyOptions, options?: PropertyOptions): MethodDecorator {\n return applyProperty(selector, targetPropertyKeyOrOptions as any, options) as MethodDecorator;\n}\n\n/**\n * @setPropertyThis - Set property on $this element\n * Can be used as: @setPropertyThis or @setPropertyThis('propertyName') or @setPropertyThis({ name: 'propertyName' })\n */\nexport function setPropertyThis(target: Object, propertyKey: string | symbol): void;\nexport function setPropertyThis(targetPropertyKey: string | symbol, options?: PropertyOptions): MethodDecorator;\nexport function setPropertyThis(options?: PropertyOptions): MethodDecorator;\nexport function setPropertyThis(targetOrOptions?: any, propertyKeyOrOptions?: any, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @setPropertyThis\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null && !Array.isArray(targetOrOptions) && \n (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {\n // Called as @setPropertyThis (target, propertyKey)\n return applyProperty('$this', undefined as any, {})(targetOrOptions, propertyKeyOrOptions, descriptor);\n }\n \n // Called with parameters\n if (typeof targetOrOptions === 'string' || typeof targetOrOptions === 'symbol') {\n // @setPropertyThis('propertyName', options?)\n return applyProperty('$this', targetOrOptions, propertyKeyOrOptions) as MethodDecorator;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // @setPropertyThis({ name: 'propertyName' })\n return applyProperty('$this', undefined as any, targetOrOptions) as MethodDecorator;\n } else {\n // @setPropertyThis() or @setPropertyThis\n return applyProperty('$this', undefined as any, {}) as MethodDecorator;\n }\n}\n\n\n\n// ============================================\n// Metadata Helpers\n// ============================================\n\nexport const findAllPropertyMetadata = (target: any): PropertyMetadata[] => {\n const actualTarget = target instanceof Function ? target : target.constructor;\n return ReflectUtils.findAllMetadata<PropertyMetadata[]>(PROPERTY_METADATA_KEY, actualTarget).flat();\n};\n\n// Backward compatibility alias\nexport const findAllPropertyApplyMetadata = (target: any): Map<string | symbol, PropertyMetadata> => {\n const result = new Map<string | symbol, PropertyMetadata>();\n findAllPropertyMetadata(target).forEach(meta => {\n result.set(meta.propertyKey, meta);\n });\n return result;\n};\n\n\nexport default applyProperty;\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAC7C,SAAS,gBAAgB;AAgBlB,MAAM,wBAAwB,OAAO,IAAI,+BAA+B;AAWxE,MAAM,yBAAyB,CAAC,MAAW,UAAkB,YAAoC;AACtG,QAAM,OAAO,iBAAiB,IAAI;AAClC,QAAM,aAAa,KAAK;AACxB,QAAM,IAAI,QAAQ,QAAQ;AAC1B,QAAM,UAAiB,CAAC;AAExB,QAAM,YAAY,CAAC,WAAgB;AACjC,QAAI,CAAC,OAAQ;AACb,QAAI,MAAM,QAAQ;AAChB,cAAQ,KAAK,MAAM;AAAA,IACrB,OAAO;AACL,UAAI,MAAM,WAAW,MAAM,MAAO,SAAQ,KAAK,MAAM;AACrD,WAAK,MAAM,YAAY,MAAM,UA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