pawa-ssr 1.3.10 → 1.3.13
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 +11 -6
- package/package.json +2 -2
- package/pawaElement.js +42 -1
- package/power.js +4 -3
- package/utils.js +6 -1
package/index.js
CHANGED
|
@@ -783,8 +783,9 @@ const textContentHandler = async(el) => {
|
|
|
783
783
|
const nodesMap = new Map();
|
|
784
784
|
const currentHtmlString = el.outerHTML;
|
|
785
785
|
el.setAttribute('c-t',true)
|
|
786
|
+
const newString=el.innerHTML.replace('-','(//)')
|
|
786
787
|
const document = el.ownerDocument
|
|
787
|
-
const comment=document.createComment(`textEvaluator-${
|
|
788
|
+
const comment=document.createComment(`textEvaluator-${newString}`)
|
|
788
789
|
el.appendChild(comment)
|
|
789
790
|
// Get all text nodes and store their original content
|
|
790
791
|
const textNodes = Array.from(el.childNodes).filter(node => node.nodeType === 3);
|
|
@@ -889,7 +890,7 @@ const attributeHandler =async (el, attr) => {
|
|
|
889
890
|
partlyPawajsDirective.add(v)
|
|
890
891
|
})
|
|
891
892
|
}
|
|
892
|
-
addToPartlyDirective('else','else-if','case','default')
|
|
893
|
+
addToPartlyDirective('else','else-if','case','s-default')
|
|
893
894
|
const checkIfRemove=(el)=>{
|
|
894
895
|
for (const v of partlyPawajsDirective) {
|
|
895
896
|
if(el.hasAttribute(v)) return true
|
|
@@ -1017,11 +1018,15 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
1017
1018
|
}
|
|
1018
1019
|
if (el._componentName) {
|
|
1019
1020
|
if(el._lazy && lazyComponents.has(el.tagName)){
|
|
1020
|
-
const lazyComponent=lazyComponents.
|
|
1021
|
+
const lazyComponent=lazyComponents.get(el.tagName)
|
|
1021
1022
|
const {name,component} =lazyComponent()
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1023
|
+
const compo=await component()
|
|
1024
|
+
if(compo[name]){
|
|
1025
|
+
components.set(name,compo[name])
|
|
1026
|
+
el._component.component=compo[name]
|
|
1027
|
+
el._component.validPropRule=compo[name]?.validateProps || {};
|
|
1028
|
+
lazyComponents.delete(el.tagName)
|
|
1029
|
+
}
|
|
1025
1030
|
}
|
|
1026
1031
|
if(isStream){
|
|
1027
1032
|
await streamingComponent(el,stream)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pawa-ssr",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"type":"module",
|
|
5
5
|
"description": "pawajs ssr libary",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"homepage": "https://github.com/Allisboy/pawajs-ssr#readme",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"linkedom": "^0.18.11",
|
|
28
|
-
"pawajs": "^1.4.
|
|
28
|
+
"pawajs": "^1.4.36"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/pawaElement.js
CHANGED
|
@@ -79,7 +79,7 @@ class PawaElement {
|
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
checkLazy(){
|
|
82
|
-
if (lazyComponents.has(this._el.tagName)) {
|
|
82
|
+
if (lazyComponents.has(splitAndAdd(this._el.tagName))) {
|
|
83
83
|
this._lazy=true
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -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
|
@@ -126,8 +126,8 @@ export const Switch = async(el, attr,stream) => {
|
|
|
126
126
|
const getChained = (sibling) => {
|
|
127
127
|
while (sibling) {
|
|
128
128
|
const next = sibling.nextElementSibling;
|
|
129
|
-
const isCase = sibling.hasAttribute('case');
|
|
130
|
-
const isDefault = sibling.hasAttribute('default');
|
|
129
|
+
const isCase = sibling.hasAttribute('case') && !sibling.hasAttribute('switch');
|
|
130
|
+
const isDefault = sibling.hasAttribute('s-default');
|
|
131
131
|
|
|
132
132
|
if (isCase) {
|
|
133
133
|
const exp = sibling.getAttribute('case');
|
|
@@ -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)
|
package/utils.js
CHANGED
|
@@ -187,7 +187,12 @@ export const convertToNumber=(str)=>{
|
|
|
187
187
|
return hash
|
|
188
188
|
};
|
|
189
189
|
export const ComponentProps=(somes,message,name)=>{
|
|
190
|
-
let some
|
|
190
|
+
let some
|
|
191
|
+
if (typeof somes === 'function') {
|
|
192
|
+
some=somes()
|
|
193
|
+
}else{
|
|
194
|
+
some=somes
|
|
195
|
+
}
|
|
191
196
|
return({
|
|
192
197
|
Array:()=>{
|
|
193
198
|
|