pawa-ssr 1.3.3 → 1.3.5
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 +28 -23
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -224,7 +224,7 @@ export const getAllServerAttrArray=()=>{
|
|
|
224
224
|
|
|
225
225
|
const {compoAfterCall,compoBeforeCall,externalPlugin,
|
|
226
226
|
fullNamePlugin,renderAfterPawa,renderBeforeChild,
|
|
227
|
-
renderBeforePawa,startsWithSet
|
|
227
|
+
renderBeforePawa,startsWithSet,pawaAttributes
|
|
228
228
|
}=pluginsMap()
|
|
229
229
|
const setPawaAttribute=(...attr)=>{
|
|
230
230
|
attr.forEach(att=>{
|
|
@@ -464,12 +464,12 @@ appContext.component._prop={children,...el._props,...slots}
|
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
// Handle multiple root nodes (Fragments)
|
|
467
|
-
const newElements =
|
|
467
|
+
const newElements = div.firstElementChild
|
|
468
468
|
for (const fn of compoAfterCall) {
|
|
469
469
|
try {
|
|
470
470
|
// Note: passing the first child might be limiting if there are multiple,
|
|
471
471
|
// but keeping API consistent for now.
|
|
472
|
-
await fn(appContext, newElements
|
|
472
|
+
await fn(appContext, newElements, el)
|
|
473
473
|
} catch (error) {
|
|
474
474
|
console.error(error.message,error.stack)
|
|
475
475
|
}
|
|
@@ -492,20 +492,19 @@ appContext.component._prop={children,...el._props,...slots}
|
|
|
492
492
|
|
|
493
493
|
comment.data=`component+${id}+${el._componentName}+${encodeJSON(hydrate)}`
|
|
494
494
|
|
|
495
|
-
|
|
496
|
-
comment.parentElement.insertBefore(newElement, endComment)
|
|
495
|
+
comment.parentElement.insertBefore(newElements, endComment)
|
|
497
496
|
|
|
498
|
-
|
|
497
|
+
newElements.setAttribute('p:c', el.getAttribute('p:c'))
|
|
499
498
|
Array.from(el.attributes).forEach((value) => {
|
|
500
499
|
if (value.name.startsWith('c-')) {
|
|
501
|
-
|
|
500
|
+
newElements.setAttribute(value.name, value.value)
|
|
502
501
|
}
|
|
503
502
|
})
|
|
504
503
|
|
|
505
|
-
|
|
506
|
-
await render(
|
|
504
|
+
newElements.setAttribute(`c-c-${el._componentName}-${id}`, id)
|
|
505
|
+
await render(newElements, el._context,stream)
|
|
507
506
|
|
|
508
|
-
|
|
507
|
+
|
|
509
508
|
store.getStore().stateContext=appContext.formerContext
|
|
510
509
|
} catch (error) {
|
|
511
510
|
console.log(error.message,error.stack);
|
|
@@ -678,12 +677,12 @@ appContext.component._prop={children,...el._props,...slots}
|
|
|
678
677
|
}
|
|
679
678
|
|
|
680
679
|
// Handle multiple root nodes (Fragments)
|
|
681
|
-
const newElements =
|
|
680
|
+
const newElements = div.firstElementChild
|
|
682
681
|
for (const fn of compoAfterCall) {
|
|
683
682
|
try {
|
|
684
683
|
// Note: passing the first child might be limiting if there are multiple,
|
|
685
684
|
// but keeping API consistent for now.
|
|
686
|
-
await fn(appContext, newElements
|
|
685
|
+
await fn(appContext, newElements, el)
|
|
687
686
|
} catch (error) {
|
|
688
687
|
console.error(error.message,error.stack)
|
|
689
688
|
}
|
|
@@ -707,26 +706,26 @@ appContext.component._prop={children,...el._props,...slots}
|
|
|
707
706
|
comment.data=`component+${id}+${el._componentName}+${encodeJSON(hydrate)}`
|
|
708
707
|
stream(`<!--${comment.data}-->`)
|
|
709
708
|
|
|
710
|
-
|
|
711
|
-
comment.parentElement.insertBefore(
|
|
709
|
+
|
|
710
|
+
comment.parentElement.insertBefore(newElements, endComment)
|
|
712
711
|
if (!isBoundary) {
|
|
713
|
-
|
|
712
|
+
newElements.setAttribute('p:c', el.getAttribute('p:c'))
|
|
714
713
|
}else{
|
|
715
|
-
|
|
716
|
-
|
|
714
|
+
newElements.setAttribute('p:c',el.getAttribute('p:c'))
|
|
715
|
+
newElements.setAttribute('p-async', el.getAttribute('p:c'))
|
|
717
716
|
}
|
|
718
717
|
Array.from(el.attributes).forEach((value) => {
|
|
719
718
|
if (value.name.startsWith('c-')) {
|
|
720
|
-
|
|
719
|
+
newElements.setAttribute(value.name, value.value)
|
|
721
720
|
}
|
|
722
721
|
})
|
|
723
722
|
|
|
724
|
-
|
|
723
|
+
newElements.setAttribute(`c-c-${el._componentName}-${id}`, id)
|
|
725
724
|
|
|
726
725
|
|
|
727
|
-
await render(
|
|
726
|
+
await render(newElements, el._context,stream)
|
|
728
727
|
|
|
729
|
-
|
|
728
|
+
|
|
730
729
|
stream(`<!--${endComment.data}-->`)
|
|
731
730
|
|
|
732
731
|
appContext.mount.forEach(async(call)=>{
|
|
@@ -915,11 +914,17 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
915
914
|
el.replaceWith(comment)
|
|
916
915
|
template.appendChild(el)
|
|
917
916
|
comment.replaceWith(template)
|
|
917
|
+
if (isStream) {
|
|
918
|
+
stream(template.outerHTML)
|
|
919
|
+
}
|
|
918
920
|
return
|
|
919
921
|
}
|
|
920
922
|
if (el.tagName === 'HEAD') {
|
|
921
923
|
if (el.querySelector('title')) {
|
|
922
924
|
el.ownerDocument.head.querySelector('title')?.remove()
|
|
925
|
+
if (isStream) {
|
|
926
|
+
stream(`<script>document.title='${el.querySelector('title').textContent || ''}'</script>`)
|
|
927
|
+
}
|
|
923
928
|
}
|
|
924
929
|
Array.from(el.children).forEach(child => {
|
|
925
930
|
el.ownerDocument.head.appendChild(child)
|
|
@@ -1184,9 +1189,9 @@ export const startStreamApp = async (html, context = {},stream,{templateStart,te
|
|
|
1184
1189
|
`).join('')}
|
|
1185
1190
|
</div>
|
|
1186
1191
|
` : ''
|
|
1187
|
-
__pawaDev.errors=[]
|
|
1188
1192
|
stream(errorHtml)
|
|
1189
|
-
|
|
1193
|
+
stream(templateEnd)
|
|
1194
|
+
__pawaDev.errors=[]
|
|
1190
1195
|
};
|
|
1191
1196
|
|
|
1192
1197
|
const resolvesAsync=async({component,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pawa-ssr",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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.25"
|
|
29
29
|
}
|
|
30
30
|
}
|