@dooboostore/simple-web-component 1.0.33 → 1.0.35

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 (150) hide show
  1. package/README.md +23 -30
  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 +5 -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 +238 -180
  16. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  17. package/dist/cjs/decorators/emitCustomEvent.js +67 -48
  18. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  19. package/dist/cjs/decorators/lifecycles.js +15 -17
  20. package/dist/cjs/decorators/lifecycles.js.map +2 -2
  21. package/dist/cjs/decorators/setProperty.js +50 -39
  22. package/dist/cjs/decorators/setProperty.js.map +2 -2
  23. package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  24. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  25. package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  26. package/dist/cjs/elements/SwcAppEngine.js +14 -8
  27. package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
  28. package/dist/cjs/elements/SwcAppMixin.js +154 -81
  29. package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
  30. package/dist/cjs/elements/SwcAsync.js +28 -18
  31. package/dist/cjs/elements/SwcAsync.js.map +2 -2
  32. package/dist/cjs/elements/SwcChoose.js +68 -45
  33. package/dist/cjs/elements/SwcChoose.js.map +2 -2
  34. package/dist/cjs/elements/SwcIf.js +52 -30
  35. package/dist/cjs/elements/SwcIf.js.map +2 -2
  36. package/dist/cjs/elements/SwcLoop.js +109 -35
  37. package/dist/cjs/elements/SwcLoop.js.map +2 -2
  38. package/dist/cjs/elements/register.js +263 -131
  39. package/dist/cjs/elements/register.js.map +2 -2
  40. package/dist/cjs/router/ElementRouter.js +4 -2
  41. package/dist/cjs/router/ElementRouter.js.map +1 -1
  42. package/dist/cjs/types.js.map +1 -1
  43. package/dist/cjs/utils/Utils.js +25 -7
  44. package/dist/cjs/utils/Utils.js.map +2 -2
  45. package/dist/esm/decorators/addEventListener.js.map +1 -1
  46. package/dist/esm/decorators/applyAttribute.js +67 -57
  47. package/dist/esm/decorators/applyAttribute.js.map +2 -2
  48. package/dist/esm/decorators/applyClass.js +80 -70
  49. package/dist/esm/decorators/applyClass.js.map +2 -2
  50. package/dist/esm/decorators/applyNode.js +5 -8
  51. package/dist/esm/decorators/applyNode.js.map +2 -2
  52. package/dist/esm/decorators/applyStyle.js +66 -56
  53. package/dist/esm/decorators/applyStyle.js.map +2 -2
  54. package/dist/esm/decorators/attribute.js +35 -29
  55. package/dist/esm/decorators/attribute.js.map +2 -2
  56. package/dist/esm/decorators/changedAttributeHost.js +32 -12
  57. package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
  58. package/dist/esm/decorators/elementDefine.js +240 -182
  59. package/dist/esm/decorators/elementDefine.js.map +2 -2
  60. package/dist/esm/decorators/emitCustomEvent.js +67 -48
  61. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  62. package/dist/esm/decorators/lifecycles.js +15 -17
  63. package/dist/esm/decorators/lifecycles.js.map +2 -2
  64. package/dist/esm/decorators/setProperty.js +50 -39
  65. package/dist/esm/decorators/setProperty.js.map +2 -2
  66. package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
  67. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
  68. package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
  69. package/dist/esm/elements/SwcAppEngine.js +14 -7
  70. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  71. package/dist/esm/elements/SwcAppMixin.js +156 -82
  72. package/dist/esm/elements/SwcAppMixin.js.map +2 -2
  73. package/dist/esm/elements/SwcAsync.js +28 -18
  74. package/dist/esm/elements/SwcAsync.js.map +2 -2
  75. package/dist/esm/elements/SwcChoose.js +69 -46
  76. package/dist/esm/elements/SwcChoose.js.map +2 -2
  77. package/dist/esm/elements/SwcIf.js +53 -31
  78. package/dist/esm/elements/SwcIf.js.map +2 -2
  79. package/dist/esm/elements/SwcLoop.js +110 -36
  80. package/dist/esm/elements/SwcLoop.js.map +2 -2
  81. package/dist/esm/elements/register.js +264 -132
  82. package/dist/esm/elements/register.js.map +2 -2
  83. package/dist/esm/router/ElementRouter.js +5 -2
  84. package/dist/esm/router/ElementRouter.js.map +1 -1
  85. package/dist/esm/types.js.map +1 -1
  86. package/dist/esm/utils/Utils.js +25 -7
  87. package/dist/esm/utils/Utils.js.map +2 -2
  88. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +728 -595
  89. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  90. package/dist/types/decorators/addEventListener.d.ts +4 -1
  91. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  92. package/dist/types/decorators/applyAttribute.d.ts +5 -1
  93. package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
  94. package/dist/types/decorators/applyClass.d.ts +4 -0
  95. package/dist/types/decorators/applyClass.d.ts.map +1 -1
  96. package/dist/types/decorators/applyNode.d.ts +5 -1
  97. package/dist/types/decorators/applyNode.d.ts.map +1 -1
  98. package/dist/types/decorators/applyStyle.d.ts +5 -1
  99. package/dist/types/decorators/applyStyle.d.ts.map +1 -1
  100. package/dist/types/decorators/attribute.d.ts +5 -0
  101. package/dist/types/decorators/attribute.d.ts.map +1 -1
  102. package/dist/types/decorators/changedAttributeHost.d.ts +14 -3
  103. package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
  104. package/dist/types/decorators/elementDefine.d.ts +1 -1
  105. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  106. package/dist/types/decorators/emitCustomEvent.d.ts +15 -7
  107. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  108. package/dist/types/decorators/lifecycles.d.ts +10 -7
  109. package/dist/types/decorators/lifecycles.d.ts.map +1 -1
  110. package/dist/types/decorators/setProperty.d.ts +5 -1
  111. package/dist/types/decorators/setProperty.d.ts.map +1 -1
  112. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
  113. package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
  114. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -6
  115. package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
  116. package/dist/types/elements/SwcAppEngine.d.ts +9 -3
  117. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  118. package/dist/types/elements/SwcAppMixin.d.ts +12 -7
  119. package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
  120. package/dist/types/elements/register.d.ts.map +1 -1
  121. package/dist/types/types.d.ts +1 -0
  122. package/dist/types/types.d.ts.map +1 -1
  123. package/dist/types/utils/Utils.d.ts +4 -1
  124. package/dist/types/utils/Utils.d.ts.map +1 -1
  125. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +728 -595
  126. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  127. package/package.json +5 -5
  128. package/src/decorators/addEventListener.ts +1 -1
  129. package/src/decorators/applyAttribute.ts +74 -61
  130. package/src/decorators/applyClass.ts +91 -77
  131. package/src/decorators/applyNode.ts +16 -13
  132. package/src/decorators/applyStyle.ts +75 -61
  133. package/src/decorators/attribute.ts +55 -43
  134. package/src/decorators/changedAttributeHost.ts +49 -15
  135. package/src/decorators/elementDefine.ts +401 -340
  136. package/src/decorators/emitCustomEvent.ts +92 -62
  137. package/src/decorators/lifecycles.ts +11 -10
  138. package/src/decorators/setProperty.ts +58 -44
  139. package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
  140. package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +11 -11
  141. package/src/elements/SwcAppEngine.ts +19 -13
  142. package/src/elements/SwcAppMixin.ts +214 -102
  143. package/src/elements/SwcAsync.ts +28 -17
  144. package/src/elements/SwcChoose.ts +94 -36
  145. package/src/elements/SwcIf.ts +59 -22
  146. package/src/elements/SwcLoop.ts +140 -27
  147. package/src/elements/register.ts +319 -100
  148. package/src/types.ts +1 -0
  149. package/src/utils/Utils.ts +38 -10
  150. package/tsconfig.json +2 -2
@@ -19,27 +19,33 @@ var changedAttributeHost_exports = {};
19
19
  __export(changedAttributeHost_exports, {
20
20
  ON_ATTRIBUTE_CHANGED_METADATA_KEY: () => ON_ATTRIBUTE_CHANGED_METADATA_KEY,
21
21
  changedAttributeHost: () => changedAttributeHost,
22
+ convertAttributeValue: () => convertAttributeValue,
22
23
  findAllAttributeChangedMetadata: () => findAllAttributeChangedMetadata,
23
24
  getChangedAttributeMetadata: () => getChangedAttributeMetadata
24
25
  });
25
26
  module.exports = __toCommonJS(changedAttributeHost_exports);
26
27
  var import_core = require("@dooboostore/core");
27
28
  const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
28
- function changedAttributeHost(attributeName) {
29
+ const convertValue = (val, type) => {
30
+ if (val === null || val === void 0) return val;
31
+ if (type === Number) return Number(val);
32
+ if (type === Boolean) return val === "false" || val === "0" ? false : true;
33
+ return val;
34
+ };
35
+ function changedAttributeHost(attributeName, options = {}) {
29
36
  return (target, propertyKey) => {
30
37
  const constructor = target.constructor;
31
- let meta = import_core.ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
32
- if (!meta) {
33
- meta = /* @__PURE__ */ new Map();
34
- import_core.ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, meta, constructor);
38
+ let metaList = import_core.ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
39
+ if (!metaList) {
40
+ metaList = [];
41
+ import_core.ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
35
42
  }
36
43
  const name = attributeName || String(propertyKey);
37
- let methods = meta.get(name);
38
- if (!methods) {
39
- methods = [];
40
- meta.set(name, methods);
41
- }
42
- if (!methods.includes(propertyKey)) methods.push(propertyKey);
44
+ metaList.push({
45
+ attributeName: name,
46
+ propertyKey,
47
+ options
48
+ });
43
49
  };
44
50
  }
45
51
  const getChangedAttributeMetadata = (target) => {
@@ -47,6 +53,20 @@ const getChangedAttributeMetadata = (target) => {
47
53
  return import_core.ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
48
54
  };
49
55
  const findAllAttributeChangedMetadata = (target) => {
50
- return import_core.ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
56
+ const constructor = target instanceof Function ? target : target.constructor;
57
+ const metaList = import_core.ReflectUtils.findAllMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
58
+ const result = /* @__PURE__ */ new Map();
59
+ metaList.forEach((meta) => {
60
+ meta.forEach((item) => {
61
+ if (!result.has(item.attributeName)) {
62
+ result.set(item.attributeName, []);
63
+ }
64
+ result.get(item.attributeName).push(item);
65
+ });
66
+ });
67
+ return result;
68
+ };
69
+ const convertAttributeValue = (val, type) => {
70
+ return convertValue(val, type);
51
71
  };
52
72
  //# sourceMappingURL=changedAttributeHost.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/changedAttributeHost.ts"],
4
- "sourcesContent": ["import {ReflectUtils} from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n */\nexport function changedAttributeHost(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,kBAA2B;AAEpB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAMhG,SAAS,qBAAqB,eAAyC;AAC5E,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,OAAO,yBAAa,eAAe,mCAAmC,WAAW;AACrF,QAAI,CAAC,MAAM;AACT,aAAO,oBAAI,IAAiC;AAC5C,+BAAa,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,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAAkD;AAChG,SAAO,yBAAa,mBAA4C,mCAAmC,MAAM;AAC3G;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\n\nexport const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');\n\nexport interface ChangedAttributeHostOptions {\n type?: typeof Number | typeof Boolean | typeof String;\n while?: 'connected';\n}\n\nexport interface ChangedAttributeHostMetadata {\n attributeName: string;\n propertyKey: string | symbol;\n options: ChangedAttributeHostOptions;\n}\n\nconst convertValue = (val: any, type: any): any => {\n if (val === null || val === undefined) return val;\n if (type === Number) return Number(val);\n if (type === Boolean) return val === 'false' || val === '0' ? false : true;\n return val;\n};\n\n/**\n * @changedAttributeHost decorator - fires when any attribute on :host changes\n * Usage: @changedAttributeHost('data-product-id')\n * @changedAttributeHost('count', { type: Number })\n */\nexport function changedAttributeHost(attributeName?: string, options: ChangedAttributeHostOptions = {}): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeHostMetadata[];\n if (!metaList) {\n metaList = [];\n ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);\n }\n\n const name = attributeName || String(propertyKey);\n metaList.push({\n attributeName: name,\n propertyKey,\n options\n });\n };\n}\n\nexport const getChangedAttributeMetadata = (target: any): ChangedAttributeHostMetadata[] | 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, ChangedAttributeHostMetadata[]> => {\n const constructor = target instanceof Function ? target : target.constructor;\n const metaList = ReflectUtils.findAllMetadata<ChangedAttributeHostMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];\n\n const result = new Map<string, ChangedAttributeHostMetadata[]>();\n metaList.forEach(meta => {\n meta.forEach(item => {\n if (!result.has(item.attributeName)) {\n result.set(item.attributeName, []);\n }\n result.get(item.attributeName)!.push(item);\n });\n });\n return result;\n};\n\nexport const convertAttributeValue = (val: any, type?: typeof Number | typeof Boolean | typeof String): any => {\n return convertValue(val, type);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAEtB,MAAM,oCAAoC,OAAO,IAAI,2CAA2C;AAavG,MAAM,eAAe,CAAC,KAAU,SAAmB;AACjD,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,MAAI,SAAS,OAAQ,QAAO,OAAO,GAAG;AACtC,MAAI,SAAS,QAAS,QAAO,QAAQ,WAAW,QAAQ,MAAM,QAAQ;AACtE,SAAO;AACT;AAOO,SAAS,qBAAqB,eAAwB,UAAuC,CAAC,GAAoB;AACvH,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,QAAI,WAAW,yBAAa,eAAe,mCAAmC,WAAW;AACzF,QAAI,CAAC,UAAU;AACb,iBAAW,CAAC;AACZ,+BAAa,eAAe,mCAAmC,UAAU,WAAW;AAAA,IACtF;AAEA,UAAM,OAAO,iBAAiB,OAAO,WAAW;AAChD,aAAS,KAAK;AAAA,MACZ,eAAe;AAAA,MACf;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,8BAA8B,CAAC,WAA4D;AACtG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,yBAAa,YAAY,mCAAmC,WAAW;AAChF;AAEO,MAAM,kCAAkC,CAAC,WAA6D;AAC3G,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,QAAM,WAAW,yBAAa,gBAAgD,mCAAmC,WAAW,KAAK,CAAC;AAElI,QAAM,SAAS,oBAAI,IAA4C;AAC/D,WAAS,QAAQ,UAAQ;AACvB,SAAK,QAAQ,UAAQ;AACnB,UAAI,CAAC,OAAO,IAAI,KAAK,aAAa,GAAG;AACnC,eAAO,IAAI,KAAK,eAAe,CAAC,CAAC;AAAA,MACnC;AACA,aAAO,IAAI,KAAK,aAAa,EAAG,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;AAEO,MAAM,wBAAwB,CAAC,KAAU,SAA+D;AAC7G,SAAO,aAAa,KAAK,IAAI;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -94,7 +94,7 @@ const handleGlobalSwcEvent = async (event) => {
94
94
  }
95
95
  };
96
96
  function buildEnv(configWindow) {
97
- const win = configWindow || (typeof window !== "undefined" ? window : void 0);
97
+ const win = configWindow;
98
98
  const doc = win?.document;
99
99
  const builtInTagMap = /* @__PURE__ */ new Map();
100
100
  for (const [cls, tag] of import_config.HTML_TAG_ENTRIES) {
@@ -133,7 +133,7 @@ const setupPrototype = (proto) => {
133
133
  const aConf = getElementConfig(ancestors[i]);
134
134
  if (aConf?.window) return aConf.window;
135
135
  }
136
- return typeof window !== "undefined" ? window : void 0;
136
+ return getElementConfig(this).window ?? (typeof window !== "undefined" ? window : void 0);
137
137
  };
138
138
  proto._invokeLifecycleMethod = function(methodName, hostSet, extraArgs = []) {
139
139
  ensureInit(this);
@@ -142,7 +142,13 @@ const setupPrototype = (proto) => {
142
142
  const app = useHostSet?.$appHost?.simpleApplication;
143
143
  if (app) {
144
144
  const otherStorage = /* @__PURE__ */ new Map();
145
- const situations = new import_Inject.SituationTypeContainers([new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOST_SET, data: useHostSet }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOST, data: useHostSet.$appHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOST, data: useHostSet.$host }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOSTS, data: useHostSet.$hosts }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.FIRST_HOST, data: useHostSet.$firstHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_HOST, data: useHostSet.$lastHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.FIRST_APP_HOST, data: useHostSet.$firstAppHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost })]);
145
+ const situations = new import_Inject.SituationTypeContainers([new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOST_SET, data: useHostSet }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOST, data: useHostSet.$appHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts }), new import_Inject.SituationTypeContainer({
146
+ situationType: import_types.InjectSituationType.HOST,
147
+ data: useHostSet.$host
148
+ }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOSTS, data: useHostSet.$hosts }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.FIRST_HOST, data: useHostSet.$firstHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_HOST, data: useHostSet.$lastHost }), new import_Inject.SituationTypeContainer({
149
+ situationType: import_types.InjectSituationType.FIRST_APP_HOST,
150
+ data: useHostSet.$firstAppHost
151
+ }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost })]);
146
152
  otherStorage.set(import_Inject.SituationTypeContainers, situations);
147
153
  return app.simstanceManager.executeBindParameterSim(
148
154
  {
@@ -235,195 +241,243 @@ const elementDefine = (name, config = {}) => (constructor) => {
235
241
  const swcOnEvents = import_config.DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
236
242
  const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
237
243
  const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
238
- const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
239
- ...metadata.observedAttributes ?? [],
240
- ...attrChangeMap.keys(),
241
- ...attributeApplyNames,
242
- ...hostAttributes,
243
- ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
244
- ...swcLifecycleAttributes,
245
- ...swcOnEvents
246
- ])];
244
+ const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
245
+ const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
247
246
  const connectedInnerHtmlList = (0, import_lifecycles.getOnConnectedInnerHtmlMetadata)(constructor) || [];
248
247
  const proto = constructor.prototype;
249
248
  setupPrototype(proto);
249
+ let helperHostSet = null;
250
250
  const originalConnected = proto.connectedCallback;
251
- proto.connectedCallback = function() {
251
+ proto.connectedCallback = async function() {
252
252
  ensureInit(this);
253
- const hostSet = import_Utils.SwcUtils.getHostSet(this);
254
- const appHost = hostSet.$appHost;
255
- const conf = getElementConfig(this);
256
- const currentWin = this._resolveWindow(conf);
257
- if ((connectedInnerHtmlList.some((it) => it.options.useShadow === true) || conf?.useShadow === true) && !this.shadowRoot) {
258
- this.attachShadow({ mode: "open" });
259
- }
260
- this._executeSwcScript("swc-on-before-connected", hostSet);
261
- const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_CONNECTED_METADATA_KEY);
262
- if (bMethods) {
263
- for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
264
- }
265
- if (connectedInnerHtmlList.length > 0) {
266
- let sContent = "", lContent = "";
267
- for (const meta of connectedInnerHtmlList) {
268
- const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
269
- if (res !== void 0) {
270
- if (meta.options.useShadow) sContent += res;
271
- else lContent += res;
272
- }
253
+ helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(win, this);
254
+ const appHost = helperHostSet.$appHost;
255
+ try {
256
+ if (appHost && typeof appHost._connected === "function") {
257
+ await appHost._connected(this);
258
+ } else if (appHost && typeof appHost) {
259
+ appHost._connected_safari ?? (appHost._connected_safari = []);
260
+ appHost._connected_safari.push(this);
273
261
  }
274
- if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
275
- if (lContent) this.innerHTML = lContent;
276
- }
277
- const root = this.getRootNode();
278
- if (!globalDelegatedRoots.has(root)) {
279
- import_config.DOM_EVENT_NAMES.forEach((type) => {
280
- root.addEventListener(type, handleGlobalSwcEvent);
281
- });
282
- globalDelegatedRoots.add(root);
283
- }
284
- const delegateListeners = [];
285
- const nonDelegateListeners = [];
286
- addEventListenerList.forEach((meta) => {
287
- if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
288
- delegateListeners.push(meta);
289
- } else {
290
- nonDelegateListeners.push(meta);
262
+ const conf = getElementConfig(this);
263
+ const currentWin = this._resolveWindow(conf);
264
+ const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
265
+ if (shadowMode && !this.shadowRoot) {
266
+ const mode = shadowMode === true ? "open" : shadowMode;
267
+ this.attachShadow({ mode });
291
268
  }
292
- });
293
- const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
294
- delegateListeners.forEach((meta) => {
295
- const r = meta.options.root || "auto";
296
- const rootKey = `${meta.type}:${r}`;
297
- if (!delegatesByTypeAndRoot.has(rootKey)) {
298
- delegatesByTypeAndRoot.set(rootKey, []);
269
+ const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_CONNECTED_METADATA_KEY);
270
+ if (bMethods) {
271
+ for (const m of bMethods) await this._invokeLifecycleMethod(m, helperHostSet);
299
272
  }
300
- delegatesByTypeAndRoot.get(rootKey).push(meta);
301
- });
302
- delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
303
- const [type, rStr] = typeRootKey.split(":");
304
- const r = rStr === "auto" ? "auto" : rStr;
305
- const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
306
- const bindRoots = [];
307
- if (r === "auto") bindRoots.push(this.shadowRoot || this);
308
- else if (r === "light") bindRoots.push(this);
309
- else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
310
- else if (r === "all") {
311
- bindRoots.push(this);
312
- if (this.shadowRoot) bindRoots.push(this.shadowRoot);
273
+ this._executeSwcScript("swc-on-before-connected", helperHostSet);
274
+ if (connectedInnerHtmlList.length > 0) {
275
+ let sContent = "", lContent = "";
276
+ for (const meta of connectedInnerHtmlList) {
277
+ let res = await this._invokeLifecycleMethod(meta.propertyKey, helperHostSet);
278
+ const actionExpression = new import_core.ActionExpression(res, {
279
+ expression: {
280
+ replace: {
281
+ start: meta.options.replaceWrap?.start || "{%{",
282
+ end: meta.options.replaceWrap?.end || "}%}"
283
+ },
284
+ callReturn: {
285
+ start: meta.options.replaceWrap?.start || "{%{=",
286
+ end: meta.options.replaceWrap?.end || "}%}"
287
+ },
288
+ call: {
289
+ start: meta.options.replaceWrap?.start || "{%{@",
290
+ end: meta.options.replaceWrap?.end || "}%}"
291
+ }
292
+ }
293
+ });
294
+ actionExpression.getExpressions().filter((it) => it.type === "replace").forEach((it) => {
295
+ try {
296
+ const sr = import_core.FunctionUtils.executeReturn({ script: it.script, context: this, args: helperHostSet });
297
+ actionExpression.replace(it, sr);
298
+ } catch (e) {
299
+ console.error(`[SWC] Failed to execute connectedInnerHTML:`, e);
300
+ }
301
+ });
302
+ res = actionExpression.getUnprocessedTemplate();
303
+ if (res !== void 0) {
304
+ if (meta.options.useShadow || conf?.useShadow) sContent += res;
305
+ else lContent += res;
306
+ }
307
+ }
308
+ try {
309
+ if (this.shadowRoot) {
310
+ this.shadowRoot.innerHTML = sContent;
311
+ }
312
+ if (lContent) {
313
+ this.innerHTML = lContent;
314
+ }
315
+ } catch (e) {
316
+ console.error("[ElementDefine] innerHTML setting error:", e);
317
+ }
313
318
  }
314
- bindRoots.forEach((br) => {
315
- const sortedMetaList = [...metaList].sort((a, b) => {
316
- const aStop = a.options.stopPropagation ? 1 : 0;
317
- const bStop = b.options.stopPropagation ? 1 : 0;
318
- return bStop - aStop;
319
+ const root = this.getRootNode();
320
+ if (!globalDelegatedRoots.has(root)) {
321
+ import_config.DOM_EVENT_NAMES.forEach((type) => {
322
+ root.addEventListener(type, handleGlobalSwcEvent);
319
323
  });
320
- const unifiedHandler = async (event) => {
321
- for (const meta of sortedMetaList) {
322
- const { selector, options } = meta;
323
- const matchedEl = event.target.closest(selector);
324
- if (matchedEl && br.contains(matchedEl)) {
325
- if (options.filter) {
326
- const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
327
- if (!options.filter(event, helper)) {
328
- continue;
324
+ globalDelegatedRoots.add(root);
325
+ }
326
+ const delegateListeners = [];
327
+ const nonDelegateListeners = [];
328
+ addEventListenerList.forEach((meta) => {
329
+ if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
330
+ delegateListeners.push(meta);
331
+ } else {
332
+ nonDelegateListeners.push(meta);
333
+ }
334
+ });
335
+ const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
336
+ delegateListeners.forEach((meta) => {
337
+ const r = meta.options.root || "auto";
338
+ const rootKey = `${meta.type}:${r}`;
339
+ if (!delegatesByTypeAndRoot.has(rootKey)) {
340
+ delegatesByTypeAndRoot.set(rootKey, []);
341
+ }
342
+ delegatesByTypeAndRoot.get(rootKey).push(meta);
343
+ });
344
+ delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
345
+ const [type, rStr] = typeRootKey.split(":");
346
+ const r = rStr === "auto" ? "auto" : rStr;
347
+ const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
348
+ const bindRoots = [];
349
+ if (r === "auto") bindRoots.push(this.shadowRoot || this);
350
+ else if (r === "light") bindRoots.push(this);
351
+ else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
352
+ else if (r === "all") {
353
+ bindRoots.push(this);
354
+ if (this.shadowRoot) bindRoots.push(this.shadowRoot);
355
+ }
356
+ bindRoots.forEach((br) => {
357
+ const sortedMetaList = [...metaList].sort((a, b) => {
358
+ const aStop = a.options.stopPropagation ? 1 : 0;
359
+ const bStop = b.options.stopPropagation ? 1 : 0;
360
+ return bStop - aStop;
361
+ });
362
+ const unifiedHandler = async (event) => {
363
+ for (const meta of sortedMetaList) {
364
+ const { selector, options } = meta;
365
+ const matchedEl = event.target.closest(selector);
366
+ if (matchedEl && br.contains(matchedEl)) {
367
+ if (options.filter) {
368
+ const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
369
+ if (!options.filter(event, helper)) {
370
+ continue;
371
+ }
329
372
  }
373
+ if (options.stopPropagation) event.stopPropagation();
374
+ if (options.stopImmediatePropagation) event.stopImmediatePropagation();
375
+ if (options.preventDefault) event.preventDefault();
376
+ const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
377
+ const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
378
+ await this[meta.propertyKey](event, { ...currentHostSet, $matchedElement: matchedEl }, args);
379
+ if (event.cancelBubble) break;
330
380
  }
331
- if (options.stopPropagation) event.stopPropagation();
332
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
333
- if (options.preventDefault) event.preventDefault();
334
- const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
335
- const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
336
- await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
337
- if (event.cancelBubble) break;
338
381
  }
382
+ };
383
+ br.addEventListener(type, unifiedHandler, opts);
384
+ this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
385
+ });
386
+ });
387
+ nonDelegateListeners.forEach((meta) => {
388
+ const { selector, type, options } = meta;
389
+ const opts = { capture: options.capture, once: options.once, passive: options.passive };
390
+ const bindTargets = [];
391
+ const r = options.root || "auto";
392
+ const applyRootOption = (target) => {
393
+ if (!target) return;
394
+ if (r === "auto") {
395
+ bindTargets.push(target.shadowRoot || target);
396
+ } else {
397
+ if (r === "light" || r === "all") bindTargets.push(target);
398
+ if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
339
399
  }
340
400
  };
341
- br.addEventListener(type, unifiedHandler, opts);
342
- this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
343
- });
344
- });
345
- nonDelegateListeners.forEach((meta) => {
346
- const { selector, type, options } = meta;
347
- const opts = { capture: options.capture, once: options.once, passive: options.passive };
348
- const bindTargets = [];
349
- const r = options.root || "auto";
350
- const applyRootOption = (target) => {
351
- if (!target) return;
352
- if (r === "auto") {
353
- bindTargets.push(target.shadowRoot || target);
354
- } else {
355
- if (r === "light" || r === "all") bindTargets.push(target);
356
- if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
357
- }
358
- };
359
- if (selector === ":window") bindTargets.push(currentWin);
360
- else if (selector === ":document") bindTargets.push(currentWin.document);
361
- else if (selector === ":parentHost") applyRootOption(hostSet.$parentHost);
362
- else if (selector === ":appHost") applyRootOption(hostSet.$appHost);
363
- else if (selector === ":firstHost") applyRootOption(hostSet.$firstHost);
364
- else if (selector === ":lastHost") applyRootOption(hostSet.$lastHost);
365
- else if (selector === ":firstAppHost") applyRootOption(hostSet.$firstAppHost);
366
- else if (selector === ":lastAppHost") applyRootOption(hostSet.$lastAppHost);
367
- else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
368
- else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
369
- else if (selector === ":host" || !selector) applyRootOption(this);
370
- else {
371
- const searchRoots = [];
372
- if (r === "auto") searchRoots.push(this.shadowRoot || this);
373
- else if (r === "light") searchRoots.push(this);
374
- else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
375
- else if (r === "all") {
376
- searchRoots.push(this);
377
- if (this.shadowRoot) searchRoots.push(this.shadowRoot);
401
+ if (selector === ":window") bindTargets.push(currentWin);
402
+ else if (selector === ":document") bindTargets.push(currentWin.document);
403
+ else if (selector === ":parentHost") applyRootOption(helperHostSet.$parentHost);
404
+ else if (selector === ":appHost") applyRootOption(helperHostSet.$appHost);
405
+ else if (selector === ":firstHost") applyRootOption(helperHostSet.$firstHost);
406
+ else if (selector === ":lastHost") applyRootOption(helperHostSet.$lastHost);
407
+ else if (selector === ":firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
408
+ else if (selector === ":lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
409
+ else if (selector === ":hosts") helperHostSet.$hosts.forEach(applyRootOption);
410
+ else if (selector === ":appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
411
+ else if (selector === ":host" || !selector) applyRootOption(this);
412
+ else {
413
+ const searchRoots = [];
414
+ if (r === "auto") searchRoots.push(this.shadowRoot || this);
415
+ else if (r === "light") searchRoots.push(this);
416
+ else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
417
+ else if (r === "all") {
418
+ searchRoots.push(this);
419
+ if (this.shadowRoot) searchRoots.push(this.shadowRoot);
420
+ }
421
+ searchRoots.forEach((sr) => {
422
+ sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
423
+ });
378
424
  }
379
- searchRoots.forEach((sr) => {
380
- sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
425
+ bindTargets.forEach((t) => {
426
+ const handler = async (event) => {
427
+ if (options.filter) {
428
+ const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, t);
429
+ if (!options.filter(event, { currentThis: this, helper })) {
430
+ return;
431
+ }
432
+ }
433
+ if (options.stopPropagation) event.stopPropagation();
434
+ if (options.stopImmediatePropagation) event.stopImmediatePropagation();
435
+ if (options.preventDefault) event.preventDefault();
436
+ const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
437
+ const args = { event, ...currentHostSet, $el: t, $root: t };
438
+ await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
439
+ };
440
+ t.addEventListener(type, handler, opts);
441
+ if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
442
+ this._boundListeners.push({ target: t, type, handler, options: opts });
443
+ }
381
444
  });
445
+ });
446
+ if (originalConnected) await originalConnected.apply(this);
447
+ const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_CONNECTED_METADATA_KEY);
448
+ if (aMethods) {
449
+ for (const m of aMethods) await this._invokeLifecycleMethod(m, helperHostSet);
382
450
  }
383
- bindTargets.forEach((t) => {
384
- const handler = async (event) => {
385
- if (options.filter) {
386
- const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, t);
387
- if (!options.filter(event, helper)) {
388
- return;
451
+ this._executeSwcScript("swc-on-connected", helperHostSet);
452
+ this._executeSwcScript("swc-on-after-connected", helperHostSet);
453
+ this.__swc_connected = true;
454
+ for (let [name2, metaList] of Array.from(attrChangeMap)) {
455
+ for (const meta of metaList) {
456
+ if (meta.options.while === "connected") {
457
+ const val = (0, import_attribute.getAttributeValue)(this, name2, { type: meta.options.type });
458
+ if (val !== null) {
459
+ await this[meta.propertyKey](val, null, name2, helperHostSet);
389
460
  }
390
461
  }
391
- if (options.stopPropagation) event.stopPropagation();
392
- if (options.stopImmediatePropagation) event.stopImmediatePropagation();
393
- if (options.preventDefault) event.preventDefault();
394
- const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
395
- const args = { event, ...currentHostSet, $el: t, $root: t };
396
- await this[meta.propertyKey](event, currentHostSet, args);
397
- };
398
- t.addEventListener(type, handler, opts);
399
- if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
400
- this._boundListeners.push({ target: t, type, handler, options: opts });
401
462
  }
402
- });
403
- });
404
- if (originalConnected) originalConnected.apply(this);
405
- const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_CONNECTED_METADATA_KEY);
406
- if (aMethods) {
407
- for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
408
- }
409
- this._executeSwcScript("swc-on-connected", hostSet);
410
- this._executeSwcScript("swc-on-after-connected", hostSet);
411
- this.__swc_connected = true;
412
- const appHostss = import_Utils.SwcUtils.findAllParentAppHostsDirect(this);
413
- if (appHost && typeof appHost._connected === "function") {
414
- appHost._connected(this);
415
- } else if (appHost && typeof appHost) {
416
- appHost._connected_safari ?? (appHost._connected_safari = []);
417
- appHost._connected_safari.push(this);
463
+ }
464
+ } finally {
465
+ if (appHost && typeof appHost._connectedDone === "function") {
466
+ await appHost._connectedDone(this);
467
+ }
418
468
  }
419
469
  };
420
470
  const originalDisconnected = proto.disconnectedCallback;
421
471
  proto.disconnectedCallback = function() {
422
- const hostSet = import_Utils.SwcUtils.getHostSet(this);
423
- this._executeSwcScript("swc-on-before-disconnected", hostSet);
472
+ console.log("disconnnnnnnnnnnnnnnnnnn", helperHostSet, this);
473
+ const appHost = helperHostSet.$appHost;
474
+ if (appHost && typeof appHost._disconnected === "function") {
475
+ appHost._disconnected(this);
476
+ }
477
+ this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
424
478
  const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_DISCONNECTED_METADATA_KEY);
425
479
  if (bMethods) {
426
- for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
480
+ for (const m of bMethods) this._invokeLifecycleMethod(m, helperHostSet);
427
481
  }
428
482
  if (this._boundListeners) {
429
483
  this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
@@ -432,15 +486,11 @@ const elementDefine = (name, config = {}) => (constructor) => {
432
486
  if (originalDisconnected) originalDisconnected.apply(this);
433
487
  const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_DISCONNECTED_METADATA_KEY);
434
488
  if (aMethods) {
435
- for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
489
+ for (const m of aMethods) this._invokeLifecycleMethod(m, helperHostSet);
436
490
  }
437
- this._executeSwcScript("swc-on-disconnected", hostSet);
438
- this._executeSwcScript("swc-on-after-disconnected", hostSet);
491
+ this._executeSwcScript("swc-on-disconnected", helperHostSet);
492
+ this._executeSwcScript("swc-on-after-disconnected", helperHostSet);
439
493
  this.__swc_connected = false;
440
- const appHost = hostSet.$appHost;
441
- if (appHost && typeof appHost._disconnected === "function") {
442
- appHost._disconnected(this);
443
- }
444
494
  };
445
495
  const originalAdopted = proto.adoptedCallback;
446
496
  proto.adoptedCallback = function() {
@@ -465,18 +515,20 @@ const elementDefine = (name, config = {}) => (constructor) => {
465
515
  let processedVal = newVal;
466
516
  if (newVal !== null) {
467
517
  const ae = new import_core.ActionExpression(newVal);
468
- const expr = ae.getFirstExpression("call-return");
518
+ const expr = ae.getFirstExpression("callReturn");
469
519
  if (expr) {
470
520
  const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
521
+ const helperAndHostSet = import_Utils.SwcUtils.getHelperAndHostSet(win2, this);
522
+ const script = import_core_web.ConvertUtils.decodeHtmlEntity(expr.script, win2.document);
471
523
  try {
472
524
  const result = import_core.FunctionUtils.executeReturn({
473
- script: import_core_web.ConvertUtils.decodeHtmlEntity(expr.script, win2.document),
525
+ script,
474
526
  context: this,
475
- args: import_Utils.SwcUtils.getHelperAndHostSet(win2, this)
527
+ args: helperAndHostSet
476
528
  });
477
- processedVal = String(result);
529
+ processedVal = result;
478
530
  } catch (e) {
479
- console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}:`, e);
531
+ console.error(`[SWC] Failed to execute directive {{= ${expr.script} }} on attribute ${name2}: ${helperAndHostSet}`, e);
480
532
  processedVal = newVal;
481
533
  }
482
534
  }
@@ -491,9 +543,15 @@ const elementDefine = (name, config = {}) => (constructor) => {
491
543
  if (hostCustomEventMeta && newVal !== null) {
492
544
  this._bindAttributeEvent(this, name2, newVal, hostCustomEventMeta.type);
493
545
  }
494
- const mKeys = attrChangeMap.get(name2);
495
- if (mKeys && Array.isArray(mKeys)) {
496
- for (const key of mKeys) this[key](processedVal, old, name2, hSet);
546
+ const metaList = attrChangeMap.get(name2);
547
+ if (metaList && Array.isArray(metaList)) {
548
+ for (const meta of metaList) {
549
+ if (meta.options.while === "connected" && !this.__swc_connected) {
550
+ continue;
551
+ }
552
+ const convertedVal = (0, import_changedAttributeHost.convertAttributeValue)(processedVal, meta.options.type);
553
+ this[meta.propertyKey](convertedVal, old, name2, hSet);
554
+ }
497
555
  }
498
556
  };
499
557
  Object.defineProperty(constructor, "observedAttributes", {