@dooboostore/simple-web-component 1.0.15 → 1.0.17

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 (108) hide show
  1. package/README.md +275 -91
  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 +161 -34
  5. package/dist/cjs/decorators/elementDefine.js.map +3 -3
  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 +47 -36
  9. package/dist/cjs/decorators/query.js.map +2 -2
  10. package/dist/cjs/decorators/queryAll.js +42 -36
  11. package/dist/cjs/decorators/queryAll.js.map +2 -2
  12. package/dist/cjs/elements/SwcAppEngine.js +2 -1
  13. package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
  14. package/dist/cjs/elements/SwcAsync.js +188 -0
  15. package/dist/cjs/elements/SwcAsync.js.map +7 -0
  16. package/dist/cjs/elements/SwcChoose.js +155 -0
  17. package/dist/cjs/elements/SwcChoose.js.map +7 -0
  18. package/dist/cjs/elements/SwcIf.js +167 -0
  19. package/dist/cjs/elements/SwcIf.js.map +7 -0
  20. package/dist/cjs/elements/SwcLoop.js +246 -0
  21. package/dist/cjs/elements/SwcLoop.js.map +7 -0
  22. package/dist/cjs/elements/SwcSubTemplates.js +65 -0
  23. package/dist/cjs/elements/SwcSubTemplates.js.map +7 -0
  24. package/dist/cjs/elements/index.js +7 -0
  25. package/dist/cjs/elements/index.js.map +2 -2
  26. package/dist/cjs/index.js +1 -1
  27. package/dist/cjs/index.js.map +2 -2
  28. package/dist/cjs/types.js +1 -0
  29. package/dist/cjs/types.js.map +2 -2
  30. package/dist/cjs/utils/Utils.js +92 -162
  31. package/dist/cjs/utils/Utils.js.map +3 -3
  32. package/dist/esm/decorators/addEventListener.js +2 -3
  33. package/dist/esm/decorators/addEventListener.js.map +2 -2
  34. package/dist/esm/decorators/elementDefine.js +161 -34
  35. package/dist/esm/decorators/elementDefine.js.map +3 -3
  36. package/dist/esm/decorators/emitCustomEvent.js +2 -14
  37. package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
  38. package/dist/esm/decorators/query.js +47 -36
  39. package/dist/esm/decorators/query.js.map +2 -2
  40. package/dist/esm/decorators/queryAll.js +42 -36
  41. package/dist/esm/decorators/queryAll.js.map +2 -2
  42. package/dist/esm/elements/SwcAppEngine.js +2 -1
  43. package/dist/esm/elements/SwcAppEngine.js.map +2 -2
  44. package/dist/esm/elements/SwcAsync.js +169 -0
  45. package/dist/esm/elements/SwcAsync.js.map +7 -0
  46. package/dist/esm/elements/SwcChoose.js +136 -0
  47. package/dist/esm/elements/SwcChoose.js.map +7 -0
  48. package/dist/esm/elements/SwcIf.js +148 -0
  49. package/dist/esm/elements/SwcIf.js.map +7 -0
  50. package/dist/esm/elements/SwcLoop.js +227 -0
  51. package/dist/esm/elements/SwcLoop.js.map +7 -0
  52. package/dist/esm/elements/SwcSubTemplates.js +46 -0
  53. package/dist/esm/elements/SwcSubTemplates.js.map +7 -0
  54. package/dist/esm/elements/index.js +7 -0
  55. package/dist/esm/elements/index.js.map +2 -2
  56. package/dist/esm/index.js +1 -1
  57. package/dist/esm/index.js.map +1 -1
  58. package/dist/esm/types.js +1 -0
  59. package/dist/esm/types.js.map +2 -2
  60. package/dist/esm/utils/Utils.js +92 -162
  61. package/dist/esm/utils/Utils.js.map +3 -3
  62. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1150 -326
  63. package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
  64. package/dist/types/decorators/addEventListener.d.ts +10 -4
  65. package/dist/types/decorators/addEventListener.d.ts.map +1 -1
  66. package/dist/types/decorators/elementDefine.d.ts.map +1 -1
  67. package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
  68. package/dist/types/decorators/query.d.ts +4 -5
  69. package/dist/types/decorators/query.d.ts.map +1 -1
  70. package/dist/types/decorators/queryAll.d.ts +4 -5
  71. package/dist/types/decorators/queryAll.d.ts.map +1 -1
  72. package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
  73. package/dist/types/elements/SwcAsync.d.ts +16 -0
  74. package/dist/types/elements/SwcAsync.d.ts.map +1 -0
  75. package/dist/types/elements/SwcChoose.d.ts +13 -0
  76. package/dist/types/elements/SwcChoose.d.ts.map +1 -0
  77. package/dist/types/elements/SwcIf.d.ts +15 -0
  78. package/dist/types/elements/SwcIf.d.ts.map +1 -0
  79. package/dist/types/elements/SwcLoop.d.ts +20 -0
  80. package/dist/types/elements/SwcLoop.d.ts.map +1 -0
  81. package/dist/types/elements/SwcSubTemplates.d.ts +13 -0
  82. package/dist/types/elements/SwcSubTemplates.d.ts.map +1 -0
  83. package/dist/types/elements/index.d.ts +7 -0
  84. package/dist/types/elements/index.d.ts.map +1 -1
  85. package/dist/types/index.d.ts +1 -1
  86. package/dist/types/index.d.ts.map +1 -1
  87. package/dist/types/types.d.ts +11 -1
  88. package/dist/types/types.d.ts.map +1 -1
  89. package/dist/types/utils/Utils.d.ts +19 -21
  90. package/dist/types/utils/Utils.d.ts.map +1 -1
  91. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1150 -326
  92. package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
  93. package/package.json +10 -3
  94. package/src/decorators/addEventListener.ts +11 -7
  95. package/src/decorators/elementDefine.ts +165 -39
  96. package/src/decorators/emitCustomEvent.ts +5 -21
  97. package/src/decorators/query.ts +46 -41
  98. package/src/decorators/queryAll.ts +45 -41
  99. package/src/elements/SwcAppEngine.ts +2 -1
  100. package/src/elements/SwcAsync.ts +163 -0
  101. package/src/elements/SwcChoose.ts +127 -0
  102. package/src/elements/SwcIf.ts +134 -0
  103. package/src/elements/SwcLoop.ts +215 -0
  104. package/src/elements/SwcSubTemplates.ts +19 -0
  105. package/src/elements/index.ts +8 -3
  106. package/src/index.ts +1 -1
  107. package/src/types.ts +15 -5
  108. package/src/utils/Utils.ts +111 -197
@@ -0,0 +1,148 @@
1
+ var __decorate = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = function(k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { elementDefine } from "../decorators/elementDefine.js";
11
+ import { changedAttribute } from "../decorators/changedAttribute.js";
12
+ import { SwcUtils } from "../utils/Utils.js";
13
+ import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
14
+ let SwcIf = class SwcIf2 extends HTMLTemplateElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this._nodes = [];
18
+ this._value = null;
19
+ }
20
+ get value() {
21
+ return this._value;
22
+ }
23
+ set value(nv) {
24
+ this._value = nv;
25
+ this.render();
26
+ }
27
+ _getTarget() {
28
+ const script = this.getAttribute("on-get-portal");
29
+ if (!script)
30
+ return null;
31
+ try {
32
+ const res = FunctionUtils.executeReturn({
33
+ script,
34
+ context: this,
35
+ args: SwcUtils.getHelperAndHostSet(window, this)
36
+ });
37
+ if (typeof res === "string")
38
+ return document.querySelector(res);
39
+ if (res instanceof Node)
40
+ return res;
41
+ } catch (e) {
42
+ console.error("[SwcIf] Portal target error:", e);
43
+ }
44
+ return null;
45
+ }
46
+ _executeCallback(attrName, extraArgs) {
47
+ const script = this.getAttribute(attrName);
48
+ if (!script)
49
+ return;
50
+ const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);
51
+ try {
52
+ FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });
53
+ } catch (e) {
54
+ console.error(`[SwcIf] Error in ${attrName}:`, e);
55
+ }
56
+ }
57
+ refresh(newValue) {
58
+ const script = newValue !== void 0 ? newValue : this.getAttribute("on-get-value");
59
+ if (!script) {
60
+ this.value = null;
61
+ return;
62
+ }
63
+ if (!this.parentElement)
64
+ return;
65
+ const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);
66
+ try {
67
+ const result = FunctionUtils.executeReturn({
68
+ script,
69
+ context: this,
70
+ args: helperHostSet
71
+ });
72
+ this.value = result;
73
+ } catch (e) {
74
+ console.error("[SwcIf] Error in on-get-value:", e);
75
+ this.value = null;
76
+ }
77
+ }
78
+ render() {
79
+ this.cleanup();
80
+ if (!this.parentElement)
81
+ return;
82
+ let fragment = null;
83
+ const ctx = { $value: this._value, $nodes: [], $elements: [] };
84
+ if (this._value) {
85
+ const clone = this.content.cloneNode(true);
86
+ Array.from(clone.querySelectorAll('template[is="swc-default"]')).forEach((t) => t.remove());
87
+ fragment = clone;
88
+ } else {
89
+ const t = this.content.querySelector('template[is="swc-default"]');
90
+ if (t)
91
+ fragment = t.content.cloneNode(true);
92
+ }
93
+ if (fragment) {
94
+ this.mount(fragment, ctx);
95
+ }
96
+ }
97
+ mount(fragment, ctx) {
98
+ const nodes = Array.from(fragment.childNodes);
99
+ const elements = nodes.filter((n) => n.nodeType === 1);
100
+ Object.assign(ctx, {
101
+ $nodes: nodes,
102
+ $elements: elements,
103
+ $firstNode: nodes[0],
104
+ $lastNode: nodes[nodes.length - 1],
105
+ $firstElement: elements[0],
106
+ $lastElement: elements[elements.length - 1]
107
+ });
108
+ this._executeCallback("on-clone-nodes", ctx);
109
+ nodes.forEach((node, nodeIndex) => {
110
+ if (node instanceof HTMLElement)
111
+ node.__swc_host = this;
112
+ this._executeCallback("on-clone-node", { ...ctx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });
113
+ });
114
+ this._nodes = nodes;
115
+ const target = this._getTarget();
116
+ if (target) {
117
+ target.appendChild(fragment);
118
+ } else {
119
+ this.parentElement?.insertBefore(fragment, this.nextSibling);
120
+ }
121
+ }
122
+ cleanup() {
123
+ this._nodes.forEach((n) => {
124
+ if (n.parentElement)
125
+ n.parentElement.removeChild(n);
126
+ });
127
+ this._nodes = [];
128
+ }
129
+ connectedCallback() {
130
+ this.refresh();
131
+ }
132
+ disconnectedCallback() {
133
+ this.cleanup();
134
+ }
135
+ };
136
+ __decorate([
137
+ changedAttribute("on-get-value"),
138
+ __metadata("design:type", Function),
139
+ __metadata("design:paramtypes", [String]),
140
+ __metadata("design:returntype", void 0)
141
+ ], SwcIf.prototype, "refresh", null);
142
+ SwcIf = __decorate([
143
+ elementDefine({ name: "swc-if", extends: "template" })
144
+ ], SwcIf);
145
+ export {
146
+ SwcIf
147
+ };
148
+ //# sourceMappingURL=SwcIf.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/elements/SwcIf.ts"],
4
+ "sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\nimport { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\n@elementDefine({ name: 'swc-if', extends: 'template' })\nexport class SwcIf extends HTMLTemplateElement {\n private _nodes: Node[] = [];\n private _value: any = null;\n\n get value(): any {\n return this._value;\n }\n\n set value(nv: any) {\n this._value = nv;\n this.render();\n }\n\n private _getTarget(): Element | DocumentFragment | null {\n const script = this.getAttribute('on-get-portal');\n if (!script) return null;\n try {\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(window, this)\n });\n if (typeof res === 'string') return document.querySelector(res);\n if (res instanceof Node) return res as any;\n } catch (e) {\n console.error('[SwcIf] Portal target error:', e);\n }\n return null;\n }\n\n private _executeCallback(attrName: string, extraArgs: Record<string, any>) {\n const script = this.getAttribute(attrName);\n if (!script) return;\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });\n } catch (e) {\n console.error(`[SwcIf] Error in ${attrName}:`, e);\n }\n }\n\n @changedAttribute('on-get-value')\n private refresh(newValue?: string | null) {\n const script = newValue !== undefined ? newValue : this.getAttribute('on-get-value');\n if (!script) {\n this.value = null;\n return;\n }\n if (!this.parentElement) return;\n\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n const result = FunctionUtils.executeReturn({\n script,\n context: this,\n args: helperHostSet\n });\n this.value = result;\n } catch (e) {\n console.error('[SwcIf] Error in on-get-value:', e);\n this.value = null;\n }\n }\n\n private render() {\n this.cleanup();\n if (!this.parentElement) return;\n\n let fragment: DocumentFragment | null = null;\n const ctx: any = { $value: this._value, $nodes: [], $elements: [] };\n\n if (this._value) {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n Array.from(clone.querySelectorAll('template[is=\"swc-default\"]')).forEach(t => t.remove());\n fragment = clone;\n } else {\n const t = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (t) fragment = t.content.cloneNode(true) as DocumentFragment;\n }\n\n if (fragment) {\n this.mount(fragment, ctx);\n }\n }\n\n private mount(fragment: DocumentFragment, ctx: any) {\n const nodes = Array.from(fragment.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n Object.assign(ctx, {\n $nodes: nodes,\n $elements: elements,\n $firstNode: nodes[0],\n $lastNode: nodes[nodes.length - 1],\n $firstElement: elements[0],\n $lastElement: elements[elements.length - 1]\n });\n\n this._executeCallback('on-clone-nodes', ctx);\n nodes.forEach((node, nodeIndex) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCallback('on-clone-node', { ...ctx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });\n });\n\n this._nodes = nodes;\n const target = this._getTarget();\n if (target) {\n target.appendChild(fragment);\n } else {\n this.parentElement?.insertBefore(fragment, this.nextSibling);\n }\n }\n\n private cleanup() {\n this._nodes.forEach(n => {\n if (n.parentElement) n.parentElement.removeChild(n);\n });\n this._nodes = [];\n }\n\n connectedCallback() {\n this.refresh();\n }\n\n disconnectedCallback() {\n this.cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAGvB,IAAM,QAAN,MAAMA,eAAc,oBAAmB;EAAvC,cAAA;;AACG,SAAA,SAAiB,CAAA;AACjB,SAAA,SAAc;EA6HxB;EA3HE,IAAI,QAAK;AACP,WAAO,KAAK;EACd;EAEA,IAAI,MAAM,IAAO;AACf,SAAK,SAAS;AACd,SAAK,OAAM;EACb;EAEQ,aAAU;AAChB,UAAM,SAAS,KAAK,aAAa,eAAe;AAChD,QAAI,CAAC;AAAQ,aAAO;AACpB,QAAI;AACF,YAAM,MAAM,cAAc,cAAc;QACtC;QACA,SAAS;QACT,MAAM,SAAS,oBAAoB,QAAQ,IAAI;OAChD;AACD,UAAI,OAAO,QAAQ;AAAU,eAAO,SAAS,cAAc,GAAG;AAC9D,UAAI,eAAe;AAAM,eAAO;IAClC,SAAS,GAAG;AACV,cAAQ,MAAM,gCAAgC,CAAC;IACjD;AACA,WAAO;EACT;EAEQ,iBAAiB,UAAkB,WAA8B;AACvE,UAAM,SAAS,KAAK,aAAa,QAAQ;AACzC,QAAI,CAAC;AAAQ;AACb,UAAM,gBAAgB,SAAS,oBAAoB,QAAQ,IAAI;AAC/D,QAAI;AACF,oBAAc,QAAQ,EAAE,QAAQ,SAAS,MAAM,MAAM,EAAE,GAAG,eAAe,GAAG,UAAS,EAAE,CAAE;IAC3F,SAAS,GAAG;AACV,cAAQ,MAAM,oBAAoB,QAAQ,KAAK,CAAC;IAClD;EACF;EAGQ,QAAQ,UAAwB;AACtC,UAAM,SAAS,aAAa,SAAY,WAAW,KAAK,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AC5D,WAAK,iBAAiB,iBAAiB,EAAE,GAAG,KAAK,OAAO,MAAM,YAAY,WAAW,YAAY,KAAK,aAAa,EAAC,CAAE;IACxH,CAAC;AAED,SAAK,SAAS;AACd,UAAM,SAAS,KAAK,WAAU;AAC9B,QAAI,QAAQ;AACV,aAAO,YAAY,QAAQ;IAC7B,OAAO;AACL,WAAK,eAAe,aAAa,UAAU,KAAK,WAAW;IAC7D;EACF;EAEQ,UAAO;AACb,SAAK,OAAO,QAAQ,OAAI;AACtB,UAAI,EAAE;AAAe,UAAE,cAAc,YAAY,CAAC;IACpD,CAAC;AACD,SAAK,SAAS,CAAA;EAChB;EAEA,oBAAiB;AACf,SAAK,QAAO;EACd;EAEA,uBAAoB;AAClB,SAAK,QAAO;EACd;;AApFQ,WAAA;EADP,iBAAiB,cAAc;;;;;AAzCrB,QAAK,WAAA;EADjB,cAAc,EAAE,MAAM,UAAU,SAAS,WAAU,CAAE;GACzC,KAAK;",
6
+ "names": ["SwcIf"]
7
+ }
@@ -0,0 +1,227 @@
1
+ var __decorate = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = function(k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { elementDefine } from "../decorators/elementDefine.js";
11
+ import { changedAttribute } from "../decorators/changedAttribute.js";
12
+ import { SwcUtils } from "../utils/Utils.js";
13
+ import { FunctionUtils } from "@dooboostore/core/function/FunctionUtils";
14
+ let SwcLoop = class SwcLoop2 extends HTMLTemplateElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this._value = [];
18
+ this._nodes = [];
19
+ this._defaultNodes = [];
20
+ }
21
+ get value() {
22
+ return this._value;
23
+ }
24
+ set value(nv) {
25
+ this._value = Array.isArray(nv) ? [...nv] : [];
26
+ this.render();
27
+ }
28
+ getNodes(index) {
29
+ return this._nodes[index] || null;
30
+ }
31
+ _getTarget() {
32
+ const script = this.getAttribute("on-get-portal");
33
+ if (!script)
34
+ return null;
35
+ try {
36
+ const res = FunctionUtils.executeReturn({
37
+ script,
38
+ context: this,
39
+ args: SwcUtils.getHelperAndHostSet(window, this)
40
+ });
41
+ if (typeof res === "string")
42
+ return document.querySelector(res);
43
+ if (res instanceof Node)
44
+ return res;
45
+ } catch (e) {
46
+ console.error("[SwcLoop] Portal target error:", e);
47
+ }
48
+ return null;
49
+ }
50
+ append(...items) {
51
+ if (!items.length || !this.parentElement)
52
+ return;
53
+ if (this._defaultNodes.length > 0)
54
+ this._cleanupDefault();
55
+ const fragment = document.createDocumentFragment();
56
+ const startIndex = this._value.length;
57
+ items.forEach((item, i) => {
58
+ const index = startIndex + i;
59
+ const nodes = this._createItemNodes(item, index);
60
+ if (nodes) {
61
+ this._nodes.push(nodes);
62
+ nodes.forEach((n) => fragment.appendChild(n));
63
+ this._value.push(item);
64
+ } else {
65
+ this._nodes.push(null);
66
+ this._value.push(null);
67
+ }
68
+ });
69
+ const target = this._getTarget();
70
+ if (target) {
71
+ target.appendChild(fragment);
72
+ } else {
73
+ const lastValidIdx = this._nodes.length - items.length - 1;
74
+ let refNode = this;
75
+ for (let i = lastValidIdx; i >= 0; i--) {
76
+ const group = this._nodes[i];
77
+ if (group && group.length > 0) {
78
+ refNode = group[group.length - 1];
79
+ break;
80
+ }
81
+ }
82
+ this.parentElement.insertBefore(fragment, refNode.nextSibling);
83
+ }
84
+ }
85
+ remove(index) {
86
+ const targetIdx = index !== void 0 ? index : this._nodes.length - 1;
87
+ if (targetIdx < 0 || targetIdx >= this._nodes.length)
88
+ return;
89
+ const nodes = this._nodes[targetIdx];
90
+ if (nodes) {
91
+ nodes.forEach((n) => {
92
+ if (n.parentElement)
93
+ n.parentElement.removeChild(n);
94
+ });
95
+ this._nodes[targetIdx] = null;
96
+ this._value[targetIdx] = null;
97
+ }
98
+ const activeRows = this._value.filter((v) => v !== null);
99
+ if (activeRows.length === 0) {
100
+ this.render();
101
+ }
102
+ }
103
+ _createItemNodes(item, index) {
104
+ const clone = this.content.cloneNode(true);
105
+ Array.from(clone.querySelectorAll('template[is="swc-default"]')).forEach((t) => t.remove());
106
+ const nodes = Array.from(clone.childNodes);
107
+ const elements = nodes.filter((n) => n.nodeType === 1);
108
+ const groupCtx = {
109
+ $index: index,
110
+ $item: item,
111
+ $nodes: nodes,
112
+ $elements: elements,
113
+ $firstNode: nodes[0],
114
+ $lastNode: nodes[nodes.length - 1],
115
+ $firstElement: elements[0],
116
+ $lastElement: elements[elements.length - 1],
117
+ $isFirst: index === 0,
118
+ $isLast: index === this._value.length - 1,
119
+ $isEven: index % 2 === 0,
120
+ $isOdd: index % 2 !== 0,
121
+ $count: this._value.length
122
+ };
123
+ this._executeCallback("on-clone-nodes", groupCtx);
124
+ nodes.forEach((node, nodeIndex) => {
125
+ if (node instanceof HTMLElement)
126
+ node.__swc_host = this;
127
+ this._executeCallback("on-clone-node", { ...groupCtx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });
128
+ });
129
+ return nodes;
130
+ }
131
+ _executeCallback(attrName, extraArgs) {
132
+ const script = this.getAttribute(attrName);
133
+ if (!script)
134
+ return;
135
+ const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);
136
+ try {
137
+ FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });
138
+ } catch (e) {
139
+ console.error(`[SwcLoop] Error in ${attrName}:`, e);
140
+ }
141
+ }
142
+ refreshValue(newValue) {
143
+ const script = newValue !== void 0 ? newValue : this.getAttribute("on-get-value");
144
+ if (!script) {
145
+ this.value = [];
146
+ return;
147
+ }
148
+ const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);
149
+ try {
150
+ const res = FunctionUtils.executeReturn({ script, context: this, args: helperHostSet });
151
+ if (Array.isArray(res)) {
152
+ this.value = res;
153
+ }
154
+ } catch (e) {
155
+ console.error("[SwcLoop] Failed to get value from on-get-value script:", e);
156
+ this.value = [];
157
+ }
158
+ }
159
+ render() {
160
+ this._cleanup();
161
+ if (!this.parentElement)
162
+ return;
163
+ const activeRows = this._value.filter((v) => v !== null);
164
+ const target = this._getTarget();
165
+ if (activeRows.length === 0) {
166
+ const t = this.content.querySelector('template[is="swc-default"]');
167
+ if (t) {
168
+ const clone = t.content.cloneNode(true);
169
+ this._defaultNodes = Array.from(clone.childNodes);
170
+ this._defaultNodes.forEach((n) => {
171
+ if (n instanceof HTMLElement)
172
+ n.__swc_host = this;
173
+ });
174
+ if (target)
175
+ target.appendChild(clone);
176
+ else
177
+ this.parentElement.insertBefore(clone, this.nextSibling);
178
+ }
179
+ return;
180
+ }
181
+ const fragment = document.createDocumentFragment();
182
+ this._value.forEach((item, index) => {
183
+ if (item === null) {
184
+ this._nodes.push(null);
185
+ return;
186
+ }
187
+ const nodes = this._createItemNodes(item, index);
188
+ this._nodes.push(nodes);
189
+ nodes.forEach((n) => fragment.appendChild(n));
190
+ });
191
+ if (target)
192
+ target.appendChild(fragment);
193
+ else
194
+ this.parentElement.insertBefore(fragment, this.nextSibling);
195
+ }
196
+ _cleanup() {
197
+ this._nodes.forEach((group) => {
198
+ if (group)
199
+ group.forEach((node) => node.parentElement?.removeChild(node));
200
+ });
201
+ this._nodes = [];
202
+ this._cleanupDefault();
203
+ }
204
+ _cleanupDefault() {
205
+ this._defaultNodes.forEach((n) => n.parentElement?.removeChild(n));
206
+ this._defaultNodes = [];
207
+ }
208
+ connectedCallback() {
209
+ this.refreshValue();
210
+ }
211
+ disconnectedCallback() {
212
+ this._cleanup();
213
+ }
214
+ };
215
+ __decorate([
216
+ changedAttribute("on-get-value"),
217
+ __metadata("design:type", Function),
218
+ __metadata("design:paramtypes", [String]),
219
+ __metadata("design:returntype", void 0)
220
+ ], SwcLoop.prototype, "refreshValue", null);
221
+ SwcLoop = __decorate([
222
+ elementDefine({ name: "swc-loop", extends: "template" })
223
+ ], SwcLoop);
224
+ export {
225
+ SwcLoop
226
+ };
227
+ //# sourceMappingURL=SwcLoop.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/elements/SwcLoop.ts"],
4
+ "sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\nimport { changedAttribute } from '../decorators/changedAttribute';\nimport { SwcUtils } from '../utils/Utils';\nimport { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';\n\n@elementDefine({ name: 'swc-loop', extends: 'template' })\nexport class SwcLoop extends HTMLTemplateElement {\n private _value: any[] = [];\n private _nodes: (Node[] | null)[] = [];\n private _defaultNodes: Node[] = [];\n\n get value(): any[] {\n return this._value;\n }\n\n set value(nv: any[]) {\n this._value = Array.isArray(nv) ? [...nv] : [];\n this.render();\n }\n\n getNodes(index: number): Node[] | null {\n return this._nodes[index] || null;\n }\n\n private _getTarget(): Element | DocumentFragment | null {\n const script = this.getAttribute('on-get-portal');\n if (!script) return null;\n try {\n const res = FunctionUtils.executeReturn({\n script,\n context: this,\n args: SwcUtils.getHelperAndHostSet(window, this)\n });\n if (typeof res === 'string') return document.querySelector(res);\n if (res instanceof Node) return res as any;\n } catch (e) {\n console.error('[SwcLoop] Portal target error:', e);\n }\n return null;\n }\n\n append(...items: any[]) {\n if (!items.length || !this.parentElement) return;\n if (this._defaultNodes.length > 0) this._cleanupDefault();\n\n const fragment = document.createDocumentFragment();\n const startIndex = this._value.length;\n\n items.forEach((item, i) => {\n const index = startIndex + i;\n const nodes = this._createItemNodes(item, index);\n if (nodes) {\n this._nodes.push(nodes);\n nodes.forEach(n => fragment.appendChild(n));\n this._value.push(item);\n } else {\n this._nodes.push(null);\n this._value.push(null);\n }\n });\n\n const target = this._getTarget();\n if (target) {\n target.appendChild(fragment);\n } else {\n const lastValidIdx = this._nodes.length - items.length - 1;\n let refNode: Node = this;\n for (let i = lastValidIdx; i >= 0; i--) {\n const group = this._nodes[i];\n if (group && group.length > 0) {\n refNode = group[group.length - 1];\n break;\n }\n }\n this.parentElement.insertBefore(fragment, refNode.nextSibling);\n }\n }\n\n remove(index?: number) {\n const targetIdx = index !== undefined ? index : this._nodes.length - 1;\n if (targetIdx < 0 || targetIdx >= this._nodes.length) return;\n\n const nodes = this._nodes[targetIdx];\n if (nodes) {\n nodes.forEach(n => {\n if (n.parentElement) n.parentElement.removeChild(n);\n });\n this._nodes[targetIdx] = null;\n this._value[targetIdx] = null;\n }\n\n const activeRows = this._value.filter(v => v !== null);\n if (activeRows.length === 0) {\n this.render();\n }\n }\n\n private _createItemNodes(item: any, index: number): Node[] {\n const clone = this.content.cloneNode(true) as DocumentFragment;\n Array.from(clone.querySelectorAll('template[is=\"swc-default\"]')).forEach(t => t.remove());\n\n const nodes = Array.from(clone.childNodes);\n const elements = nodes.filter(n => n.nodeType === 1) as HTMLElement[];\n\n const groupCtx = {\n $index: index,\n $item: item,\n $nodes: nodes,\n $elements: elements,\n $firstNode: nodes[0],\n $lastNode: nodes[nodes.length - 1],\n $firstElement: elements[0],\n $lastElement: elements[elements.length - 1],\n $isFirst: index === 0,\n $isLast: index === this._value.length - 1,\n $isEven: index % 2 === 0,\n $isOdd: index % 2 !== 0,\n $count: this._value.length\n };\n\n this._executeCallback('on-clone-nodes', groupCtx);\n nodes.forEach((node, nodeIndex) => {\n if (node instanceof HTMLElement) (node as any).__swc_host = this;\n this._executeCallback('on-clone-node', { ...groupCtx, $node: node, $nodeIndex: nodeIndex, $isElement: node.nodeType === 1 });\n });\n\n return nodes;\n }\n\n private _executeCallback(attrName: string, extraArgs: Record<string, any>) {\n const script = this.getAttribute(attrName);\n if (!script) return;\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n FunctionUtils.execute({ script, context: this, args: { ...helperHostSet, ...extraArgs } });\n } catch (e) {\n console.error(`[SwcLoop] Error in ${attrName}:`, e);\n }\n }\n\n @changedAttribute('on-get-value')\n private refreshValue(newValue?: string | null) {\n const script = newValue !== undefined ? newValue : this.getAttribute('on-get-value');\n if (!script) {\n this.value = [];\n return;\n }\n const helperHostSet = SwcUtils.getHelperAndHostSet(window, this);\n try {\n const res = FunctionUtils.executeReturn({ script, context: this, args: helperHostSet });\n if (Array.isArray(res)) {\n this.value = res;\n }\n } catch (e) {\n console.error('[SwcLoop] Failed to get value from on-get-value script:', e);\n this.value = [];\n }\n }\n\n render() {\n this._cleanup();\n if (!this.parentElement) return;\n\n const activeRows = this._value.filter(v => v !== null);\n const target = this._getTarget();\n\n if (activeRows.length === 0) {\n const t = this.content.querySelector('template[is=\"swc-default\"]') as HTMLTemplateElement;\n if (t) {\n const clone = t.content.cloneNode(true) as DocumentFragment;\n this._defaultNodes = Array.from(clone.childNodes);\n this._defaultNodes.forEach(n => {\n if (n instanceof HTMLElement) (n as any).__swc_host = this;\n });\n if (target) target.appendChild(clone);\n else this.parentElement.insertBefore(clone, this.nextSibling);\n }\n return;\n }\n\n const fragment = document.createDocumentFragment();\n this._value.forEach((item, index) => {\n if (item === null) {\n this._nodes.push(null);\n return;\n }\n const nodes = this._createItemNodes(item, index);\n this._nodes.push(nodes);\n nodes.forEach(n => fragment.appendChild(n));\n });\n\n if (target) target.appendChild(fragment);\n else this.parentElement.insertBefore(fragment, this.nextSibling);\n }\n\n private _cleanup() {\n this._nodes.forEach(group => {\n if (group) group.forEach(node => node.parentElement?.removeChild(node));\n });\n this._nodes = [];\n this._cleanupDefault();\n }\n\n private _cleanupDefault() {\n this._defaultNodes.forEach(n => n.parentElement?.removeChild(n));\n this._defaultNodes = [];\n }\n\n connectedCallback() {\n this.refreshValue();\n }\n disconnectedCallback() {\n this._cleanup();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,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A;EADnB,cAAc,EAAE,MAAM,YAAY,SAAS,WAAU,CAAE;GAC3C,OAAO;",
6
+ "names": ["SwcLoop"]
7
+ }
@@ -0,0 +1,46 @@
1
+ var __decorate = function(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { elementDefine } from "../decorators/elementDefine.js";
8
+ let SwcLoading = class SwcLoading2 extends HTMLTemplateElement {
9
+ };
10
+ SwcLoading = __decorate([
11
+ elementDefine({ name: "swc-loading", extends: "template" })
12
+ ], SwcLoading);
13
+ let SwcError = class SwcError2 extends HTMLTemplateElement {
14
+ };
15
+ SwcError = __decorate([
16
+ elementDefine({ name: "swc-error", extends: "template" })
17
+ ], SwcError);
18
+ let SwcSuccess = class SwcSuccess2 extends HTMLTemplateElement {
19
+ };
20
+ SwcSuccess = __decorate([
21
+ elementDefine({ name: "swc-success", extends: "template" })
22
+ ], SwcSuccess);
23
+ let SwcWhen = class SwcWhen2 extends HTMLTemplateElement {
24
+ };
25
+ SwcWhen = __decorate([
26
+ elementDefine({ name: "swc-when", extends: "template" })
27
+ ], SwcWhen);
28
+ let SwcOtherwise = class SwcOtherwise2 extends HTMLTemplateElement {
29
+ };
30
+ SwcOtherwise = __decorate([
31
+ elementDefine({ name: "swc-otherwise", extends: "template" })
32
+ ], SwcOtherwise);
33
+ let SwcDefault = class SwcDefault2 extends HTMLTemplateElement {
34
+ };
35
+ SwcDefault = __decorate([
36
+ elementDefine({ name: "swc-default", extends: "template" })
37
+ ], SwcDefault);
38
+ export {
39
+ SwcDefault,
40
+ SwcError,
41
+ SwcLoading,
42
+ SwcOtherwise,
43
+ SwcSuccess,
44
+ SwcWhen
45
+ };
46
+ //# sourceMappingURL=SwcSubTemplates.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/elements/SwcSubTemplates.ts"],
4
+ "sourcesContent": ["import { elementDefine } from '../decorators/elementDefine';\n\n@elementDefine({ name: 'swc-loading', extends: 'template' })\nexport class SwcLoading extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-error', extends: 'template' })\nexport class SwcError extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-success', extends: 'template' })\nexport class SwcSuccess extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-when', extends: 'template' })\nexport class SwcWhen extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-otherwise', extends: 'template' })\nexport class SwcOtherwise extends HTMLTemplateElement {}\n\n@elementDefine({ name: 'swc-default', extends: 'template' })\nexport class SwcDefault extends HTMLTemplateElement {}\n"],
5
+ "mappings": ";;;;;;AAAA,SAAS,qBAAqB;AAGvB,IAAM,aAAN,MAAMA,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;EADtB,cAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;AAGhB,IAAM,WAAN,MAAMC,kBAAiB,oBAAmB;;AAApC,WAAQ,WAAA;EADpB,cAAc,EAAE,MAAM,aAAa,SAAS,WAAU,CAAE;GAC5C,QAAQ;AAGd,IAAM,aAAN,MAAMC,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;EADtB,cAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;AAGhB,IAAM,UAAN,MAAMC,iBAAgB,oBAAmB;;AAAnC,UAAO,WAAA;EADnB,cAAc,EAAE,MAAM,YAAY,SAAS,WAAU,CAAE;GAC3C,OAAO;AAGb,IAAM,eAAN,MAAMC,sBAAqB,oBAAmB;;AAAxC,eAAY,WAAA;EADxB,cAAc,EAAE,MAAM,iBAAiB,SAAS,WAAU,CAAE;GAChD,YAAY;AAGlB,IAAM,aAAN,MAAMC,oBAAmB,oBAAmB;;AAAtC,aAAU,WAAA;EADtB,cAAc,EAAE,MAAM,eAAe,SAAS,WAAU,CAAE;GAC9C,UAAU;",
6
+ "names": ["SwcLoading", "SwcError", "SwcSuccess", "SwcWhen", "SwcOtherwise", "SwcDefault"]
7
+ }
@@ -1,2 +1,9 @@
1
1
  export * from "./is/index.js";
2
+ export * from "./SwcSubTemplates.js";
3
+ export * from "./SwcLoop.js";
4
+ export * from "./SwcIf.js";
5
+ export * from "./SwcChoose.js";
6
+ export * from "./SwcAsync.js";
7
+ export * from "./SwcApp.js";
8
+ export * from "./SwcAppEngine.js";
2
9
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/elements/index.ts"],
4
- "sourcesContent": ["// import {SwcHTMLElement} from \"./SwcHTMLElement\";\n\nexport * from './is'"],
5
- "mappings": "AAEA,cAAc;",
4
+ "sourcesContent": ["export * from './is';\nexport * from './SwcSubTemplates';\nexport * from './SwcLoop';\nexport * from './SwcIf';\nexport * from './SwcChoose';\nexport * from './SwcAsync';\nexport * from './SwcApp';\nexport * from './SwcAppEngine';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -9,6 +9,6 @@ export * from "./decorators/query.js";
9
9
  export * from "./decorators/queryAll.js";
10
10
  export * from "./decorators/addEventListener.js";
11
11
  export * from "./types.js";
12
- export * from "./elements/is/index.js";
12
+ export * from "./elements/index.js";
13
13
  export * from "./utils/Utils.js";
14
14
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["import 'reflect-metadata';\n\n// Decorators\nexport * from './decorators/elementDefine';\nexport * from './decorators/setAttribute';\nexport * from './decorators/changedAttribute';\nexport * from './decorators/innerHtml';\nexport * from './decorators/emitCustomEvent';\nexport * from './decorators/lifecycles';\nexport * from './decorators/query';\nexport * from './decorators/queryAll';\nexport * from './decorators/addEventListener';\n\n// Types\nexport * from './types';\n\n// Apps (Customized Built-in Elements)\nexport * from './elements/is';\n\n// Utilities\nexport * from './utils/Utils';\n"],
4
+ "sourcesContent": ["import 'reflect-metadata';\n\n// Decorators\nexport * from './decorators/elementDefine';\nexport * from './decorators/setAttribute';\nexport * from './decorators/changedAttribute';\nexport * from './decorators/innerHtml';\nexport * from './decorators/emitCustomEvent';\nexport * from './decorators/lifecycles';\nexport * from './decorators/query';\nexport * from './decorators/queryAll';\nexport * from './decorators/addEventListener';\n\n// Types\nexport * from './types';\n\n// Apps (Customized Built-in Elements)\nexport * from './elements';\n\n// Utilities\nexport * from './utils/Utils';\n"],
5
5
  "mappings": "AAAA,OAAO;AAGP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,cAAc;AAGd,cAAc;",
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}\nexport type HelperSet = {\n $d: Document;\n $w: Window;\n $q: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\n $qa: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement[];\n $qi: (selector: string, root?: Element | Document | ShadowRoot) => HTMLElement | null;\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 type HelperHostSet = HelperSet & HostSet;\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
  }