pawajs 1.4.38 → 1.4.39

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 (3) hide show
  1. package/index.js +26 -15
  2. package/merger/for.js +5 -18
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -244,10 +244,11 @@ export const getPawaAttributes = () => {
244
244
  let laziler
245
245
  export const lazyComponentElement=new Map()
246
246
  export const addLazyComponentElement=(element,func)=>{
247
- if (lazyComponentElement.has(element.tagName)) {
248
- lazyComponentElement.get(element.tagName).push({element:element,func})
247
+ const tagName=splitAndAdd(element.tagName)
248
+ if (lazyComponentElement.has(tagName)) {
249
+ lazyComponentElement.get(tagName).push({element:element,func})
249
250
  }else{
250
- lazyComponentElement.set(element.tagName, [{element:element,func}])
251
+ lazyComponentElement.set(tagName, [{element:element,func}])
251
252
  }
252
253
  }
253
254
  /**
@@ -286,7 +287,7 @@ export const createIntersectionObserver = (element, observeBy) => {
286
287
  const observer = new IntersectionObserver(entries => {
287
288
  entries.forEach(entry => {
288
289
  if (entry.isIntersecting) {
289
- const tagName = element.tagName;
290
+ const tagName = splitAndAdd(element.tagName);
290
291
  const lazyData = lazyComponents.get(tagName);
291
292
 
292
293
  if (!lazyData) return;
@@ -313,6 +314,7 @@ export const createIntersectionObserver = (element, observeBy) => {
313
314
  el._stateContext._hasRun = true;
314
315
  }
315
316
  }
317
+ lazyComponentElement.delete(tagName)
316
318
  observer.disconnect();
317
319
  }).catch(err => console.error(`Lazy load failed for ${tagName}:`, err));
318
320
  }
@@ -856,13 +858,14 @@ export const restoreContext = (state_context) => {
856
858
  stateContext = state_context._formerContext
857
859
  }
858
860
  export const HmrComponentMap=new Map()
861
+ const renderedComponentsRusumed=new Set()
859
862
  /**
860
863
  *
861
864
  * @param {PawaElement|HTMLElement} el
862
865
  * @returns null
863
866
  */
864
867
  const component = (el, resume = false, attr, notRender, stopResume) => {
865
- if (el._running) {
868
+ if (el._running || (resume && renderedComponentsRusumed.has(attr.value))) {
866
869
  return
867
870
  }
868
871
  el._running = true
@@ -870,6 +873,7 @@ const component = (el, resume = false, attr, notRender, stopResume) => {
870
873
  if (!resume) {
871
874
  if (el._lazy) {
872
875
  // pas the normal component to lazy handler
876
+ el.style.opacity=0
873
877
  addLazyComponentElement(el,()=>normal_component(el, stateContext, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch))
874
878
  return
875
879
  }else{
@@ -877,7 +881,7 @@ const component = (el, resume = false, attr, notRender, stopResume) => {
877
881
  }
878
882
  } else {
879
883
  stopResume.stop = true
880
- let name
884
+ let name=''
881
885
  let comment
882
886
  let endComment
883
887
  const children = []
@@ -933,12 +937,14 @@ const component = (el, resume = false, attr, notRender, stopResume) => {
933
937
  numberComponentChildren = notRender.index + children.length -1
934
938
  }
935
939
  notRender.notRender = numberComponentChildren
936
- if (lazyComponents.has(name)) {
940
+ renderedComponentsRusumed.add(attr.value)
941
+
942
+ if (lazyComponents.has(name.toUpperCase())) {
937
943
  const trackElement=document.createElement(name)
938
944
  trackElement._stateContext=el._stateContext
939
945
  addLazyComponentElement(trackElement,()=>resumer.resume_component?.(el, attr, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch, { comment, endComment, name, serialized, id, children }))
940
- if (!lazyComponentElement.has(name)) {
941
- createInsectObserver(trackElement,el)
946
+ if (lazyComponentElement.has(name.toUpperCase())) {
947
+ createIntersectionObserver(trackElement,el)
942
948
  }
943
949
  }else{
944
950
  resumer.resume_component?.(el, attr, setStateContext, mapsPlugins, formerStateContext, pawaContext, stateWatch, { comment, endComment, name, serialized, id, children })
@@ -1009,6 +1015,7 @@ const mainAttribute = (el, exp) => {
1009
1015
  el.setAttribute(exp.name, value);
1010
1016
  } else {
1011
1017
  if ((exp.name === 'class' || exp.name === 'style') && enter) {
1018
+ console.log('entered',enter);
1012
1019
 
1013
1020
  requestAnimationFrame(()=>{
1014
1021
  el.setAttribute(exp.name, value);
@@ -1149,11 +1156,7 @@ export const render = (el, contexts = {}, notRender, isName) => {
1149
1156
  }
1150
1157
  }
1151
1158
 
1152
- if (Array.from(el.childNodes).some(node =>
1153
- node.nodeType === Node.TEXT_NODE && node.nodeValue.includes('@{')
1154
- ) && !el._avoidPawaRender) {
1155
- textContentHandler(el, isName)
1156
- }
1159
+
1157
1160
  let startAttribute = false
1158
1161
  const startObject = {}
1159
1162
  //get startsWith plugin
@@ -1170,6 +1173,7 @@ export const render = (el, contexts = {}, notRender, isName) => {
1170
1173
  })
1171
1174
  const number = { notRender: null }
1172
1175
  const isAcomponent=el._componentName?true:false
1176
+
1173
1177
  el._attributes.forEach(attr => {
1174
1178
 
1175
1179
  if (stopResume.stop || el._hasRun) return
@@ -1191,6 +1195,8 @@ export const render = (el, contexts = {}, notRender, isName) => {
1191
1195
  }
1192
1196
  else if (attr.name.startsWith('c-c-')) {
1193
1197
  stopResume.stop = true
1198
+
1199
+
1194
1200
  component(el, true, attr, notRender, stopResume)// component continuity
1195
1201
  } else if (attr.name.startsWith('c-at-')) {
1196
1202
  resumer.resume_attribute?.(el, attr, notRender) //attribute continuity
@@ -1239,7 +1245,13 @@ export const render = (el, contexts = {}, notRender, isName) => {
1239
1245
 
1240
1246
  })
1241
1247
  }
1248
+
1242
1249
  if (stopResume.stop) return
1250
+ if (Array.from(el.childNodes).some(node =>
1251
+ node.nodeType === Node.TEXT_NODE && node.nodeValue.includes('@{')
1252
+ ) && !el._avoidPawaRender) {
1253
+ textContentHandler(el, isName)
1254
+ }
1243
1255
  if (el._componentName && !el._avoidPawaRender) {
1244
1256
  component(el)
1245
1257
  return
@@ -1336,7 +1348,6 @@ const Pawa = {
1336
1348
  useAsync,
1337
1349
  useInnerContext,
1338
1350
  RegisterComponent,
1339
- forwardProps,
1340
1351
  runEffect,
1341
1352
  html
1342
1353
  }
package/merger/for.js CHANGED
@@ -12,6 +12,7 @@ export const merger_for = (el, stateContext, attr, arrayName, arrayItem, indexes
12
12
  let context=el._context
13
13
  const keyOrder=keyOrders || new Map()
14
14
  let noKey
15
+ let array
15
16
  const evaluate = () => {
16
17
  if (endComment.parentElement === null) {
17
18
  el._deleteEffects()
@@ -20,7 +21,7 @@ export const merger_for = (el, stateContext, attr, arrayName, arrayItem, indexes
20
21
  if (!func) {
21
22
  func=el.safeEval(context, arrayName, 'for-each');
22
23
  }
23
- let array = func(...getEvalValues(context))
24
+ array = func(...getEvalValues(context))
24
25
  let update;
25
26
  if (!firstEnter) {
26
27
  const div = document.createElement('div')
@@ -56,6 +57,7 @@ export const merger_for = (el, stateContext, attr, arrayName, arrayItem, indexes
56
57
  return
57
58
  }
58
59
  if(lookLike) return
60
+
59
61
  if (lookLike === null) {
60
62
  elementArray.delete(keyComment)
61
63
 
@@ -82,7 +84,7 @@ export const merger_for = (el, stateContext, attr, arrayName, arrayItem, indexes
82
84
  let indexKey=0
83
85
  keyOrder.forEach((value,key)=>{
84
86
  if(update)return;
85
- if(div.children[indexKey]?.getAttribute('data-for-index') !== key){
87
+ if(div.children[indexKey]?.getAttribute('data-for-index') && indexKey !== key){
86
88
  update=true
87
89
  }
88
90
  indexKey++
@@ -185,22 +187,7 @@ export const merger_for = (el, stateContext, attr, arrayName, arrayItem, indexes
185
187
  stateContext._hasRun = true
186
188
  elementArray.add(keyComment)
187
189
  })
188
-
189
- } else {
190
- if(!resume)return
191
- if(once)return
192
- const number={notRender:null,index:null}
193
- elementArray.forEach((keyComment) => {
194
- if(keyComment.nextElementSibling === null) return
195
- const itemContext = {
196
- [arrayItem]: array[keyComment._index],
197
- [indexes]: keyComment._index,
198
- ...context
199
- }
200
- render(keyComment.nextElementSibling, itemContext,{notRender:false,index:null})
201
- })
202
- once=true
203
- }
190
+ }
204
191
  firstEnter = false
205
192
  } catch (error) {
206
193
  setPawaDevError({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.4.38",
3
+ "version": "1.4.39",
4
4
  "type":"module",
5
5
  "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend etc ",
6
6
  "main": "index.js",