@dooboostore/simple-web-component 1.0.19 → 1.0.22

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 (174) hide show
  1. package/README.md +2759 -201
  2. package/dist/cjs/decorators/addEventListener.js +8 -4
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/{appendChild.js → applyNode.js} +26 -18
  5. package/dist/cjs/decorators/applyNode.js.map +7 -0
  6. package/dist/cjs/decorators/attribute.js +162 -0
  7. package/dist/cjs/decorators/attribute.js.map +7 -0
  8. package/dist/cjs/decorators/{changedAttribute.js → changedAttributeHost.js} +11 -11
  9. package/dist/cjs/decorators/changedAttributeHost.js.map +7 -0
  10. package/dist/cjs/decorators/classList.js +15 -5
  11. package/dist/cjs/decorators/classList.js.map +2 -2
  12. package/dist/cjs/decorators/elementDefine.js +124 -46
  13. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  14. package/dist/cjs/decorators/emitCustomEvent.js +8 -7
  15. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  16. package/dist/cjs/decorators/index.js +3 -3
  17. package/dist/cjs/decorators/index.js.map +2 -2
  18. package/dist/cjs/decorators/lifecycles.js +8 -4
  19. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  20. package/dist/cjs/decorators/onConnectedInnerHtml.js +4 -4
  21. package/dist/cjs/decorators/onConnectedInnerHtml.js.map +2 -2
  22. package/dist/cjs/decorators/query.js +9 -5
  23. package/dist/cjs/decorators/query.js.map +2 -2
  24. package/dist/cjs/decorators/queryAll.js +9 -5
  25. package/dist/cjs/decorators/queryAll.js.map +2 -2
  26. package/dist/cjs/decorators/setAttribute.js +51 -21
  27. package/dist/cjs/decorators/setAttribute.js.map +2 -2
  28. package/dist/cjs/decorators/style.js +4 -4
  29. package/dist/cjs/decorators/style.js.map +2 -2
  30. package/dist/cjs/elements/SwcAppEngine.js +8 -8
  31. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  32. package/dist/cjs/elements/SwcAppMixin.js +28 -1
  33. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  34. package/dist/cjs/elements/SwcAsync.js +6 -6
  35. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  36. package/dist/cjs/elements/SwcChoose.js +6 -6
  37. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  38. package/dist/cjs/elements/SwcIf.js +6 -6
  39. package/dist/cjs/elements/SwcIf.js.map +2 -2
  40. package/dist/cjs/elements/SwcLoop.js +6 -6
  41. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  42. package/dist/cjs/elements/register.js +19 -18
  43. package/dist/cjs/elements/register.js.map +2 -2
  44. package/dist/cjs/index.js +6 -17
  45. package/dist/cjs/index.js.map +2 -2
  46. package/dist/cjs/router/ElementRouter.js +7 -7
  47. package/dist/cjs/router/ElementRouter.js.map +2 -2
  48. package/dist/cjs/types.js.map +2 -2
  49. package/dist/esm/decorators/addEventListener.js +5 -1
  50. package/dist/esm/decorators/addEventListener.js.map +2 -2
  51. package/dist/esm/decorators/{appendChild.js → applyNode.js} +23 -15
  52. package/dist/esm/decorators/applyNode.js.map +7 -0
  53. package/dist/esm/decorators/attribute.js +143 -0
  54. package/dist/esm/decorators/attribute.js.map +7 -0
  55. package/dist/esm/decorators/{changedAttribute.js → changedAttributeHost.js} +4 -4
  56. package/dist/esm/decorators/changedAttributeHost.js.map +7 -0
  57. package/dist/esm/decorators/classList.js +12 -2
  58. package/dist/esm/decorators/classList.js.map +2 -2
  59. package/dist/esm/decorators/elementDefine.js +119 -41
  60. package/dist/esm/decorators/elementDefine.js.map +2 -2
  61. package/dist/esm/decorators/emitCustomEvent.js +5 -4
  62. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  63. package/dist/esm/decorators/index.js +3 -3
  64. package/dist/esm/decorators/index.js.map +1 -1
  65. package/dist/esm/decorators/lifecycles.js +5 -1
  66. package/dist/esm/decorators/lifecycles.js.map +2 -2
  67. package/dist/esm/decorators/onConnectedInnerHtml.js +1 -1
  68. package/dist/esm/decorators/onConnectedInnerHtml.js.map +1 -1
  69. package/dist/esm/decorators/query.js +6 -2
  70. package/dist/esm/decorators/query.js.map +2 -2
  71. package/dist/esm/decorators/queryAll.js +6 -2
  72. package/dist/esm/decorators/queryAll.js.map +2 -2
  73. package/dist/esm/decorators/setAttribute.js +47 -17
  74. package/dist/esm/decorators/setAttribute.js.map +2 -2
  75. package/dist/esm/decorators/style.js +1 -1
  76. package/dist/esm/decorators/style.js.map +1 -1
  77. package/dist/esm/elements/SwcAppEngine.js +4 -4
  78. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  79. package/dist/esm/elements/SwcAppMixin.js +28 -1
  80. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  81. package/dist/esm/elements/SwcAsync.js +3 -3
  82. package/dist/esm/elements/SwcAsync.js.map +2 -2
  83. package/dist/esm/elements/SwcChoose.js +3 -3
  84. package/dist/esm/elements/SwcChoose.js.map +2 -2
  85. package/dist/esm/elements/SwcIf.js +3 -3
  86. package/dist/esm/elements/SwcIf.js.map +2 -2
  87. package/dist/esm/elements/SwcLoop.js +3 -3
  88. package/dist/esm/elements/SwcLoop.js.map +2 -2
  89. package/dist/esm/elements/register.js +7 -6
  90. package/dist/esm/elements/register.js.map +2 -2
  91. package/dist/esm/index.js +6 -17
  92. package/dist/esm/index.js.map +2 -2
  93. package/dist/esm/router/ElementRouter.js +2 -2
  94. package/dist/esm/router/ElementRouter.js.map +1 -1
  95. package/dist/esm/types.js.map +2 -2
  96. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +5444 -3317
  97. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  98. package/dist/types/decorators/addEventListener.d.ts +6 -0
  99. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  100. package/dist/types/decorators/applyNode.d.ts +38 -0
  101. package/dist/types/decorators/applyNode.d.ts.map +1 -0
  102. package/dist/types/decorators/attribute.d.ts +29 -0
  103. package/dist/types/decorators/attribute.d.ts.map +1 -0
  104. package/dist/types/decorators/{changedAttribute.d.ts → changedAttributeHost.d.ts} +6 -2
  105. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -0
  106. package/dist/types/decorators/classList.d.ts +25 -0
  107. package/dist/types/decorators/classList.d.ts.map +1 -1
  108. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  109. package/dist/types/decorators/emitCustomEvent.d.ts +14 -2
  110. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  111. package/dist/types/decorators/index.d.ts +3 -3
  112. package/dist/types/decorators/index.d.ts.map +1 -1
  113. package/dist/types/decorators/lifecycles.d.ts +2 -0
  114. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  115. package/dist/types/decorators/query.d.ts +6 -0
  116. package/dist/types/decorators/query.d.ts.map +1 -1
  117. package/dist/types/decorators/queryAll.d.ts +6 -0
  118. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  119. package/dist/types/decorators/setAttribute.d.ts +8 -0
  120. package/dist/types/decorators/setAttribute.d.ts.map +1 -1
  121. package/dist/types/elements/SwcAppEngine.d.ts +5 -4
  122. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  123. package/dist/types/elements/SwcAppMixin.d.ts +1 -1
  124. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  125. package/dist/types/elements/register.d.ts +1 -1
  126. package/dist/types/elements/register.d.ts.map +1 -1
  127. package/dist/types/index.d.ts +3 -14
  128. package/dist/types/index.d.ts.map +1 -1
  129. package/dist/types/router/ElementRouter.d.ts +1 -1
  130. package/dist/types/router/ElementRouter.d.ts.map +1 -1
  131. package/dist/types/types.d.ts +3 -1
  132. package/dist/types/types.d.ts.map +1 -1
  133. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +5444 -3317
  134. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  135. package/package.json +10 -5
  136. package/src/decorators/addEventListener.ts +10 -1
  137. package/src/decorators/applyNode.ts +127 -0
  138. package/src/decorators/attribute.ts +192 -0
  139. package/src/decorators/{changedAttribute.ts → changedAttributeHost.ts} +6 -2
  140. package/src/decorators/classList.ts +33 -1
  141. package/src/decorators/elementDefine.ts +148 -47
  142. package/src/decorators/emitCustomEvent.ts +14 -6
  143. package/src/decorators/index.ts +3 -3
  144. package/src/decorators/lifecycles.ts +4 -2
  145. package/src/decorators/onConnectedInnerHtml.ts +1 -1
  146. package/src/decorators/query.ts +10 -1
  147. package/src/decorators/queryAll.ts +10 -1
  148. package/src/decorators/setAttribute.ts +57 -17
  149. package/src/decorators/style.ts +1 -1
  150. package/src/elements/SwcAppEngine.ts +10 -8
  151. package/src/elements/SwcAppMixin.ts +34 -2
  152. package/src/elements/SwcAsync.ts +3 -3
  153. package/src/elements/SwcChoose.ts +3 -3
  154. package/src/elements/SwcIf.ts +3 -3
  155. package/src/elements/SwcLoop.ts +3 -3
  156. package/src/elements/register.ts +8 -6
  157. package/src/index.ts +8 -16
  158. package/src/router/ElementRouter.ts +2 -2
  159. package/src/types.ts +3 -1
  160. package/dist/cjs/decorators/appendChild.js.map +0 -7
  161. package/dist/cjs/decorators/changedAttribute.js.map +0 -7
  162. package/dist/cjs/decorators/replaceChildren.js +0 -79
  163. package/dist/cjs/decorators/replaceChildren.js.map +0 -7
  164. package/dist/esm/decorators/appendChild.js.map +0 -7
  165. package/dist/esm/decorators/changedAttribute.js.map +0 -7
  166. package/dist/esm/decorators/replaceChildren.js +0 -60
  167. package/dist/esm/decorators/replaceChildren.js.map +0 -7
  168. package/dist/types/decorators/appendChild.d.ts +0 -17
  169. package/dist/types/decorators/appendChild.d.ts.map +0 -1
  170. package/dist/types/decorators/changedAttribute.d.ts.map +0 -1
  171. package/dist/types/decorators/replaceChildren.d.ts +0 -9
  172. package/dist/types/decorators/replaceChildren.d.ts.map +0 -1
  173. package/src/decorators/appendChild.ts +0 -86
  174. package/src/decorators/replaceChildren.ts +0 -64
@@ -1,6 +1,6 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
- import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
3
+ import { FunctionUtils } from '@dooboostore/core';
4
4
 
5
5
  export class SwcAsync extends HTMLTemplateElement {
6
6
  private _nodes: Node[] = [];
@@ -28,7 +28,7 @@ export class SwcAsync extends HTMLTemplateElement {
28
28
  FunctionUtils.execute({ script, context: this, args });
29
29
  }
30
30
 
31
- @changedAttribute('on-get-value')
31
+ @changedAttributeHost('on-get-value')
32
32
  private refresh() {
33
33
  const script = this.getAttribute('on-get-value');
34
34
  if (!script) return;
@@ -1,6 +1,6 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
- import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
3
+ import { FunctionUtils } from '@dooboostore/core';
4
4
 
5
5
  export class SwcChoose extends HTMLTemplateElement {
6
6
  private _nodes: Node[] = [];
@@ -36,7 +36,7 @@ export class SwcChoose extends HTMLTemplateElement {
36
36
  FunctionUtils.execute({ script, context: this, args });
37
37
  }
38
38
 
39
- @changedAttribute('on-get-value')
39
+ @changedAttributeHost('on-get-value')
40
40
  private refresh() {
41
41
  const script = this.getAttribute('on-get-value');
42
42
  if (!script) {
@@ -1,6 +1,6 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
- import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
3
+ import { FunctionUtils } from '@dooboostore/core';
4
4
 
5
5
  export class SwcIf extends HTMLTemplateElement {
6
6
  private _value = false;
@@ -36,7 +36,7 @@ export class SwcIf extends HTMLTemplateElement {
36
36
  FunctionUtils.execute({ script, context: this, args });
37
37
  }
38
38
 
39
- @changedAttribute('on-get-value')
39
+ @changedAttributeHost('on-get-value')
40
40
  private refreshValue() {
41
41
  const script = this.getAttribute('on-get-value');
42
42
  if (!script) {
@@ -1,6 +1,6 @@
1
- import { changedAttribute } from '../decorators/changedAttribute';
1
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
2
2
  import { SwcUtils } from '../utils/Utils';
3
- import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
3
+ import { FunctionUtils } from '@dooboostore/core';
4
4
 
5
5
  export class SwcLoop extends HTMLTemplateElement {
6
6
  private _value: any[] = [];
@@ -41,7 +41,7 @@ export class SwcLoop extends HTMLTemplateElement {
41
41
  this._nodeGroups = [];
42
42
  }
43
43
 
44
- @changedAttribute('on-get-value')
44
+ @changedAttributeHost('on-get-value')
45
45
  private refreshValue() {
46
46
  const script = this.getAttribute('on-get-value');
47
47
  if (!script) {
@@ -1,8 +1,8 @@
1
1
  import { elementDefine } from '../decorators/elementDefine';
2
2
  import { SwcAppMixin } from './SwcAppMixin';
3
3
  import { SwcUtils } from '../utils/Utils';
4
- import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
5
- import { changedAttribute } from '../decorators/changedAttribute';
4
+ import { FunctionUtils } from '@dooboostore/core';
5
+ import { changedAttributeHost } from '../decorators/changedAttributeHost';
6
6
 
7
7
  export const registerAllElements = (w: any) => {
8
8
  const {
@@ -179,7 +179,7 @@ export const registerAllElements = (w: any) => {
179
179
  FunctionUtils.execute({ script, context: this, args });
180
180
  }
181
181
 
182
- @changedAttribute('on-get-value')
182
+ @changedAttributeHost('on-get-value')
183
183
  private refreshValue() {
184
184
  const script = this.getAttribute('on-get-value');
185
185
  if (!script) {
@@ -294,7 +294,7 @@ export const registerAllElements = (w: any) => {
294
294
  this._nodeGroups = [];
295
295
  }
296
296
 
297
- @changedAttribute('on-get-value')
297
+ @changedAttributeHost('on-get-value')
298
298
  private refreshValue() {
299
299
  const script = this.getAttribute('on-get-value');
300
300
  if (!script) {
@@ -405,7 +405,7 @@ export const registerAllElements = (w: any) => {
405
405
  FunctionUtils.execute({ script, context: this, args });
406
406
  }
407
407
 
408
- @changedAttribute('on-get-value')
408
+ @changedAttributeHost('on-get-value')
409
409
  private refresh() {
410
410
  const script = this.getAttribute('on-get-value');
411
411
  if (!script) {
@@ -496,7 +496,7 @@ export const registerAllElements = (w: any) => {
496
496
  FunctionUtils.execute({ script, context: this, args });
497
497
  }
498
498
 
499
- @changedAttribute('on-get-value')
499
+ @changedAttributeHost('on-get-value')
500
500
  private refresh() {
501
501
  const script = this.getAttribute('on-get-value');
502
502
  if (!script) return;
@@ -732,4 +732,6 @@ export const registerAllElements = (w: any) => {
732
732
  @elementDefine('swc-app-body', { extends: 'body', window: w })
733
733
  class SwcAppBody extends SwcAppMixin(HTMLBodyElement) {}
734
734
 
735
+
736
+ return []
735
737
  };
package/src/index.ts CHANGED
@@ -1,20 +1,9 @@
1
1
  import 'reflect-metadata';
2
2
  import { registerAllElements } from './elements/register';
3
+ import {ConstructorType} from "@dooboostore/core";
3
4
 
4
5
  // Decorators
5
- export * from './decorators/elementDefine';
6
- export * from './decorators/setAttribute';
7
- export * from './decorators/changedAttribute';
8
- export { onConnectedInnerHtml } from './decorators/onConnectedInnerHtml';
9
- export * from './decorators/replaceChildren';
10
- export * from './decorators/appendChild';
11
- export * from './decorators/classList';
12
- export * from './decorators/style';
13
- export * from './decorators/emitCustomEvent';
14
- export * from './decorators/lifecycles';
15
- export * from './decorators/query';
16
- export * from './decorators/queryAll';
17
- export * from './decorators/addEventListener';
6
+ export * from './decorators';
18
7
 
19
8
  // Types
20
9
  export * from './types';
@@ -27,9 +16,12 @@ export * from './utils/TemplateUtils';
27
16
  export * from './config/config';
28
17
 
29
18
  // Registration Factory
30
- export default (w: Window, other?: ((w:Window)=>void)[]): void => {
19
+ export default (w: Window, other?: ((w: Window) => ConstructorType<any>)[]): ConstructorType<any>[] => {
31
20
  registerAllElements(w);
32
- other?.forEach(fn => {
33
- fn(w);
21
+ const r = other?.map(fn => {
22
+ const a = fn(w);
23
+ // console.log('l', fn, a)
24
+ return a;
34
25
  });
26
+ return r??[];
35
27
  };
@@ -1,5 +1,5 @@
1
- import { ChangeStateConfig, ChangeStateResult, RouteAction, Router, RouterConfig, RouterMethodOptions } from '@dooboostore/core-web/routers/Router';
2
- import { UrlUtils } from '@dooboostore/core/url/UrlUtils';
1
+ import { ChangeStateConfig, ChangeStateResult, RouteAction, Router, RouterConfig, RouterMethodOptions } from '@dooboostore/core-web';
2
+ import { UrlUtils } from '@dooboostore/core';
3
3
 
4
4
  export class ElementRouter extends Router {
5
5
  private _history: { url: string; data: any; title?: string }[] = [];
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
2
- import { Router } from '@dooboostore/core-web/routers/Router';
2
+ import { Router } from '@dooboostore/core-web';
3
+ import {SwcAttributeConfigType} from "./elements/SwcAppEngine";
3
4
 
4
5
  export enum InjectSituationType {
5
6
  HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',
@@ -45,5 +46,6 @@ export type HelperHostSet = HelperSet & HostSet;
45
46
  export interface SwcAppInterface extends HTMLElement {
46
47
  simpleApplication?: SimpleApplication;
47
48
  router?: Router;
49
+ connect(config?: SwcAttributeConfigType): Promise<void>;
48
50
  routing(path: string): Promise<void>;
49
51
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/appendChild.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\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 * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_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 let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_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;;;;;;;0BAA6B;AAC7B,2BAA6C;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,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;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SAAO,CAAC,QAAgB,aAA8B,eAAkC;AACtF,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,iCAAa,eAAe,2BAA2B,WAAW;AACjF,QAAI,CAAC,UAAU;AACb,iBAAW,oBAAI,IAAG;AAClB,uCAAa,eAAe,2BAA2B,UAAU,WAAW;IAC9E;AACA,aAAS,IAAI,aAAa,EAAE,aAAa,UAAU,QAAO,CAAE;AAE5D,UAAM,WAAW,WAAW;AAC5B,eAAW,QAAQ,kBAAmB,MAAW;AAC/C,2CAAW,IAAI;AACf,YAAM,MAAM,MAAM,SAAS,MAAM,MAAM,IAAI;AAC3C,UAAI,QAAQ,QAAW;AACrB,cAAM,WAAO,uCAAiB,IAAI;AAClC,cAAM,aAAc,KAAa,iBAAiB,IAAI,MAAO,OAAO,WAAW,cAAc,SAAS;AACtG,cAAM,aAAa,WAAW;AAE9B,YAAI,WAA+B;AACnC,YAAI,aAAa,WAAW,CAAC,UAAU;AACrC,qBAAW;QACb,OAAO;AACL,sBAAY,KAAK,cAAe,MAAc,cAAc,QAAQ;QACtE;AAEA,YAAI,UAAU;AACZ,gBAAM,QAAQ,eAAe,KAAK,UAAU;AAC5C,gBAAM,MAAM,QAAQ,YAAY;AAEhC,cAAI,OAAO,QAAQ,UAAU;AAC3B,qBAAS,mBAAmB,KAAuB,GAAG;UACxD,WAAW,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,OAAK,OAAO,MAAM,QAAQ,GAAG;AACtE,qBAAS,mBAAmB,KAAuB,IAAI,KAAK,EAAE,CAAC;UACjE,OAAO;AACL,gBAAI,QAAQ;AAAa,uBAAS,OAAO,GAAG,KAAK;qBACxC,QAAQ;AAAc,uBAAS,QAAQ,GAAG,KAAK;qBAC/C,QAAQ;AAAe,uBAAS,OAAO,GAAG,KAAK;qBAC/C,QAAQ;AAAY,uBAAS,MAAM,GAAG,KAAK;UACtD;QACF;MACF;AACA,aAAO;IACT;EACF;AACF;AAEO,MAAM,6BAA6B,CAAC,WAA0D;AACnG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,iCAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/changedAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,iCAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,uCAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,iCAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,iCAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
- "names": []
7
- }
@@ -1,79 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var replaceChildren_exports = {};
19
- __export(replaceChildren_exports, {
20
- REPLACE_CHILDREN_METADATA_KEY: () => REPLACE_CHILDREN_METADATA_KEY,
21
- findAllReplaceChildrenMetadata: () => findAllReplaceChildrenMetadata,
22
- getReplaceChildrenMetadata: () => getReplaceChildrenMetadata,
23
- replaceChildren: () => replaceChildren
24
- });
25
- module.exports = __toCommonJS(replaceChildren_exports);
26
- var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
27
- var import_elementDefine = require("./elementDefine");
28
- const REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
29
- function replaceChildren(selector) {
30
- return (target, propertyKey, descriptor) => {
31
- const constructor = target.constructor;
32
- let meta = import_ReflectUtils.ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
33
- if (!meta) {
34
- meta = /* @__PURE__ */ new Map();
35
- import_ReflectUtils.ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
36
- }
37
- meta.set(propertyKey, selector);
38
- const original = descriptor.value;
39
- descriptor.value = async function(...args) {
40
- (0, import_elementDefine.ensureInit)(this);
41
- const res = await original.apply(this, args);
42
- if (res !== void 0) {
43
- const conf = (0, import_elementDefine.getElementConfig)(this);
44
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
45
- const currentDoc = currentWin.document;
46
- let targetEl = null;
47
- if (selector === ":host" || !selector) {
48
- targetEl = this;
49
- } else {
50
- targetEl = (this.shadowRoot || this).querySelector(selector);
51
- }
52
- if (targetEl) {
53
- if (typeof res === "string") {
54
- targetEl.textContent = res;
55
- } else {
56
- const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
57
- targetEl.replaceChildren(...nodes);
58
- }
59
- }
60
- }
61
- return res;
62
- };
63
- };
64
- }
65
- const getReplaceChildrenMetadata = (target) => {
66
- const constructor = target instanceof Function ? target : target.constructor;
67
- return import_ReflectUtils.ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
68
- };
69
- const findAllReplaceChildrenMetadata = (target) => {
70
- const result = /* @__PURE__ */ new Map();
71
- const maps = import_ReflectUtils.ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
72
- maps.forEach((map) => {
73
- if (map instanceof Map) {
74
- map.forEach((v, k) => result.set(k, v));
75
- }
76
- });
77
- return result;
78
- };
79
- //# sourceMappingURL=replaceChildren.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/replaceChildren.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');\n\n/**\n * @replaceChildren decorator to surgically replace children of a target element.\n * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }\n */\nexport function replaceChildren(selector: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;\n if (!meta) {\n meta = new Map<string | symbol, string>();\n ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);\n }\n meta.set(propertyKey, selector);\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 let targetEl: Element | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n if (typeof res === 'string') {\n targetEl.textContent = res;\n } else {\n const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];\n (targetEl as any).replaceChildren(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);\n};\n\nexport const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {\n const result = new Map<string | symbol, string>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAC7B,2BAA6C;AAEtC,MAAM,gCAAgC,OAAO,uCA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AAO,iCAAa,gBAA8C,+BAA+B,MAAM;AAC7G,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,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/appendChild.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';\n\nexport interface AppendChildOptions {\n position?: AppendChildPosition;\n}\n\nexport interface AppendChildMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: AppendChildOptions;\n}\n\nexport const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');\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 * @appendChild decorator to surgically add nodes to a target element.\n * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }\n */\nexport function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, AppendChildMetadata>();\n ReflectUtils.defineMetadata(APPEND_CHILD_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 let targetEl: HTMLElement | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n const nodes = normalizeNodes(res, currentDoc);\n const pos = options.position || 'beforeEnd';\n\n if (typeof res === 'string') {\n targetEl.insertAdjacentText(pos as InsertPosition, res);\n } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {\n targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));\n } else {\n if (pos === 'beforeEnd') targetEl.append(...nodes);\n else if (pos === 'afterBegin') targetEl.prepend(...nodes);\n else if (pos === 'beforeBegin') targetEl.before(...nodes);\n else if (pos === 'afterEnd') targetEl.after(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {\n const result = new Map<string | symbol, AppendChildMetadata>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_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,YAAY,wBAAwB;AActC,MAAM,4BAA4B,OAAO,mCAAmC;AAEnF,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;AAMM,SAAU,YAAY,UAAkB,UAA8B,EAAE,UAAU,YAAW,GAAE;AACnG,SA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nG,QAAM,SAAS,oBAAI,IAAG;AACtB,QAAM,OAAO,aAAa,gBAA2D,2BAA2B,MAAM;AACtH,OAAK,QAAQ,SAAM;AACjB,QAAI,eAAe,KAAK;AACtB,UAAI,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI,GAAG,CAAC,CAAC;IACxC;EACF,CAAC;AACD,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/changedAttribute.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol('simple-web-component:on-attribute-changed');\n\nexport function changedAttribute(attributeName?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as Map<string, (string | symbol)[]>;\n if (!meta) {\n meta = new Map<string, (string | symbol)[]>();\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n let methods = meta.get(name);\n if (!methods) {\n methods = [];\n meta.set(name, methods);\n }\n if (!methods.includes(propertyKey)) methods.push(propertyKey);\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): Map<string, (string | symbol)[]> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);\n};\n\nexport const findAllAttributeChangedMetadata = (target: any): Map<string, (string | symbol)[]> => {\n return ReflectUtils.findAllMapMetadata<string, string | symbol>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAEtB,MAAM,oCAAoC,OAAO,2CAA2C;AAE5F,SAAS,iBAAiB,eAAyC;AACxE,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,mBAAa,eAAe,mCAAmC,MAAM,WAAW;AAAA,IAClF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,QAAI,UAAU,KAAK,IAAI,IAAI;AAC3B,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAC;AACX,WAAK,IAAI,MAAM,OAAO;AAAA,IACxB;AACA,QAAI,CAAC,QAAQ,SAAS,WAAW,EAAG,SAAQ,KAAK,WAAW;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA8D;AACxG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,aAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
6
- "names": []
7
- }
@@ -1,60 +0,0 @@
1
- import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
2
- import { ensureInit, getElementConfig } from "./elementDefine.js";
3
- const REPLACE_CHILDREN_METADATA_KEY = Symbol("simple-web-component:replace-children");
4
- function replaceChildren(selector) {
5
- return (target, propertyKey, descriptor) => {
6
- const constructor = target.constructor;
7
- let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
8
- if (!meta) {
9
- meta = /* @__PURE__ */ new Map();
10
- ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
11
- }
12
- meta.set(propertyKey, selector);
13
- const original = descriptor.value;
14
- descriptor.value = async function(...args) {
15
- ensureInit(this);
16
- const res = await original.apply(this, args);
17
- if (res !== void 0) {
18
- const conf = getElementConfig(this);
19
- const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
20
- const currentDoc = currentWin.document;
21
- let targetEl = null;
22
- if (selector === ":host" || !selector) {
23
- targetEl = this;
24
- } else {
25
- targetEl = (this.shadowRoot || this).querySelector(selector);
26
- }
27
- if (targetEl) {
28
- if (typeof res === "string") {
29
- targetEl.textContent = res;
30
- } else {
31
- const nodes = Array.isArray(res) ? res.map((n) => typeof n === "string" ? currentDoc.createTextNode(n) : n) : [res];
32
- targetEl.replaceChildren(...nodes);
33
- }
34
- }
35
- }
36
- return res;
37
- };
38
- };
39
- }
40
- const getReplaceChildrenMetadata = (target) => {
41
- const constructor = target instanceof Function ? target : target.constructor;
42
- return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
43
- };
44
- const findAllReplaceChildrenMetadata = (target) => {
45
- const result = /* @__PURE__ */ new Map();
46
- const maps = ReflectUtils.findAllMetadata(REPLACE_CHILDREN_METADATA_KEY, target);
47
- maps.forEach((map) => {
48
- if (map instanceof Map) {
49
- map.forEach((v, k) => result.set(k, v));
50
- }
51
- });
52
- return result;
53
- };
54
- export {
55
- REPLACE_CHILDREN_METADATA_KEY,
56
- findAllReplaceChildrenMetadata,
57
- getReplaceChildrenMetadata,
58
- replaceChildren
59
- };
60
- //# sourceMappingURL=replaceChildren.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/decorators/replaceChildren.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { ensureInit, getElementConfig } from './elementDefine';\n\nexport const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');\n\n/**\n * @replaceChildren decorator to surgically replace children of a target element.\n * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }\n */\nexport function replaceChildren(selector: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;\n if (!meta) {\n meta = new Map<string | symbol, string>();\n ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);\n }\n meta.set(propertyKey, selector);\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 let targetEl: Element | null = null;\n if (selector === ':host' || !selector) {\n targetEl = this as any;\n } else {\n targetEl = (this.shadowRoot || (this as any)).querySelector(selector);\n }\n\n if (targetEl) {\n if (typeof res === 'string') {\n targetEl.textContent = res;\n } else {\n const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];\n (targetEl as any).replaceChildren(...nodes);\n }\n }\n }\n return res;\n };\n };\n}\n\nexport const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);\n};\n\nexport const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {\n const result = new Map<string | symbol, string>();\n const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_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,YAAY,wBAAwB;AAEtC,MAAM,gCAAgC,OAAO,uCAAuC;AAMpF,SAAS,gBAAgB,UAAmC;AACjE,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,aAAa,eAAe,+BAA+B,WAAW;AACjF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAA6B;AACxC,mBAAa,eAAe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
@@ -1,17 +0,0 @@
1
- export type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';
2
- export interface AppendChildOptions {
3
- position?: AppendChildPosition;
4
- }
5
- export interface AppendChildMetadata {
6
- propertyKey: string | symbol;
7
- selector: string;
8
- options: AppendChildOptions;
9
- }
10
- export declare const APPEND_CHILD_METADATA_KEY: unique symbol;
11
- /**
12
- * @appendChild decorator to surgically add nodes to a target element.
13
- * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }
14
- */
15
- export declare function appendChild(selector: string, options?: AppendChildOptions): MethodDecorator;
16
- export declare const findAllAppendChildMetadata: (target: any) => Map<string | symbol, AppendChildMetadata>;
17
- //# sourceMappingURL=appendChild.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appendChild.d.ts","sourceRoot":"","sources":["../../../src/decorators/appendChild.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAE1F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,eAAO,MAAM,yBAAyB,eAA8C,CAAC;AAUrF;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,kBAA8C,GAAG,eAAe,CA6CtH;AAED,eAAO,MAAM,0BAA0B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,mBAAmB,CAShG,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"changedAttribute.d.ts","sourceRoot":"","sources":["../../../src/decorators/changedAttribute.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,eAAsD,CAAC;AAErG,wBAAgB,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,eAAe,CAiBxE;AAED,eAAO,MAAM,2BAA2B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,SAG5F,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAE5F,CAAC"}
@@ -1,9 +0,0 @@
1
- export declare const REPLACE_CHILDREN_METADATA_KEY: unique symbol;
2
- /**
3
- * @replaceChildren decorator to surgically replace children of a target element.
4
- * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }
5
- */
6
- export declare function replaceChildren(selector: string): MethodDecorator;
7
- export declare const getReplaceChildrenMetadata: (target: any) => Map<string | symbol, string> | undefined;
8
- export declare const findAllReplaceChildrenMetadata: (target: any) => Map<string | symbol, string>;
9
- //# sourceMappingURL=replaceChildren.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replaceChildren.d.ts","sourceRoot":"","sources":["../../../src/decorators/replaceChildren.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,6BAA6B,eAAkD,CAAC;AAE7F;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAsCjE;AAED,eAAO,MAAM,0BAA0B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,GAAG,SAGvF,CAAC;AAEF,eAAO,MAAM,8BAA8B,GAAI,QAAQ,GAAG,KAAG,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CASvF,CAAC"}
@@ -1,86 +0,0 @@
1
- import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
2
- import { ensureInit, getElementConfig } from './elementDefine';
3
-
4
- export type AppendChildPosition = 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd';
5
-
6
- export interface AppendChildOptions {
7
- position?: AppendChildPosition;
8
- }
9
-
10
- export interface AppendChildMetadata {
11
- propertyKey: string | symbol;
12
- selector: string;
13
- options: AppendChildOptions;
14
- }
15
-
16
- export const APPEND_CHILD_METADATA_KEY = Symbol('simple-web-component:append-child');
17
-
18
- const normalizeNodes = (res: any, doc: Document): Node[] => {
19
- const items = Array.isArray(res) ? res : [res];
20
- return items.map(it => {
21
- if (it instanceof Node) return it;
22
- return doc.createTextNode(it !== undefined && it !== null ? String(it) : '');
23
- });
24
- };
25
-
26
- /**
27
- * @appendChild decorator to surgically add nodes to a target element.
28
- * Usage: @appendChild('#list') addItem() { return '<li>New Item</li>'; }
29
- */
30
- export function appendChild(selector: string, options: AppendChildOptions = { position: 'beforeEnd' }): MethodDecorator {
31
- return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
32
- const constructor = target.constructor;
33
- let metaList = ReflectUtils.getOwnMetadata(APPEND_CHILD_METADATA_KEY, constructor) as Map<string | symbol, AppendChildMetadata>;
34
- if (!metaList) {
35
- metaList = new Map<string | symbol, AppendChildMetadata>();
36
- ReflectUtils.defineMetadata(APPEND_CHILD_METADATA_KEY, metaList, constructor);
37
- }
38
- metaList.set(propertyKey, { propertyKey, selector, options });
39
-
40
- const original = descriptor.value;
41
- descriptor.value = async function (...args: any[]) {
42
- ensureInit(this);
43
- const res = await original.apply(this, args);
44
- if (res !== undefined) {
45
- const conf = getElementConfig(this);
46
- const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
47
- const currentDoc = currentWin.document;
48
-
49
- let targetEl: HTMLElement | null = null;
50
- if (selector === ':host' || !selector) {
51
- targetEl = this as any;
52
- } else {
53
- targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
54
- }
55
-
56
- if (targetEl) {
57
- const nodes = normalizeNodes(res, currentDoc);
58
- const pos = options.position || 'beforeEnd';
59
-
60
- if (typeof res === 'string') {
61
- targetEl.insertAdjacentText(pos as InsertPosition, res);
62
- } else if (Array.isArray(res) && res.every(n => typeof n === 'string')) {
63
- targetEl.insertAdjacentText(pos as InsertPosition, res.join(''));
64
- } else {
65
- if (pos === 'beforeEnd') targetEl.append(...nodes);
66
- else if (pos === 'afterBegin') targetEl.prepend(...nodes);
67
- else if (pos === 'beforeBegin') targetEl.before(...nodes);
68
- else if (pos === 'afterEnd') targetEl.after(...nodes);
69
- }
70
- }
71
- }
72
- return res;
73
- };
74
- };
75
- }
76
-
77
- export const findAllAppendChildMetadata = (target: any): Map<string | symbol, AppendChildMetadata> => {
78
- const result = new Map<string | symbol, AppendChildMetadata>();
79
- const maps = ReflectUtils.findAllMetadata<Map<string | symbol, AppendChildMetadata>>(APPEND_CHILD_METADATA_KEY, target);
80
- maps.forEach(map => {
81
- if (map instanceof Map) {
82
- map.forEach((v, k) => result.set(k, v));
83
- }
84
- });
85
- return result;
86
- };
@@ -1,64 +0,0 @@
1
- import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
2
- import { ensureInit, getElementConfig } from './elementDefine';
3
-
4
- export const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');
5
-
6
- /**
7
- * @replaceChildren decorator to surgically replace children of a target element.
8
- * Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }
9
- */
10
- export function replaceChildren(selector: string): MethodDecorator {
11
- return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
12
- const constructor = target.constructor;
13
- let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;
14
- if (!meta) {
15
- meta = new Map<string | symbol, string>();
16
- ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
17
- }
18
- meta.set(propertyKey, selector);
19
-
20
- const original = descriptor.value;
21
- descriptor.value = async function (...args: any[]) {
22
- ensureInit(this);
23
- const res = await original.apply(this, args);
24
- if (res !== undefined) {
25
- const conf = getElementConfig(this);
26
- const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
27
- const currentDoc = currentWin.document;
28
-
29
- let targetEl: Element | null = null;
30
- if (selector === ':host' || !selector) {
31
- targetEl = this as any;
32
- } else {
33
- targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
34
- }
35
-
36
- if (targetEl) {
37
- if (typeof res === 'string') {
38
- targetEl.textContent = res;
39
- } else {
40
- const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];
41
- (targetEl as any).replaceChildren(...nodes);
42
- }
43
- }
44
- }
45
- return res;
46
- };
47
- };
48
- }
49
-
50
- export const getReplaceChildrenMetadata = (target: any): Map<string | symbol, string> | undefined => {
51
- const constructor = target instanceof Function ? target : target.constructor;
52
- return ReflectUtils.getMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor);
53
- };
54
-
55
- export const findAllReplaceChildrenMetadata = (target: any): Map<string | symbol, string> => {
56
- const result = new Map<string | symbol, string>();
57
- const maps = ReflectUtils.findAllMetadata<Map<string | symbol, string>>(REPLACE_CHILDREN_METADATA_KEY, target);
58
- maps.forEach(map => {
59
- if (map instanceof Map) {
60
- map.forEach((v, k) => result.set(k, v));
61
- }
62
- });
63
- return result;
64
- };