pawa-ssr 1.3.23 → 1.3.24
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 +4 -7
- package/package.json +2 -2
- package/pawaElement.js +3 -0
- package/test/App.js +9 -0
- package/test/check.js +13 -0
- package/test/index.js +15 -64
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { propsValidator, evaluateExpr,extractAtExpressions, reArrangeAttri,resum
|
|
|
5
5
|
import {AsyncLocalStorage} from'node:async_hooks'
|
|
6
6
|
import { If,For,State,Switch, Key } from'./power.js';
|
|
7
7
|
import PawaElement from'./pawaElement.js'
|
|
8
|
-
import { pluginsMap, lazyComponents } from "pawajs/index.js";
|
|
8
|
+
import { pluginsMap, lazyComponents,components } from "pawajs/index.js";
|
|
9
9
|
|
|
10
10
|
const PAWA_STORE_SYMBOL = Symbol.for('pawa.ssr.store');
|
|
11
11
|
|
|
@@ -216,10 +216,7 @@ setServer({
|
|
|
216
216
|
forwardProps
|
|
217
217
|
})
|
|
218
218
|
export const pawaForServer=setServer
|
|
219
|
-
|
|
220
|
-
export const getPawaComponentsMap =()=>{
|
|
221
|
-
return components ;
|
|
222
|
-
}
|
|
219
|
+
|
|
223
220
|
const getStore=()=>{
|
|
224
221
|
return store.getStore()
|
|
225
222
|
}
|
|
@@ -1124,10 +1121,10 @@ export const render =async (el, contexts = {},stream) => {
|
|
|
1124
1121
|
const compo=await component()
|
|
1125
1122
|
if(compo[name]){
|
|
1126
1123
|
|
|
1127
|
-
components.set(name,compo[name])
|
|
1124
|
+
components.set(name.toUpperCase(),compo[name])
|
|
1128
1125
|
el._component.component=compo[name]
|
|
1129
1126
|
el._component.validPropRule=compo[name]?.validateProps || {};
|
|
1130
|
-
lazyComponents.delete(
|
|
1127
|
+
lazyComponents.delete(name.toUpperCase())
|
|
1131
1128
|
}
|
|
1132
1129
|
} catch (error) {
|
|
1133
1130
|
throw new Error(`lazy component ${el.tagName} : Error from the component - ${error.message}`,error.message)
|
package/package.json
CHANGED
package/pawaElement.js
CHANGED
|
@@ -90,6 +90,7 @@ class PawaElement {
|
|
|
90
90
|
this._el.setAttribute('p:C',this._resumeAttr)
|
|
91
91
|
}
|
|
92
92
|
pawaAttribute(){
|
|
93
|
+
const componentAllowedAttribute=['if','else-if','for-each','switch','case','key','s-default','else']
|
|
93
94
|
const pawaAttr=getPawaAttributes()
|
|
94
95
|
const setTextResume=()=>{
|
|
95
96
|
if( this._componentName === ''&& this._el.firstElementChild === null && this._el.childNodes.some(node=>node.nodeType === 3 && node.nodeValue.includes('@{')) && !this._avoidPawaRender){
|
|
@@ -103,12 +104,14 @@ class PawaElement {
|
|
|
103
104
|
if (this._el.hasAttribute('p:c')) {
|
|
104
105
|
this._resumeAttr=this._el.getAttribute('p:c')
|
|
105
106
|
this._el.attributes.forEach((value, index, array) => {
|
|
107
|
+
// if (this._componentName && !componentAllowedAttribute.includes(value.name)) return
|
|
106
108
|
if(this._resumeAttr.includes(value.name) || value.name === 'p:c')return
|
|
107
109
|
if (value.name.startsWith(':')) return
|
|
108
110
|
this._resumeAttr+=`${value.name};`
|
|
109
111
|
})
|
|
110
112
|
}else{
|
|
111
113
|
this._el.attributes.forEach((value, index, array) => {
|
|
114
|
+
if (this._componentName && !componentAllowedAttribute.includes(value.name)) return
|
|
112
115
|
if(this._resumeAttr.includes(value.name) || value.name === 'p:c' )return
|
|
113
116
|
if (value.name.startsWith(':')) return
|
|
114
117
|
this._resumeAttr+=`${value.name};`
|
package/test/App.js
ADDED
package/test/check.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const Check=()=>{
|
|
2
|
+
return `<div class="p-4">
|
|
3
|
+
<h1 class="text-2xl font-bold mb-4">Hello, World!</h1>
|
|
4
|
+
<p class="text-gray-700">This is a test Checker</p>
|
|
5
|
+
</div>`
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Check2=()=>{
|
|
9
|
+
return `<div class="p-4">
|
|
10
|
+
<h1 class="text-2xl font-bold mb-4">Hello, World!</h1>
|
|
11
|
+
<p class="text-gray-700">This is a test Checker 2</p>
|
|
12
|
+
</div>`
|
|
13
|
+
}
|
package/test/index.js
CHANGED
|
@@ -1,67 +1,18 @@
|
|
|
1
1
|
import {useValidateComponent, RegisterComponent,useContext,useInsert,setContext} from 'pawajs'
|
|
2
2
|
import {startApp} from '../index.js'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
useInsert({user,array,name})
|
|
9
|
-
return `
|
|
10
|
-
<div>
|
|
11
|
-
<h1 title="@{user ? name():'Guest'}" -->
|
|
12
|
-
<span>@{name()}</span>
|
|
13
|
-
<span if="user">Allwell</span>
|
|
14
|
-
<span else>false</span>
|
|
15
|
-
</h1>
|
|
16
|
-
<div s-for="items in array" s-pawa-avoid>
|
|
17
|
-
<span>@{items}</span>
|
|
18
|
-
</div>
|
|
19
|
-
<small-app></small-app>
|
|
20
|
-
</div>
|
|
21
|
-
`
|
|
22
|
-
}
|
|
23
|
-
const SmallApp=()=>{
|
|
24
|
-
const {name}=useContext(auth)
|
|
25
|
-
useInsert({name})
|
|
26
|
-
return /*html*/`
|
|
27
|
-
<div state-count="0">
|
|
28
|
-
<h1>Small App Component</h1>
|
|
29
|
-
<span>@{name}</span>
|
|
30
|
-
<h1>@{count.value}</h1>
|
|
31
|
-
<new-app></new-app>
|
|
32
|
-
</div>`
|
|
33
|
-
}
|
|
34
|
-
useValidateComponent(component,{
|
|
35
|
-
name:{
|
|
36
|
-
strict:true,
|
|
37
|
-
type:String
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
const NewApp=()=>{
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
RegisterComponent(component,SmallApp,NewApp)
|
|
44
|
-
const html=()=>{
|
|
45
|
-
return `
|
|
46
|
-
<!doctype html>
|
|
47
|
-
<html lang="en">
|
|
48
|
-
<head>
|
|
49
|
-
<meta charset="UTF-8" />
|
|
50
|
-
<link rel="icon" type="image/svg+xml" href="/pawajs.svg" />
|
|
51
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
52
|
-
<title>pawajs-template</title>
|
|
53
|
-
</head>
|
|
54
|
-
<body>
|
|
55
|
-
<div id="app">
|
|
56
|
-
<div>
|
|
57
|
-
<component :name="'Allwell'"></component>
|
|
58
|
-
</div>
|
|
3
|
+
RegisterComponent.lazy(
|
|
4
|
+
'App',()=>import('./App.js'),
|
|
5
|
+
'Check',()=>import('./check.js'),
|
|
6
|
+
'Check2',()=>import('./check.js'),
|
|
7
|
+
)
|
|
59
8
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
9
|
+
const app=`
|
|
10
|
+
<div>
|
|
11
|
+
<app>
|
|
12
|
+
<check></check>
|
|
13
|
+
<check-2></check-2>
|
|
14
|
+
</app>
|
|
15
|
+
</div>
|
|
16
|
+
`
|
|
17
|
+
const {toString}=await startApp(app)
|
|
18
|
+
console.log(await toString());
|