pawa-ssr 1.3.11 → 1.3.14
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/index.js +9 -8
- package/package.json +1 -1
- package/pawaElement.js +41 -0
- package/power.js +2 -1
package/index.js
CHANGED
|
@@ -375,13 +375,7 @@ const component=async (el,stream)=>{
|
|
|
375
375
|
}
|
|
376
376
|
})
|
|
377
377
|
const children=el._componentChildren
|
|
378
|
-
|
|
379
|
-
children:children,
|
|
380
|
-
props:{
|
|
381
|
-
...el._hydrateProps,
|
|
382
|
-
},
|
|
383
|
-
slots:{...slotHydrates},
|
|
384
|
-
}
|
|
378
|
+
|
|
385
379
|
|
|
386
380
|
const id=pawaGenerateId(10)
|
|
387
381
|
const encodeJSON = (obj) => Buffer.from(JSON.stringify(obj)).toString('base64').replace(/\+/g, '-');
|
|
@@ -450,7 +444,13 @@ appContext.component._prop={children,...el._props,...slots}
|
|
|
450
444
|
if (appContext?.insert){
|
|
451
445
|
Object.assign(el._context,appContext.insert)
|
|
452
446
|
}
|
|
453
|
-
|
|
447
|
+
const hydrate={
|
|
448
|
+
children:children,
|
|
449
|
+
props:{
|
|
450
|
+
...el._hydrateProps,
|
|
451
|
+
},
|
|
452
|
+
slots:{...slotHydrates},
|
|
453
|
+
}
|
|
454
454
|
if(typeof compo !== 'boolean' && typeof compo === 'string'){
|
|
455
455
|
div.innerHTML=compo
|
|
456
456
|
}
|
|
@@ -1024,6 +1024,7 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
1024
1024
|
if(compo[name]){
|
|
1025
1025
|
components.set(name,compo[name])
|
|
1026
1026
|
el._component.component=compo[name]
|
|
1027
|
+
el._component.validPropRule=compo[name]?.validateProps || {};
|
|
1027
1028
|
lazyComponents.delete(el.tagName)
|
|
1028
1029
|
}
|
|
1029
1030
|
}
|
package/package.json
CHANGED
package/pawaElement.js
CHANGED
|
@@ -195,6 +195,47 @@ class PawaElement {
|
|
|
195
195
|
}else{
|
|
196
196
|
name=attr.name
|
|
197
197
|
}
|
|
198
|
+
const setProps=()=>{
|
|
199
|
+
delete this._restProps[name]
|
|
200
|
+
let hydatename
|
|
201
|
+
if(name === 'class'){
|
|
202
|
+
hydatename=':'+'className'
|
|
203
|
+
}else if(name === 'default'){
|
|
204
|
+
hydatename=':'+'defaultValue'
|
|
205
|
+
}else{
|
|
206
|
+
hydatename=':'+name
|
|
207
|
+
}
|
|
208
|
+
this._hydrateProps[name]=attr.value
|
|
209
|
+
let value=attr.value
|
|
210
|
+
if (value.includes('@{')) {
|
|
211
|
+
const regex = /@{([^}]*)}/g;
|
|
212
|
+
value = value.replace(regex, (match, expression) => {
|
|
213
|
+
if (checkKeywordsExistence(this._staticContext, expression)) {
|
|
214
|
+
return value
|
|
215
|
+
} else {
|
|
216
|
+
const res = this.evaluateExpr(expression,this._context,`evaluating props with template operators at ${attr.name} - ${attr.value} : ${this._template}`)
|
|
217
|
+
return res
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return value
|
|
221
|
+
}else if( attr.name.startsWith('on-') || attr.name.startsWith('out-')){
|
|
222
|
+
const res=this.evaluateExpr(`(e)=>{
|
|
223
|
+
${attr.value}
|
|
224
|
+
}`, this._context,`evaluating props with template operators at ${attr.name} - ${attr.value} : ${this._template}`)
|
|
225
|
+
return res
|
|
226
|
+
}
|
|
227
|
+
return attr.value
|
|
228
|
+
}
|
|
229
|
+
name=name.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
230
|
+
if (this._props[name] || this._props.className || this._props.defaultValue) return
|
|
231
|
+
if (name === 'class') {
|
|
232
|
+
this._props['className']=setProps
|
|
233
|
+
}else if(name === 'default'){
|
|
234
|
+
this._props['defaultValue']=setProps
|
|
235
|
+
}else{
|
|
236
|
+
this._props[name]=setProps
|
|
237
|
+
}
|
|
238
|
+
|
|
198
239
|
this._restProps[name]={name:name,value:attr.value}
|
|
199
240
|
|
|
200
241
|
} else if(attr.name.startsWith(':')) {
|
package/power.js
CHANGED
|
@@ -190,6 +190,7 @@ const switchFunc=el._evaluateExpr(attr.value,el._context,`at switch directive ${
|
|
|
190
190
|
const getRightElement=chainMap.get(latestChain.id)
|
|
191
191
|
if (getRightElement && (current || latestChain.condition === 'default')) {
|
|
192
192
|
const copyElement=getRightElement.element.cloneNode(true)
|
|
193
|
+
|
|
193
194
|
copyElement.attributes.forEach((att)=>{
|
|
194
195
|
if(att.name.startsWith('c-')){
|
|
195
196
|
copyElement.removeAttribute(att.name)
|
|
@@ -200,7 +201,7 @@ const switchFunc=el._evaluateExpr(attr.value,el._context,`at switch directive ${
|
|
|
200
201
|
el._replaceResumeAttr(latestChain.condition,`c-sw-${id}`,latestChain.id)
|
|
201
202
|
newElement = el.cloneNode(true);
|
|
202
203
|
}else{
|
|
203
|
-
el._replaceResumeAttr(latestChain.condition,`c-sw-${id}`,latestChain.id,copyElement)
|
|
204
|
+
el._replaceResumeAttr(latestChain.condition === 's-default'?'s-default':latestChain.condition ,`c-sw-${id}`,latestChain.id,copyElement)
|
|
204
205
|
newElement = copyElement;
|
|
205
206
|
}
|
|
206
207
|
newElement.removeAttribute(latestChain.condition)
|