pawajs-continue 1.0.11 → 1.0.13

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.
Files changed (2) hide show
  1. package/component.js +26 -5
  2. package/package.json +2 -2
package/component.js CHANGED
@@ -1,4 +1,4 @@
1
- import { components,keepContext,render,getCurrentContext } from "pawajs/index.js"
1
+ import { components,keepContext,render,getCurrentContext, HmrComponentMap } from "pawajs/index.js"
2
2
  import { PawaElement, PawaComment } from "pawajs/pawaElement.js"
3
3
  import PawaComponent from "pawajs/pawaComponent.js"
4
4
  import { createEffect } from "pawajs/reactive.js"
@@ -103,7 +103,7 @@ const oldState=getCurrentContext()
103
103
  }
104
104
  stateContexts._prop={children:'',...props._props}
105
105
  stateContexts._elementContext={...element._context}
106
- stateContexts._static=[...stateContexts._static,...props.context]
106
+ stateContexts._static=[...oldState?._static,...props.context]
107
107
  const number={notRender:null,index:null}
108
108
 
109
109
  children.forEach((value, index) => {
@@ -149,6 +149,7 @@ const oldState=getCurrentContext()
149
149
  const component =element._component
150
150
  const stateContexts=setStateContext(component)
151
151
  stateContexts._resume=true
152
+ stateContexts._static=[...oldState?._static,...props.context]
152
153
  stateContexts._prop={children:props.children,...element._props}
153
154
  stateContexts._elementContext={...element._context}
154
155
  stateContexts._name=element._componentName
@@ -158,6 +159,21 @@ const oldState=getCurrentContext()
158
159
  }
159
160
  stateContexts._serializedData=props.data
160
161
  let isAwait=false
162
+ if (__pawaDev.tool) {
163
+ const id= crypto.randomUUID()
164
+ if (HmrComponentMap.has(stateContexts.component._filePath) && stateContexts.component._filePath) {
165
+ HmrComponentMap.get(stateContexts.component._filePath).push({id:id,template:el._template,el:el,stateContext:stateContexts})
166
+ }else{
167
+ HmrComponentMap.set(stateContexts.component._filePath,[{id:id,template:el._template,el:el,stateContext:stateContexts}])
168
+ }
169
+ el._setUnMount(()=>{
170
+ const array=HmrComponentMap.get(stateContexts.component._filePath)
171
+ if(array){
172
+ const index=array.findIndex(item => item.id === id)
173
+ if(index !== -1) array.splice(index,1)
174
+ }
175
+ })
176
+ }
161
177
  if(done){
162
178
  const compoCall=component.component(apps)
163
179
  isAwait=compoCall instanceof Promise
@@ -188,9 +204,14 @@ const oldState=getCurrentContext()
188
204
  }
189
205
  const context=element._context
190
206
  const childInsert=()=>{
191
- // if (getCorrectContext(component._insert)) { // check if the component context doesn't match with the servers
192
- // return
193
- // }
207
+ for (const key in component._insert) {
208
+ if (stateContexts._static.includes(key)) {
209
+ const index=stateContexts._static.findIndex((v)=>v === key)
210
+ if (index !== -1) {
211
+ stateContexts>_static.splice(index,1)
212
+ }
213
+ }
214
+ }
194
215
  element._component?._hook?.beforeMount?.forEach((bfm) => {
195
216
  const result= bfm(comment)
196
217
  if (typeof result === 'function') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs-continue",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Pawajs continuity initializer library for ssr",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,6 +23,6 @@
23
23
  },
24
24
  "homepage": "https://github.com/Allisboy/pawajs-continue#readme",
25
25
  "dependencies": {
26
- "pawajs": "^1.4.24"
26
+ "pawajs": "^1.4.25"
27
27
  }
28
28
  }