@dooboostore/simple-web-component 1.0.49 → 1.0.50
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.
- package/README.md +72 -0
- package/dist/cjs/decorators/addEventListener.js +1994 -9
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +10 -4
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +10 -4
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +10 -4
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +14 -8
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +6 -5
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +10 -4
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/changedAttribute.js +22 -13
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +18 -3
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/eventMedia.js +84 -0
- package/dist/cjs/decorators/eventMedia.js.map +7 -0
- package/dist/cjs/decorators/index.js +3 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/intersectionObserver.js +46 -55
- package/dist/cjs/decorators/intersectionObserver.js.map +2 -2
- package/dist/cjs/decorators/mutationObserver.js +46 -55
- package/dist/cjs/decorators/mutationObserver.js.map +2 -2
- package/dist/cjs/decorators/parameter.js +73 -0
- package/dist/cjs/decorators/parameter.js.map +7 -0
- package/dist/cjs/decorators/requestAnimationFrame.js +124 -0
- package/dist/cjs/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/cjs/decorators/resizeObserver.js +46 -55
- package/dist/cjs/decorators/resizeObserver.js.map +2 -2
- package/dist/cjs/decorators/setInterval.js +46 -14
- package/dist/cjs/decorators/setInterval.js.map +2 -2
- package/dist/cjs/decorators/setTimeout.js +49 -14
- package/dist/cjs/decorators/setTimeout.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +19 -3
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/types/window.d.js.map +1 -1
- package/dist/esm/decorators/addEventListener.js +1994 -9
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +10 -4
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +10 -4
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +10 -4
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +14 -8
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +6 -5
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +10 -4
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/changedAttribute.js +22 -13
- package/dist/esm/decorators/changedAttribute.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +18 -3
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/eventMedia.js +66 -0
- package/dist/esm/decorators/eventMedia.js.map +7 -0
- package/dist/esm/decorators/index.js +3 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/intersectionObserver.js +46 -55
- package/dist/esm/decorators/intersectionObserver.js.map +2 -2
- package/dist/esm/decorators/mutationObserver.js +46 -55
- package/dist/esm/decorators/mutationObserver.js.map +2 -2
- package/dist/esm/decorators/parameter.js +54 -0
- package/dist/esm/decorators/parameter.js.map +7 -0
- package/dist/esm/decorators/requestAnimationFrame.js +105 -0
- package/dist/esm/decorators/requestAnimationFrame.js.map +7 -0
- package/dist/esm/decorators/resizeObserver.js +46 -55
- package/dist/esm/decorators/resizeObserver.js.map +2 -2
- package/dist/esm/decorators/setInterval.js +46 -15
- package/dist/esm/decorators/setInterval.js.map +2 -2
- package/dist/esm/decorators/setTimeout.js +49 -15
- package/dist/esm/decorators/setTimeout.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +20 -4
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2813 -571
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +962 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +2 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +2 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +2 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +4 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +2 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/changedAttribute.d.ts +1 -3
- package/dist/types/decorators/changedAttribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/eventMedia.d.ts +25 -0
- package/dist/types/decorators/eventMedia.d.ts.map +1 -0
- package/dist/types/decorators/index.d.ts +3 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/intersectionObserver.d.ts +9 -0
- package/dist/types/decorators/intersectionObserver.d.ts.map +1 -1
- package/dist/types/decorators/mutationObserver.d.ts +10 -1
- package/dist/types/decorators/mutationObserver.d.ts.map +1 -1
- package/dist/types/decorators/parameter.d.ts +35 -0
- package/dist/types/decorators/parameter.d.ts.map +1 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts +47 -0
- package/dist/types/decorators/requestAnimationFrame.d.ts.map +1 -0
- package/dist/types/decorators/resizeObserver.d.ts +9 -0
- package/dist/types/decorators/resizeObserver.d.ts.map +1 -1
- package/dist/types/decorators/setInterval.d.ts +17 -5
- package/dist/types/decorators/setInterval.d.ts.map +1 -1
- package/dist/types/decorators/setTimeout.d.ts +17 -5
- package/dist/types/decorators/setTimeout.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2813 -571
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +3 -3
- package/src/decorators/addEventListener.ts +1060 -8
- package/src/decorators/applyAttribute.ts +14 -4
- package/src/decorators/applyClass.ts +14 -4
- package/src/decorators/applyNode.ts +14 -4
- package/src/decorators/applyProperty.ts +28 -8
- package/src/decorators/applySlot.ts +6 -5
- package/src/decorators/applyStyle.ts +14 -4
- package/src/decorators/changedAttribute.ts +30 -15
- package/src/decorators/elementDefine.ts +32 -5
- package/src/decorators/eventMedia.ts +78 -0
- package/src/decorators/index.ts +3 -0
- package/src/decorators/intersectionObserver.ts +77 -61
- package/src/decorators/mutationObserver.ts +78 -61
- package/src/decorators/parameter.ts +81 -0
- package/src/decorators/requestAnimationFrame.ts +158 -0
- package/src/decorators/resizeObserver.ts +76 -60
- package/src/decorators/setInterval.ts +71 -15
- package/src/decorators/setTimeout.ts +74 -15
- package/src/elements/SwcAppMixin.ts +20 -5
- package/src/types/window.d.ts +2 -18
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
|
@@ -476,11 +476,21 @@ export const attr = applyAttribute;
|
|
|
476
476
|
|
|
477
477
|
// ─── 편의 헬퍼 (selector/root 생략) ───
|
|
478
478
|
|
|
479
|
-
export function attrThis(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator
|
|
480
|
-
|
|
479
|
+
export function attrThis(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator;
|
|
480
|
+
export function attrThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
481
|
+
export function attrThis(targetAttributeNameOrTarget?: string | Object, optionsOrPropertyKey?: AttributeQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
482
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
483
|
+
return (applyAttribute('$this', undefined as any, {}) as any)(targetAttributeNameOrTarget, optionsOrPropertyKey, descriptor);
|
|
484
|
+
}
|
|
485
|
+
return applyAttribute('$this', targetAttributeNameOrTarget as any, optionsOrPropertyKey as AttributeQueryOptions);
|
|
481
486
|
}
|
|
482
|
-
export function attrAppHost(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator
|
|
483
|
-
|
|
487
|
+
export function attrAppHost(targetAttributeName?: string, options?: AttributeQueryOptions): MethodDecorator;
|
|
488
|
+
export function attrAppHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
489
|
+
export function attrAppHost(targetAttributeNameOrTarget?: string | Object, optionsOrPropertyKey?: AttributeQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
490
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
491
|
+
return (applyAttribute('$appHost', undefined as any, {}) as any)(targetAttributeNameOrTarget, optionsOrPropertyKey, descriptor);
|
|
492
|
+
}
|
|
493
|
+
return applyAttribute('$appHost', targetAttributeNameOrTarget as any, optionsOrPropertyKey as AttributeQueryOptions);
|
|
484
494
|
}
|
|
485
495
|
export function attrLight(selector: string, targetAttributeName?: string, options?: Omit<AttributeQueryOptions, 'root'>): MethodDecorator {
|
|
486
496
|
return applyAttribute(selector, targetAttributeName, {...options ?? {}, root: 'light'});
|
|
@@ -325,11 +325,21 @@ export const cls = applyClass;
|
|
|
325
325
|
|
|
326
326
|
// ─── 편의 헬퍼 (selector/root 생략) ───
|
|
327
327
|
|
|
328
|
-
export function clsThis(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator
|
|
329
|
-
|
|
328
|
+
export function clsThis(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator;
|
|
329
|
+
export function clsThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
330
|
+
export function clsThis(actionOrTarget?: ClassAction | Object, optionsOrPropertyKey?: ClassQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
331
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
332
|
+
return (applyClass('$this', undefined as any, {}) as any)(actionOrTarget, optionsOrPropertyKey, descriptor);
|
|
333
|
+
}
|
|
334
|
+
return applyClass('$this', actionOrTarget as any, optionsOrPropertyKey as ClassQueryOptions);
|
|
330
335
|
}
|
|
331
|
-
export function clsAppHost(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator
|
|
332
|
-
|
|
336
|
+
export function clsAppHost(action?: ClassAction, options?: ClassQueryOptions): MethodDecorator;
|
|
337
|
+
export function clsAppHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
338
|
+
export function clsAppHost(actionOrTarget?: ClassAction | Object, optionsOrPropertyKey?: ClassQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
339
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
340
|
+
return (applyClass('$appHost', undefined as any, {}) as any)(actionOrTarget, optionsOrPropertyKey, descriptor);
|
|
341
|
+
}
|
|
342
|
+
return applyClass('$appHost', actionOrTarget as any, optionsOrPropertyKey as ClassQueryOptions);
|
|
333
343
|
}
|
|
334
344
|
export function clsLight(selector: string, action?: ClassAction, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
|
|
335
345
|
export function clsLight(selector: string, options?: Omit<ClassQueryOptions, 'root'>): MethodDecorator;
|
|
@@ -642,11 +642,21 @@ export const node = applyNode;
|
|
|
642
642
|
|
|
643
643
|
// ─── 편의 헬퍼 (selector/root 생략) ───
|
|
644
644
|
|
|
645
|
-
export function applyThis(options?: ApplyNodeQueryOptions): MethodDecorator
|
|
646
|
-
|
|
645
|
+
export function applyThis(options?: ApplyNodeQueryOptions): MethodDecorator;
|
|
646
|
+
export function applyThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
647
|
+
export function applyThis(optionsOrTarget?: ApplyNodeQueryOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
|
|
648
|
+
if ((typeof propertyKey === 'string' || typeof propertyKey === 'symbol') && descriptor !== undefined) {
|
|
649
|
+
return (applyNode('$this', {}) as any)(optionsOrTarget, propertyKey, descriptor);
|
|
650
|
+
}
|
|
651
|
+
return applyNode('$this', optionsOrTarget as ApplyNodeQueryOptions);
|
|
647
652
|
}
|
|
648
|
-
export function applyAppHost(options?: ApplyNodeQueryOptions): MethodDecorator
|
|
649
|
-
|
|
653
|
+
export function applyAppHost(options?: ApplyNodeQueryOptions): MethodDecorator;
|
|
654
|
+
export function applyAppHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
655
|
+
export function applyAppHost(optionsOrTarget?: ApplyNodeQueryOptions | Object, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | PropertyDescriptor | void {
|
|
656
|
+
if ((typeof propertyKey === 'string' || typeof propertyKey === 'symbol') && descriptor !== undefined) {
|
|
657
|
+
return (applyNode('$appHost', {}) as any)(optionsOrTarget, propertyKey, descriptor);
|
|
658
|
+
}
|
|
659
|
+
return applyNode('$appHost', optionsOrTarget as ApplyNodeQueryOptions);
|
|
650
660
|
}
|
|
651
661
|
export function applyLight(selector: string, options?: Omit<ApplyNodeQueryOptions, 'root'>): MethodDecorator {
|
|
652
662
|
return applyNode(selector, {...options ?? {}, root: 'light'});
|
|
@@ -434,17 +434,37 @@ export const prop = applyProperty;
|
|
|
434
434
|
|
|
435
435
|
// ─── 편의 헬퍼 (selector/root 생략) ───
|
|
436
436
|
|
|
437
|
-
|
|
438
|
-
|
|
437
|
+
const dispatchPropConvenience = (
|
|
438
|
+
selector: '$this' | '$appHost' | '$window' | '$document',
|
|
439
|
+
targetPropertyKeyOrTarget?: string | symbol | Object,
|
|
440
|
+
optionsOrPropertyKey?: PropertyQueryOptions | string | symbol,
|
|
441
|
+
descriptor?: PropertyDescriptor
|
|
442
|
+
): any => {
|
|
443
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
444
|
+
return (applyProperty(selector, undefined as any, {}) as any)(targetPropertyKeyOrTarget, optionsOrPropertyKey, descriptor);
|
|
445
|
+
}
|
|
446
|
+
return applyProperty(selector, targetPropertyKeyOrTarget as any, optionsOrPropertyKey as PropertyQueryOptions);
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
export function propThis(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator;
|
|
450
|
+
export function propThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
451
|
+
export function propThis(targetPropertyKeyOrTarget?: string | symbol | Object, optionsOrPropertyKey?: PropertyQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
452
|
+
return dispatchPropConvenience('$this', targetPropertyKeyOrTarget, optionsOrPropertyKey, descriptor);
|
|
439
453
|
}
|
|
440
|
-
export function propAppHost(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator
|
|
441
|
-
|
|
454
|
+
export function propAppHost(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator;
|
|
455
|
+
export function propAppHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
456
|
+
export function propAppHost(targetPropertyKeyOrTarget?: string | symbol | Object, optionsOrPropertyKey?: PropertyQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
457
|
+
return dispatchPropConvenience('$appHost', targetPropertyKeyOrTarget, optionsOrPropertyKey, descriptor);
|
|
442
458
|
}
|
|
443
|
-
export function propWindow(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator
|
|
444
|
-
|
|
459
|
+
export function propWindow(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator;
|
|
460
|
+
export function propWindow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
461
|
+
export function propWindow(targetPropertyKeyOrTarget?: string | symbol | Object, optionsOrPropertyKey?: PropertyQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
462
|
+
return dispatchPropConvenience('$window', targetPropertyKeyOrTarget, optionsOrPropertyKey, descriptor);
|
|
445
463
|
}
|
|
446
|
-
export function propDocument(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator
|
|
447
|
-
|
|
464
|
+
export function propDocument(targetPropertyKey?: string | symbol, options?: PropertyQueryOptions): MethodDecorator;
|
|
465
|
+
export function propDocument(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
466
|
+
export function propDocument(targetPropertyKeyOrTarget?: string | symbol | Object, optionsOrPropertyKey?: PropertyQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
467
|
+
return dispatchPropConvenience('$document', targetPropertyKeyOrTarget, optionsOrPropertyKey, descriptor);
|
|
448
468
|
}
|
|
449
469
|
export function propLight(selector: string, targetPropertyKey?: string | symbol, options?: Omit<PropertyQueryOptions, 'root'>): MethodDecorator {
|
|
450
470
|
return applyProperty(selector, targetPropertyKey, {...options ?? {}, root: 'light'});
|
|
@@ -73,8 +73,8 @@ export const APPLY_SLOT_METADATA_KEY = Symbol.for('simple-web-component:apply-sl
|
|
|
73
73
|
// }
|
|
74
74
|
// };
|
|
75
75
|
|
|
76
|
-
const applyToDom = (swcId: string, id: string, pos: ApplySlotPosition, nodes: Node[]) => {
|
|
77
|
-
const nodeSlot = new NodeSlot(
|
|
76
|
+
const applyToDom = (host: HTMLElement, swcId: string, id: string, pos: ApplySlotPosition, nodes: Node[]) => {
|
|
77
|
+
const nodeSlot = new NodeSlot(host, swcId);
|
|
78
78
|
if (pos === 'replaceChildrenText' || pos === 'replaceChildren' || pos === 'replaceChildrenHtml') {
|
|
79
79
|
nodeSlot.replaceChildren(id, ...nodes);
|
|
80
80
|
} else if (pos === 'appendHtml' || pos === 'append' || pos === 'appendText') {
|
|
@@ -109,6 +109,7 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
|
|
|
109
109
|
descriptor.value = function (...args: any[]) {
|
|
110
110
|
ensureInit(this);
|
|
111
111
|
|
|
112
|
+
const host = this;
|
|
112
113
|
const conf = getElementConfig(this);
|
|
113
114
|
const currentWin = conf.window;
|
|
114
115
|
const swcId = this._swcId;
|
|
@@ -137,7 +138,7 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
|
|
|
137
138
|
const res: string | Node = options.fallback.call(this, hostSet);
|
|
138
139
|
const nodes: Node[] = resToNodes(res);
|
|
139
140
|
fallbackNodes.push(...nodes);
|
|
140
|
-
applyToDom(swcId, targetId, options.position, nodes);
|
|
141
|
+
applyToDom(host, swcId, targetId, options.position, nodes);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -162,12 +163,12 @@ export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions,
|
|
|
162
163
|
const extracted = extractValue(asyncRes);
|
|
163
164
|
const nodes = resToNodes(extracted)
|
|
164
165
|
fallbackNodes.forEach((it: any) => it.remove());
|
|
165
|
-
applyToDom(swcId, targetId, options.position, nodes);
|
|
166
|
+
applyToDom(host, swcId, targetId, options.position, nodes);
|
|
166
167
|
})
|
|
167
168
|
} else {
|
|
168
169
|
const extracted = extractValue(res);
|
|
169
170
|
const nodes: Node[] = resToNodes(extracted);
|
|
170
|
-
applyToDom(swcId, targetId, options.position, nodes);
|
|
171
|
+
applyToDom(host, swcId, targetId, options.position, nodes);
|
|
171
172
|
}
|
|
172
173
|
};
|
|
173
174
|
};
|
|
@@ -266,11 +266,21 @@ export const style = applyStyle;
|
|
|
266
266
|
|
|
267
267
|
// ─── 편의 헬퍼 (selector/root 생략) ───
|
|
268
268
|
|
|
269
|
-
export function styleThis(action?: StyleAction, options?: StyleQueryOptions): MethodDecorator
|
|
270
|
-
|
|
269
|
+
export function styleThis(action?: StyleAction, options?: StyleQueryOptions): MethodDecorator;
|
|
270
|
+
export function styleThis(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
271
|
+
export function styleThis(actionOrTarget?: StyleAction | Object, optionsOrPropertyKey?: StyleQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
272
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
273
|
+
return (applyStyle('$this', undefined as any, {}) as any)(actionOrTarget, optionsOrPropertyKey, descriptor);
|
|
274
|
+
}
|
|
275
|
+
return applyStyle('$this', actionOrTarget as any, optionsOrPropertyKey as StyleQueryOptions);
|
|
271
276
|
}
|
|
272
|
-
export function styleAppHost(action?: StyleAction, options?: StyleQueryOptions): MethodDecorator
|
|
273
|
-
|
|
277
|
+
export function styleAppHost(action?: StyleAction, options?: StyleQueryOptions): MethodDecorator;
|
|
278
|
+
export function styleAppHost(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
279
|
+
export function styleAppHost(actionOrTarget?: StyleAction | Object, optionsOrPropertyKey?: StyleQueryOptions | string | symbol, descriptor?: PropertyDescriptor): any {
|
|
280
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
281
|
+
return (applyStyle('$appHost', undefined as any, {}) as any)(actionOrTarget, optionsOrPropertyKey, descriptor);
|
|
282
|
+
}
|
|
283
|
+
return applyStyle('$appHost', actionOrTarget as any, optionsOrPropertyKey as StyleQueryOptions);
|
|
274
284
|
}
|
|
275
285
|
export function styleLight(selector: string, action?: StyleAction, options?: Omit<StyleQueryOptions, 'root'>): MethodDecorator;
|
|
276
286
|
export function styleLight(selector: string, options?: Omit<StyleQueryOptions, 'root'>): MethodDecorator;
|
|
@@ -20,24 +20,39 @@ const convertValue = (val: any, type: any): any => {
|
|
|
20
20
|
return val;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
const applyChangedAttribute = (attributeName: string | undefined, options: ChangedAttributeThisOptions, target: Object, propertyKey: string | symbol): void => {
|
|
24
|
+
const constructor = target.constructor;
|
|
25
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];
|
|
26
|
+
if (!metaList) {
|
|
27
|
+
metaList = [];
|
|
28
|
+
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const name = attributeName || String(propertyKey);
|
|
32
|
+
metaList.push({
|
|
33
|
+
attributeName: name,
|
|
34
|
+
propertyKey,
|
|
35
|
+
options
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function changedAttribute(attributeName?: string, options?: ChangedAttributeThisOptions): MethodDecorator;
|
|
40
|
+
export function changedAttribute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
23
41
|
/**
|
|
24
|
-
* @changedAttributeThis decorator - fires when any attribute on $this changes
|
|
42
|
+
* @changedAttributeThis decorator - fires when any attribute on $this changes.
|
|
43
|
+
* 옵션 없이 `@changedAttribute` 그대로 붙여도 되고, `@changedAttribute(...)`처럼 이름/옵션을 줄 수도 있다.
|
|
25
44
|
*/
|
|
26
|
-
export function changedAttribute(
|
|
45
|
+
export function changedAttribute(attributeNameOrTarget?: string | Object, optionsOrPropertyKey?: ChangedAttributeThisOptions | string | symbol, descriptor?: PropertyDescriptor): MethodDecorator | void {
|
|
46
|
+
if ((typeof optionsOrPropertyKey === 'string' || typeof optionsOrPropertyKey === 'symbol') && descriptor !== undefined) {
|
|
47
|
+
// 옵션 없이: @changedAttribute
|
|
48
|
+
applyChangedAttribute(undefined, {}, attributeNameOrTarget as Object, optionsOrPropertyKey);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// 옵션과 함께: @changedAttribute() / @changedAttribute('name', options?)
|
|
52
|
+
const attributeName = attributeNameOrTarget as string | undefined;
|
|
53
|
+
const options = (optionsOrPropertyKey as ChangedAttributeThisOptions) ?? {};
|
|
27
54
|
return (target: Object, propertyKey: string | symbol) => {
|
|
28
|
-
|
|
29
|
-
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];
|
|
30
|
-
if (!metaList) {
|
|
31
|
-
metaList = [];
|
|
32
|
-
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const name = attributeName || String(propertyKey);
|
|
36
|
-
metaList.push({
|
|
37
|
-
attributeName: name,
|
|
38
|
-
propertyKey,
|
|
39
|
-
options
|
|
40
|
-
});
|
|
55
|
+
applyChangedAttribute(attributeName, options, target, propertyKey);
|
|
41
56
|
};
|
|
42
57
|
}
|
|
43
58
|
|
|
@@ -11,6 +11,8 @@ import {getQueryMetadata, getQueryAllMetadata} from './query';
|
|
|
11
11
|
import {SwcUtils} from '../utils/Utils';
|
|
12
12
|
import {DOM_EVENT_NAMES, HTML_TAG_ENTRIES} from '../config/config';
|
|
13
13
|
import {SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot/decorators/inject/Inject';
|
|
14
|
+
import {FirstCheckMaker} from '@dooboostore/simple-boot';
|
|
15
|
+
import {buildSwcParameterArgs, getParameterMetadata} from './parameter';
|
|
14
16
|
import {ElementDefineLifeCycler, HelperHostSet, HostSet, InjectSituationType, IntersectionObserverSet, MutationObserverSet, OnConnectedResult, ResizeObserverSet, ResizeObserverSetEntry, SwcRootType} from '../types';
|
|
15
17
|
import {ConvertUtils, ElementApply} from '@dooboostore/core-web';
|
|
16
18
|
import {isSSR} from "../elements/SwcAppMixin";
|
|
@@ -20,6 +22,8 @@ import {MessageSubscribeLifeCycler} from "./subscribeSwcAppMessageWhileConnected
|
|
|
20
22
|
import {RouteSubscribeLifeCycler} from "./subscribeSwcAppRouteChangeWhileConnected";
|
|
21
23
|
import {SetIntervalLifeCycler} from "./setInterval";
|
|
22
24
|
import {SetTimeoutLifeCycler} from "./setTimeout";
|
|
25
|
+
import {RequestAnimationFrameLifeCycler} from "./requestAnimationFrame";
|
|
26
|
+
import {EventMediaLifeCycler} from "./eventMedia";
|
|
23
27
|
|
|
24
28
|
// --- Core Interfaces & Types ---
|
|
25
29
|
|
|
@@ -236,6 +240,13 @@ const setupPrototype = (proto: any, win: Window) => {
|
|
|
236
240
|
if (typeof (this as any)[methodName] !== 'function') return;
|
|
237
241
|
const useHostSet = hostSet ?? SwcUtils.getHelperAndHostSet(win, this);
|
|
238
242
|
const app = useHostSet?.$appHost?.simpleApplication;
|
|
243
|
+
|
|
244
|
+
// @hostSet/@helperHostSet/@helperSet(parameter.ts)를 위한 값. lifecycle 메서드는
|
|
245
|
+
// event/matched 개념이 없으므로 이 세 가지만 채운다.
|
|
246
|
+
const helperSetValue = SwcUtils.getHelperSet(win);
|
|
247
|
+
const helperHostSetValue = {...helperSetValue, ...useHostSet, $this: this};
|
|
248
|
+
const kindValues = {hostSet: useHostSet, helperHostSet: helperHostSetValue, helperSet: helperSetValue};
|
|
249
|
+
|
|
239
250
|
// console.log('---->hh',app, this, methodName);
|
|
240
251
|
if (app) {
|
|
241
252
|
const otherStorage = new Map<any, any>();
|
|
@@ -248,16 +259,30 @@ const setupPrototype = (proto: any, win: Window) => {
|
|
|
248
259
|
}), new SituationTypeContainer({situationType: InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost})]);
|
|
249
260
|
otherStorage.set(SituationTypeContainers, situations);
|
|
250
261
|
|
|
262
|
+
// @hostSet/@helperHostSet/@helperSet가 붙은 파라미터는 @Inject/situationType 기반
|
|
263
|
+
// 해석보다 먼저 처리되고(firstCheckMaker), 그 외 파라미터는 기존처럼 @Inject/타입
|
|
264
|
+
// 기반으로 정상 해석된다 — 같은 메서드에서 두 방식을 섞어 써도 된다.
|
|
265
|
+
const firstCheckMaker: FirstCheckMaker = ({target, targetKey}, token, idx) => {
|
|
266
|
+
const saves = getParameterMetadata(target, targetKey!);
|
|
267
|
+
const found = saves.find(s => s.index === idx);
|
|
268
|
+
return found ? (kindValues as any)[found.kind] : undefined;
|
|
269
|
+
};
|
|
270
|
+
|
|
251
271
|
return app.simstanceManager.executeBindParameterSim(
|
|
252
272
|
{
|
|
253
273
|
target: this,
|
|
254
274
|
targetKey: methodName,
|
|
255
|
-
inputParameters: extraArgs
|
|
275
|
+
inputParameters: extraArgs,
|
|
276
|
+
firstCheckMaker: [firstCheckMaker]
|
|
256
277
|
},
|
|
257
278
|
otherStorage
|
|
258
279
|
);
|
|
259
280
|
} else {
|
|
260
|
-
|
|
281
|
+
// SimpleApplication(DI 컨테이너)이 없는 standalone 사용 시에도 @hostSet/@helperHostSet/
|
|
282
|
+
// @helperSet만큼은 buildSwcParameterArgs로 주입해준다 — 해당 데코레이터가 하나도 없으면
|
|
283
|
+
// extraArgs를 그대로 반환하므로(기존 동작 그대로) 하위호환 깨지지 않는다.
|
|
284
|
+
const args = buildSwcParameterArgs(this, methodName, kindValues, extraArgs);
|
|
285
|
+
return (this as any)[methodName](...args);
|
|
261
286
|
}
|
|
262
287
|
};
|
|
263
288
|
|
|
@@ -372,6 +397,8 @@ export const elementDefine =
|
|
|
372
397
|
new RouteSubscribeLifeCycler(),
|
|
373
398
|
new SetIntervalLifeCycler(),
|
|
374
399
|
new SetTimeoutLifeCycler(),
|
|
400
|
+
new RequestAnimationFrameLifeCycler(),
|
|
401
|
+
new EventMediaLifeCycler(),
|
|
375
402
|
];
|
|
376
403
|
|
|
377
404
|
// observedAttributes 기여 cycler (define-time, constructor 기반)
|
|
@@ -416,7 +443,7 @@ export const elementDefine =
|
|
|
416
443
|
const resizeObserved = new WeakSet<Element>();
|
|
417
444
|
if (resizeObserverSet?.length) {
|
|
418
445
|
const roCallbacks = [...new Set(resizeObserverSet.map(e => e.callback))];
|
|
419
|
-
const ro = new
|
|
446
|
+
const ro = new win.ResizeObserver((entries, obs) => {
|
|
420
447
|
for (const cb of roCallbacks) cb(entries, obs);
|
|
421
448
|
});
|
|
422
449
|
for (const e of resizeObserverSet) {
|
|
@@ -453,7 +480,7 @@ export const elementDefine =
|
|
|
453
480
|
const intersectionDelegates: Array<{ target: string; delegateRoot?: SwcRootType; observe: (el: Element) => void; unobserve: (el: Element) => void }> = [];
|
|
454
481
|
for (const group of intersectionObserverSet) {
|
|
455
482
|
const ioCallbacks = [...new Set(group.observeTargets.map(e => e.callback))];
|
|
456
|
-
const io = new
|
|
483
|
+
const io = new win.IntersectionObserver((entries, obs) => {
|
|
457
484
|
for (const cb of ioCallbacks) cb(entries, obs);
|
|
458
485
|
}, group.options);
|
|
459
486
|
const ioObserved = new WeakSet<Element>();
|
|
@@ -534,7 +561,7 @@ export const elementDefine =
|
|
|
534
561
|
if (mutationObserverSet?.length || resizeDelegates.length > 0 || intersectionDelegates.length > 0) {
|
|
535
562
|
// 하나의 MutationObserver 로 resize/intersection delegate 동적 추적 + mutation 콜백을 함께 처리
|
|
536
563
|
const callbacks = [...new Set((mutationObserverSet ?? []).map(e => e.callback))];
|
|
537
|
-
const mo = new
|
|
564
|
+
const mo = new win.MutationObserver((mutations, obs) => {
|
|
538
565
|
for (const mut of mutations) {
|
|
539
566
|
Array.from(mut.addedNodes || []).forEach(n => { handleResizeDelegate(n as Node, true); handleIntersectionDelegate(n as Node, true); });
|
|
540
567
|
Array.from(mut.removedNodes || []).forEach(n => { handleResizeDelegate(n as Node, false); handleIntersectionDelegate(n as Node, false); });
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { ElementDefineLifeCycler, HelperHostSet } from '../types';
|
|
3
|
+
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
|
|
5
|
+
export const EVENT_MEDIA_METADATA_KEY = Symbol.for('simple-web-component:event-media');
|
|
6
|
+
|
|
7
|
+
export interface EventMediaMetadata {
|
|
8
|
+
propertyKey: string | symbol;
|
|
9
|
+
query: string;
|
|
10
|
+
eventType: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* CSS 미디어쿼리(`window.matchMedia`) 상태 변화를 감지한다.
|
|
15
|
+
* connect 시 자동으로 구독하고, disconnect 시 자동으로 해제한다.
|
|
16
|
+
*
|
|
17
|
+
* MediaQueryList는 스펙상 'change' 이벤트 하나만 정의돼있다 — eventType은 그래도 명시적으로 받는다
|
|
18
|
+
* (다른 @event* 계열처럼 베이스는 명시적, 편의 별칭이 값을 고정하는 컨벤션을 따름). 'change' 고정 버전은
|
|
19
|
+
* eventMediaChange를 사용한다.
|
|
20
|
+
*/
|
|
21
|
+
export function eventMedia(query: string, eventType: string): MethodDecorator {
|
|
22
|
+
return (target: Object, propertyKey: string | symbol) => {
|
|
23
|
+
const constructor = target.constructor;
|
|
24
|
+
let metaList = ReflectUtils.getOwnMetadata(EVENT_MEDIA_METADATA_KEY, constructor) as EventMediaMetadata[];
|
|
25
|
+
if (!metaList) {
|
|
26
|
+
metaList = [];
|
|
27
|
+
ReflectUtils.defineMetadata(EVENT_MEDIA_METADATA_KEY, metaList, constructor);
|
|
28
|
+
}
|
|
29
|
+
metaList.push({ propertyKey, query, eventType });
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** eventMedia(query, 'change')의 별칭 - MediaQueryList가 실제로 발생시키는 유일한 이벤트. */
|
|
34
|
+
export function eventMediaChange(query: string): MethodDecorator {
|
|
35
|
+
return eventMedia(query, 'change');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const findAllEventMediaMetadata = (target: any): EventMediaMetadata[] => {
|
|
39
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
40
|
+
return (ReflectUtils.findAllMetadata<EventMediaMetadata[]>(EVENT_MEDIA_METADATA_KEY, constructor) || []).flat();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export class EventMediaLifeCycler implements ElementDefineLifeCycler {
|
|
44
|
+
private readonly entriesMap = new WeakMap<any, Array<{ mql: MediaQueryList; eventType: string; handler: (e: Event) => void }>>();
|
|
45
|
+
|
|
46
|
+
onConnected(helperHostSet: HelperHostSet): void {
|
|
47
|
+
const inst = helperHostSet.$this;
|
|
48
|
+
const metaList = findAllEventMediaMetadata(inst);
|
|
49
|
+
if (metaList.length === 0) return;
|
|
50
|
+
|
|
51
|
+
const entries: Array<{ mql: MediaQueryList; eventType: string; handler: (e: Event) => void }> = [];
|
|
52
|
+
for (const meta of metaList) {
|
|
53
|
+
const mql = helperHostSet.$w.matchMedia(meta.query);
|
|
54
|
+
const handler = (e: Event) => {
|
|
55
|
+
try {
|
|
56
|
+
inst[meta.propertyKey](e, helperHostSet);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('[SWC] eventMedia handler error:', err);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
mql.addEventListener(meta.eventType, handler);
|
|
62
|
+
entries.push({ mql, eventType: meta.eventType, handler });
|
|
63
|
+
}
|
|
64
|
+
this.entriesMap.set(inst, entries);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onDisconnected(helperHostSet: HelperHostSet): void {
|
|
68
|
+
const inst = helperHostSet.$this;
|
|
69
|
+
for (const { mql, eventType, handler } of this.entriesMap.get(inst) ?? []) {
|
|
70
|
+
try {
|
|
71
|
+
mql.removeEventListener(eventType, handler);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error('[SWC] eventMedia cleanup error:', e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.entriesMap.delete(inst);
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/decorators/index.ts
CHANGED