@dooboostore/simple-web-component 1.0.24 → 1.0.26

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 (130) hide show
  1. package/README.md +162 -33
  2. package/dist/cjs/decorators/addEventListener.js +1 -1
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/applyAttribute.js +148 -0
  5. package/dist/cjs/decorators/applyAttribute.js.map +7 -0
  6. package/dist/cjs/decorators/applyClass.js +164 -0
  7. package/dist/cjs/decorators/applyClass.js.map +7 -0
  8. package/dist/cjs/decorators/applyNode.js +87 -194
  9. package/dist/cjs/decorators/applyNode.js.map +2 -2
  10. package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
  11. package/dist/cjs/decorators/applyStyle.js.map +7 -0
  12. package/dist/cjs/decorators/attribute.js +10 -16
  13. package/dist/cjs/decorators/attribute.js.map +2 -2
  14. package/dist/cjs/decorators/changedAttributeHost.js +1 -1
  15. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  16. package/dist/cjs/decorators/elementDefine.js +14 -23
  17. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  18. package/dist/cjs/decorators/emitCustomEvent.js +5 -2
  19. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  20. package/dist/cjs/decorators/index.js +3 -3
  21. package/dist/cjs/decorators/index.js.map +2 -2
  22. package/dist/cjs/decorators/lifecycles.js +9 -9
  23. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  24. package/dist/cjs/decorators/query.js +1 -1
  25. package/dist/cjs/decorators/query.js.map +2 -2
  26. package/dist/cjs/decorators/queryAll.js +1 -1
  27. package/dist/cjs/decorators/queryAll.js.map +2 -2
  28. package/dist/cjs/elements/SwcAppEngine.js +19 -4
  29. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  30. package/dist/cjs/elements/SwcAppMixin.js +2 -0
  31. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  32. package/dist/cjs/utils/Utils.js +1 -1
  33. package/dist/cjs/utils/Utils.js.map +2 -2
  34. package/dist/esm/decorators/addEventListener.js +1 -1
  35. package/dist/esm/decorators/addEventListener.js.map +2 -2
  36. package/dist/esm/decorators/applyAttribute.js +129 -0
  37. package/dist/esm/decorators/applyAttribute.js.map +7 -0
  38. package/dist/esm/decorators/applyClass.js +145 -0
  39. package/dist/esm/decorators/applyClass.js.map +7 -0
  40. package/dist/esm/decorators/applyNode.js +87 -194
  41. package/dist/esm/decorators/applyNode.js.map +2 -2
  42. package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
  43. package/dist/esm/decorators/applyStyle.js.map +7 -0
  44. package/dist/esm/decorators/attribute.js +10 -16
  45. package/dist/esm/decorators/attribute.js.map +2 -2
  46. package/dist/esm/decorators/changedAttributeHost.js +1 -1
  47. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  48. package/dist/esm/decorators/elementDefine.js +14 -23
  49. package/dist/esm/decorators/elementDefine.js.map +2 -2
  50. package/dist/esm/decorators/emitCustomEvent.js +5 -2
  51. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  52. package/dist/esm/decorators/index.js +3 -3
  53. package/dist/esm/decorators/index.js.map +1 -1
  54. package/dist/esm/decorators/lifecycles.js +9 -9
  55. package/dist/esm/decorators/lifecycles.js.map +2 -2
  56. package/dist/esm/decorators/query.js +1 -1
  57. package/dist/esm/decorators/query.js.map +2 -2
  58. package/dist/esm/decorators/queryAll.js +1 -1
  59. package/dist/esm/decorators/queryAll.js.map +2 -2
  60. package/dist/esm/elements/SwcAppEngine.js +19 -4
  61. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  62. package/dist/esm/elements/SwcAppMixin.js +2 -0
  63. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  64. package/dist/esm/utils/Utils.js +1 -1
  65. package/dist/esm/utils/Utils.js.map +2 -2
  66. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
  67. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  68. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  69. package/dist/types/decorators/applyAttribute.d.ts +22 -0
  70. package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
  71. package/dist/types/decorators/applyClass.d.ts +65 -0
  72. package/dist/types/decorators/applyClass.d.ts.map +1 -0
  73. package/dist/types/decorators/applyNode.d.ts +15 -123
  74. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  75. package/dist/types/decorators/applyStyle.d.ts +21 -0
  76. package/dist/types/decorators/applyStyle.d.ts.map +1 -0
  77. package/dist/types/decorators/attribute.d.ts +10 -19
  78. package/dist/types/decorators/attribute.d.ts.map +1 -1
  79. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  80. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  81. package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
  82. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  83. package/dist/types/decorators/index.d.ts +3 -3
  84. package/dist/types/decorators/index.d.ts.map +1 -1
  85. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  86. package/dist/types/decorators/query.d.ts.map +1 -1
  87. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  88. package/dist/types/elements/SwcAppEngine.d.ts +7 -0
  89. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  90. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  91. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  92. package/dist/types/utils/Utils.d.ts.map +1 -1
  93. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
  94. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  95. package/package.json +2 -2
  96. package/src/decorators/addEventListener.ts +1 -1
  97. package/src/decorators/applyAttribute.ts +147 -0
  98. package/src/decorators/applyClass.ts +158 -0
  99. package/src/decorators/applyNode.ts +112 -330
  100. package/src/decorators/applyStyle.ts +128 -0
  101. package/src/decorators/attribute.ts +21 -55
  102. package/src/decorators/changedAttributeHost.ts +1 -1
  103. package/src/decorators/elementDefine.ts +18 -39
  104. package/src/decorators/emitCustomEvent.ts +6 -3
  105. package/src/decorators/index.ts +3 -3
  106. package/src/decorators/lifecycles.ts +9 -11
  107. package/src/decorators/query.ts +1 -1
  108. package/src/decorators/queryAll.ts +1 -1
  109. package/src/elements/SwcAppEngine.ts +32 -4
  110. package/src/elements/SwcAppMixin.ts +2 -0
  111. package/src/utils/Utils.ts +2 -1
  112. package/dist/cjs/decorators/classList.js +0 -177
  113. package/dist/cjs/decorators/classList.js.map +0 -7
  114. package/dist/cjs/decorators/setAttribute.js +0 -111
  115. package/dist/cjs/decorators/setAttribute.js.map +0 -7
  116. package/dist/cjs/decorators/style.js.map +0 -7
  117. package/dist/esm/decorators/classList.js +0 -158
  118. package/dist/esm/decorators/classList.js.map +0 -7
  119. package/dist/esm/decorators/setAttribute.js +0 -92
  120. package/dist/esm/decorators/setAttribute.js.map +0 -7
  121. package/dist/esm/decorators/style.js.map +0 -7
  122. package/dist/types/decorators/classList.d.ts +0 -71
  123. package/dist/types/decorators/classList.d.ts.map +0 -1
  124. package/dist/types/decorators/setAttribute.d.ts +0 -23
  125. package/dist/types/decorators/setAttribute.d.ts.map +0 -1
  126. package/dist/types/decorators/style.d.ts +0 -58
  127. package/dist/types/decorators/style.d.ts.map +0 -1
  128. package/src/decorators/classList.ts +0 -234
  129. package/src/decorators/setAttribute.ts +0 -114
  130. package/src/decorators/style.ts +0 -185
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/applyClass.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions, HelperHostSet } from '../types';\n\nexport const CLASS_METADATA_KEY = Symbol.for('simple-web-component:class');\n\nexport type ClassAction = 'set' | 'update' | 'add' | 'remove' | 'toggle';\n\nexport interface ClassApplyOptions extends SwcQueryOptions {}\n\nexport interface ClassApplyMetadata {\n propertyKey: string | symbol;\n selector: string;\n action: ClassAction;\n options: ClassApplyOptions;\n}\n\nfunction createClassDecorator(action: ClassAction) {\n return (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(CLASS_METADATA_KEY, constructor) as Map<string | symbol, ClassApplyMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, ClassApplyMetadata>();\n ReflectUtils.defineMetadata(CLASS_METADATA_KEY, metaList, constructor);\n }\n\n let classMap: any = undefined;\n let finalOptions = options;\n\n if (typeof classMapOrOptions === 'string' || (typeof classMapOrOptions === 'object' && classMapOrOptions !== null && !('root' in classMapOrOptions))) {\n classMap = classMapOrOptions;\n } else if (typeof classMapOrOptions === 'object' && classMapOrOptions !== null && 'root' in classMapOrOptions) {\n finalOptions = classMapOrOptions as ClassApplyOptions;\n }\n\n metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });\n\n const original = descriptor.value;\n descriptor.value = async function (...args: any[]) {\n ensureInit(this);\n const res = await (original as any).apply(this, args);\n if (res !== undefined) {\n const win = (this as any).ownerDocument?.defaultView || window;\n const host = this as unknown as HTMLElement;\n const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host), $this: this };\n const r = finalOptions.root || 'auto';\n const targetEls: HTMLElement[] = [];\n\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof win.HTMLElement)) return;\n targetEls.push(t);\n };\n\n if (selector === ':parentHost') applyRoot(hostSet.$parentHost);\n else if (selector === ':appHost') applyRoot(hostSet.$appHost);\n else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);\n else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);\n else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);\n else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);\n else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);\n else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);\n else if (selector === ':host' || !selector) applyRoot(host);\n else {\n const targetRoot = r === 'auto' ? (host.shadowRoot || host) : (r === 'shadow' ? host.shadowRoot : host);\n if (targetRoot) {\n const found = targetRoot.querySelectorAll(selector);\n if (found) targetEls.push(...(Array.from(found) as HTMLElement[]));\n }\n }\n\n targetEls.forEach(targetEl => {\n const resolvedRes = typeof res === 'function' ? (res as any)(targetEl, hostSet) : res;\n\n if (action === 'set') {\n let classes = '';\n if (classMap && typeof classMap === 'string') {\n classes = resolvedRes ? classMap : '';\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n classes = Object.entries(resolvedRes as any)\n .filter(([_, force]) => typeof force === 'function' ? force(targetEl, hostSet) : !!force)\n .map(([cls]) => cls)\n .join(' ');\n } else {\n classes = Array.isArray(resolvedRes) ? (resolvedRes as any[]).join(' ') : String(resolvedRes);\n }\n targetEl.className = classes;\n } else if (action === 'update' || action === 'toggle') {\n if (classMap && typeof classMap === 'string') {\n targetEl.classList.toggle(classMap, !!resolvedRes);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([cls, force]) => {\n const isActive = typeof force === 'function' ? force(targetEl, hostSet) : !!force;\n targetEl.classList.toggle(cls, isActive);\n });\n } else {\n const classes = Array.isArray(resolvedRes) ? (resolvedRes as any[]).map(String) : [String(resolvedRes)];\n if (action === 'update') targetEl.classList.add(...classes);\n else classes.forEach(c => targetEl.classList.toggle(c));\n }\n } else if (action === 'add' || action === 'remove') {\n if (classMap && typeof classMap === 'string' && !!resolvedRes) {\n if (action === 'add') targetEl.classList.add(classMap);\n else targetEl.classList.remove(classMap);\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n Object.entries(resolvedRes as any).forEach(([cls, force]) => {\n const shouldExecute = typeof force === 'function' ? force(targetEl, hostSet) : !!force;\n if (shouldExecute) {\n if (action === 'add') targetEl.classList.add(cls);\n else targetEl.classList.remove(cls);\n }\n });\n } else {\n const classes = Array.isArray(resolvedRes) ? (resolvedRes as any[]).map(String) : [String(resolvedRes)];\n if (action === 'add') targetEl.classList.add(...classes);\n else targetEl.classList.remove(...classes);\n }\n }\n });\n }\n return res;\n };\n return descriptor;\n };\n };\n}\n\nexport function applyClass(selector: string, action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {\n return createClassDecorator(action)(selector, options);\n}\n\nexport const setClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')(selector, classMapOrOptions, options);\nexport const updateClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')(selector, classMapOrOptions, options);\nexport const addClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')(selector, classMapOrOptions, options);\nexport const removeClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(selector, classMapOrOptions, options);\nexport const toggleClass = (selector: string, classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(selector, classMapOrOptions, options);\n\n// Host versions\nexport function applyClassHost(action: ClassAction = 'update', options: ClassApplyOptions = {}): MethodDecorator {\n return createClassDecorator(action)(':host', options);\n}\nexport const setClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('set')(':host', classMapOrOptions, options);\nexport const updateClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('update')(':host', classMapOrOptions, options);\nexport const addClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('add')(':host', classMapOrOptions, options);\nexport const removeClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('remove')(':host', classMapOrOptions, options);\nexport const toggleClassHost = (classMapOrOptions?: string | { [className: string]: (el: HTMLElement, value: any, helper: HelperHostSet & { $this: any }) => boolean } | ClassApplyOptions, options: ClassApplyOptions = {}) => createClassDecorator('toggle')(':host', classMapOrOptions, options);\n\nexport const findAllClassMetadata = (target: any): Map<string | symbol, ClassApplyMetadata> => {\n const result = new Map<string | symbol, ClassApplyMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, ClassApplyMetadata>>(CLASS_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"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAGlB,MAAM,qBAAqB,OAAO,IAAI,4BAA4B;AAazE,SAAS,qBAAqB,QAAqB;AACjD,SAAO,CAAC,UAAkB,mBAA4J,UAA6B,CAAC,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,CAAC,MAAM,qBAAqB,QAAQ,EAAE,SAAS,mBAAmB,OAAO;AAE3R,MAAM,uBAAuB,CAAC,WAA0D;AAC7F,QAAM,SAAS,oBAAI,IAAyC;AAC5D,QAAM,OAAO,aAAa,gBAA0D,oBAAoB,MAAM;AAC9G,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
+ "names": []
7
+ }
@@ -1,18 +1,42 @@
1
1
  import { ReflectUtils } from "@dooboostore/core";
2
2
  import { ensureInit, getElementConfig } from "./elementDefine.js";
3
3
  import { SwcUtils } from "../utils/Utils.js";
4
- const APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
4
+ const APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
5
5
  const normalizeNodes = (res, doc) => {
6
6
  const items = Array.isArray(res) ? res : [res];
7
7
  return items.map((it) => {
8
- if (it instanceof Node)
9
- return it;
8
+ if (it instanceof Node) return it;
10
9
  return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
11
10
  });
12
11
  };
12
+ const applyToDom = (targetEl, res, pos, doc) => {
13
+ if (!targetEl) return;
14
+ if (pos === "innerHtml") {
15
+ targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
16
+ return;
17
+ }
18
+ if (pos === "innerText") {
19
+ if (targetEl.innerText !== void 0) {
20
+ targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
21
+ }
22
+ return;
23
+ }
24
+ const isShadowRoot = targetEl instanceof ShadowRoot;
25
+ const nodes = normalizeNodes(res, doc);
26
+ if (pos === "replace") {
27
+ if (!isShadowRoot) targetEl.replaceWith(...nodes);
28
+ } else if (pos === "replaceChildren") {
29
+ targetEl.replaceChildren(...nodes);
30
+ } else {
31
+ if (pos === "beforeEnd") targetEl.append(...nodes);
32
+ else if (pos === "afterBegin") targetEl.prepend(...nodes);
33
+ else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
34
+ else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
35
+ }
36
+ };
13
37
  function applyNode(selector, options = { position: "beforeEnd" }) {
14
- return (target, propertyKey, descriptor) => {
15
- const constructor = target.constructor;
38
+ return (targetObj, propertyKey, descriptor) => {
39
+ const constructor = targetObj.constructor;
16
40
  let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
17
41
  if (!metaList) {
18
42
  metaList = /* @__PURE__ */ new Map();
@@ -20,94 +44,58 @@ function applyNode(selector, options = { position: "beforeEnd" }) {
20
44
  }
21
45
  metaList.set(propertyKey, { propertyKey, selector, options });
22
46
  const original = descriptor.value;
23
- descriptor.value = async function(...args) {
47
+ descriptor.value = function(...args) {
24
48
  ensureInit(this);
25
- const res = await original.apply(this, args);
26
- if (res !== void 0) {
27
- const conf = getElementConfig(this);
28
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
29
- const currentDoc = currentWin.document;
30
- const pos = options.position || "beforeEnd";
49
+ const conf = getElementConfig(this);
50
+ const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
51
+ const currentDoc = currentWin.document;
52
+ const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
53
+ const getTarget = () => {
31
54
  const r = options.root || "auto";
32
55
  const applyRoot = (t) => {
33
- if (!t || !(t instanceof HTMLElement))
34
- return t;
35
- if (r === "auto")
36
- return t.shadowRoot || t;
37
- if (r === "shadow")
38
- return t.shadowRoot;
39
- if (r === "light")
40
- return t;
41
- if (r === "all")
42
- return t.shadowRoot || t;
56
+ if (!t) return t;
57
+ if (r === "auto") return t.shadowRoot || t;
58
+ if (r === "shadow") return t.shadowRoot;
59
+ if (r === "light") return t;
60
+ if (r === "all") return t.shadowRoot || t;
43
61
  return t;
44
62
  };
45
- const hostSet = SwcUtils.getHostSet(this);
46
- if (pos === "remove") {
47
- if (res) {
48
- if (selector === ":host" || !selector) {
49
- if (r === "shadow" && this.shadowRoot) {
50
- this.shadowRoot.replaceChildren();
51
- } else {
52
- this.remove();
53
- }
54
- } else {
55
- const targetRoot = applyRoot(this);
56
- if (targetRoot) {
57
- const targets = targetRoot.querySelectorAll(selector);
58
- targets.forEach((el) => el.remove());
59
- }
60
- }
61
- }
62
- } else {
63
- let targetEl = null;
64
- if (selector === ":host") {
65
- targetEl = applyRoot(this);
66
- } else if (selector === ":parentHost") {
67
- targetEl = applyRoot(hostSet.$parentHost);
68
- } else if (selector === ":appHost") {
69
- targetEl = applyRoot(hostSet.$appHost);
70
- } else if (selector === ":firstHost") {
71
- targetEl = applyRoot(hostSet.$firstHost);
72
- } else if (selector === ":lastHost") {
73
- targetEl = applyRoot(hostSet.$lastHost);
74
- } else if (selector === ":firstAppHost") {
75
- targetEl = applyRoot(hostSet.$firstHost);
76
- } else if (selector === ":lastAppHost") {
77
- targetEl = applyRoot(hostSet.$lastAppHost);
78
- } else {
79
- const targetRoot = applyRoot(this);
80
- targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
81
- }
82
- if (targetEl) {
83
- const isShadowRoot = targetEl instanceof ShadowRoot;
84
- const nodes = normalizeNodes(res, currentDoc);
85
- if (pos === "replace") {
86
- if (!isShadowRoot) {
87
- targetEl.replaceWith(...nodes);
88
- }
89
- } else if (pos === "replaceChildren") {
90
- targetEl.replaceChildren(...nodes);
91
- } else if (pos === "innerHtml") {
92
- targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
93
- } else if (pos === "innerText") {
94
- if (targetEl.innerText !== void 0) {
95
- targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
96
- }
97
- } else {
98
- if (pos === "beforeEnd")
99
- targetEl.append(...nodes);
100
- else if (pos === "afterBegin")
101
- targetEl.prepend(...nodes);
102
- else if (pos === "beforeBegin" && !isShadowRoot)
103
- targetEl.before(...nodes);
104
- else if (pos === "afterEnd" && !isShadowRoot)
105
- targetEl.after(...nodes);
106
- }
107
- }
63
+ if (selector === ":host") return applyRoot(this);
64
+ if (selector === ":parentHost") return applyRoot(hostSet.$parentHost);
65
+ if (selector === ":appHost") return applyRoot(hostSet.$appHost);
66
+ if (selector === ":firstHost") return applyRoot(hostSet.$firstHost);
67
+ if (selector === ":lastHost") return applyRoot(hostSet.$lastHost);
68
+ const targetRoot = applyRoot(this);
69
+ return targetRoot ? targetRoot.querySelector(selector) : null;
70
+ };
71
+ const targetEl = getTarget();
72
+ const res = original.apply(this, args);
73
+ const runApply = (target, val) => {
74
+ const pos = options.position || "beforeEnd";
75
+ const defaultFilter = (t, v) => {
76
+ if (v instanceof Node) return !t.contains(v);
77
+ if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
78
+ if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
79
+ return true;
80
+ };
81
+ const activeFilter = options.filter || defaultFilter;
82
+ if (activeFilter(target, val, hostSet)) {
83
+ applyToDom(target, val, pos, currentDoc);
108
84
  }
85
+ };
86
+ if (res instanceof Promise) {
87
+ if (targetEl && options.loading) {
88
+ const loadingRes = options.loading.call(this, hostSet);
89
+ applyToDom(targetEl, loadingRes, options.position || "beforeEnd", currentDoc);
90
+ }
91
+ return res.then((finalRes) => {
92
+ if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
93
+ return finalRes;
94
+ });
95
+ } else {
96
+ if (res !== void 0 && targetEl) runApply(targetEl, res);
97
+ return res;
109
98
  }
110
- return res;
111
99
  };
112
100
  };
113
101
  }
@@ -122,129 +110,34 @@ const findAllApplyNodeMetadata = (target) => {
122
110
  return result;
123
111
  };
124
112
  function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
125
- console.log("vvvvv");
126
- if (propertyKey !== void 0 && typeof propertyKey === "string" || typeof propertyKey === "symbol") {
127
- return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
128
- }
129
- if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
130
- const options = targetOrOptions;
131
- return applyNode(":host", { ...options, position: options.position || "beforeEnd" });
132
- } else {
133
- return applyNode(":host", { position: "beforeEnd" });
134
- }
135
- }
136
- function applyBeforeBeginNode(selector, options) {
137
- return applyNode(selector, { ...options, position: "beforeBegin" });
113
+ if (propertyKey !== void 0) return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
114
+ const opt = targetOrOptions || {};
115
+ return applyNode(":host", { position: "beforeEnd", ...opt });
138
116
  }
139
- function applyAfterBeginNode(selector, options) {
140
- return applyNode(selector, { ...options, position: "afterBegin" });
117
+ function applyReplaceChildrenNodeHost(targetOrOptions, propertyKey, descriptor) {
118
+ if (propertyKey !== void 0) return applyNode(":host", { position: "replaceChildren" })(targetOrOptions, propertyKey, descriptor);
119
+ const opt = targetOrOptions || {};
120
+ return applyNode(":host", { position: "replaceChildren", ...opt });
141
121
  }
142
- function applyBeforeEndNode(selector, options) {
143
- return applyNode(selector, { ...options, position: "beforeEnd" });
122
+ function applyInnerHtmlNodeHost(targetOrOptions, propertyKey, descriptor) {
123
+ if (propertyKey !== void 0) return applyNode(":host", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
124
+ const opt = targetOrOptions || {};
125
+ return applyNode(":host", { position: "innerHtml", ...opt });
144
126
  }
145
- function applyAfterEndNode(selector, options) {
146
- return applyNode(selector, { ...options, position: "afterEnd" });
147
- }
148
- function applyReplaceNode(selector, options) {
149
- return applyNode(selector, { ...options, position: "replace" });
150
- }
151
- function applyReplaceChildrenNode(selector, options) {
127
+ function applyReplaceChildrenNode(selector, options = {}) {
152
128
  return applyNode(selector, { ...options, position: "replaceChildren" });
153
129
  }
154
- function applyInnerHtmlNode(selector, options) {
130
+ function applyInnerHtmlNode(selector, options = {}) {
155
131
  return applyNode(selector, { ...options, position: "innerHtml" });
156
132
  }
157
- function applyInnerTextNode(selector, options) {
158
- return applyNode(selector, { ...options, position: "innerText" });
159
- }
160
- function applyRemoveNode(selector, options) {
161
- return applyNode(selector, { ...options, position: "remove" });
162
- }
163
- function applyBeforeBeginNodeHost(targetOrOptions, propertyKey, descriptor) {
164
- if (propertyKey !== void 0) {
165
- const decorator = applyNode(":host", { position: "beforeBegin" });
166
- return decorator(targetOrOptions, propertyKey, descriptor);
167
- }
168
- return applyNode(":host", { ...targetOrOptions || {}, position: "beforeBegin" });
169
- }
170
- function applyAfterBeginNodeHost(optionsOrTarget, propertyKey, descriptor) {
171
- if (propertyKey !== void 0) {
172
- const decorator = applyNode(":host", { position: "afterBegin" });
173
- return decorator(optionsOrTarget, propertyKey, descriptor);
174
- }
175
- return applyNode(":host", { ...optionsOrTarget || {}, position: "afterBegin" });
176
- }
177
- function applyBeforeEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
178
- if (propertyKey !== void 0) {
179
- const decorator = applyNode(":host", { position: "beforeEnd" });
180
- return decorator(optionsOrTarget, propertyKey, descriptor);
181
- }
182
- return applyNode(":host", { ...optionsOrTarget || {}, position: "beforeEnd" });
183
- }
184
- function applyAfterEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
185
- if (propertyKey !== void 0) {
186
- const decorator = applyNode(":host", { position: "afterEnd" });
187
- return decorator(optionsOrTarget, propertyKey, descriptor);
188
- }
189
- return applyNode(":host", { ...optionsOrTarget || {}, position: "afterEnd" });
190
- }
191
- function applyReplaceNodeHost(optionsOrTarget, propertyKey, descriptor) {
192
- if (propertyKey !== void 0) {
193
- const decorator = applyNode(":host", { position: "replace" });
194
- return decorator(optionsOrTarget, propertyKey, descriptor);
195
- }
196
- return applyNode(":host", { ...optionsOrTarget || {}, position: "replace" });
197
- }
198
- function applyReplaceChildrenNodeHost(optionsOrTarget, propertyKey, descriptor) {
199
- if (propertyKey !== void 0) {
200
- const decorator = applyNode(":host", { position: "replaceChildren" });
201
- return decorator(optionsOrTarget, propertyKey, descriptor);
202
- }
203
- return applyNode(":host", { ...optionsOrTarget || {}, position: "replaceChildren" });
204
- }
205
- function applyInnerHtmlNodeHost(optionsOrTarget, propertyKey, descriptor) {
206
- if (propertyKey !== void 0) {
207
- const decorator = applyNode(":host", { position: "innerHtml" });
208
- return decorator(optionsOrTarget, propertyKey, descriptor);
209
- }
210
- return applyNode(":host", { ...optionsOrTarget || {}, position: "innerHtml" });
211
- }
212
- function applyInnerTextNodeHost(optionsOrTarget, propertyKey, descriptor) {
213
- if (propertyKey !== void 0) {
214
- const decorator = applyNode(":host", { position: "innerText" });
215
- return decorator(optionsOrTarget, propertyKey, descriptor);
216
- }
217
- return applyNode(":host", { ...optionsOrTarget || {}, position: "innerText" });
218
- }
219
- function applyRemoveNodeHost(optionsOrTarget, propertyKey, descriptor) {
220
- if (propertyKey !== void 0) {
221
- const decorator = applyNode(":host", { position: "remove" });
222
- return decorator(optionsOrTarget, propertyKey, descriptor);
223
- }
224
- return applyNode(":host", { ...optionsOrTarget || {}, position: "remove" });
225
- }
226
133
  export {
227
134
  APPLY_NODE_METADATA_KEY,
228
- applyAfterBeginNode,
229
- applyAfterBeginNodeHost,
230
- applyAfterEndNode,
231
- applyAfterEndNodeHost,
232
- applyBeforeBeginNode,
233
- applyBeforeBeginNodeHost,
234
- applyBeforeEndNode,
235
- applyBeforeEndNodeHost,
236
135
  applyInnerHtmlNode,
237
136
  applyInnerHtmlNodeHost,
238
- applyInnerTextNode,
239
- applyInnerTextNodeHost,
240
137
  applyNode,
241
138
  applyNodeHost,
242
- applyRemoveNode,
243
- applyRemoveNodeHost,
244
139
  applyReplaceChildrenNode,
245
140
  applyReplaceChildrenNodeHost,
246
- applyReplaceNode,
247
- applyReplaceNodeHost,
248
141
  findAllApplyNodeMetadata
249
142
  };
250
143
  //# 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 { SwcRootType } from '../types';\nimport {SwcUtils} from \"../utils/Utils\";\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\nexport interface ApplyNodeMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: ApplyNodeOptions;\n}\n\nexport const APPLY_NODE_METADATA_KEY = Symbol('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\n/**\n * @applyNode decorator to surgically add/replace nodes to a target element.\n * \n * Usage examples:\n * @applyNode('#list') addItem() { return '<li>New Item</li>'; } // append at end\n * @applyNode('#header', { position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; } // prepend at start\n * @applyNode('#item', { position: 'replace' }) replaceItem() { return '<div>Replaced</div>'; } // replace element\n * @applyNode('#list', { position: 'replaceChildren' }) updateList() { return [item1, item2]; } // replace all children\n * @applyNode('#notification', { position: 'remove' }) dismissNotification() { return shouldDismiss; } // remove if truthy\n * @applyNode('.items', { position: 'remove', root: 'shadow' }) clearItems() { return true; } // remove shadow DOM elements\n * \n * Positions:\n * - 'beforeEnd' (default): Append at end of target\n * - 'afterBegin': Prepend at start of target\n * - 'beforeBegin': Insert before target\n * - 'afterEnd': Insert after target\n * - 'replace': Replace the entire target element\n * - 'replaceChildren': Replace all children of target element\n * - 'innerHtml': Set target's innerHTML\n * - 'innerText': Set target's innerText\n * - 'remove': Remove target element if returned value is truthy\n * \n * Root Options:\n * - 'auto' (default): Search shadow DOM first, then light DOM\n * - 'shadow': Search only in shadow DOM\n * - 'light': Search only in light DOM\n * - 'all': Use both (shadow preferred for query, both for remove)\n */\nexport function applyNode(selector: string, options: ApplyNodeOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.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 = async function (...args: any[]) {\n ensureInit(this);\n const res = await original.apply(this, args);\n if (res !== undefined) {\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\n const pos = options.position || 'beforeEnd';\n const r = options.root || 'auto';\n const applyRoot = (t: any) => {\n if (!t || !(t instanceof HTMLElement)) 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; // query only returns one, so shadow preferred\n return t;\n };\n\n const hostSet = SwcUtils.getHostSet(this);\n // const getTargetRoot = () => {\n // if (r === 'shadow') return this.shadowRoot;\n // if (r === 'light') return this as any;\n // if (r === 'all') return this.shadowRoot || (this as any);\n // return this.shadowRoot || (this as any); // auto\n // };\n\n if (pos === 'remove') {\n // Remove element(s) if returned value is truthy\n if (res) {\n if (selector === ':host' || !selector) {\n if (r === 'shadow' && this.shadowRoot) {\n // Remove all children from shadow DOM\n this.shadowRoot.replaceChildren();\n } else {\n // Remove the component itself\n (this as any).remove();\n }\n } else {\n const targetRoot = applyRoot(this);\n if (targetRoot) {\n const targets = targetRoot.querySelectorAll(selector);\n targets.forEach((el: Element) => el.remove());\n }\n }\n }\n } else {\n let targetEl: any = null;\n\n if (selector === ':host') {\n targetEl = applyRoot(this)\n } else if (selector === ':parentHost') {\n targetEl = applyRoot(hostSet.$parentHost)\n } else if (selector === ':appHost') {\n targetEl = applyRoot(hostSet.$appHost)\n } else if (selector === ':firstHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastHost') {\n targetEl = applyRoot(hostSet.$lastHost)\n } else if (selector === ':firstAppHost') {\n targetEl = applyRoot(hostSet.$firstHost)\n } else if (selector === ':lastAppHost') {\n targetEl = applyRoot(hostSet.$lastAppHost);\n } else {\n const targetRoot = applyRoot(this);\n targetEl = targetRoot ? targetRoot.querySelector(selector) : null;\n }\n\n if (targetEl) {\n const isShadowRoot = targetEl instanceof ShadowRoot;\n const nodes = normalizeNodes(res, currentDoc);\n\n if (pos === 'replace') {\n // ShadowRoot doesn't support replaceWith\n if (!isShadowRoot) {\n targetEl.replaceWith(...nodes);\n }\n } else if (pos === 'replaceChildren') {\n // Replace all children of target element\n targetEl.replaceChildren(...nodes);\n } else if (pos === 'innerHtml') {\n // Set innerHTML\n targetEl.innerHTML = res !== undefined && res !== null ? String(res) : '';\n } else if (pos === 'innerText') {\n // Set innerText\n if (targetEl.innerText !== undefined) {\n targetEl.innerText = res !== undefined && res !== null ? String(res) : '';\n }\n } else {\n /*\n <!-- beforebegin -->\n <p>\n <!-- afterbegin -->\n foo\n <!-- beforeend -->\n </p>\n <!-- afterend -->\n */\n if (pos === 'beforeEnd') targetEl.append(...nodes);\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 return res;\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\n/**\n * @applyNodeHost decorator - simplified version of @applyNode for :host selector\n * Usage: @applyNodeHost addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost() addItem() { return '<li>New Item</li>'; }\n * Usage: @applyNodeHost({ position: 'afterBegin' }) prependItem() { return '<h1>Title</h1>'; }\n */\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(): MethodDecorator;\nexport function applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // Direct decorator usage: @applyNodeHost (no parentheses)\n console.log('vvvvv')\n if (propertyKey !== undefined && typeof propertyKey === 'string' || typeof propertyKey === 'symbol') {\n return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n }\n\n // @applyNodeHost() or @applyNodeHost(options)\n if (typeof targetOrOptions === 'object' && targetOrOptions !== null) {\n const options = targetOrOptions as ApplyNodeOptions;\n return applyNode(':host', { ...options, position: options.position || 'beforeEnd' });\n } else {\n // @applyNodeHost() - use default position\n return applyNode(':host', { position: 'beforeEnd' });\n }\n}\n\n// Convenience decorators for specific positions\n\n/**\n * @applyBeforeBeginNode - Insert before target element\n */\nexport function applyBeforeBeginNode(selector: string): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNode - Prepend to target element\n */\nexport function applyAfterBeginNode(selector: string): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNode - Append to target element (default)\n */\nexport function applyBeforeEndNode(selector: string): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNode - Insert after target element\n */\nexport function applyAfterEndNode(selector: string): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNode - Replace entire target element\n */\nexport function applyReplaceNode(selector: string): MethodDecorator;\nexport function applyReplaceNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNode - Replace all children of target element\n */\nexport function applyReplaceChildrenNode(selector: string): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNode - Set target's innerHTML\n */\nexport function applyInnerHtmlNode(selector: string): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNode - Set target's innerText\n */\nexport function applyInnerTextNode(selector: string): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'innerText' });\n}\n\n/**\n * @applyRemoveNode - Remove target element if truthy\n */\nexport function applyRemoveNode(selector: string): MethodDecorator;\nexport function applyRemoveNode(selector: string, options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNode(selector: string, options?: ApplyNodeOptions): any {\n return applyNode(selector, { ...options, position: 'remove' });\n}\n\n// Host versions\n\n/**\n * @applyBeforeBeginNodeHost - Insert before :host\n */\nexport function applyBeforeBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;\nexport function applyBeforeBeginNodeHost(): MethodDecorator;\nexport function applyBeforeBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeBeginNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeBegin' });\n return decorator(targetOrOptions, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(targetOrOptions as ApplyNodeOptions || {}), position: 'beforeBegin' });\n}\n\n/**\n * @applyAfterBeginNodeHost - Prepend to :host\n */export function applyAfterBeginNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterBeginNodeHost(): MethodDecorator;\nexport function applyAfterBeginNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterBeginNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterBegin' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterBegin' });\n}\n\n/**\n * @applyBeforeEndNodeHost - Append to :host\n */export function applyBeforeEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyBeforeEndNodeHost(): MethodDecorator;\nexport function applyBeforeEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyBeforeEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'beforeEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'beforeEnd' });\n}\n\n/**\n * @applyAfterEndNodeHost - Insert after :host\n */export function applyAfterEndNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyAfterEndNodeHost(): MethodDecorator;\nexport function applyAfterEndNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyAfterEndNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'afterEnd' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'afterEnd' });\n}\n\n/**\n * @applyReplaceNodeHost - Replace :host\n */export function applyReplaceNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceNodeHost(): MethodDecorator;\nexport function applyReplaceNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replace' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replace' });\n}\n\n/**\n * @applyReplaceChildrenNodeHost - Replace children of :host\n */export function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyReplaceChildrenNodeHost(): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'replaceChildren' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'replaceChildren' });\n}\n\n/**\n * @applyInnerHtmlNodeHost - Set :host innerHTML\n */export function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerHtmlNodeHost(): MethodDecorator;\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerHtml' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerHtml' });\n}\n\n/**\n * @applyInnerTextNodeHost - Set :host innerText\n */export function applyInnerTextNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyInnerTextNodeHost(): MethodDecorator;\nexport function applyInnerTextNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerTextNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'innerText' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'innerText' });\n}\n\n/**\n * @applyRemoveNodeHost - Remove :host if truthy\n */export function applyRemoveNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): any;export function applyRemoveNodeHost(): MethodDecorator;\nexport function applyRemoveNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyRemoveNodeHost(optionsOrTarget?: ApplyNodeOptions | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) {\n const decorator = applyNode(':host', { position: 'remove' });\n return decorator(optionsOrTarget, propertyKey, descriptor);\n }\n return applyNode(':host', { ...(optionsOrTarget as ApplyNodeOptions || {}), position: 'remove' });\n}\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAQ,gBAAe;AAehB,MAAM,0BAA0B,OAAO,iCAAiC;AAE/E,MAAM,iBAAiB,CAAC,KAAU,QAAyB;AACzD,QAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG;AAC7C,SAAO,MAAM,IAAI,QAAK;AACpB,QAAI,cAAc;AAAM,aAAO;AAC/B,WAAO,IAAI,eAAe,OAAO,UAAa,OAAO,OAAO,OAAO,EAAE,IAAI,EAAE;EAC7E,CAAC;AACH;AA8BM,SAAU,UAAU,UAAkB,UAA4B,EAAE,UAAU,YAAW,GAAE;AAC/F,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,aAAa,eAAe,yBAAyB,WAAW;AAC/E,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,mBAAa,eAAe,yBAAyB,UAAU,WAAW;IAC5E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,iBAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,OAAO,iBAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,cAAM,MAAM,QAAQ,YAAY;AAChC,cAAM,IAAI,QAAQ,QAAQ;AAC1B,cAAM,YAAY,CAAC,MAAU;AAC3B,cAA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AS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,kBAAiB,CAAE;AAC3G;AAMM,SAAU,uBAAuB,iBAA0C,aAA+B,YAA+B;AAC7I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,uBAAuB,iBAA0C,aAA+B,YAA+B;AAC7I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,YAAW,CAAE;AAC9D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,YAAW,CAAE;AACrG;AAMM,SAAU,oBAAoB,iBAA0C,aAA+B,YAA+B;AAC1I,MAAI,gBAAgB,QAAW;AAC7B,UAAM,YAAY,UAAU,SAAS,EAAE,UAAU,SAAQ,CAAE;AAC3D,WAAO,UAAU,iBAAiB,aAAa,UAAU;EAC3D;AACA,SAAO,UAAU,SAAS,EAAE,GAAI,mBAAuC,CAAA,GAAK,UAAU,SAAQ,CAAE;AAClG;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit, getElementConfig } from './elementDefine';\nimport { HelperHostSet, SwcRootType } from '../types';\nimport { SwcUtils } from \"../utils/Utils\";\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, helper: HelperHostSet) => boolean;\n /**\n * Optional loading content to display while an async method is executing.\n */\n loading?: (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 = (targetEl: any, res: any, pos: ApplyNodePosition, doc: Document) => {\n if (!targetEl) return;\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 isShadowRoot = targetEl instanceof 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') targetEl.append(...nodes);\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: 'beforeEnd' }): 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 === ':host') return applyRoot(this);\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 \n // Intelligent Default Filter\n const defaultFilter = (t: any, v: any) => {\n if (v instanceof Node) return !t.contains(v);\n if (pos === 'innerHtml' && typeof v === 'string') return t.innerHTML !== v;\n if (pos === 'replaceChildren' && v instanceof Node) return !t.contains(v);\n return true;\n };\n \n const activeFilter = options.filter || defaultFilter;\n \n if (activeFilter(target, val, hostSet)) {\n applyToDom(target, val, pos, currentDoc);\n }\n };\n\n if (res instanceof Promise) {\n // \uBE44\uB3D9\uAE30\uC77C \uB54C\uB9CC \uB85C\uB529 \uD45C\uC2DC\n if (targetEl && options.loading) {\n const loadingRes = options.loading.call(this, hostSet);\n applyToDom(targetEl, loadingRes, options.position || 'beforeEnd', currentDoc);\n }\n\n return res.then(finalRes => {\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 applyNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'beforeEnd' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'beforeEnd', ...opt });\n}\n\nexport function applyReplaceChildrenNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyReplaceChildrenNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyReplaceChildrenNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'replaceChildren' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'replaceChildren', ...opt });\n}\n\nexport function applyInnerHtmlNodeHost(options: ApplyNodeOptions): MethodDecorator;\nexport function applyInnerHtmlNodeHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function applyInnerHtmlNodeHost(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n if (propertyKey !== undefined) return applyNode(':host', { position: 'innerHtml' })(targetOrOptions, propertyKey, descriptor);\n const opt = targetOrOptions || {};\n return applyNode(':host', { position: 'innerHtml', ...opt });\n}\n\nexport function applyReplaceChildrenNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'replaceChildren' });\n}\n\nexport function applyInnerHtmlNode(selector: string, options: ApplyNodeOptions = {}): MethodDecorator {\n return applyNode(selector, { ...options, position: 'innerHtml' });\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,wBAAwB;AAE7C,SAAS,gBAAgB;AAwBlB,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,UAAe,KAAU,KAAwB,QAAkB;AACnF,MAAI,CAAC,SAAU;AAEf,MAAI,QAAQ,aAAa;AACrB,aAAS,YAAY,QAAQ,UAAa,QAAQ,OAAO,OAAO,GAAG,IAAI;AACvE;AAAA,EACJ;AAEA,MAAI,QAAQ,aAAa;AACrB,QAAI,SAAS,cAAc,QAAW;AAClC,eAAS,YAAY,QAAQ,UAAa,QAAQ,OAAO,OAAO,GAAG,IAAI;AAAA,IAC3E;AACA;AAAA,EACJ;AAEA,QAAM,eAAe,oBAAoB;AACzC,QAAM,QAAQ,eAAe,KAAK,GAAG;AACrC,MAAI,QAAQ,WAAW;AACrB,QAAI,CAAC,aAAc,UAAS,YAAY,GAAG,KAAK;AAAA,EAClD,WAAW,QAAQ,mBAAmB;AACpC,aAAS,gBAAgB,GAAG,KAAK;AAAA,EACnC,OAAO;AACL,QAAI,QAAQ,YAAa,UAAS,OAAO,GAAG,KAAK;AAAA,aACxC,QAAQ,aAAc,UAAS,QAAQ,GAAG,KAAK;AAAA,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