@dooboostore/simple-web-component 1.0.15 → 1.0.16

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 (53) hide show
  1. package/README.md +183 -92
  2. package/dist/cjs/decorators/addEventListener.js +2 -3
  3. package/dist/cjs/decorators/addEventListener.js.map +2 -2
  4. package/dist/cjs/decorators/elementDefine.js +89 -33
  5. package/dist/cjs/decorators/elementDefine.js.map +2 -2
  6. package/dist/cjs/decorators/emitCustomEvent.js +2 -14
  7. package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
  8. package/dist/cjs/decorators/query.js +25 -36
  9. package/dist/cjs/decorators/query.js.map +2 -2
  10. package/dist/cjs/decorators/queryAll.js +28 -36
  11. package/dist/cjs/decorators/queryAll.js.map +2 -2
  12. package/dist/cjs/types.js +1 -0
  13. package/dist/cjs/types.js.map +2 -2
  14. package/dist/cjs/utils/Utils.js +36 -143
  15. package/dist/cjs/utils/Utils.js.map +2 -2
  16. package/dist/esm/decorators/addEventListener.js +2 -3
  17. package/dist/esm/decorators/addEventListener.js.map +2 -2
  18. package/dist/esm/decorators/elementDefine.js +89 -33
  19. package/dist/esm/decorators/elementDefine.js.map +2 -2
  20. package/dist/esm/decorators/emitCustomEvent.js +2 -14
  21. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  22. package/dist/esm/decorators/query.js +25 -36
  23. package/dist/esm/decorators/query.js.map +2 -2
  24. package/dist/esm/decorators/queryAll.js +28 -36
  25. package/dist/esm/decorators/queryAll.js.map +2 -2
  26. package/dist/esm/types.js +1 -0
  27. package/dist/esm/types.js.map +2 -2
  28. package/dist/esm/utils/Utils.js +36 -143
  29. package/dist/esm/utils/Utils.js.map +2 -2
  30. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +183 -266
  31. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
  32. package/dist/types/decorators/addEventListener.d.ts +9 -4
  33. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  34. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  35. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  36. package/dist/types/decorators/query.d.ts +6 -5
  37. package/dist/types/decorators/query.d.ts.map +1 -1
  38. package/dist/types/decorators/queryAll.d.ts +6 -5
  39. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  40. package/dist/types/types.d.ts +3 -1
  41. package/dist/types/types.d.ts.map +1 -1
  42. package/dist/types/utils/Utils.d.ts +6 -14
  43. package/dist/types/utils/Utils.d.ts.map +1 -1
  44. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +183 -266
  45. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
  46. package/package.json +3 -3
  47. package/src/decorators/addEventListener.ts +10 -7
  48. package/src/decorators/elementDefine.ts +86 -31
  49. package/src/decorators/emitCustomEvent.ts +5 -21
  50. package/src/decorators/query.ts +33 -46
  51. package/src/decorators/queryAll.ts +36 -46
  52. package/src/types.ts +6 -4
  53. package/src/utils/Utils.ts +40 -176
@@ -1,11 +1,11 @@
1
1
  import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
2
2
  const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol("simple-web-component:emit-custom-event");
3
3
  function emitCustomEvent(typeOrOptions) {
4
- return (target, propertyKey, descriptor) => {
4
+ return (target, propertyKey) => {
5
5
  const constructor = target.constructor;
6
6
  const options = typeof typeOrOptions === "string" ? { type: typeOrOptions } : typeOrOptions;
7
7
  if (!options.attributeName) {
8
- options.attributeName = `on${options.type}`;
8
+ options.attributeName = `swc-on-${options.type}`;
9
9
  }
10
10
  if (options.bubbles === void 0) options.bubbles = true;
11
11
  if (options.composed === void 0) options.composed = true;
@@ -15,18 +15,6 @@ function emitCustomEvent(typeOrOptions) {
15
15
  ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
16
16
  }
17
17
  list.push({ propertyKey, options });
18
- const originalMethod = descriptor.value;
19
- descriptor.value = function(...args) {
20
- const detail = originalMethod.apply(this, args);
21
- const event = new CustomEvent(options.type, {
22
- detail,
23
- bubbles: options.bubbles,
24
- composed: options.composed,
25
- cancelable: options.cancelable
26
- });
27
- this.dispatchEvent(event);
28
- return detail;
29
- };
30
18
  };
31
19
  }
32
20
  const getEmitCustomEventMetadataList = (target) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/emitCustomEvent.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface EmitCustomEventOptions {\n type: string;\n attributeName?: string; // Default: on + type\n bubbles?: boolean; // Default: true\n composed?: boolean; // Default: true\n cancelable?: boolean;\n}\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n options: EmitCustomEventOptions;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(typeOrOptions: string | EmitCustomEventOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = target.constructor;\n const options: EmitCustomEventOptions = typeof typeOrOptions === 'string' ? { type: typeOrOptions } : typeOrOptions;\n\n if (!options.attributeName) {\n options.attributeName = `on${options.type}`;\n }\n if (options.bubbles === undefined) options.bubbles = true;\n if (options.composed === undefined) options.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n\n // Wrap the original method to dispatch event after execution\n const originalMethod = descriptor.value;\n descriptor.value = function (this: HTMLElement, ...args: any[]) {\n const detail = originalMethod.apply(this, args);\n\n const event = new CustomEvent(options.type, {\n detail,\n bubbles: options.bubbles,\n composed: options.composed,\n cancelable: options.cancelable\n });\n\n this.dispatchEvent(event);\n return detail;\n };\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AAetB,MAAM,iCAAiC,OAAO,wCAAwC;AAEtF,SAAS,gBAAgB,eAAiE;AAC/F,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,UAAM,cAAc,OAAO;AAC3B,UAAM,UAAkC,OAAO,kBAAkB,WAAW,EAAE,MAAM,cAAc,IAAI;AAEtG,QAAI,CAAC,QAAQ,eAAe;AAC1B,cAAQ,gBAAgB,KAAK,QAAQ,IAAI;AAAA,IAC3C;AACA,QAAI,QAAQ,YAAY,OAAW,SAAQ,UAAU;AACrD,QAAI,QAAQ,aAAa,OAAW,SAAQ,WAAW;AAEvD,QAAI,OAAO,aAAa,YAAuC,gCAAgC,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,gCAAgC,MAAM,WAAW;AAAA,IAC/E;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAGlC,UAAM,iBAAiB,WAAW;AAClC,eAAW,QAAQ,YAAgC,MAAa;AAC9D,YAAM,SAAS,eAAe,MAAM,MAAM,IAAI;AAE9C,YAAM,QAAQ,IAAI,YAAY,QAAQ,MAAM;AAAA,QAC1C;AAAA,QACA,SAAS,QAAQ;AAAA,QACjB,UAAU,QAAQ;AAAA,QAClB,YAAY,QAAQ;AAAA,MACtB,CAAC;AAED,WAAK,cAAc,KAAK;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,iCAAiC,CAAC,WAAuD;AACpG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,gCAAgC,WAAW;AAC7E;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface EmitCustomEventOptions {\n type: string;\n attributeName?: string;\n bubbles?: boolean;\n composed?: boolean;\n cancelable?: boolean;\n}\n\nexport interface EmitCustomEventMetadata {\n propertyKey: string | symbol;\n options: EmitCustomEventOptions;\n}\n\nexport const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol('simple-web-component:emit-custom-event');\n\nexport function emitCustomEvent(typeOrOptions: string | EmitCustomEventOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol) => {\n const constructor = target.constructor;\n const options: EmitCustomEventOptions = typeof typeOrOptions === 'string' ? { type: typeOrOptions } : typeOrOptions;\n\n if (!options.attributeName) {\n options.attributeName = `swc-on-${options.type}`;\n }\n if (options.bubbles === undefined) options.bubbles = true;\n if (options.composed === undefined) options.composed = true;\n\n let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n if (!list) {\n list = [];\n ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);\n }\n list.push({ propertyKey, options });\n };\n}\n\nexport const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAetB,MAAM,iCAAiC,OAAO,wCAAwC;AAEtF,SAAS,gBAAgB,eAAiE;AAC/F,SAAO,CAAC,QAAgB,gBAAiC;AACvD,UAAM,cAAc,OAAO;AAC3B,UAAM,UAAkC,OAAO,kBAAkB,WAAW,EAAE,MAAM,cAAc,IAAI;AAEtG,QAAI,CAAC,QAAQ,eAAe;AAC1B,cAAQ,gBAAgB,UAAU,QAAQ,IAAI;AAAA,IAChD;AACA,QAAI,QAAQ,YAAY,OAAW,SAAQ,UAAU;AACrD,QAAI,QAAQ,aAAa,OAAW,SAAQ,WAAW;AAEvD,QAAI,OAAO,aAAa,YAAuC,gCAAgC,WAAW;AAC1G,QAAI,CAAC,MAAM;AACT,aAAO,CAAC;AACR,mBAAa,eAAe,gCAAgC,MAAM,WAAW;AAAA,IAC/E;AACA,SAAK,KAAK,EAAE,aAAa,QAAQ,CAAC;AAAA,EACpC;AACF;AAEO,MAAM,iCAAiC,CAAC,WAAuD;AACpG,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,gCAAgC,WAAW;AAC7E;",
6
6
  "names": []
7
7
  }
@@ -1,47 +1,36 @@
1
1
  import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
2
2
  const QUERY_METADATA_KEY = Symbol("simple-web-component:query");
3
- function query(arg1, arg2) {
4
- const decorator = (selector, options, target, propertyKey, descriptor) => {
5
- const isMethod = !!descriptor;
3
+ function query(selector, options = {}) {
4
+ return (target, propertyKey, descriptor) => {
5
+ if (descriptor !== void 0) {
6
+ throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
7
+ }
6
8
  const constructor = target.constructor;
7
9
  let queries = ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);
8
10
  if (!queries) {
9
11
  queries = [];
10
12
  ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
11
13
  }
12
- queries.push({ selector, options, propertyKey, isMethod });
13
- if (!isMethod) {
14
- Object.defineProperty(target, propertyKey, {
15
- get() {
16
- if (!selector)
17
- return this;
18
- let searchRoot = this;
19
- if (options.root === "shadow")
20
- searchRoot = this.shadowRoot || this;
21
- else if (options.root === "light")
22
- searchRoot = this;
23
- else
24
- searchRoot = this.shadowRoot || this;
25
- return searchRoot.querySelector(selector);
26
- },
27
- enumerable: true,
28
- configurable: true
29
- });
30
- }
31
- };
32
- if (arg1 && typeof arg2 === "string") {
33
- return decorator("", {}, arg1, arg2);
34
- }
35
- return (target, propertyKey, descriptor) => {
36
- let selector = "";
37
- let options = {};
38
- if (typeof arg1 === "string") {
39
- selector = arg1;
40
- } else if (typeof arg1 === "object") {
41
- options = arg1;
42
- selector = options.selector || "";
43
- }
44
- decorator(selector, options, target, propertyKey, descriptor);
14
+ queries.push({ selector, options, propertyKey });
15
+ Object.defineProperty(target, propertyKey, {
16
+ get() {
17
+ if (!selector || selector === ":host")
18
+ return this;
19
+ const r = options.root || "auto";
20
+ if (r === "shadow") {
21
+ return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
22
+ }
23
+ if (r === "light") {
24
+ return this.querySelector(selector);
25
+ }
26
+ if (r === "all") {
27
+ return this.shadowRoot?.querySelector(selector) || this.querySelector(selector);
28
+ }
29
+ return (this.shadowRoot || this).querySelector(selector);
30
+ },
31
+ enumerable: true,
32
+ configurable: true
33
+ });
45
34
  };
46
35
  }
47
36
  const getQueryMetadata = (target) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/query.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryOptions {\n selector?: string;\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryMetadata {\n selector: string;\n options: QueryOptions;\n propertyKey: string | symbol;\n isMethod: boolean;\n}\n\nexport const QUERY_METADATA_KEY = Symbol('simple-web-component:query');\n\nexport function query(selector: string): any;\nexport function query(options: QueryOptions): any;\nexport function query(target: Object, propertyKey: string | symbol): void;\nexport function query(arg1?: string | QueryOptions | Object, arg2?: string | symbol): any {\n const decorator = (selector: string, options: QueryOptions, target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const isMethod = !!descriptor;\n const constructor = target.constructor;\n\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ selector, options, propertyKey, isMethod });\n\n if (!isMethod) {\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector) return this;\n let searchRoot: Node = this;\n if (options.root === 'shadow') searchRoot = this.shadowRoot || this;\n else if (options.root === 'light') searchRoot = this;\n else searchRoot = this.shadowRoot || this; // Default: Auto (Shadow-First)\n\n return (searchRoot as HTMLElement).querySelector(selector);\n },\n enumerable: true,\n configurable: true\n });\n }\n };\n\n // Case: @query (parameterless decorator)\n if (arg1 && typeof arg2 === 'string') {\n return decorator('', {}, arg1 as Object, arg2 as string | symbol);\n }\n\n // Case: @query('selector') or @query({ selector: '...', ... })\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n let selector = '';\n let options: QueryOptions = {};\n\n if (typeof arg1 === 'string') {\n selector = arg1;\n } else if (typeof arg1 === 'object') {\n options = arg1 as QueryOptions;\n selector = options.selector || '';\n }\n\n decorator(selector, options, target, propertyKey, descriptor);\n };\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AActB,MAAM,qBAAqB,OAAO,4BAA4B;AAK/D,SAAU,MAAM,MAAuC,MAAsB;AACjF,QAAM,YAAY,CAAC,UAAkB,SAAuB,QAAgB,aAA8B,eAAmC;AAC3I,UAAM,WAAW,CAAC,CAAC;AACnB,UAAM,cAAc,OAAO;AAE3B,QAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,UAAU,SAAS,aAAa,SAAQ,CAAE;AAEzD,QAAI,CAAC,UAAU;AACb,aAAO,eAAe,QAAQ,aAAa;QACzC,MAAG;AACD,cAAI,CAAC;AAAU,mBAAO;AACtB,cAAI,aAAmB;AACvB,cAAI,QAAQ,SAAS;AAAU,yBAAa,KAAK,cAAc;mBACtD,QAAQ,SAAS;AAAS,yBAAa;;AAC3C,yBAAa,KAAK,cAAc;AAErC,iBAAQ,WAA2B,cAAc,QAAQ;QAC3D;QACA,YAAY;QACZ,cAAc;OACf;IACH;EACF;AAGA,MAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,WAAO,UAAU,IAAI,CAAA,GAAI,MAAgB,IAAuB;EAClE;AAGA,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,QAAI,WAAW;AACf,QAAI,UAAwB,CAAA;AAE5B,QAAI,OAAO,SAAS,UAAU;AAC5B,iBAAW;IACb,WAAW,OAAO,SAAS,UAAU;AACnC,gBAAU;AACV,iBAAW,QAAQ,YAAY;IACjC;AAEA,cAAU,UAAU,SAAS,QAAQ,aAAa,UAAU;EAC9D;AACF;AAEO,MAAM,mBAAmB,CAAC,WAA4C;AAC3E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,oBAAoB,WAAW;AACjE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryOptions {\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryMetadata {\n selector: string;\n options: QueryOptions;\n propertyKey: string | symbol;\n}\n\nexport const QUERY_METADATA_KEY = Symbol('simple-web-component:query');\n\n/**\n * @query decorator to inject a single element into a class property.\n * Usage: @query('.my-class') myEl!: HTMLElement;\n * Usage: @query('#my-id', { root: 'shadow' }) myEl!: HTMLElement;\n */\nexport function query(selector: string, options: QueryOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = target.constructor;\n let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);\n }\n queries.push({ selector, options, propertyKey });\n\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector || selector === ':host') return this;\n const r = options.root || 'auto';\n\n if (r === 'shadow') {\n return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;\n }\n if (r === 'light') {\n return this.querySelector(selector);\n }\n if (r === 'all') {\n return this.shadowRoot?.querySelector(selector) || this.querySelector(selector);\n }\n // auto\n return (this.shadowRoot || this).querySelector(selector);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryMetadata = (target: any): QueryMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAYtB,MAAM,qBAAqB,OAAO,4BAA4B;AAO/D,SAAU,MAAM,UAAkB,UAAwB,CAAA,GAAE;AAChE,SAAO,CAAC,QAAgB,aAA8B,eAA4B;AAChF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,wDAAwD,OAAO,WAAW,CAAC,GAAG;IAChG;AAEA,UAAM,cAAc,OAAO;AAC3B,QAAI,UAAU,aAAa,YAA6B,oBAAoB,WAAW;AACvF,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,oBAAoB,SAAS,WAAW;IACtE;AACA,YAAQ,KAAK,EAAE,UAAU,SAAS,YAAW,CAAE;AAE/C,WAAO,eAAe,QAAQ,aAAa;MACzC,MAAG;AACD,YAAI,CAAC,YAAY,aAAa;AAAS,iBAAO;AAC9C,cAAM,IAAI,QAAQ,QAAQ;AAE1B,YAAI,MAAM,UAAU;AAClB,iBAAO,KAAK,aAAa,KAAK,WAAW,cAAc,QAAQ,IAAI;QACrE;AACA,YAAI,MAAM,SAAS;AACjB,iBAAO,KAAK,cAAc,QAAQ;QACpC;AACA,YAAI,MAAM,OAAO;AACf,iBAAO,KAAK,YAAY,cAAc,QAAQ,KAAK,KAAK,cAAc,QAAQ;QAChF;AAEA,gBAAQ,KAAK,cAAc,MAAM,cAAc,QAAQ;MACzD;MACA,YAAY;MACZ,cAAc;KACf;EACH;AACF;AAEO,MAAM,mBAAmB,CAAC,WAA4C;AAC3E,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,oBAAoB,WAAW;AACjE;",
6
6
  "names": []
7
7
  }
@@ -1,47 +1,39 @@
1
1
  import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
2
2
  const QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
3
- function queryAll(arg1, arg2) {
4
- const decorator = (selector, options, target, propertyKey, descriptor) => {
5
- const isMethod = !!descriptor;
3
+ function queryAll(selector, options = {}) {
4
+ return (target, propertyKey, descriptor) => {
5
+ if (descriptor !== void 0) {
6
+ throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
7
+ }
6
8
  const constructor = target.constructor;
7
9
  let queries = ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);
8
10
  if (!queries) {
9
11
  queries = [];
10
12
  ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
11
13
  }
12
- queries.push({ selector, options, propertyKey, isMethod });
13
- if (!isMethod) {
14
- Object.defineProperty(target, propertyKey, {
15
- get() {
16
- if (!selector)
17
- return [this];
18
- let searchRoot = this;
19
- if (options.root === "shadow")
20
- searchRoot = this.shadowRoot || this;
21
- else if (options.root === "light")
22
- searchRoot = this;
23
- else
24
- searchRoot = this.shadowRoot || this;
25
- return searchRoot.querySelectorAll(selector);
26
- },
27
- enumerable: true,
28
- configurable: true
29
- });
30
- }
31
- };
32
- if (arg1 && typeof arg2 === "string") {
33
- return decorator("", {}, arg1, arg2);
34
- }
35
- return (target, propertyKey, descriptor) => {
36
- let selector = "";
37
- let options = {};
38
- if (typeof arg1 === "string") {
39
- selector = arg1;
40
- } else if (typeof arg1 === "object") {
41
- options = arg1;
42
- selector = options.selector || "";
43
- }
44
- decorator(selector, options, target, propertyKey, descriptor);
14
+ queries.push({ selector, options, propertyKey });
15
+ Object.defineProperty(target, propertyKey, {
16
+ get() {
17
+ if (!selector || selector === ":host")
18
+ return [this];
19
+ const r = options.root || "auto";
20
+ if (r === "shadow") {
21
+ return this.shadowRoot ? this.shadowRoot.querySelectorAll(selector) : [];
22
+ }
23
+ if (r === "light") {
24
+ return this.querySelectorAll(selector);
25
+ }
26
+ if (r === "all") {
27
+ const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
28
+ const lNodes = Array.from(this.querySelectorAll(selector));
29
+ return [...sNodes, ...lNodes];
30
+ }
31
+ const root = this.shadowRoot || this;
32
+ return root.querySelectorAll(selector);
33
+ },
34
+ enumerable: true,
35
+ configurable: true
36
+ });
45
37
  };
46
38
  }
47
39
  const getQueryAllMetadata = (target) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/queryAll.ts"],
4
- "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryAllOptions {\n selector?: string;\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryAllMetadata {\n selector: string;\n options: QueryAllOptions;\n propertyKey: string | symbol;\n isMethod: boolean;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');\n\nexport function queryAll(selector: string): any;\nexport function queryAll(options: QueryAllOptions): any;\nexport function queryAll(target: Object, propertyKey: string | symbol): void;\nexport function queryAll(arg1?: string | QueryAllOptions | Object, arg2?: string | symbol): any {\n const decorator = (selector: string, options: QueryAllOptions, target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n const isMethod = !!descriptor;\n const constructor = target.constructor;\n\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ selector, options, propertyKey, isMethod });\n\n if (!isMethod) {\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector) return [this];\n let searchRoot: Node = this;\n if (options.root === 'shadow') searchRoot = this.shadowRoot || this;\n else if (options.root === 'light') searchRoot = this;\n else searchRoot = this.shadowRoot || this; // Default: Auto (Shadow-First)\n\n return (searchRoot as HTMLElement).querySelectorAll(selector);\n },\n enumerable: true,\n configurable: true\n });\n }\n };\n\n // Case: @queryAll (parameterless decorator)\n if (arg1 && typeof arg2 === 'string') {\n return decorator('', {}, arg1 as Object, arg2 as string | symbol);\n }\n\n // Case: @queryAll('selector') or @queryAll({ selector: '...', ... })\n return (target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor) => {\n let selector = '';\n let options: QueryAllOptions = {};\n\n if (typeof arg1 === 'string') {\n selector = arg1;\n } else if (typeof arg1 === 'object') {\n options = arg1 as QueryAllOptions;\n selector = options.selector || '';\n }\n\n decorator(selector, options, target, propertyKey, descriptor);\n };\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n"],
5
- "mappings": "AAAA,SAAS,oBAAoB;AActB,MAAM,yBAAyB,OAAO,gCAAgC;AAKvE,SAAU,SAAS,MAA0C,MAAsB;AACvF,QAAM,YAAY,CAAC,UAAkB,SAA0B,QAAgB,aAA8B,eAAmC;AAC9I,UAAM,WAAW,CAAC,CAAC;AACnB,UAAM,cAAc,OAAO;AAE3B,QAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KAAK,EAAE,UAAU,SAAS,aAAa,SAAQ,CAAE;AAEzD,QAAI,CAAC,UAAU;AACb,aAAO,eAAe,QAAQ,aAAa;QACzC,MAAG;AACD,cAAI,CAAC;AAAU,mBAAO,CAAC,IAAI;AAC3B,cAAI,aAAmB;AACvB,cAAI,QAAQ,SAAS;AAAU,yBAAa,KAAK,cAAc;mBACtD,QAAQ,SAAS;AAAS,yBAAa;;AAC3C,yBAAa,KAAK,cAAc;AAErC,iBAAQ,WAA2B,iBAAiB,QAAQ;QAC9D;QACA,YAAY;QACZ,cAAc;OACf;IACH;EACF;AAGA,MAAI,QAAQ,OAAO,SAAS,UAAU;AACpC,WAAO,UAAU,IAAI,CAAA,GAAI,MAAgB,IAAuB;EAClE;AAGA,SAAO,CAAC,QAAgB,aAA8B,eAAmC;AACvF,QAAI,WAAW;AACf,QAAI,UAA2B,CAAA;AAE/B,QAAI,OAAO,SAAS,UAAU;AAC5B,iBAAW;IACb,WAAW,OAAO,SAAS,UAAU;AACnC,gBAAU;AACV,iBAAW,QAAQ,YAAY;IACjC;AAEA,cAAU,UAAU,SAAS,QAAQ,aAAa,UAAU;EAC9D;AACF;AAEO,MAAM,sBAAsB,CAAC,WAA+C;AACjF,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,wBAAwB,WAAW;AACrE;",
4
+ "sourcesContent": ["import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\n\nexport interface QueryAllOptions {\n root?: 'light' | 'shadow' | 'all' | 'auto';\n}\n\nexport interface QueryAllMetadata {\n selector: string;\n options: QueryAllOptions;\n propertyKey: string | symbol;\n}\n\nexport const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');\n\n/**\n * @queryAll decorator to inject a list of elements into a class property.\n * Usage: @queryAll('.items') list!: NodeListOf<HTMLElement>;\n * Usage: @queryAll('li', { root: 'shadow' }) list!: HTMLElement[];\n */\nexport function queryAll(selector: string, options: QueryAllOptions = {}): PropertyDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor?: never): void => {\n if (descriptor !== undefined) {\n throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);\n }\n\n const constructor = target.constructor;\n let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);\n if (!queries) {\n queries = [];\n ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);\n }\n queries.push({ selector, options, propertyKey });\n\n Object.defineProperty(target, propertyKey, {\n get(this: HTMLElement) {\n if (!selector || selector === ':host') return [this];\n const r = options.root || 'auto';\n\n if (r === 'shadow') {\n return this.shadowRoot ? this.shadowRoot.querySelectorAll(selector) : [];\n }\n if (r === 'light') {\n return this.querySelectorAll(selector);\n }\n if (r === 'all') {\n const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];\n const lNodes = Array.from(this.querySelectorAll(selector));\n return [...sNodes, ...lNodes];\n }\n // auto\n const root = this.shadowRoot || this;\n return root.querySelectorAll(selector);\n },\n enumerable: true,\n configurable: true\n });\n };\n}\n\nexport const getQueryAllMetadata = (target: any): QueryAllMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(QUERY_ALL_METADATA_KEY, constructor);\n};\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB;AAYtB,MAAM,yBAAyB,OAAO,gCAAgC;AAOvE,SAAU,SAAS,UAAkB,UAA2B,CAAA,GAAE;AACtE,SAAO,CAAC,QAAgB,aAA8B,eAA4B;AAChF,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,2DAA2D,OAAO,WAAW,CAAC,GAAG;IACnG;AAEA,UAAM,cAAc,OAAO;AAC3B,QAAI,UAAU,aAAa,YAAgC,wBAAwB,WAAW;AAC9F,QAAI,CAAC,SAAS;AACZ,gBAAU,CAAA;AACV,mBAAa,eAAe,wBAAwB,SAAS,WAAW;IAC1E;AACA,YAAQ,KAAK,EAAE,UAAU,SAAS,YAAW,CAAE;AAE/C,WAAO,eAAe,QAAQ,aAAa;MACzC,MAAG;AACD,YAAI,CAAC,YAAY,aAAa;AAAS,iBAAO,CAAC,IAAI;AACnD,cAAM,IAAI,QAAQ,QAAQ;AAE1B,YAAI,MAAM,UAAU;AAClB,iBAAO,KAAK,aAAa,KAAK,WAAW,iBAAiB,QAAQ,IAAI,CAAA;QACxE;AACA,YAAI,MAAM,SAAS;AACjB,iBAAO,KAAK,iBAAiB,QAAQ;QACvC;AACA,YAAI,MAAM,OAAO;AACf,gBAAM,SAAS,KAAK,aAAa,MAAM,KAAK,KAAK,WAAW,iBAAiB,QAAQ,CAAC,IAAI,CAAA;AAC1F,gBAAM,SAAS,MAAM,KAAK,KAAK,iBAAiB,QAAQ,CAAC;AACzD,iBAAO,CAAC,GAAG,QAAQ,GAAG,MAAM;QAC9B;AAEA,cAAM,OAAO,KAAK,cAAc;AAChC,eAAO,KAAK,iBAAiB,QAAQ;MACvC;MACA,YAAY;MACZ,cAAc;KACf;EACH;AACF;AAEO,MAAM,sBAAsB,CAAC,WAA+C;AACjF,QAAM,cAAc,kBAAkB,WAAW,SAAS,OAAO;AACjE,SAAO,aAAa,YAAY,wBAAwB,WAAW;AACrE;",
6
6
  "names": []
7
7
  }
package/dist/esm/types.js CHANGED
@@ -3,6 +3,7 @@ var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
3
3
  InjectSituationType2["APP_HOST"] = "SIMPLE_WEB_COMPONENT://APPHOST";
4
4
  InjectSituationType2["APP_HOSTS"] = "SIMPLE_WEB_COMPONENT://APPHOSTS";
5
5
  InjectSituationType2["HOST"] = "SIMPLE_WEB_COMPONENT://HOST";
6
+ InjectSituationType2["PARENT_HOST"] = "SIMPLE_WEB_COMPONENT://PARENTHOST";
6
7
  InjectSituationType2["HOSTS"] = "SIMPLE_WEB_COMPONENT://HOSTS";
7
8
  InjectSituationType2["FIRST_HOST"] = "SIMPLE_WEB_COMPONENT://FIRSTHOST";
8
9
  InjectSituationType2["LAST_HOST"] = "SIMPLE_WEB_COMPONENT://LASTHOST";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/types.ts"],
4
- "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type HostSet = {\n $host: HTMLElement | null;\n $hosts: HTMLElement[];\n $firstHost: HTMLElement | null;\n $lastHost: HTMLElement | null;\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n routing(path: string): Promise<void>;\n}\n"],
5
- "mappings": "AAGO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AATN,SAAAA;AAAA,GAAA;",
4
+ "sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';\nimport { Router } from '@dooboostore/core-web/routers/Router';\n\nexport enum InjectSituationType {\n HOST_SET = 'SIMPLE_WEB_COMPONENT://HOSTSET',\n APP_HOST = 'SIMPLE_WEB_COMPONENT://APPHOST',\n APP_HOSTS = 'SIMPLE_WEB_COMPONENT://APPHOSTS',\n HOST = 'SIMPLE_WEB_COMPONENT://HOST',\n PARENT_HOST = 'SIMPLE_WEB_COMPONENT://PARENTHOST',\n HOSTS = 'SIMPLE_WEB_COMPONENT://HOSTS',\n FIRST_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTHOST',\n LAST_HOST = 'SIMPLE_WEB_COMPONENT://LASTHOST',\n FIRST_APP_HOST = 'SIMPLE_WEB_COMPONENT://FIRSTAPPHOST',\n LAST_APP_HOST = 'SIMPLE_WEB_COMPONENT://LASTAPPHOST'\n}\n\nexport type HostSet = {\n $host: HTMLElement; // Current component itself\n $parentHost: HTMLElement | null; // Nearest parent SWC component\n $hosts: HTMLElement[]; // [self, parent, ..., top]\n $firstHost: HTMLElement | null; // Top-most SWC ancestor\n $lastHost: HTMLElement | null; // Same as $parentHost (for backward compatibility or clarity)\n $appHost: SwcAppInterface | null;\n $appHosts: SwcAppInterface[];\n $firstAppHost: SwcAppInterface | null;\n $lastAppHost: SwcAppInterface | null;\n};\n\nexport interface SwcAppInterface extends HTMLElement {\n simpleApplication?: SimpleApplication;\n router?: Router;\n routing(path: string): Promise<void>;\n}\n"],
5
+ "mappings": "AAGO,IAAK,sBAAL,kBAAKA,yBAAL;AACL,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,UAAO;AACP,EAAAA,qBAAA,iBAAc;AACd,EAAAA,qBAAA,WAAQ;AACR,EAAAA,qBAAA,gBAAa;AACb,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,mBAAgB;AAVN,SAAAA;AAAA,GAAA;",
6
6
  "names": ["InjectSituationType"]
7
7
  }
@@ -1,146 +1,42 @@
1
+ import { getElementConfig } from "../decorators/elementDefine.js";
1
2
  const SWC_NOT_FOUND = Symbol("SWC_NOT_FOUND");
2
3
  class SwcUtils {
3
4
  static getValueByPath(obj, path, rootName) {
4
5
  if (!obj || !path) return SWC_NOT_FOUND;
5
6
  const parts = path.split(".");
6
- if (parts[0] === rootName && parts.length > 1) {
7
- const subParts = parts.slice(1);
8
- let subResult = obj;
9
- for (const part of subParts) {
10
- if (subResult === null || typeof subResult !== "object" || !(part in subResult)) return SWC_NOT_FOUND;
11
- subResult = subResult[part];
12
- }
13
- return subResult;
14
- }
15
- let result = obj;
7
+ let current = obj;
16
8
  for (const part of parts) {
17
- if (result === null || typeof result !== "object" || !(part in result)) {
18
- return SWC_NOT_FOUND;
19
- }
20
- result = result[part];
21
- }
22
- if (result !== obj && !(result instanceof HTMLElement)) {
23
- return result;
9
+ if (current === null || current === void 0) return SWC_NOT_FOUND;
10
+ current = current[part];
24
11
  }
25
- return SWC_NOT_FOUND;
26
- }
27
- static evalExpression(expr, context) {
28
- try {
29
- const keys = Object.keys(context);
30
- const values = Object.values(context);
31
- return new Function(...keys, `return (${expr})`).apply(null, values);
32
- } catch {
33
- return SWC_NOT_FOUND;
34
- }
35
- }
36
- static applyData(node, data, options) {
37
- const { asKey, asIndexKey, index, hostContext } = options;
38
- const context = {};
39
- if (index !== void 0) {
40
- context[asIndexKey] = index;
41
- }
42
- if (data !== null && data !== void 0) {
43
- context[asKey] = data;
44
- context["value"] = data;
45
- }
46
- const fullContext = { ...hostContext || {}, ...context };
47
- const resolveExpr = (expr, match) => {
48
- expr = expr.trim();
49
- const simpleVal = SwcUtils.getValueByPath(data, expr, asKey);
50
- if (simpleVal !== SWC_NOT_FOUND && typeof simpleVal !== "symbol") {
51
- return simpleVal === null || simpleVal === void 0 ? "" : String(simpleVal);
52
- }
53
- const exprVal = SwcUtils.evalExpression(expr, fullContext);
54
- if (exprVal !== SWC_NOT_FOUND && typeof exprVal !== "symbol") {
55
- return exprVal === null || exprVal === void 0 ? "" : String(exprVal);
56
- }
57
- return match;
58
- };
59
- const walk = (n) => {
60
- if (n.nodeType === Node.TEXT_NODE) {
61
- if (!n._original) n._original = n.textContent;
62
- let text = n._original;
63
- text = text.replace(/{{(.*?)}}/g, (match, path) => {
64
- return resolveExpr(path, match);
65
- });
66
- if (n.textContent !== text) n.textContent = text;
67
- } else if (n.nodeType === Node.ELEMENT_NODE) {
68
- const el = n;
69
- Array.from(el.attributes).forEach((a) => {
70
- if (!a._original) a._original = a.value;
71
- let val = a._original;
72
- val = val.replace(/{{(.*?)}}/g, (match, path) => {
73
- return resolveExpr(path, match);
74
- });
75
- if (a.value !== val) a.value = val;
76
- });
77
- el.childNodes.forEach(walk);
78
- }
79
- };
80
- walk(node);
81
- }
82
- static createReactiveProxy(target, onChange, onIndexChange) {
83
- const makeRecursiveProxy = (obj) => {
84
- if (typeof obj !== "object" || obj === null || obj instanceof Node) return obj;
85
- if (obj.__swc_is_proxy) return obj;
86
- const IS_PROXY_KEY = "__swc_is_proxy";
87
- const proxy = new Proxy(obj, {
88
- get: (t, prop) => {
89
- if (prop === IS_PROXY_KEY) return true;
90
- if (typeof prop === "symbol") return t[prop];
91
- return t[prop];
92
- },
93
- set: (t, prop, val) => {
94
- if (prop === IS_PROXY_KEY) return true;
95
- if (typeof prop === "symbol") {
96
- t[prop] = val;
97
- return true;
98
- }
99
- const oldVal = t[prop];
100
- if (oldVal === val) return true;
101
- t[prop] = makeRecursiveProxy(val);
102
- const isIndex = !isNaN(Number(prop)) && Array.isArray(t);
103
- if (isIndex && onIndexChange) {
104
- onIndexChange(Number(prop), val);
105
- } else {
106
- onChange();
107
- }
108
- return true;
109
- },
110
- deleteProperty: (t, prop) => {
111
- delete t[prop];
112
- onChange();
113
- return true;
114
- }
115
- });
116
- return proxy;
117
- };
118
- return makeRecursiveProxy(target);
12
+ return current;
119
13
  }
120
14
  static findNearestSwcHost(el) {
121
- const hosts = this.findAllSwcHosts(el);
122
- return hosts.length > 0 ? hosts[hosts.length - 1] : null;
15
+ let current = el instanceof Node && !(el instanceof HTMLElement) ? el.host : el;
16
+ current = current?.parentElement || current?.getRootNode()?.host;
17
+ while (current) {
18
+ if (getElementConfig(current)) return current;
19
+ current = current.parentElement || current?.getRootNode()?.host;
20
+ }
21
+ return void 0;
123
22
  }
23
+ /**
24
+ * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.
25
+ */
124
26
  static findAllSwcHosts(el) {
125
27
  const hosts = [];
126
- let curr = el instanceof Node && !(el instanceof HTMLElement) ? el.host : el;
127
- curr = curr?.parentElement || curr?.getRootNode()?.host;
128
- while (curr) {
129
- if (curr._swcId) hosts.push(curr);
130
- curr = curr.parentElement || curr?.getRootNode()?.host;
28
+ let current = this.findNearestSwcHost(el);
29
+ while (current) {
30
+ hosts.push(current);
31
+ current = this.findNearestSwcHost(current);
131
32
  }
132
33
  return hosts.reverse();
133
34
  }
134
35
  static getHosts(el) {
135
- return this.findAllSwcHosts(el);
36
+ return [...this.findAllSwcHosts(el), el];
136
37
  }
137
38
  static getHost(el) {
138
- const hosts = this.getHosts(el);
139
- return hosts.length > 0 ? hosts[hosts.length - 1] : void 0;
140
- }
141
- static getFirstHost(el) {
142
- const hosts = this.getHosts(el);
143
- return hosts.length > 0 ? hosts[0] : void 0;
39
+ return el;
144
40
  }
145
41
  static getAppHosts(el) {
146
42
  const hosts = this.getHosts(el);
@@ -148,31 +44,28 @@ class SwcUtils {
148
44
  }
149
45
  static getAppHost(el) {
150
46
  const appHosts = this.getAppHosts(el);
151
- return appHosts.length > 0 ? appHosts[appHosts.length - 1] : void 0;
152
- }
153
- static getFirstAppHost(el) {
154
- const appHosts = this.getAppHosts(el);
155
- return appHosts.length > 0 ? appHosts[0] : void 0;
156
- }
157
- static getLastAppHost(el) {
158
- return this.getAppHost(el);
47
+ const appHostsWithoutSelf = appHosts.filter((h) => h !== el);
48
+ return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : void 0;
159
49
  }
160
50
  static getHostSet(el) {
161
- const $hosts = this.getHosts(el);
162
- const $appHosts = this.getAppHosts(el);
163
- const $firstHost = $hosts[0] || null;
164
- const $lastHost = $hosts[$hosts.length - 1] || null;
165
- const $firstAppHost = $appHosts[0] || null;
166
- const $lastAppHost = $appHosts[$appHosts.length - 1] || null;
51
+ const ancestors = this.findAllSwcHosts(el);
52
+ const $host = el;
53
+ const $hosts = [...ancestors, $host];
54
+ const $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;
55
+ const $firstHost = ancestors.length > 0 ? ancestors[0] : null;
56
+ const $appHosts = $hosts.filter((h) => h.tagName.toLowerCase() === "swc-app" || h.getAttribute("is")?.startsWith("swc-app-"));
57
+ const $appHost = $appHosts.length > 0 ? $appHosts[$appHosts.length - 1] === el ? $appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null : $appHosts[$appHosts.length - 1] : null;
58
+ const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;
167
59
  return {
168
- $host: $lastHost,
60
+ $host,
61
+ $parentHost,
169
62
  $hosts,
170
63
  $firstHost,
171
- $lastHost,
172
- $appHost: $lastAppHost,
64
+ $lastHost: $parentHost,
65
+ $appHost,
173
66
  $appHosts,
174
67
  $firstAppHost,
175
- $lastAppHost
68
+ $lastAppHost: $appHost
176
69
  };
177
70
  }
178
71
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/utils/Utils.ts"],
4
- "sourcesContent": ["import {HostSet, SwcAppInterface} from '../types';\n\nexport const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');\n\nexport class SwcUtils {\n static getValueByPath(obj: any, path: string, rootName: string) {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n\n // 1. If the path starts with the rootName (alias), strip it and resolve within obj\n if (parts[0] === rootName && parts.length > 1) {\n const subParts = parts.slice(1);\n let subResult = obj;\n for (const part of subParts) {\n if (subResult === null || typeof subResult !== 'object' || !(part in subResult)) return SWC_NOT_FOUND;\n subResult = subResult[part];\n }\n return subResult;\n }\n\n // 2. Fallback: resolve directly on obj (standard behavior)\n let result = obj;\n for (const part of parts) {\n if (result === null || typeof result !== 'object' || !(part in result)) {\n return SWC_NOT_FOUND;\n }\n result = result[part];\n }\n\n // Safety: don't return the instance itself or a DOM element as a template value\n if (result !== obj && !(result instanceof HTMLElement)) {\n return result;\n }\n\n return SWC_NOT_FOUND;\n }\n\n static evalExpression(expr: string, context: Record<string, any>): any {\n try {\n const keys = Object.keys(context);\n const values = Object.values(context);\n // eslint-disable-next-line no-new-func\n return new Function(...keys, `return (${expr})`).apply(null, values);\n } catch {\n return SWC_NOT_FOUND;\n }\n }\n\n static applyData(\n node: Node,\n data: any,\n options: {\n asKey: string;\n asIndexKey: string;\n index?: number;\n hostContext?: Record<string, any>;\n }\n ) {\n const { asKey, asIndexKey, index, hostContext } = options;\n const context: Record<string, any> = {};\n if (index !== undefined) {\n context[asIndexKey] = index;\n }\n if (data !== null && data !== undefined) {\n context[asKey] = data;\n context['value'] = data; // Always provide 'value' as well\n }\n const fullContext: Record<string, any> = { ...(hostContext || {}), ...context };\n\n const resolveExpr = (expr: string, match: string): string => {\n expr = expr.trim();\n // 1. Local path resolve\n const simpleVal = SwcUtils.getValueByPath(data, expr, asKey);\n if (simpleVal !== SWC_NOT_FOUND && typeof simpleVal !== 'symbol') {\n return simpleVal === null || simpleVal === undefined ? '' : String(simpleVal);\n }\n // 2. Full context eval (alias, host states, etc.)\n const exprVal = SwcUtils.evalExpression(expr, fullContext);\n if (exprVal !== SWC_NOT_FOUND && typeof exprVal !== 'symbol') {\n return exprVal === null || exprVal === undefined ? '' : String(exprVal);\n }\n return match;\n };\n\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) {\n if (!(n as any)._original) (n as any)._original = n.textContent;\n let text = (n as any)._original;\n text = text.replace(/{{(.*?)}}/g, (match: string, path: string) => {\n return resolveExpr(path, match);\n });\n if (n.textContent !== text) n.textContent = text;\n } else if (n.nodeType === Node.ELEMENT_NODE) {\n const el = n as HTMLElement;\n Array.from(el.attributes).forEach(a => {\n if (!(a as any)._original) (a as any)._original = a.value;\n let val = (a as any)._original;\n val = val.replace(/{{(.*?)}}/g, (match: string, path: string) => {\n return resolveExpr(path, match);\n });\n if (a.value !== val) a.value = val;\n });\n el.childNodes.forEach(walk);\n }\n };\n walk(node);\n }\n\n static createReactiveProxy(target: any, onChange: () => void, onIndexChange?: (index: number, val: any) => void) {\n const makeRecursiveProxy = (obj: any): any => {\n if (typeof obj !== 'object' || obj === null || obj instanceof Node) return obj;\n if ((obj as any).__swc_is_proxy) return obj;\n\n const IS_PROXY_KEY = '__swc_is_proxy';\n\n const proxy = new Proxy(obj, {\n get: (t, prop) => {\n if (prop === IS_PROXY_KEY) return true;\n if (typeof prop === 'symbol') return t[prop];\n return t[prop];\n },\n set: (t, prop, val) => {\n if (prop === IS_PROXY_KEY) return true;\n if (typeof prop === 'symbol') {\n t[prop] = val;\n return true;\n }\n const oldVal = t[prop];\n if (oldVal === val) return true;\n t[prop] = makeRecursiveProxy(val);\n const isIndex = !isNaN(Number(prop)) && Array.isArray(t);\n if (isIndex && onIndexChange) {\n onIndexChange(Number(prop), val);\n } else {\n onChange();\n }\n return true;\n },\n deleteProperty: (t, prop) => {\n delete t[prop];\n onChange();\n return true;\n }\n });\n return proxy;\n };\n\n return makeRecursiveProxy(target);\n }\n\n static findNearestSwcHost(el: HTMLElement | Node): any {\n const hosts = this.findAllSwcHosts(el);\n return hosts.length > 0 ? hosts[hosts.length - 1] : null;\n }\n\n static findAllSwcHosts(el: HTMLElement | Node): any[] {\n const hosts: any[] = [];\n let curr: any = el instanceof Node && !(el instanceof HTMLElement) ? (el as any).host : el;\n curr = curr?.parentElement || (curr?.getRootNode() as any)?.host;\n\n while (curr) {\n if (curr._swcId) hosts.push(curr);\n curr = curr.parentElement || (curr?.getRootNode() as any)?.host;\n }\n return hosts.reverse();\n }\n\n static getHosts(el: HTMLElement): HTMLElement[] {\n return this.findAllSwcHosts(el);\n }\n\n static getHost(el: HTMLElement): HTMLElement | undefined {\n const hosts = this.getHosts(el);\n return hosts.length > 0 ? hosts[hosts.length - 1] : undefined;\n }\n\n static getFirstHost(el: HTMLElement): HTMLElement | undefined {\n const hosts = this.getHosts(el);\n return hosts.length > 0 ? hosts[0] : undefined;\n }\n\n static getAppHosts(el: HTMLElement): SwcAppInterface[] {\n const hosts = this.getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n }\n\n static getAppHost(el: HTMLElement): SwcAppInterface | undefined {\n const appHosts = this.getAppHosts(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : undefined;\n }\n\n static getFirstAppHost(el: HTMLElement): SwcAppInterface | undefined {\n const appHosts = this.getAppHosts(el);\n return appHosts.length > 0 ? appHosts[0] : undefined;\n }\n\n static getLastAppHost(el: HTMLElement): SwcAppInterface | undefined {\n return this.getAppHost(el);\n }\n\n static getHostSet(el: HTMLElement): HostSet {\n const $hosts = this.getHosts(el);\n const $appHosts = this.getAppHosts(el);\n\n const $firstHost = $hosts[0] || null;\n const $lastHost = $hosts[$hosts.length - 1] || null;\n\n const $firstAppHost = $appHosts[0] || null;\n const $lastAppHost = $appHosts[$appHosts.length - 1] || null;\n\n return {\n $host: $lastHost,\n $hosts,\n $firstHost,\n $lastHost,\n $appHost: $lastAppHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost\n };\n }\n}\n"],
5
- "mappings": "AAEO,MAAM,gBAAgB,OAAO,eAAe;AAE5C,MAAM,SAAS;AAAA,EACpB,OAAO,eAAe,KAAU,MAAc,UAAkB;AAC9D,QAAI,CAAC,OAAO,CAAC,KA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WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { SwcAppInterface, HostSet } from '../types';\nimport { getElementConfig } from '../decorators/elementDefine';\n\nexport const SWC_NOT_FOUND = Symbol('SWC_NOT_FOUND');\n\nexport class SwcUtils {\n static getValueByPath(obj: any, path: string, rootName: string) {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n }\n\n static findNearestSwcHost(el: HTMLElement | Node): HTMLElement | undefined {\n let current: any = el instanceof Node && !(el instanceof HTMLElement) ? (el as any).host : el;\n current = current?.parentElement || (current?.getRootNode() as any)?.host;\n\n while (current) {\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current?.getRootNode() as any)?.host;\n }\n return undefined;\n }\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n static findAllSwcHosts(el: HTMLElement | Node): HTMLElement[] {\n const hosts: HTMLElement[] = [];\n let current = this.findNearestSwcHost(el);\n while (current) {\n hosts.push(current);\n current = this.findNearestSwcHost(current);\n }\n return hosts.reverse();\n }\n\n static getHosts(el: HTMLElement): HTMLElement[] {\n return [...this.findAllSwcHosts(el), el];\n }\n\n static getHost(el: HTMLElement): HTMLElement | undefined {\n return el;\n }\n\n static getAppHosts(el: HTMLElement): SwcAppInterface[] {\n const hosts = this.getHosts(el);\n return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n }\n\n static getAppHost(el: HTMLElement): SwcAppInterface | undefined {\n const appHosts = this.getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n // Nearest app host is the last one in [root, ..., parent]\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n }\n\n static getHostSet(el: HTMLElement): HostSet {\n const ancestors = this.findAllSwcHosts(el); // [root, ..., parent]\n const $host = el;\n const $hosts = [...ancestors, $host]; // [root, ..., parent, self]\n const $parentHost = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n const $firstHost = ancestors.length > 0 ? ancestors[0] : null;\n\n const $appHosts = $hosts.filter(h => h.tagName.toLowerCase() === 'swc-app' || h.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $parentHost,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost\n };\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,wBAAwB;AAE1B,MAAM,gBAAgB,OAAO,eAAe;AAE5C,MAAM,SAAS;AAAA,EACpB,OAAO,eAAe,KAAU,MAAc,UAAkB;AAC9D,QAAI,CAAC,OAAO,CAAC,KAAM,QAAO;AAE1B,UAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,QAAI,UAAU;AAEd,eAAW,QAAQ,OAAO;AACxB,UAAI,YAAY,QAAQ,YAAY,OAAW,QAAO;AACtD,gBAAU,QAAQ,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,mBAAmB,IAAiD;AACzE,QAAI,UAAe,cAAc,QAAQ,EAAE,cAAc,eAAgB,GAAW,OAAO;AAC3F,cAAU,SAAS,iBAAkB,SAAS,YAAY,GAAW;AAErE,WAAO,SAAS;AACd,UAAI,iBAAiB,OAAO,EAAG,QAAO;AACtC,gBAAU,QAAQ,iBAAkB,SAAS,YAAY,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