@dooboostore/simple-web-component 1.0.38 → 1.0.40
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/LICENSE.md +7 -0
- package/README.md +88 -871
- package/dist/cjs/SwcAppEngine.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +194 -111
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +82 -80
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +213 -0
- package/dist/cjs/decorators/applyProperty.js.map +7 -0
- package/dist/cjs/decorators/applySlot.js +93 -82
- package/dist/cjs/decorators/applySlot.js.map +3 -3
- package/dist/cjs/decorators/changedAttributeThis.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +14 -34
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -2
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -4
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/state.js +0 -1
- package/dist/cjs/decorators/state.js.map +2 -2
- package/dist/cjs/elements/SwcApp.js.map +2 -2
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/SwcAppEngine.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +196 -113
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +82 -80
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +194 -0
- package/dist/esm/decorators/applyProperty.js.map +7 -0
- package/dist/esm/decorators/applySlot.js +93 -82
- package/dist/esm/decorators/applySlot.js.map +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +14 -34
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -2
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +4 -4
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/state.js +0 -1
- package/dist/esm/decorators/state.js.map +2 -2
- package/dist/esm/elements/SwcApp.js.map +2 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +525 -513
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +56 -15
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +28 -24
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +61 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -0
- package/dist/types/decorators/applySlot.d.ts +17 -15
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -2
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +4 -4
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -6
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +525 -513
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +1 -1
- package/src/SwcAppEngine.ts +1 -0
- package/src/decorators/applyAttribute.ts +311 -126
- package/src/decorators/applyNode.ts +108 -105
- package/src/decorators/applyProperty.ts +302 -0
- package/src/decorators/applySlot.ts +112 -94
- package/src/decorators/changedAttributeThis.ts +1 -1
- package/src/decorators/elementDefine.ts +44 -33
- package/src/decorators/index.ts +2 -3
- package/src/decorators/lifecycles.ts +6 -6
- package/src/decorators/state.ts +0 -1
- package/src/elements/SwcApp.ts +0 -1
- package/src/types/index.ts +7 -7
- package/dist/cjs/decorators/attribute.js +0 -187
- package/dist/cjs/decorators/attribute.js.map +0 -7
- package/dist/cjs/decorators/setProperty.js +0 -109
- package/dist/cjs/decorators/setProperty.js.map +0 -7
- package/dist/esm/decorators/attribute.js +0 -168
- package/dist/esm/decorators/attribute.js.map +0 -7
- package/dist/esm/decorators/setProperty.js +0 -90
- package/dist/esm/decorators/setProperty.js.map +0 -7
- package/dist/types/decorators/attribute.d.ts +0 -31
- package/dist/types/decorators/attribute.d.ts.map +0 -1
- package/dist/types/decorators/setProperty.d.ts +0 -17
- package/dist/types/decorators/setProperty.d.ts.map +0 -1
- package/src/decorators/attribute.ts +0 -223
- package/src/decorators/setProperty.ts +0 -112
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {ReflectUtils} from '@dooboostore/core';
|
|
1
|
+
import {OptionalType, ReflectUtils} from '@dooboostore/core';
|
|
2
2
|
import {ensureInit, getElementConfig} from './elementDefine';
|
|
3
3
|
import {SwcUtils} from "../utils/Utils";
|
|
4
4
|
import {NodeSlot} from "@dooboostore/core-web";
|
|
5
|
+
import {HelperHostSet} from "../types";
|
|
5
6
|
/*
|
|
6
7
|
<!-- beforebegin -->
|
|
7
8
|
<p> <-- it's me
|
|
@@ -11,10 +12,11 @@ import {NodeSlot} from "@dooboostore/core-web";
|
|
|
11
12
|
</p>
|
|
12
13
|
<!-- afterend -->
|
|
13
14
|
*/
|
|
14
|
-
export type ApplySlotPosition = 'prependHtml' | 'prependText' | 'appendHtml' | 'appendText' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';
|
|
15
|
+
export type ApplySlotPosition = 'prepend' | 'prependHtml' | 'prependText' | 'append' | 'appendHtml' | 'appendText' | 'replaceChildren' | 'replaceChildrenHtml' | 'replaceChildrenText' | 'clear';
|
|
15
16
|
|
|
16
17
|
export interface ApplySlotOptions {
|
|
17
|
-
position
|
|
18
|
+
position: ApplySlotPosition;
|
|
19
|
+
fallback?: (helper: HelperHostSet) => string | Node;
|
|
18
20
|
// root?: SwcRootType;
|
|
19
21
|
/**
|
|
20
22
|
* Filter function to determine whether to perform DOM operation.
|
|
@@ -29,8 +31,8 @@ export interface ApplySlotOptions {
|
|
|
29
31
|
|
|
30
32
|
export interface ApplySlotMetadata {
|
|
31
33
|
propertyKey: string | symbol;
|
|
32
|
-
|
|
33
|
-
type: 'method' | 'property';
|
|
34
|
+
targetId: string;
|
|
35
|
+
// type: 'method' | 'property';
|
|
34
36
|
options: ApplySlotOptions;
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -75,33 +77,28 @@ export const APPLY_SLOT_METADATA_KEY = Symbol.for('simple-web-component:apply-sl
|
|
|
75
77
|
// }
|
|
76
78
|
// };
|
|
77
79
|
|
|
80
|
+
const applyToDom = (swcId: string, id: string, pos: ApplySlotPosition, nodes: Node[]) => {
|
|
81
|
+
const nodeSlot = new NodeSlot(this, swcId);
|
|
82
|
+
if (pos === 'replaceChildrenText' || pos === 'replaceChildren' || pos === 'replaceChildrenHtml') {
|
|
83
|
+
nodeSlot.replaceChildren(id, ...nodes);
|
|
84
|
+
} else if (pos === 'appendHtml' || pos === 'append' || pos === 'appendText') {
|
|
85
|
+
nodeSlot.append(id, ...nodes);
|
|
86
|
+
} else if (pos === 'prependHtml' || pos === 'prepend' || pos === 'prependText') {
|
|
87
|
+
nodeSlot.prepend(id, ...nodes);
|
|
88
|
+
} else if (pos === 'clear') {
|
|
89
|
+
nodeSlot.clear(id);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
78
93
|
/**
|
|
79
94
|
* @applyNode decorator to surgically add/replace nodes to a target element.
|
|
80
95
|
*/
|
|
81
|
-
export function applySlot(
|
|
82
|
-
return (targetObj: Object, propertyKey: string | symbol, descriptor
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
get(this: any) {
|
|
88
|
-
const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
|
|
89
|
-
return nodeSlot;
|
|
90
|
-
},
|
|
91
|
-
set(this: any, nv: any) {
|
|
92
|
-
if(nv) {
|
|
93
|
-
// 있을때 아무일도안함
|
|
94
|
-
} else {
|
|
95
|
-
const nodeSlot = new NodeSlot(this, `${this._swcId}-${id}`);
|
|
96
|
-
nodeSlot.clear();
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
configurable: true,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
})
|
|
102
|
-
// return nodeSlot;
|
|
103
|
-
// return;
|
|
104
|
-
}
|
|
96
|
+
export function applySlot(targetId: string, opt: OptionalType<ApplySlotOptions, 'position'>): MethodDecorator {
|
|
97
|
+
return (targetObj: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => {
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
const options: ApplySlotOptions = {position: 'replaceChildren', ...opt};
|
|
101
|
+
|
|
105
102
|
|
|
106
103
|
const constructor = targetObj.constructor;
|
|
107
104
|
let metaList = ReflectUtils.getOwnMetadata(APPLY_SLOT_METADATA_KEY, constructor) as ApplySlotMetadata[];
|
|
@@ -109,80 +106,101 @@ export function applySlot(id: string, options: ApplySlotOptions = { position: 'r
|
|
|
109
106
|
metaList = []
|
|
110
107
|
ReflectUtils.defineMetadata(APPLY_SLOT_METADATA_KEY, metaList, constructor);
|
|
111
108
|
}
|
|
112
|
-
metaList.push({
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
} else if (pos === 'appendText') {
|
|
138
|
-
nodeSlot.appendText(id, res);
|
|
139
|
-
} else if (pos === 'prependHtml') {
|
|
140
|
-
nodeSlot.prependHtml(id, res);
|
|
141
|
-
} else if (pos === 'prependText') {
|
|
142
|
-
nodeSlot.prependText(id, res);
|
|
143
|
-
} else if (pos === 'clear') {
|
|
144
|
-
nodeSlot.clear(id);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// const stateContext: any = {...hostSet};
|
|
148
|
-
// getStateMetadata(this).forEach(it => {
|
|
149
|
-
// stateContext[it.name] = this[it.propertyKey]
|
|
150
|
-
// })
|
|
151
|
-
// new ElementApply(this, {id: this._swcId}).apply({target:'noInitialized', context: stateContext, bind: this});
|
|
109
|
+
metaList.push({propertyKey, targetId, options});
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
const original = descriptor.value;
|
|
113
|
+
descriptor.value = function (...args: any[]) {
|
|
114
|
+
ensureInit(this);
|
|
115
|
+
|
|
116
|
+
const conf = getElementConfig(this);
|
|
117
|
+
const currentWin = conf.window;
|
|
118
|
+
const swcId = this._swcId;
|
|
119
|
+
const currentDoc = currentWin.document;
|
|
120
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
121
|
+
const pos = options.position;
|
|
122
|
+
|
|
123
|
+
const resToNodes = (res: string | Node) => {
|
|
124
|
+
const nodes: Node[] = [];
|
|
125
|
+
|
|
126
|
+
if (typeof res === 'string' && (pos === 'replaceChildrenHtml' || pos === 'appendHtml' || pos === 'prependHtml')) {
|
|
127
|
+
const t = currentWin.document.createElement('template');
|
|
128
|
+
t.innerHTML = res;
|
|
129
|
+
nodes.push(...Array.from(t.content.childNodes));
|
|
130
|
+
} else if (typeof res === 'string' && (pos === 'replaceChildrenText' || pos === 'prependText' || pos === 'appendText')) {
|
|
131
|
+
nodes.push(currentWin.document.createTextNode(res));
|
|
132
|
+
} else if (typeof res === 'object') {
|
|
133
|
+
nodes.push(res);
|
|
152
134
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
135
|
+
SwcUtils.projectProcessHtml(swcId, nodes, currentDoc);
|
|
136
|
+
return nodes;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const fallbackNodes: Node[] = [];
|
|
140
|
+
if (options.fallback) {
|
|
141
|
+
const res: string | Node = options.fallback.call(this, hostSet);
|
|
142
|
+
const nodes: Node[] = resToNodes(res);
|
|
143
|
+
fallbackNodes.push(...nodes);
|
|
144
|
+
applyToDom(swcId, targetId, options.position, nodes);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let res = original.apply(this, args);
|
|
148
|
+
if (res instanceof Promise) {
|
|
149
|
+
return res.then(asyncRes => {
|
|
150
|
+
const nodes = resToNodes(asyncRes)
|
|
151
|
+
fallbackNodes.forEach((it: any) => it.remove());
|
|
152
|
+
applyToDom(swcId, targetId, options.position, nodes);
|
|
153
|
+
})
|
|
154
|
+
} else {
|
|
155
|
+
const nodes: Node[] = resToNodes(res);
|
|
156
|
+
applyToDom(swcId, targetId, options.position, nodes);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
156
159
|
};
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
163
|
-
};
|
|
162
|
+
export function clearSlot(targetId: string): MethodDecorator {
|
|
163
|
+
return applySlot(targetId, {position: 'clear'});
|
|
164
|
+
}
|
|
164
165
|
|
|
165
|
-
export function
|
|
166
|
-
return applySlot(
|
|
166
|
+
export function prependHtmlSlot(targetId: string): MethodDecorator {
|
|
167
|
+
return applySlot(targetId, {position: 'prependHtml'});
|
|
167
168
|
}
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
|
|
170
|
+
export function prependSlot(targetId: string): MethodDecorator {
|
|
171
|
+
return applySlot(targetId, {position: 'prepend'});
|
|
170
172
|
}
|
|
171
|
-
|
|
172
|
-
export function
|
|
173
|
-
return applySlot(
|
|
173
|
+
|
|
174
|
+
export function prependTextSlot(targetId: string): MethodDecorator {
|
|
175
|
+
return applySlot(targetId, {position: 'prependText'});
|
|
174
176
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
|
|
178
|
+
export function appendHtmlSlot(targetId: string): MethodDecorator {
|
|
179
|
+
return applySlot(targetId, {position: 'appendHtml'});
|
|
177
180
|
}
|
|
178
|
-
|
|
179
|
-
|
|
181
|
+
|
|
182
|
+
export function appendTextSlot(targetId: string): MethodDecorator {
|
|
183
|
+
return applySlot(targetId, {position: 'appendText'});
|
|
180
184
|
}
|
|
181
|
-
|
|
182
|
-
export function
|
|
183
|
-
return applySlot(
|
|
185
|
+
|
|
186
|
+
export function appendSlot(targetId: string): MethodDecorator {
|
|
187
|
+
return applySlot(targetId, {position: 'append'});
|
|
184
188
|
}
|
|
185
|
-
|
|
186
|
-
export function
|
|
187
|
-
return applySlot(
|
|
189
|
+
|
|
190
|
+
export function replaceChildrenHtmlSlot(targetId: string): MethodDecorator {
|
|
191
|
+
return applySlot(targetId, {position: 'replaceChildrenHtml'});
|
|
188
192
|
}
|
|
193
|
+
|
|
194
|
+
export function replaceChildrenSlot(targetId: string): MethodDecorator {
|
|
195
|
+
return applySlot(targetId, {position: 'replaceChildren'});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function replaceChildrenTextSlot(targetId: string): MethodDecorator {
|
|
199
|
+
return applySlot(targetId, {position: 'replaceChildrenText'});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// export const findAllApplySlotMetadata = (target: any): Map<string | symbol, ApplySlotMetadata> => {
|
|
203
|
+
export const findAllApplySlotMetadata = (target: any): ApplySlotMetadata[] => {
|
|
204
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
205
|
+
return ReflectUtils.getMetadata(APPLY_SLOT_METADATA_KEY, constructor);
|
|
206
|
+
};
|
|
@@ -2,7 +2,7 @@ import { ReflectUtils } from '@dooboostore/core';
|
|
|
2
2
|
|
|
3
3
|
export const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');
|
|
4
4
|
|
|
5
|
-
export interface ChangedAttributeThisOptions
|
|
5
|
+
export interface ChangedAttributeThisOptions {
|
|
6
6
|
type?: typeof Number | typeof Boolean | typeof String;
|
|
7
7
|
while?: 'connected';
|
|
8
8
|
}
|
|
@@ -3,8 +3,7 @@ import {getAddEventListenerMetadata} from './addEventListener';
|
|
|
3
3
|
import {findAllLifecycleMetadata, findAllOnConnectedAfterMetadata, findAllOnConnectedBeforeMetadata, findAllOnConnectedMetadata, ON_AFTER_ADOPTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_CONNECTED_COMPLETED_METADATA_KEY, ON_INITIALIZE_METADATA_KEY} from './lifecycles';
|
|
4
4
|
import {getEmitCustomEventMetadataList} from './emitCustomEvent';
|
|
5
5
|
import {convertAttributeValue, findAllAttributeChangedMetadata} from './changedAttributeThis';
|
|
6
|
-
import {findAllAttributeApplyMetadata} from './applyAttribute';
|
|
7
|
-
import {findAllAttributeMetadata, getAttributeValue} from './attribute';
|
|
6
|
+
import {findAllAttributeApplyMetadata, findAllAttributeMetadata, getAttributeValue} from './applyAttribute';
|
|
8
7
|
import {getQueryMetadata} from './query';
|
|
9
8
|
import {getQueryAllMetadata} from './queryAll';
|
|
10
9
|
import {SwcUtils} from '../utils/Utils';
|
|
@@ -15,6 +14,7 @@ import {ConvertUtils, ElementApply, NodeSlot} from '@dooboostore/core-web';
|
|
|
15
14
|
import {isSSR} from "../elements/SwcAppMixin";
|
|
16
15
|
import {findAllApplySlotMetadata} from "./applySlot";
|
|
17
16
|
import {findAllStateMetadata} from "./state";
|
|
17
|
+
import {findAllPropertyMetadata} from "./applyProperty";
|
|
18
18
|
|
|
19
19
|
// --- Core Interfaces & Types ---
|
|
20
20
|
|
|
@@ -69,16 +69,18 @@ export const ensureInit = (inst: any) => { // HTMLElement
|
|
|
69
69
|
// ║ 4. own property를 삭제하면 JavaScript가 prototype의 getter를 찾게 됨 ║
|
|
70
70
|
// ║ → getter 호출됨 → DOM 속성 값 동기화됨 ║
|
|
71
71
|
// ╚════════════════════════════════════════════════════════════════════════════════╝
|
|
72
|
+
// 함수는 decorator에서 값자체를 descriptor.value = function (...args: any[]) {...
|
|
72
73
|
|
|
73
74
|
// @attribute 필드의 own property 삭제 → getter/setter 작동
|
|
74
|
-
const attributeList = findAllAttributeMetadata(target);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
// const attributeList = findAllAttributeMetadata(target);
|
|
76
|
+
const attributeAllList = findAllAttributeMetadata(target).filter(it => it.type === 'property');
|
|
77
|
+
if (attributeAllList) {
|
|
78
|
+
attributeAllList.forEach(meta => {
|
|
79
|
+
// const initUserData = (inst as any)[meta.propertyKey];
|
|
80
|
+
delete (inst as any)[meta.propertyKey];
|
|
81
|
+
// (inst as any)[meta.propertyKey] = initUserData;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
82
84
|
|
|
83
85
|
// @query 필드의 own property 삭제 → getter 작동
|
|
84
86
|
const queryList = getQueryMetadata(target);
|
|
@@ -95,12 +97,21 @@ export const ensureInit = (inst: any) => { // HTMLElement
|
|
|
95
97
|
delete (inst as any)[meta.propertyKey];
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
|
-
const slotAllList = findAllApplySlotMetadata(target);
|
|
99
|
-
if (slotAllList) {
|
|
100
|
-
|
|
100
|
+
// const slotAllList = findAllApplySlotMetadata(target);
|
|
101
|
+
// if (slotAllList) {
|
|
102
|
+
// slotAllList.filter(it => it.type === 'property').forEach(meta => {
|
|
103
|
+
// delete (inst as any)[meta.propertyKey];
|
|
104
|
+
// });
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const propertyAllList = findAllPropertyMetadata(target).filter(it => it.type === 'property');
|
|
109
|
+
if (propertyAllList) {
|
|
110
|
+
propertyAllList.forEach(meta => {
|
|
101
111
|
delete (inst as any)[meta.propertyKey];
|
|
102
112
|
});
|
|
103
113
|
}
|
|
114
|
+
|
|
104
115
|
const stateAllList = findAllStateMetadata(target);
|
|
105
116
|
if (stateAllList) {
|
|
106
117
|
stateAllList.forEach(meta => {
|
|
@@ -170,24 +181,24 @@ const setupPrototype = (proto: any, win: Window) => {
|
|
|
170
181
|
proto.__swc_proto_setup = true;
|
|
171
182
|
|
|
172
183
|
|
|
173
|
-
proto.createSlotString = function (id: string) {
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
proto.createEaHtml = function (id: string, script: string) {
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
proto.createEaText = function (id: string, script: string) {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
proto.createEaAttribute = function (id: string, name: string, script: string) {
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
proto.createEaEvent = function (id: string, name: string, script: string) {
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
proto.createEaProperty = function (id: string, name: string, script: string) {
|
|
189
|
-
|
|
190
|
-
}
|
|
184
|
+
// proto.createSlotString = function (id: string) {
|
|
185
|
+
// return NodeSlot.slot(`${this._swcId}-${id}`);
|
|
186
|
+
// }
|
|
187
|
+
// proto.createEaHtml = function (id: string, script: string) {
|
|
188
|
+
// return ElementApply.html(id, script);
|
|
189
|
+
// }
|
|
190
|
+
// proto.createEaText = function (id: string, script: string) {
|
|
191
|
+
// return ElementApply.text(id, script);
|
|
192
|
+
// }
|
|
193
|
+
// proto.createEaAttribute = function (id: string, name: string, script: string) {
|
|
194
|
+
// return ElementApply.attribute(id, name, script);
|
|
195
|
+
// }
|
|
196
|
+
// proto.createEaEvent = function (id: string, name: string, script: string) {
|
|
197
|
+
// return ElementApply.event(id, name, script);
|
|
198
|
+
// }
|
|
199
|
+
// proto.createEaProperty = function (id: string, name: string, script: string) {
|
|
200
|
+
// return ElementApply.property(id, name, script);
|
|
201
|
+
// }
|
|
191
202
|
|
|
192
203
|
// swc-id-asdasdasdasd-click=" :value="" {: value fsdfsdafsad :} {html: aaa :} {text: asdas :}
|
|
193
204
|
|
|
@@ -339,9 +350,9 @@ export const elementDefine =
|
|
|
339
350
|
const swcOnEvents = DOM_EVENT_NAMES.map(e => `swc-on-${e}`);
|
|
340
351
|
|
|
341
352
|
const attributeApplyNames = Array.from(applyAttributeMap.values())
|
|
342
|
-
.map(it => it.
|
|
353
|
+
.map(it => it.targetAttributeName)
|
|
343
354
|
.filter(Boolean) as string[];
|
|
344
|
-
const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.
|
|
355
|
+
const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.propertyKey || String(it.propertyKey));
|
|
345
356
|
// Get original static observedAttributes before they're overwritten by Object.defineProperty
|
|
346
357
|
const originalStaticObservedAttributes = (constructor.observedAttributes ?? []) as string[];
|
|
347
358
|
const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map(it => (it.options as any).attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './addEventListener';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './applyAttribute';
|
|
3
3
|
export * from './elementDefine';
|
|
4
4
|
export * from './changedAttributeThis';
|
|
5
5
|
export * from './emitCustomEvent';
|
|
@@ -10,10 +10,9 @@ export * from './queryAll';
|
|
|
10
10
|
export * from './applyClass';
|
|
11
11
|
export * from './applyStyle';
|
|
12
12
|
export * from './applyAttribute';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './applyProperty';
|
|
14
14
|
export * from './subscribeSwcAppRouteChangeWhileConnected';
|
|
15
15
|
export * from './subscribeSwcAppMessageWhileConnected';
|
|
16
16
|
export * from './publishSwcAppMessage';
|
|
17
17
|
export * from './applySlot';
|
|
18
18
|
export * from './state';
|
|
19
|
-
|
|
@@ -122,9 +122,9 @@ const decorator = (options: InnerHtmlOptions, target: Object, propertyKey: strin
|
|
|
122
122
|
list.push({ propertyKey, options });
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
export function
|
|
126
|
-
export function
|
|
127
|
-
export function
|
|
125
|
+
export function onConnectedShadow(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
126
|
+
export function onConnectedShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
127
|
+
export function onConnectedShadow(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
128
128
|
if (propertyKey) { // no parameter option @decorator
|
|
129
129
|
return decorator({useShadow: true}, optionOrTarget!, propertyKey);
|
|
130
130
|
}
|
|
@@ -134,9 +134,9 @@ export function onConnectedShadowDom(optionOrTarget: Omit<InnerHtmlOptions, 'use
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export function
|
|
138
|
-
export function
|
|
139
|
-
export function
|
|
137
|
+
export function onConnectedLight(options: Omit<InnerHtmlOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
138
|
+
export function onConnectedLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
139
|
+
export function onConnectedLight(optionOrTarget: Omit<InnerHtmlOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
140
140
|
if (propertyKey) { // no parameter option @decorator
|
|
141
141
|
return decorator({useShadow: false}, optionOrTarget!, propertyKey);
|
|
142
142
|
}
|
package/src/decorators/state.ts
CHANGED
|
@@ -28,7 +28,6 @@ export function state(nameOrTarget?: string | Object, propertyKey?: string | sym
|
|
|
28
28
|
// console.log('ssssssssssssssss', storage, stateMetadata.propertyKey)
|
|
29
29
|
Object.defineProperty(targetObj, stateMetadata.propertyKey, {
|
|
30
30
|
set(this: any, nv: string) {
|
|
31
|
-
console.log('setState!!', nv)
|
|
32
31
|
storage = nv;
|
|
33
32
|
const config = getElementConfig(this)
|
|
34
33
|
const ea = new ElementApply(this, {id: this._swcId});
|
package/src/elements/SwcApp.ts
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -64,11 +64,11 @@ export interface SwcAppInterface extends HTMLElement {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export interface SwcElement {
|
|
67
|
-
|
|
68
|
-
createSlotString(id: string): string
|
|
69
|
-
createEaHtml(id: string, script: string): string
|
|
70
|
-
createEaText(id: string, script: string): string
|
|
71
|
-
createEaAttribute(id: string, attributeName: string): string
|
|
72
|
-
createEaEvent(id: string, eventName: string): string
|
|
73
|
-
createEaProperty(id: string, propertyName: string): string
|
|
67
|
+
_swcId: string;
|
|
68
|
+
// createSlotString(id: string): string
|
|
69
|
+
// createEaHtml(id: string, script: string): string
|
|
70
|
+
// createEaText(id: string, script: string): string
|
|
71
|
+
// createEaAttribute(id: string, attributeName: string): string
|
|
72
|
+
// createEaEvent(id: string, eventName: string): string
|
|
73
|
+
// createEaProperty(id: string, propertyName: string): string
|
|
74
74
|
}
|