pawajs 2.0.9 → 2.1.0

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
@@ -12,11 +12,11 @@ function isPawaState(obj) {
12
12
  }
13
13
  function restorePawaStateFromContext(oldCtx, newCtx) {
14
14
  if (!oldCtx || !newCtx) return
15
-
16
- for (const key of Object.keys(oldCtx)) {
15
+ for (const key of Object.keys(newCtx)) {
17
16
  const oldVal = oldCtx[key]
18
17
  const newVal = newCtx[key]
19
18
  if (isPawaState(oldVal) && isPawaState(newVal)) {
19
+
20
20
  const newOne=newVal.value
21
21
  const oldOne=oldVal.value
22
22
  if (typeof newOne === typeof oldOne) {
@@ -24,6 +24,7 @@ function restorePawaStateFromContext(oldCtx, newCtx) {
24
24
  }else if (newVal === null) {
25
25
  newVal.value = oldVal.value
26
26
  }
27
+
27
28
  }
28
29
  }
29
30
  }
@@ -189,6 +190,9 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
189
190
 
190
191
  div.innerHTML = compo;
191
192
  if (component?._insert) {
193
+ if (hmrPreserverContext) {
194
+ restorePawaStateFromContext(hmrPreserverContext,component._insert)
195
+ }
192
196
  Object.assign(el._context,component._insert)
193
197
  }
194
198
  const restProps={}
@@ -286,12 +290,8 @@ export const normal_component=(el,stateContext,setStateContext,mapsPlugin,former
286
290
  stateContexts?._error?.forEach((error) => {
287
291
  throw Error(error)
288
292
  })
289
- if (hmr) {
290
- if (hmrPreserverContext) {
291
- restorePawaStateFromContext(context, hmrPreserverContext)
292
- }
293
+
293
294
 
294
- }
295
295
  render(child, context)
296
296
  }
297
297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
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",