pawajs 1.4.5 → 1.4.7

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 CHANGED
@@ -592,12 +592,7 @@ export const useAsync = () => {
592
592
  }
593
593
  } else {
594
594
  //sets server initialization to default
595
- return {
596
- $async: (callback) => {
597
- return callback()
598
- },
599
- onSuspense:(html)=>{}
600
- }
595
+ return serverInstance.useAsync?.()
601
596
  }
602
597
  }
603
598
  //resume state during after ssr
@@ -992,7 +987,7 @@ const mainAttribute = (el, exp) => {
992
987
  };
993
988
 
994
989
  const textContentHandler = (el, isName) => {
995
- if (el._hasForOrIf()) {
990
+ if (el._hasForOrIf() || el._componentName) {
996
991
  return
997
992
  }
998
993
  if (el._running) {
@@ -1093,7 +1088,8 @@ export const render = (el, contexts = {}, notRender, isName) => {
1093
1088
  }
1094
1089
  }
1095
1090
  PawaElement.Element(el, context)
1096
- el._staticContext = stateContext._static
1091
+ el._staticContext = stateContext?._static
1092
+ el._stateContext=stateContext
1097
1093
  for (const fn of renderAfterPawa) {
1098
1094
  try {
1099
1095
  fn(el)
@@ -1222,13 +1218,35 @@ export const render = (el, contexts = {}, notRender, isName) => {
1222
1218
  render(child, context, number, isName)
1223
1219
  })
1224
1220
  el._callMount()
1225
- if (el.hasAttribute('p:c')) {
1221
+ if (el.hasAttribute('p:c') && !el.hasAttribute('p-async')) {
1226
1222
  el.removeAttribute('p:c')
1227
1223
  }
1228
1224
  }
1229
1225
  }
1230
-
1231
-
1226
+ // added streaming awareness
1227
+ if (typeof window !== 'undefined') {
1228
+ window.__pawaStream=(element,context,statecontext)=>{
1229
+ let appContext
1230
+ if(!window?.__pawaHasStarted){
1231
+ if(window?.__startClient === null )return
1232
+ window?.__startClient()
1233
+
1234
+ window.__startClient=null
1235
+ window.__pawaHasStarted=true
1236
+ return
1237
+ }
1238
+ if(statecontext === undefined){
1239
+ appContext=stateContext
1240
+ }else{
1241
+ appContext=statecontext
1242
+ }
1243
+ keepContext(appContext)
1244
+ appContext._hasRun=false
1245
+ render(element,context,{index:0,notRender:null})
1246
+ appContext._hasRun=true
1247
+ }
1248
+
1249
+ }
1232
1250
  export const pawaStartApp = (app, context = {}) => {
1233
1251
  render(app, context)
1234
1252
  }
@@ -101,7 +101,9 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
101
101
  Object.assign(el._context,storeContext._insert)
102
102
  }
103
103
  childInsert(false)
104
- lifeCircle()
104
+ Promise.resolve().then(()=>{
105
+ lifeCircle()
106
+ })
105
107
  storeContext._hasRun=true
106
108
  stateContext=null
107
109
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "type":"module",
5
5
  "description": "pawajs library (html runtime) for easily building web ui, enhancing html element, micro frontend etc ",
6
6
  "main": "index.js",
package/pawaElement.js CHANGED
@@ -21,6 +21,7 @@ export class PawaElement {
21
21
  this._avoidPawaRender=element.hasAttribute('pawa-avoid');
22
22
  this._el=element
23
23
  this._out=false;
24
+ this._stateContext=null
24
25
  this._terminateEffects=new Set()
25
26
  this._deleteEffects=this.terminateEffects
26
27
  /**
@@ -136,6 +137,7 @@ export class PawaElement {
136
137
  }
137
138
  setPawaAttr(){
138
139
  const isResume=this._el.hasAttribute('p:c')
140
+ if (this._el.hasAttribute('p-async')) return
139
141
  if(isResume){
140
142
  const pawaAttr=this._el.getAttribute('p:c')
141
143
  const array=pawaAttr.split(';')
@@ -347,7 +349,11 @@ export class PawaElement {
347
349
  }`
348
350
  const value=this.safeEval(this._context,expression,`prop sdvd :${propsName}`,true)
349
351
  if (value) {
350
- this._props[propsName]=value
352
+ let name=propsName
353
+ if(name.includes('-')){
354
+ name=name.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
355
+ }
356
+ this._props[name]=value
351
357
  }
352
358
  }
353
359
  })
package/server.js CHANGED
@@ -9,6 +9,7 @@ const serverInstance={
9
9
  $state:null,
10
10
  accessChild:null,
11
11
  useServer:null,
12
+ useAsync:null,
12
13
  }
13
14
  export const getServerInstance=()=>serverInstance
14
15
  export const setServer=(obj={})=>{