@dooboostore/simple-web-component 1.0.32 → 1.0.34

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 (143) hide show
  1. package/README.md +280 -43
  2. package/dist/cjs/decorators/addEventListener.js.map +1 -1
  3. package/dist/cjs/decorators/applyAttribute.js +67 -57
  4. package/dist/cjs/decorators/applyAttribute.js.map +2 -2
  5. package/dist/cjs/decorators/applyClass.js +80 -70
  6. package/dist/cjs/decorators/applyClass.js.map +2 -2
  7. package/dist/cjs/decorators/applyNode.js +1 -8
  8. package/dist/cjs/decorators/applyNode.js.map +2 -2
  9. package/dist/cjs/decorators/applyStyle.js +66 -56
  10. package/dist/cjs/decorators/applyStyle.js.map +2 -2
  11. package/dist/cjs/decorators/attribute.js +35 -29
  12. package/dist/cjs/decorators/attribute.js.map +2 -2
  13. package/dist/cjs/decorators/changedAttributeHost.js +32 -12
  14. package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
  15. package/dist/cjs/decorators/elementDefine.js +29 -16
  16. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  17. package/dist/cjs/decorators/emitCustomEvent.js +57 -44
  18. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  19. package/dist/cjs/decorators/index.js +3 -1
  20. package/dist/cjs/decorators/index.js.map +2 -2
  21. package/dist/cjs/decorators/publishSwcAppMessage.js +86 -0
  22. package/dist/cjs/decorators/publishSwcAppMessage.js.map +7 -0
  23. package/dist/cjs/decorators/setProperty.js +50 -39
  24. package/dist/cjs/decorators/setProperty.js.map +2 -2
  25. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js +62 -0
  26. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  27. package/dist/cjs/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +16 -16
  28. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  29. package/dist/cjs/elements/SwcAppEngine.js +7 -7
  30. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  31. package/dist/cjs/elements/SwcAppMixin.js +90 -43
  32. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  33. package/dist/cjs/elements/SwcChoose.js +19 -15
  34. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  35. package/dist/cjs/elements/register.js +21 -16
  36. package/dist/cjs/elements/register.js.map +2 -2
  37. package/dist/cjs/types.js.map +1 -1
  38. package/dist/cjs/utils/Utils.js +7 -3
  39. package/dist/cjs/utils/Utils.js.map +2 -2
  40. package/dist/esm/decorators/addEventListener.js.map +1 -1
  41. package/dist/esm/decorators/applyAttribute.js +67 -57
  42. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  43. package/dist/esm/decorators/applyClass.js +80 -70
  44. package/dist/esm/decorators/applyClass.js.map +2 -2
  45. package/dist/esm/decorators/applyNode.js +1 -8
  46. package/dist/esm/decorators/applyNode.js.map +2 -2
  47. package/dist/esm/decorators/applyStyle.js +66 -56
  48. package/dist/esm/decorators/applyStyle.js.map +2 -2
  49. package/dist/esm/decorators/attribute.js +35 -29
  50. package/dist/esm/decorators/attribute.js.map +2 -2
  51. package/dist/esm/decorators/changedAttributeHost.js +32 -12
  52. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  53. package/dist/esm/decorators/elementDefine.js +30 -17
  54. package/dist/esm/decorators/elementDefine.js.map +2 -2
  55. package/dist/esm/decorators/emitCustomEvent.js +57 -44
  56. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  57. package/dist/esm/decorators/index.js +3 -1
  58. package/dist/esm/decorators/index.js.map +2 -2
  59. package/dist/esm/decorators/publishSwcAppMessage.js +67 -0
  60. package/dist/esm/decorators/publishSwcAppMessage.js.map +7 -0
  61. package/dist/esm/decorators/setProperty.js +50 -39
  62. package/dist/esm/decorators/setProperty.js.map +2 -2
  63. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js +43 -0
  64. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +7 -0
  65. package/dist/esm/decorators/{subscribeSwcAppRouteChange.js → subscribeSwcAppRouteChangeWhileConnected.js} +13 -13
  66. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +7 -0
  67. package/dist/esm/elements/SwcAppEngine.js +6 -6
  68. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  69. package/dist/esm/elements/SwcAppMixin.js +90 -43
  70. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  71. package/dist/esm/elements/SwcChoose.js +20 -16
  72. package/dist/esm/elements/SwcChoose.js.map +2 -2
  73. package/dist/esm/elements/register.js +22 -17
  74. package/dist/esm/elements/register.js.map +2 -2
  75. package/dist/esm/types.js.map +1 -1
  76. package/dist/esm/utils/Utils.js +7 -3
  77. package/dist/esm/utils/Utils.js.map +2 -2
  78. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +543 -348
  79. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  80. package/dist/types/decorators/addEventListener.d.ts +4 -1
  81. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  82. package/dist/types/decorators/applyAttribute.d.ts +5 -1
  83. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  84. package/dist/types/decorators/applyClass.d.ts +4 -0
  85. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  86. package/dist/types/decorators/applyNode.d.ts +4 -1
  87. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  88. package/dist/types/decorators/applyStyle.d.ts +5 -1
  89. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  90. package/dist/types/decorators/attribute.d.ts +5 -0
  91. package/dist/types/decorators/attribute.d.ts.map +1 -1
  92. package/dist/types/decorators/changedAttributeHost.d.ts +13 -3
  93. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  94. package/dist/types/decorators/elementDefine.d.ts +1 -0
  95. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  96. package/dist/types/decorators/emitCustomEvent.d.ts +5 -1
  97. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  98. package/dist/types/decorators/index.d.ts +3 -1
  99. package/dist/types/decorators/index.d.ts.map +1 -1
  100. package/dist/types/decorators/publishSwcAppMessage.d.ts +13 -0
  101. package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -0
  102. package/dist/types/decorators/setProperty.d.ts +5 -1
  103. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  104. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +16 -0
  105. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -0
  106. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +18 -0
  107. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -0
  108. package/dist/types/elements/SwcAppEngine.d.ts +6 -3
  109. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  110. package/dist/types/elements/SwcAppMixin.d.ts +8 -3
  111. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  112. package/dist/types/elements/register.d.ts.map +1 -1
  113. package/dist/types/types.d.ts +6 -0
  114. package/dist/types/types.d.ts.map +1 -1
  115. package/dist/types/utils/Utils.d.ts.map +1 -1
  116. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +543 -348
  117. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  118. package/package.json +4 -4
  119. package/src/decorators/addEventListener.ts +1 -1
  120. package/src/decorators/applyAttribute.ts +74 -61
  121. package/src/decorators/applyClass.ts +91 -77
  122. package/src/decorators/applyNode.ts +3 -12
  123. package/src/decorators/applyStyle.ts +75 -61
  124. package/src/decorators/attribute.ts +55 -43
  125. package/src/decorators/changedAttributeHost.ts +47 -14
  126. package/src/decorators/elementDefine.ts +38 -19
  127. package/src/decorators/emitCustomEvent.ts +65 -49
  128. package/src/decorators/index.ts +3 -1
  129. package/src/decorators/publishSwcAppMessage.ts +100 -0
  130. package/src/decorators/setProperty.ts +58 -44
  131. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +73 -0
  132. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +71 -0
  133. package/src/elements/SwcAppEngine.ts +11 -12
  134. package/src/elements/SwcAppMixin.ts +115 -44
  135. package/src/elements/SwcChoose.ts +28 -7
  136. package/src/elements/register.ts +28 -7
  137. package/src/types.ts +8 -0
  138. package/src/utils/Utils.ts +15 -5
  139. package/dist/cjs/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  140. package/dist/esm/decorators/subscribeSwcAppRouteChange.js.map +0 -7
  141. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts +0 -18
  142. package/dist/types/decorators/subscribeSwcAppRouteChange.d.ts.map +0 -1
  143. package/src/decorators/subscribeSwcAppRouteChange.ts +0 -71
@@ -45,48 +45,59 @@ const setProperty = (selector, propertyNameOrOptions, options = {}) => {
45
45
  options: { ...finalOptions, name: propertyName }
46
46
  });
47
47
  const original = descriptor.value;
48
- descriptor.value = async function(...args) {
48
+ descriptor.value = function(...args) {
49
49
  (0, import_elementDefine.ensureInit)(this);
50
- const res = await original.apply(this, args);
51
- if (res !== void 0) {
52
- const win = this.ownerDocument?.defaultView || window;
53
- const host = this;
54
- const hostSet = { ...import_Utils.SwcUtils.getHelperAndHostSet(win, host), $this: this };
55
- const r = finalOptions.root || "auto";
56
- const targetEls = [];
57
- const applyRoot = (t) => {
58
- if (!t || !(t instanceof win.HTMLElement)) return;
59
- targetEls.push(t);
60
- };
61
- if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
62
- else if (selector === ":appHost") applyRoot(hostSet.$appHost);
63
- else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
64
- else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
65
- else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
66
- else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
67
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
68
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
69
- else if (selector === ":host" || !selector) applyRoot(host);
70
- else {
71
- const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
72
- if (targetRoot) {
73
- const found = targetRoot.querySelectorAll(selector);
74
- if (found) targetEls.push(...Array.from(found));
50
+ const res = original.apply(this, args);
51
+ const handleResult = (resolvedValue) => {
52
+ if (resolvedValue !== void 0) {
53
+ const win = this.ownerDocument?.defaultView || window;
54
+ const host = this;
55
+ const hostSet = { ...import_Utils.SwcUtils.getHelperAndHostSet(win, host), $this: this };
56
+ const r = finalOptions.root || "auto";
57
+ const targetEls = [];
58
+ const applyRoot = (t) => {
59
+ if (!t || !(t instanceof win.HTMLElement)) return;
60
+ targetEls.push(t);
61
+ };
62
+ if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
63
+ else if (selector === ":appHost") applyRoot(hostSet.$appHost);
64
+ else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
65
+ else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
66
+ else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
67
+ else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
68
+ else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
69
+ else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
70
+ else if (selector === ":host" || !selector) applyRoot(host);
71
+ else {
72
+ const targetRoot = r === "auto" ? host.shadowRoot || host : r === "shadow" ? host.shadowRoot : host;
73
+ if (targetRoot) {
74
+ const found = targetRoot.querySelectorAll(selector);
75
+ if (found) targetEls.push(...Array.from(found));
76
+ }
75
77
  }
78
+ targetEls.forEach((targetEl) => {
79
+ if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, { currentThis: this, helper: hostSet })) {
80
+ return;
81
+ }
82
+ const resolvedRes = typeof resolvedValue === "function" ? resolvedValue(targetEl, hostSet) : resolvedValue;
83
+ if (propertyName) {
84
+ targetEl[propertyName] = resolvedRes;
85
+ } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
86
+ Object.entries(resolvedRes).forEach(([prop, val]) => {
87
+ const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
88
+ targetEl[prop] = finalVal;
89
+ });
90
+ } else {
91
+ targetEl.value = resolvedRes;
92
+ }
93
+ });
76
94
  }
77
- targetEls.forEach((targetEl) => {
78
- const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
79
- if (propertyName) {
80
- targetEl[propertyName] = resolvedRes;
81
- } else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
82
- Object.entries(resolvedRes).forEach(([prop, val]) => {
83
- const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
84
- targetEl[prop] = finalVal;
85
- });
86
- } else {
87
- targetEl.value = resolvedRes;
88
- }
89
- });
95
+ return resolvedValue;
96
+ };
97
+ if (res instanceof Promise) {
98
+ return res.then(handleResult);
99
+ } else {
100
+ return handleResult(res);
90
101
  }
91
102
  };
92
103
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/setProperty.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\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 (propertyName) {\n // Case: @setProperty(selector, 'propertyName')\n (targetEl as any)[propertyName] = resolvedRes;\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @setProperty(selector) with Object return - assign multiple properties\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n (targetEl as any)[prop] = finalVal;\n });\n } else {\n // Simple value - assign to 'value' property by default\n (targetEl as any).value = resolvedRes;\n }\n });\n }\n };\n };\n};\n\nexport const setPropertyHost = (propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return setProperty(':host', propertyNameOrOptions, options);\n};\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { ensureInit } from './elementDefine';\nimport { SwcUtils } from '../utils/Utils';\nimport { HelperHostSet, SwcQueryOptions } from '../types';\n\nexport interface PropertySetOptions extends SwcQueryOptions {\n name?: string;\n filter?: (target: HTMLElement, value: any, meta: {currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface PropertySetMetadata {\n propertyKey: string | symbol;\n selector: string;\n options: PropertySetOptions;\n}\n\nexport const PROPERTY_SET_METADATA_KEY = Symbol.for('simple-web-component:property-set');\n\nexport const setProperty = (selector: string, propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(PROPERTY_SET_METADATA_KEY, constructor) as Map<string | symbol, PropertySetMetadata>;\n if (!metaList) {\n metaList = new Map<string | symbol, PropertySetMetadata>();\n ReflectUtils.defineMetadata(PROPERTY_SET_METADATA_KEY, metaList, constructor);\n }\n\n let propertyName = typeof propertyNameOrOptions === 'string' ? propertyNameOrOptions : undefined;\n let finalOptions = options;\n \n if (typeof propertyNameOrOptions === 'object' && propertyNameOrOptions !== null) {\n finalOptions = propertyNameOrOptions as PropertySetOptions;\n }\n\n metaList.set(propertyKey, { \n propertyKey, \n selector, \n options: { ...finalOptions, name: propertyName } \n });\n\n const original = descriptor.value;\n descriptor.value = function (...args: any[]) {\n ensureInit(this);\n const res = (original as any).apply(this, args);\n\n const handleResult = (resolvedValue: any) => {\n if (resolvedValue !== 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 if (finalOptions.filter && !finalOptions.filter(targetEl, resolvedValue, {currentThis: this, helper: hostSet})) {\n return;\n }\n const resolvedRes = typeof resolvedValue === 'function' ? (resolvedValue as any)(targetEl, hostSet) : resolvedValue;\n\n if (propertyName) {\n // Case: @setProperty(selector, 'propertyName')\n (targetEl as any)[propertyName] = resolvedRes;\n } else if (typeof resolvedRes === 'object' && resolvedRes !== null && !Array.isArray(resolvedRes)) {\n // Case: @setProperty(selector) with Object return - assign multiple properties\n Object.entries(resolvedRes as any).forEach(([prop, val]) => {\n const finalVal = typeof val === 'function' ? val(targetEl, hostSet) : val;\n (targetEl as any)[prop] = finalVal;\n });\n } else {\n // Simple value - assign to 'value' property by default\n (targetEl as any).value = resolvedRes;\n }\n });\n }\n return resolvedValue;\n };\n\n if (res instanceof Promise) {\n return res.then(handleResult);\n } else {\n return handleResult(res);\n }\n };\n };\n};\n\nexport const setPropertyHost = (propertyNameOrOptions?: string | PropertySetOptions, options: PropertySetOptions = {}): MethodDecorator => {\n return setProperty(':host', propertyNameOrOptions, options);\n};\n"],
5
+ "mappings": "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",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,62 @@
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 subscribeSwcAppMessageWhileConnected_exports = {};
19
+ __export(subscribeSwcAppMessageWhileConnected_exports, {
20
+ SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY,
21
+ getSubscribeSwcAppMessageWhileConnectedMetadata: () => getSubscribeSwcAppMessageWhileConnectedMetadata,
22
+ subscribeSwcAppMessageWhileConnected: () => subscribeSwcAppMessageWhileConnected
23
+ });
24
+ module.exports = __toCommonJS(subscribeSwcAppMessageWhileConnected_exports);
25
+ var import_core = require("@dooboostore/core");
26
+ const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-message-while-connected");
27
+ function createSubscribeSwcAppMessageWhileConnected(options, messageType) {
28
+ return (target, propertyKey, descriptor) => {
29
+ const filter = options?.filter;
30
+ const constructor = target.constructor;
31
+ let list = import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
32
+ if (!list) {
33
+ list = [];
34
+ import_core.ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
35
+ }
36
+ list.push({ propertyKey, messageType, filter });
37
+ return descriptor;
38
+ };
39
+ }
40
+ function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions, optionsOrPropertyKey, descriptor) {
41
+ if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && optionsOrPropertyKey && (typeof optionsOrPropertyKey === "string" || typeof optionsOrPropertyKey === "symbol") && descriptor) {
42
+ const target = targetOrMessageTypeOrOptions;
43
+ const propertyKey = optionsOrPropertyKey;
44
+ return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);
45
+ }
46
+ let messageType;
47
+ let options = {};
48
+ if (typeof targetOrMessageTypeOrOptions === "string") {
49
+ messageType = targetOrMessageTypeOrOptions;
50
+ if (optionsOrPropertyKey && typeof optionsOrPropertyKey === "object") {
51
+ options = optionsOrPropertyKey;
52
+ }
53
+ } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object") {
54
+ options = targetOrMessageTypeOrOptions;
55
+ }
56
+ return createSubscribeSwcAppMessageWhileConnected(options, messageType);
57
+ }
58
+ const getSubscribeSwcAppMessageWhileConnectedMetadata = (target) => {
59
+ const constructor = target instanceof Function ? target : target.constructor;
60
+ return import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);
61
+ };
62
+ //# sourceMappingURL=subscribeSwcAppMessageWhileConnected.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/subscribeSwcAppMessageWhileConnected.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SwcAppMessage } from '../types';\n\nexport const SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-message-while-connected');\n\nexport interface SwcAppMessageSubscriberMetadata {\n propertyKey: string | symbol;\n messageType?: string;\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nexport interface SwcAppMessageOptions {\n filter?: (message: SwcAppMessage, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppMessageWhileConnected(options?: SwcAppMessageOptions, messageType?: string): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppMessageSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, messageType, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppMessageWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(messageType: string): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uC635\uC158\uB9CC\nexport function subscribeSwcAppMessageWhileConnected(options: SwcAppMessageOptions): MethodDecorator;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C) - \uBA54\uC2DC\uC9C0 \uD0C0\uC785 + \uC635\uC158\nexport function subscribeSwcAppMessageWhileConnected(messageType: string, options: SwcAppMessageOptions): MethodDecorator;\n\nexport function subscribeSwcAppMessageWhileConnected(targetOrMessageTypeOrOptions?: any, optionsOrPropertyKey?: any, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppMessageWhileConnected\n if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object' && \n optionsOrPropertyKey && (typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') &&\n descriptor) {\n const target = targetOrMessageTypeOrOptions;\n const propertyKey = optionsOrPropertyKey;\n return createSubscribeSwcAppMessageWhileConnected({})(target, propertyKey, descriptor);\n }\n\n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C)\n let messageType: string | undefined;\n let options: SwcAppMessageOptions = {};\n\n if (typeof targetOrMessageTypeOrOptions === 'string') {\n // \uBA54\uC2DC\uC9C0 \uD0C0\uC785 \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected('messageType') \uB610\uB294 @subscribeSwcAppMessageWhileConnected('messageType', options)\n messageType = targetOrMessageTypeOrOptions;\n if (optionsOrPropertyKey && typeof optionsOrPropertyKey === 'object') {\n options = optionsOrPropertyKey;\n }\n } else if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === 'object') {\n // \uC635\uC158\uB9CC \uC804\uB2EC: @subscribeSwcAppMessageWhileConnected({ filter: ... })\n options = targetOrMessageTypeOrOptions;\n }\n\n return createSubscribeSwcAppMessageWhileConnected(options, messageType);\n}\n\n// Helper function to retrieve message subscribers metadata\nexport const getSubscribeSwcAppMessageWhileConnectedMetadata = (target: any): SwcAppMessageSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_MESSAGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAGtB,MAAM,yDAAyD,OAAO,IAAI,gEAAgE;AAYjJ,SAAS,2CAA2C,SAAgC,aAAuC;AACzH,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,wDAAwD,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,wDAAwD,MAAM,WAAW;AAAA,IACvG;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,qCAAqC,8BAAoC,sBAA4B,YAAsC;AAEzJ,MAAI,gCAAgC,OAAO,iCAAiC,YACxE,yBAAyB,OAAO,yBAAyB,YAAY,OAAO,yBAAyB,aACrG,YAAY;AACd,UAAM,SAAS;AACf,UAAM,cAAc;AACpB,WAAO,2CAA2C,CAAC,CAAC,EAAE,QAAQ,aAAa,UAAU;AAAA,EACvF;AAGA,MAAI;AACJ,MAAI,UAAgC,CAAC;AAErC,MAAI,OAAO,iCAAiC,UAAU;AAEpD,kBAAc;AACd,QAAI,wBAAwB,OAAO,yBAAyB,UAAU;AACpE,gBAAU;AAAA,IACZ;AAAA,EACF,WAAW,gCAAgC,OAAO,iCAAiC,UAAU;AAE3F,cAAU;AAAA,EACZ;AAEA,SAAO,2CAA2C,SAAS,WAAW;AACxE;AAGO,MAAM,kDAAkD,CAAC,WAA+D;AAC7H,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,eAAe,wDAAwD,WAAW;AACxG;",
6
+ "names": []
7
+ }
@@ -15,32 +15,32 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var subscribeSwcAppRouteChange_exports = {};
19
- __export(subscribeSwcAppRouteChange_exports, {
20
- SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY: () => SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY,
21
- getSubscribeSwcAppRouteChangeMetadata: () => getSubscribeSwcAppRouteChangeMetadata,
22
- subscribeSwcAppRouteChange: () => subscribeSwcAppRouteChange
18
+ var subscribeSwcAppRouteChangeWhileConnected_exports = {};
19
+ __export(subscribeSwcAppRouteChangeWhileConnected_exports, {
20
+ SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY: () => SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY,
21
+ getSubscribeSwcAppRouteChangeWhileConnectedMetadata: () => getSubscribeSwcAppRouteChangeWhileConnectedMetadata,
22
+ subscribeSwcAppRouteChangeWhileConnected: () => subscribeSwcAppRouteChangeWhileConnected
23
23
  });
24
- module.exports = __toCommonJS(subscribeSwcAppRouteChange_exports);
24
+ module.exports = __toCommonJS(subscribeSwcAppRouteChangeWhileConnected_exports);
25
25
  var import_core = require("@dooboostore/core");
26
- const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change");
27
- function createSwcAppRouteChangeSubscriber(options) {
26
+ const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:subscribe-swc-app-route-change-while-connected");
27
+ function createSubscribeSwcAppRouteChangeWhileConnected(options) {
28
28
  return (target, propertyKey, descriptor) => {
29
29
  const pathPattern = options?.path;
30
30
  const filter = options?.filter;
31
31
  const constructor = target.constructor;
32
- let list = import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
32
+ let list = import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
33
33
  if (!list) {
34
34
  list = [];
35
- import_core.ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, list, constructor);
35
+ import_core.ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);
36
36
  }
37
37
  list.push({ propertyKey, pathPattern, filter });
38
38
  return descriptor;
39
39
  };
40
40
  }
41
- function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
41
+ function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions, propertyKey, descriptor) {
42
42
  if (propertyKey && (typeof propertyKey === "string" || typeof propertyKey === "symbol")) {
43
- return createSwcAppRouteChangeSubscriber({})(targetOrOptions, propertyKey, descriptor);
43
+ return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);
44
44
  }
45
45
  let options = {};
46
46
  if (Array.isArray(targetOrOptions)) {
@@ -50,10 +50,10 @@ function subscribeSwcAppRouteChange(targetOrOptions, propertyKey, descriptor) {
50
50
  } else if (targetOrOptions && typeof targetOrOptions === "object") {
51
51
  options = targetOrOptions;
52
52
  }
53
- return createSwcAppRouteChangeSubscriber(options);
53
+ return createSubscribeSwcAppRouteChangeWhileConnected(options);
54
54
  }
55
- const getSubscribeSwcAppRouteChangeMetadata = (target) => {
55
+ const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target) => {
56
56
  const constructor = target instanceof Function ? target : target.constructor;
57
- return import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_METADATA_KEY, constructor);
57
+ return import_core.ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);
58
58
  };
59
- //# sourceMappingURL=subscribeSwcAppRouteChange.js.map
59
+ //# sourceMappingURL=subscribeSwcAppRouteChangeWhileConnected.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts"],
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { Router } from '@dooboostore/core-web';\n\nexport const SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY = Symbol.for('simple-web-component:subscribe-swc-app-route-change-while-connected');\n\nexport interface SwcAppRouteChangeSubscriberMetadata {\n propertyKey: string | symbol;\n pathPattern?: string | string[];\n filter?: (router: Router, currentThis: any) => boolean;\n}\n\nexport interface SwcAppRouteChangeOptions {\n path?: string | string[];\n filter?: (router: Router, currentThis: any) => boolean;\n}\n\nfunction createSubscribeSwcAppRouteChangeWhileConnected(options?: SwcAppRouteChangeOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const pathPattern = options?.path;\n const filter = options?.filter;\n\n const constructor = target.constructor;\n let list = ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor) as SwcAppRouteChangeSubscriberMetadata[];\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, pathPattern, filter });\n \n return descriptor;\n };\n}\n\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uC9C1\uC811 \uC0AC\uC6A9 (\uAD04\uD638 \uC5C6\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;\n// \uC624\uBC84\uB85C\uB4DC \uC2DC\uADF8\uB2C8\uCC98 - \uD568\uC218 \uD638\uCD9C (\uAD04\uD638 \uC788\uC74C)\nexport function subscribeSwcAppRouteChangeWhileConnected(): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPattern: string): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(pathPatterns: string[]): MethodDecorator;\nexport function subscribeSwcAppRouteChangeWhileConnected(options: SwcAppRouteChangeOptions): MethodDecorator;\n\n// \uC2E4\uC81C \uAD6C\uD604 (\uC774\uC911 \uBAA8\uB4DC)\nexport function subscribeSwcAppRouteChangeWhileConnected(targetOrOptions?: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): any {\n // \uC9C1\uC811 \uB370\uCF54\uB808\uC774\uD130\uB85C \uC0AC\uC6A9\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC5C6\uC74C): @subscribeSwcAppRouteChangeWhileConnected\n // propertyKey\uAC00 string | symbol\uC774\uACE0 descriptor\uAC00 \uC788\uC73C\uBA74 \uC9C1\uC811 \uC0AC\uC6A9\n if (propertyKey && (typeof propertyKey === 'string' || typeof propertyKey === 'symbol')) {\n return createSubscribeSwcAppRouteChangeWhileConnected({})(targetOrOptions, propertyKey, descriptor);\n }\n \n // \uD568\uC218\uB85C \uD638\uCD9C\uB41C \uACBD\uC6B0 (\uAD04\uD638 \uC788\uC74C): @subscribeSwcAppRouteChangeWhileConnected() / @subscribeSwcAppRouteChangeWhileConnected('/path')\n let options: SwcAppRouteChangeOptions = {};\n\n if (Array.isArray(targetOrOptions)) {\n // \uBC30\uC5F4: @subscribeSwcAppRouteChangeWhileConnected(['/path1', '/path2'])\n options.path = targetOrOptions;\n } else if (typeof targetOrOptions === 'string') {\n // \uBB38\uC790\uC5F4: @subscribeSwcAppRouteChangeWhileConnected('/path')\n options.path = targetOrOptions;\n } else if (targetOrOptions && typeof targetOrOptions === 'object') {\n // \uAC1D\uCCB4: @subscribeSwcAppRouteChangeWhileConnected({ path: '/path', filter: ... })\n options = targetOrOptions;\n }\n\n return createSubscribeSwcAppRouteChangeWhileConnected(options);\n}\n\n// Helper function to retrieve route change subscribers metadata\nexport const getSubscribeSwcAppRouteChangeWhileConnectedMetadata = (target: any): SwcAppRouteChangeSubscriberMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getOwnMetadata(SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAGtB,MAAM,8DAA8D,OAAO,IAAI,qEAAqE;AAa3J,SAAS,+CAA+C,SAAqD;AAC3G,SAAO,CAAC,QAAgB,aAA8B,eAAoC;AACxF,UAAM,cAAc,SAAS;AAC7B,UAAM,SAAS,SAAS;AAExB,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,6DAA6D,WAAW;AAC/G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,+BAAa,eAAe,6DAA6D,MAAM,WAAW;AAAA,IAC5G;AACA,SAAK,KAAK,EAAE,aAAa,aAAa,OAAO,CAAC;AAE9C,WAAO;AAAA,EACT;AACF;AAWO,SAAS,yCAAyC,iBAAuB,aAA+B,YAAsC;AAGnJ,MAAI,gBAAgB,OAAO,gBAAgB,YAAY,OAAO,gBAAgB,WAAW;AACvF,WAAO,+CAA+C,CAAC,CAAC,EAAE,iBAAiB,aAAa,UAAU;AAAA,EACpG;AAGA,MAAI,UAAoC,CAAC;AAEzC,MAAI,MAAM,QAAQ,eAAe,GAAG;AAElC,YAAQ,OAAO;AAAA,EACjB,WAAW,OAAO,oBAAoB,UAAU;AAE9C,YAAQ,OAAO;AAAA,EACjB,WAAW,mBAAmB,OAAO,oBAAoB,UAAU;AAEjE,cAAU;AAAA,EACZ;AAEA,SAAO,+CAA+C,OAAO;AAC/D;AAGO,MAAM,sDAAsD,CAAC,WAAmE;AACrI,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,eAAe,6DAA6D,WAAW;AAC7G;",
6
+ "names": []
7
+ }
@@ -22,10 +22,8 @@ __export(SwcAppEngine_exports, {
22
22
  module.exports = __toCommonJS(SwcAppEngine_exports);
23
23
  var import_SimpleApplication = require("@dooboostore/simple-boot/SimpleApplication");
24
24
  var import_core_web = require("@dooboostore/core-web");
25
- var import_core_web2 = require("@dooboostore/core-web");
26
25
  var import_ElementRouter = require("../router/ElementRouter");
27
26
  var import_SimOption = require("@dooboostore/simple-boot/SimOption");
28
- var import_core_web3 = require("@dooboostore/core-web");
29
27
  class SwcAppEngine {
30
28
  constructor(host) {
31
29
  this.host = host;
@@ -39,25 +37,27 @@ class SwcAppEngine {
39
37
  if (this._config.routeType === "path") {
40
38
  this.router = new import_core_web.PathRouter({ window: this._config.window, firstUrl: this._config.path });
41
39
  } else if (this._config.routeType === "hash") {
42
- this.router = new import_core_web2.HashRouter({ window: this._config.window, firstUrl: this._config.path });
40
+ this.router = new import_core_web.HashRouter({ window: this._config.window, firstUrl: this._config.path });
43
41
  } else if (this._config.routeType === "element") {
44
42
  this.router = new import_ElementRouter.ElementRouter({ window: this._config.window, firstUrl: this._config.path });
45
43
  }
46
- const containerSymbol = this._config.container || this.host.getContainerSymbol?.();
47
44
  this.simpleApplication = new import_SimpleApplication.SimpleApplication(
48
45
  new import_SimOption.SimOption({
49
46
  excludeProxys: [Node],
50
- container: containerSymbol
47
+ container: this._config.container
51
48
  })
52
49
  );
53
50
  const otherInstanceSim = /* @__PURE__ */ new Map();
54
- if (this.router) otherInstanceSim.set(import_core_web3.Router, this.router);
51
+ this.config.otherInstanceSim?.forEach((v, k) => {
52
+ otherInstanceSim.set(k, v);
53
+ });
54
+ if (this.router) otherInstanceSim.set(import_core_web.Router, this.router);
55
55
  this.simpleApplication.run(otherInstanceSim);
56
56
  if (this._config.onEngineStarted) {
57
57
  this._config.onEngineStarted(this.simpleApplication, this.host);
58
58
  }
59
59
  } catch (e) {
60
- console.error("[SWC-APP-ENGINE] Init failed:", e);
60
+ console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
61
61
  }
62
62
  }
63
63
  disconnect() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/SwcAppEngine.ts"],
4
- "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { PathRouter } from '@dooboostore/core-web';\nimport { HashRouter } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { Router, RouterEventType } from '@dooboostore/core-web';\nimport { Subscription } from '@dooboostore/core';\nimport { ConstructorType, OptionalType } from '@dooboostore/core';\nimport { FunctionUtils } from '@dooboostore/core';\nimport { SwcUtils } from '../utils/Utils';\n\nimport { SwcAppInterface } from '../types';\nimport {Intent} from \"@dooboostore/simple-boot\";\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap';\n container?: symbol;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n const containerSymbol = this._config.container || (this.host as any).getContainerSymbol?.();\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [Node],\n container: containerSymbol\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAkC;AAClC,sBAA2B;AAC3B,IAAAA,mBAA2B;AAC3B,2BAA8B;AAC9B,uBAA0B;AAC1B,IAAAA,mBAAwC;AAsBjC,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,4BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,mCAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,YAAM,kBAAkB,KAAK,QAAQ,aAAc,KAAK,KAAa,qBAAqB;AAC1F,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,2BAAU;AAAA,UACZ,eAAe,CAAC,IAAI;AAAA,UACpB,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,UAAI,KAAK,OAAQ,kBAAiB,IAAI,yBAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,aAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MAC9F;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,CAAC;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
- "names": ["import_core_web"]
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';\nimport { ElementRouter } from '../router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot/SimOption';\nimport { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';\n\nimport { SwcAppInterface } from '../types';\nimport { SimConfig } from '@dooboostore/simple-boot';\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n connectMode?: 'direct' | 'swap' | 'clear-swap';\n container?: symbol;\n otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n onRouteChanged?: (event: RouterEventType, app: SwcAppInterface) => void;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [Node],\n container: this._config.container\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n this.config.otherInstanceSim?.forEach((v, k) => {\n otherInstanceSim.set(k, v);\n });\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n if (this._config.onEngineStarted) {\n this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAkC;AAClC,sBAAgE;AAChE,2BAA8B;AAC9B,uBAA0B;AAqBnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EACA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,2BAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,mCAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,2BAAU;AAAA,UACZ,eAAe,CAAC,IAAI;AAAA,UACpB,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,OAAO,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC9C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,wBAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAE3C,UAAI,KAAK,QAAQ,iBAAiB;AAChC,aAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MAC9F;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,GAAG,KAAK,OAAO;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
6
+ "names": []
7
7
  }
@@ -24,13 +24,22 @@ var import_SwcAppEngine = require("./SwcAppEngine");
24
24
  var import_Utils = require("../utils/Utils");
25
25
  var import_core = require("@dooboostore/core");
26
26
  var import_lifecycles = require("../decorators/lifecycles");
27
- var import_subscribeSwcAppRouteChange = require("../decorators/subscribeSwcAppRouteChange");
27
+ var import_subscribeSwcAppRouteChangeWhileConnected = require("../decorators/subscribeSwcAppRouteChangeWhileConnected");
28
+ var import_subscribeSwcAppMessageWhileConnected = require("../decorators/subscribeSwcAppMessageWhileConnected");
28
29
  function SwcAppMixin(Base) {
29
30
  return class extends Base {
30
31
  constructor() {
31
32
  super(...arguments);
32
33
  this.__swc_engine = new import_SwcAppEngine.SwcAppEngine(this);
33
34
  this._swc_connected_instance = /* @__PURE__ */ new Set();
35
+ this._swc_started_instances = /* @__PURE__ */ new WeakSet();
36
+ this._swc_notified_routes = /* @__PURE__ */ new WeakMap();
37
+ /*
38
+ 사파리 is 일경우
39
+ <script src="https://unpkg.com/@ungap/custom-elements"><\/script>
40
+ 이걸사용하는데 is 대응하는거다 그런데 이때 처리되는 순서가 크롬이나 표준에서는 부모부터 만들어지고 자식들이 만들어지는데
41
+ 저 polyfill에서는 자식부터 만들어지고 부모가 만들어진다 is일때 아 .. 이문제때문에 자식이 _connected_safari 에 강제로 자기자식넣어준다
42
+ */
34
43
  this._connected_safari = [];
35
44
  }
36
45
  get simpleApplication() {
@@ -39,11 +48,13 @@ function SwcAppMixin(Base) {
39
48
  get router() {
40
49
  return this.__swc_engine.router;
41
50
  }
42
- _invokeRouteChangeSubscribers(instance, re) {
43
- const routeChangeSubscribers = (0, import_subscribeSwcAppRouteChange.getSubscribeSwcAppRouteChangeMetadata)(instance);
51
+ async _invokeRouteChangeSubscribers(instance, re) {
52
+ if (this._swc_notified_routes.get(instance) === re) return;
53
+ this._swc_notified_routes.set(instance, re);
54
+ const routeChangeSubscribers = (0, import_subscribeSwcAppRouteChangeWhileConnected.getSubscribeSwcAppRouteChangeWhileConnectedMetadata)(instance);
44
55
  if (routeChangeSubscribers && Array.isArray(routeChangeSubscribers)) {
45
- routeChangeSubscribers.forEach((metadata) => {
46
- const methodName = metadata.propertyKey || metadata;
56
+ const ps = routeChangeSubscribers.map(async (metadata) => {
57
+ const methodName = metadata.propertyKey;
47
58
  const pathPattern = metadata.pathPattern;
48
59
  const filter = metadata.filter;
49
60
  let pathMatched = false;
@@ -64,11 +75,12 @@ function SwcAppMixin(Base) {
64
75
  pathData = import_Utils.SwcUtils.parsePathPattern(pathPattern, re.path || "/");
65
76
  pathMatched = pathData !== null;
66
77
  }
67
- const filterPassed = !filter || filter(this.router);
68
- if (pathMatched && filterPassed) {
69
- instance[methodName]?.({ ...re, pathData });
78
+ const filterPassed = !filter || filter(this.router, instance);
79
+ if (pathMatched && filterPassed && instance[methodName]) {
80
+ await instance[methodName]({ ...re, pathData });
70
81
  }
71
82
  });
83
+ return await Promise.allSettled(ps);
72
84
  }
73
85
  }
74
86
  _connected(instance) {
@@ -85,15 +97,17 @@ function SwcAppMixin(Base) {
85
97
  _disconnected(instance) {
86
98
  if (instance) {
87
99
  this._swc_connected_instance.delete(instance);
100
+ this._swc_started_instances.delete(instance);
101
+ this._swc_notified_routes.delete(instance);
88
102
  }
89
103
  }
90
- _handleRouteChange(route) {
104
+ async _handleRouteChange(route) {
105
+ this._lastRouterEvent = route;
91
106
  if (route.triggerPoint === "end") {
92
- this._swc_connected_instance.forEach((instance) => {
93
- this._invokeRouteChangeSubscribers(instance, route);
94
- });
107
+ const swcConnectedInstance = Array.from(this._swc_connected_instance);
108
+ const ps = swcConnectedInstance.map((instance) => this._invokeRouteChangeSubscribers(instance, route));
109
+ await Promise.allSettled(ps);
95
110
  }
96
- this._lastRouterEvent = route;
97
111
  }
98
112
  async connect(config) {
99
113
  const swcConfig = {
@@ -105,50 +119,56 @@ function SwcAppMixin(Base) {
105
119
  if (mode === "direct") {
106
120
  await this.__swc_engine.connect(swcConfig);
107
121
  this.setAttribute("swc-connect-mode", "direct");
108
- } else if (mode === "swap" && !this.parentNode) {
109
- await this.__swc_engine.connect(swcConfig);
110
- this.setAttribute("swc-connect-mode", "direct");
111
- const clonedApp = this.cloneNode(true);
112
- clonedApp.style.display = "none";
113
- this.parentNode.insertBefore(clonedApp, this.nextSibling);
114
- try {
115
- await clonedApp.connect({ ...config || {}, connectMode: "direct" });
116
- if (this.parentNode) {
117
- this.parentNode.removeChild(this);
118
- }
119
- clonedApp.setAttribute("swc-connect-mode", "swap");
120
- clonedApp.style.display = "";
121
- } catch (e) {
122
- if (clonedApp.parentNode) {
123
- clonedApp.parentNode.removeChild(clonedApp);
122
+ } else if (mode === "swap" || mode === "clear-swap") {
123
+ if (!this.parentNode) {
124
+ await this.__swc_engine.connect(swcConfig);
125
+ this.setAttribute("swc-connect-mode", "direct");
126
+ } else {
127
+ const clonedApp = this.cloneNode(mode === "swap");
128
+ clonedApp.style.display = "none";
129
+ this.parentNode.insertBefore(clonedApp, this.nextSibling);
130
+ try {
131
+ await clonedApp.connect({ ...config || {}, connectMode: "direct" });
132
+ if (this.parentNode) {
133
+ this.parentNode.removeChild(this);
134
+ }
135
+ clonedApp.style.display = "";
136
+ clonedApp.setAttribute("swc-connect-mode", mode);
137
+ return;
138
+ } catch (e) {
139
+ if (clonedApp.parentNode) {
140
+ clonedApp.parentNode.removeChild(clonedApp);
141
+ }
142
+ await this.__swc_engine.connect(swcConfig);
143
+ this.setAttribute("swc-connect-mode", "direct");
124
144
  }
125
- throw e;
126
145
  }
127
146
  }
128
147
  this._connected_safari.forEach((instance) => {
129
148
  this._swc_connected_instance.add(instance);
130
149
  });
131
- this._swc_connected_instance.forEach((instance) => {
132
- this._invokeOnConnectedSwcAppStarted(instance);
133
- });
150
+ const scis = Array.from(this._swc_connected_instance);
151
+ await Promise.allSettled(scis.map((instance) => this._invokeOnConnectedSwcAppStarted(instance)));
134
152
  if (!this._routerSubscription && this.router) {
153
+ const config2 = this.__swc_engine.config;
135
154
  this._routerSubscription = this.router.observable.subscribe((route) => {
136
- this._handleRouteChange(route);
155
+ this._handleRouteChange(route).then((it) => {
156
+ config2?.onRouteChanged?.(route, this);
157
+ });
137
158
  });
138
- const config2 = this.__swc_engine.config;
139
159
  }
140
160
  }
141
- _invokeOnConnectedSwcAppStarted(instance) {
161
+ async _invokeOnConnectedSwcAppStarted(instance) {
162
+ if (this._swc_started_instances.has(instance)) return;
163
+ this._swc_started_instances.add(instance);
142
164
  const startedMethods = (0, import_lifecycles.findAllLifecycleMetadata)(instance, import_lifecycles.ON_CONNECTED_SWC_APP_METADATA_KEY);
143
165
  if (startedMethods) {
144
- for (const m of startedMethods) {
145
- instance._invokeLifecycleMethod(m);
146
- }
166
+ const ps = startedMethods.map((m) => instance._invokeLifecycleMethod(m));
167
+ return await Promise.allSettled(ps);
147
168
  }
148
169
  }
149
170
  connectedCallback() {
150
- if (super.connectedCallback)
151
- super.connectedCallback();
171
+ if (super.connectedCallback) super.connectedCallback();
152
172
  const configStr = this.getAttribute("swc-get-application-config");
153
173
  const win = this.ownerDocument?.defaultView || window;
154
174
  if (configStr && win) {
@@ -166,8 +186,7 @@ function SwcAppMixin(Base) {
166
186
  this.__swc_engine?.config?.onConnected?.(this);
167
187
  }
168
188
  disconnectedCallback() {
169
- if (super.disconnectedCallback)
170
- super.disconnectedCallback();
189
+ if (super.disconnectedCallback) super.disconnectedCallback();
171
190
  this._routerSubscription?.unsubscribe();
172
191
  this._routerSubscription = void 0;
173
192
  this._lastRouterEvent = void 0;
@@ -186,6 +205,34 @@ function SwcAppMixin(Base) {
186
205
  reload() {
187
206
  this.router?.reload();
188
207
  }
208
+ publishMessage(message) {
209
+ this._swc_connected_instance.forEach((instance) => {
210
+ this._invokeMessageSubscribers(instance, message);
211
+ });
212
+ }
213
+ _invokeMessageSubscribers(instance, message) {
214
+ const messageSubscribers = (0, import_subscribeSwcAppMessageWhileConnected.getSubscribeSwcAppMessageWhileConnectedMetadata)(instance);
215
+ if (messageSubscribers && Array.isArray(messageSubscribers)) {
216
+ messageSubscribers.forEach((metadata) => {
217
+ const methodName = metadata.propertyKey;
218
+ const messageType = metadata.messageType;
219
+ const filter = metadata.filter;
220
+ let typeMatched = false;
221
+ if (!messageType) {
222
+ typeMatched = true;
223
+ } else if (message.type === messageType) {
224
+ typeMatched = true;
225
+ }
226
+ let filterMatched = true;
227
+ if (filter && typeMatched) {
228
+ filterMatched = filter(message, instance);
229
+ }
230
+ if (typeMatched && filterMatched && typeof instance[methodName] === "function") {
231
+ instance[methodName](message);
232
+ }
233
+ });
234
+ }
235
+ }
189
236
  };
190
237
  }
191
238
  //# sourceMappingURL=SwcAppMixin.js.map