pawajs 2.0.9 → 2.0.10

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.d.ts CHANGED
@@ -384,7 +384,7 @@ export function forwardProps(props?: Record<string, any>): void;
384
384
  export function useInsert(obj?: Record<string, any>): void;
385
385
 
386
386
  export function setStateContext(context: any): any;
387
- export function globalRerender(el:HTMLElement | string,formercontext)
387
+ export function globalRerender(el:HTMLElement | string,formercontext:StateContextType,context:any)
388
388
  /**
389
389
  * Creates a reactive state.
390
390
  * @template T
@@ -11,12 +11,16 @@ function isPawaState(obj) {
11
11
  )
12
12
  }
13
13
  function restorePawaStateFromContext(oldCtx, newCtx) {
14
+
14
15
  if (!oldCtx || !newCtx) return
15
16
 
16
- for (const key of Object.keys(oldCtx)) {
17
+ for (const key of Object.keys(newCtx)) {
18
+ console.log(key,'inside preserverState');
19
+
17
20
  const oldVal = oldCtx[key]
18
21
  const newVal = newCtx[key]
19
22
  if (isPawaState(oldVal) && isPawaState(newVal)) {
23
+
20
24
  const newOne=newVal.value
21
25
  const oldOne=oldVal.value
22
26
  if (typeof newOne === typeof oldOne) {
@@ -24,6 +28,8 @@ function restorePawaStateFromContext(oldCtx, newCtx) {
24
28
  }else if (newVal === null) {
25
29
  newVal.value = oldVal.value
26
30
  }
31
+ console.log('is updating',key, newVal,'from',oldVal);
32
+
27
33
  }
28
34
  }
29
35
  }
@@ -189,6 +195,9 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
189
195
 
190
196
  div.innerHTML = compo;
191
197
  if (component?._insert) {
198
+ if (hmrPreserverContext) {
199
+ restorePawaStateFromContext(hmrPreserverContext,component._insert)
200
+ }
192
201
  Object.assign(el._context,component._insert)
193
202
  }
194
203
  const restProps={}
@@ -286,12 +295,8 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
286
295
  stateContexts?._error?.forEach((error) => {
287
296
  throw Error(error)
288
297
  })
289
- if (hmr) {
290
- if (hmrPreserverContext) {
291
- restorePawaStateFromContext(context, hmrPreserverContext)
292
- }
298
+
293
299
 
294
- }
295
300
  render(child, context)
296
301
  }
297
302
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "type":"module",
5
5
  "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend, spa etc ",
6
6
  "main": "index.js",