@pinegrow/vite-plugin 3.0.0-beta.14 → 3.0.0-beta.140

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.
@@ -40,6 +40,8 @@
40
40
  * Released under the MIT License.
41
41
  */
42
42
 
43
+ /*! ../../../src/framework-mgmt/pinegrow-config-manager.js */
44
+
43
45
  /*! ../../../src/framework-mgmt/transform-plugins.js */
44
46
 
45
47
  /*! ../contrib/parseqs.js */
@@ -240,7 +242,7 @@
240
242
 
241
243
  /*! https */
242
244
 
243
- /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
245
+ /*! https://mths.be/punycode v1.4.1 by @mathias */
244
246
 
245
247
  /*! is-binary-path */
246
248
 
@@ -374,28 +376,52 @@
374
376
  !*** external "utf-8-validate" ***!
375
377
  \*********************************/
376
378
 
379
+ /*!*************************************!*\
380
+ !*** ./node_modules/ws/wrapper.mjs ***!
381
+ \*************************************/
382
+
377
383
  /*!**************************************!*\
378
384
  !*** ../../node_modules/ms/index.js ***!
379
385
  \**************************************/
380
386
 
387
+ /*!***************************************!*\
388
+ !*** ./node_modules/ws/lib/sender.js ***!
389
+ \***************************************/
390
+
391
+ /*!***************************************!*\
392
+ !*** ./node_modules/ws/lib/stream.js ***!
393
+ \***************************************/
394
+
395
+ /*!****************************************!*\
396
+ !*** ./node_modules/ws/lib/limiter.js ***!
397
+ \****************************************/
398
+
381
399
  /*!*****************************************!*\
382
- !*** ../../node_modules/ws/wrapper.mjs ***!
400
+ !*** ./node_modules/ws/lib/receiver.js ***!
383
401
  \*****************************************/
384
402
 
385
403
  /*!******************************************!*\
386
404
  !*** ../../node_modules/braces/index.js ***!
387
405
  \******************************************/
388
406
 
389
- /*!*******************************************!*\
390
- !*** ../../node_modules/is-glob/index.js ***!
391
- \*******************************************/
407
+ /*!******************************************!*\
408
+ !*** ./node_modules/ws/lib/constants.js ***!
409
+ \******************************************/
410
+
411
+ /*!******************************************!*\
412
+ !*** ./node_modules/ws/lib/extension.js ***!
413
+ \******************************************/
414
+
415
+ /*!******************************************!*\
416
+ !*** ./node_modules/ws/lib/websocket.js ***!
417
+ \******************************************/
392
418
 
393
419
  /*!*******************************************!*\
394
- !*** ../../node_modules/ws/lib/sender.js ***!
420
+ !*** ../../node_modules/is-glob/index.js ***!
395
421
  \*******************************************/
396
422
 
397
423
  /*!*******************************************!*\
398
- !*** ../../node_modules/ws/lib/stream.js ***!
424
+ !*** ./node_modules/ws/lib/validation.js ***!
399
425
  \*******************************************/
400
426
 
401
427
  /*!********************************************!*\
@@ -419,7 +445,11 @@
419
445
  \********************************************/
420
446
 
421
447
  /*!********************************************!*\
422
- !*** ../../node_modules/ws/lib/limiter.js ***!
448
+ !*** ./node_modules/ws/lib/buffer-util.js ***!
449
+ \********************************************/
450
+
451
+ /*!********************************************!*\
452
+ !*** ./node_modules/ws/lib/subprotocol.js ***!
423
453
  \********************************************/
424
454
 
425
455
  /*!*********************************************!*\
@@ -435,7 +465,7 @@
435
465
  \*********************************************/
436
466
 
437
467
  /*!*********************************************!*\
438
- !*** ../../node_modules/ws/lib/receiver.js ***!
468
+ !*** ./node_modules/ws/lib/event-target.js ***!
439
469
  \*********************************************/
440
470
 
441
471
  /*!**********************************************!*\
@@ -458,18 +488,6 @@
458
488
  !*** ../../node_modules/is-extglob/index.js ***!
459
489
  \**********************************************/
460
490
 
461
- /*!**********************************************!*\
462
- !*** ../../node_modules/ws/lib/constants.js ***!
463
- \**********************************************/
464
-
465
- /*!**********************************************!*\
466
- !*** ../../node_modules/ws/lib/extension.js ***!
467
- \**********************************************/
468
-
469
- /*!**********************************************!*\
470
- !*** ../../node_modules/ws/lib/websocket.js ***!
471
- \**********************************************/
472
-
473
491
  /*!***********************************************!*\
474
492
  !*** ../../node_modules/braces/lib/expand.js ***!
475
493
  \***********************************************/
@@ -482,10 +500,6 @@
482
500
  !*** ../../node_modules/glob-parent/index.js ***!
483
501
  \***********************************************/
484
502
 
485
- /*!***********************************************!*\
486
- !*** ../../node_modules/ws/lib/validation.js ***!
487
- \***********************************************/
488
-
489
503
  /*!************************************************!*\
490
504
  !*** ../../node_modules/braces/lib/compile.js ***!
491
505
  \************************************************/
@@ -494,14 +508,6 @@
494
508
  !*** ../../node_modules/picomatch/lib/scan.js ***!
495
509
  \************************************************/
496
510
 
497
- /*!************************************************!*\
498
- !*** ../../node_modules/ws/lib/buffer-util.js ***!
499
- \************************************************/
500
-
501
- /*!************************************************!*\
502
- !*** ../../node_modules/ws/lib/subprotocol.js ***!
503
- \************************************************/
504
-
505
511
  /*!*************************************************!*\
506
512
  !*** ../../node_modules/picomatch/lib/parse.js ***!
507
513
  \*************************************************/
@@ -511,7 +517,7 @@
511
517
  \*************************************************/
512
518
 
513
519
  /*!*************************************************!*\
514
- !*** ../../node_modules/ws/lib/event-target.js ***!
520
+ !*** ./node_modules/ws/lib/websocket-server.js ***!
515
521
  \*************************************************/
516
522
 
517
523
  /*!**************************************************!*\
@@ -538,6 +544,10 @@
538
544
  !*** ../../node_modules/to-regex-range/index.js ***!
539
545
  \**************************************************/
540
546
 
547
+ /*!***************************************************!*\
548
+ !*** ./node_modules/ws/lib/permessage-deflate.js ***!
549
+ \***************************************************/
550
+
541
551
  /*!****************************************************!*\
542
552
  !*** ../../node_modules/chokidar/lib/constants.js ***!
543
553
  \****************************************************/
@@ -554,18 +564,10 @@
554
564
  !*** ../../node_modules/picomatch/lib/picomatch.js ***!
555
565
  \*****************************************************/
556
566
 
557
- /*!*****************************************************!*\
558
- !*** ../../node_modules/ws/lib/websocket-server.js ***!
559
- \*****************************************************/
560
-
561
567
  /*!*****************************************************!*\
562
568
  !*** ../../src/framework-mgmt/transform-plugins.js ***!
563
569
  \*****************************************************/
564
570
 
565
- /*!*******************************************************!*\
566
- !*** ../../node_modules/ws/lib/permessage-deflate.js ***!
567
- \*******************************************************/
568
-
569
571
  /*!*********************************************************!*\
570
572
  !*** ../../node_modules/chokidar/lib/nodefs-handler.js ***!
571
573
  \*********************************************************/
@@ -578,6 +580,10 @@
578
580
  !*** ../../node_modules/chokidar/lib/fsevents-handler.js ***!
579
581
  \***********************************************************/
580
582
 
583
+ /*!***********************************************************!*\
584
+ !*** ../../src/framework-mgmt/pinegrow-config-manager.js ***!
585
+ \***********************************************************/
586
+
581
587
  /*!*************************************************************!*\
582
588
  !*** ./node_modules/socket.io-client/build/esm-debug/on.js ***!
583
589
  \*************************************************************/
@@ -594,6 +600,10 @@
594
600
  !*** ./node_modules/socket.io-client/build/esm-debug/url.js ***!
595
601
  \**************************************************************/
596
602
 
603
+ /*!***************************************************************!*\
604
+ !*** ./node_modules/engine.io-client/build/esm-debug/util.js ***!
605
+ \***************************************************************/
606
+
597
607
  /*!****************************************************************!*\
598
608
  !*** ../../node_modules/@babel/runtime/helpers/createClass.js ***!
599
609
  \****************************************************************/
@@ -606,6 +616,10 @@
606
616
  !*** ../../node_modules/engine.io-parser/build/esm/commons.js ***!
607
617
  \****************************************************************/
608
618
 
619
+ /*!****************************************************************!*\
620
+ !*** ./node_modules/engine.io-client/build/esm-debug/index.js ***!
621
+ \****************************************************************/
622
+
609
623
  /*!****************************************************************!*\
610
624
  !*** ./node_modules/socket.io-client/build/esm-debug/index.js ***!
611
625
  \****************************************************************/
@@ -614,6 +628,10 @@
614
628
  !*** ../../node_modules/@socket.io/component-emitter/index.mjs ***!
615
629
  \*****************************************************************/
616
630
 
631
+ /*!*****************************************************************!*\
632
+ !*** ./node_modules/engine.io-client/build/esm-debug/socket.js ***!
633
+ \*****************************************************************/
634
+
617
635
  /*!*****************************************************************!*\
618
636
  !*** ./node_modules/socket.io-client/build/esm-debug/socket.js ***!
619
637
  \*****************************************************************/
@@ -646,10 +664,6 @@
646
664
  !*** ../../node_modules/binary-extensions/binary-extensions.json ***!
647
665
  \*******************************************************************/
648
666
 
649
- /*!*******************************************************************!*\
650
- !*** ../../node_modules/engine.io-client/build/esm-debug/util.js ***!
651
- \*******************************************************************/
652
-
653
667
  /*!*******************************************************************!*\
654
668
  !*** ../../node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js ***!
655
669
  \*******************************************************************/
@@ -663,11 +677,11 @@
663
677
  \********************************************************************/
664
678
 
665
679
  /*!********************************************************************!*\
666
- !*** ../../node_modules/engine.io-client/build/esm-debug/index.js ***!
680
+ !*** ../../node_modules/socket.io-parser/build/esm-debug/index.js ***!
667
681
  \********************************************************************/
668
682
 
669
683
  /*!********************************************************************!*\
670
- !*** ../../node_modules/socket.io-parser/build/esm-debug/index.js ***!
684
+ !*** ./node_modules/engine.io-client/build/esm-debug/transport.js ***!
671
685
  \********************************************************************/
672
686
 
673
687
  /*!*********************************************************************!*\
@@ -678,10 +692,6 @@
678
692
  !*** ../../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
679
693
  \*********************************************************************/
680
694
 
681
- /*!*********************************************************************!*\
682
- !*** ../../node_modules/engine.io-client/build/esm-debug/socket.js ***!
683
- \*********************************************************************/
684
-
685
695
  /*!*********************************************************************!*\
686
696
  !*** ../../node_modules/engine.io-parser/build/esm/decodePacket.js ***!
687
697
  \*********************************************************************/
@@ -694,6 +704,10 @@
694
704
  !*** ../../node_modules/socket.io-parser/build/esm-debug/binary.js ***!
695
705
  \*********************************************************************/
696
706
 
707
+ /*!*********************************************************************!*\
708
+ !*** ./node_modules/engine.io-client/build/esm-debug/globalThis.js ***!
709
+ \*********************************************************************/
710
+
697
711
  /*!**********************************************************************!*\
698
712
  !*** ../../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
699
713
  \**********************************************************************/
@@ -711,68 +725,60 @@
711
725
  \***********************************************************************/
712
726
 
713
727
  /*!************************************************************************!*\
714
- !*** ../../node_modules/engine.io-client/build/esm-debug/transport.js ***!
728
+ !*** ../../node_modules/socket.io-parser/build/esm-debug/is-binary.js ***!
715
729
  \************************************************************************/
716
730
 
717
731
  /*!************************************************************************!*\
718
- !*** ../../node_modules/socket.io-parser/build/esm-debug/is-binary.js ***!
732
+ !*** ./node_modules/engine.io-client/build/esm-debug/contrib/yeast.js ***!
719
733
  \************************************************************************/
720
734
 
721
735
  /*!*************************************************************************!*\
722
736
  !*** ../../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
723
737
  \*************************************************************************/
724
738
 
725
- /*!*************************************************************************!*\
726
- !*** ../../node_modules/engine.io-client/build/esm-debug/globalThis.js ***!
727
- \*************************************************************************/
728
-
729
739
  /*!*************************************************************************!*\
730
740
  !*** ./node_modules/socket.io-client/build/esm-debug/contrib/backo2.js ***!
731
741
  \*************************************************************************/
732
742
 
733
- /*!****************************************************************************!*\
734
- !*** ../../node_modules/@babel/runtime/helpers/objectWithoutProperties.js ***!
735
- \****************************************************************************/
743
+ /*!**************************************************************************!*\
744
+ !*** ./node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js ***!
745
+ \**************************************************************************/
746
+
747
+ /*!***************************************************************************!*\
748
+ !*** ./node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js ***!
749
+ \***************************************************************************/
750
+
751
+ /*!***************************************************************************!*\
752
+ !*** ./node_modules/engine.io-client/build/esm-debug/transports/index.js ***!
753
+ \***************************************************************************/
736
754
 
737
755
  /*!****************************************************************************!*\
738
- !*** ../../node_modules/engine.io-client/build/esm-debug/contrib/yeast.js ***!
756
+ !*** ../../node_modules/@babel/runtime/helpers/objectWithoutProperties.js ***!
739
757
  \****************************************************************************/
740
758
 
741
- /*!******************************************************************************!*\
742
- !*** ../../node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js ***!
743
- \******************************************************************************/
759
+ /*!*****************************************************************************!*\
760
+ !*** ./node_modules/engine.io-client/build/esm-debug/transports/polling.js ***!
761
+ \*****************************************************************************/
744
762
 
745
763
  /*!*******************************************************************************!*\
746
764
  !*** ../../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
747
765
  \*******************************************************************************/
748
766
 
749
767
  /*!*******************************************************************************!*\
750
- !*** ../../node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js ***!
751
- \*******************************************************************************/
752
-
753
- /*!*******************************************************************************!*\
754
- !*** ../../node_modules/engine.io-client/build/esm-debug/transports/index.js ***!
768
+ !*** ./node_modules/engine.io-client/build/esm-debug/transports/websocket.js ***!
755
769
  \*******************************************************************************/
756
770
 
757
771
  /*!*********************************************************************************!*\
758
772
  !*** ../../node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js ***!
759
773
  \*********************************************************************************/
760
774
 
761
- /*!*********************************************************************************!*\
762
- !*** ../../node_modules/engine.io-client/build/esm-debug/transports/polling.js ***!
763
- \*********************************************************************************/
764
-
765
- /*!***********************************************************************************!*\
766
- !*** ../../node_modules/engine.io-client/build/esm-debug/transports/websocket.js ***!
767
- \***********************************************************************************/
768
-
769
- /*!****************************************************************************************!*\
770
- !*** ../../node_modules/engine.io-client/build/esm-debug/transports/xmlhttprequest.js ***!
771
- \****************************************************************************************/
775
+ /*!************************************************************************************!*\
776
+ !*** ./node_modules/engine.io-client/build/esm-debug/transports/xmlhttprequest.js ***!
777
+ \************************************************************************************/
772
778
 
773
- /*!***********************************************************************************************!*\
774
- !*** ../../node_modules/engine.io-client/build/esm-debug/transports/websocket-constructor.js ***!
775
- \***********************************************************************************************/
779
+ /*!*******************************************************************************************!*\
780
+ !*** ./node_modules/engine.io-client/build/esm-debug/transports/websocket-constructor.js ***!
781
+ \*******************************************************************************************/
776
782
 
777
783
  /**
778
784
  * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.
@@ -0,0 +1,310 @@
1
+ import {
2
+ onBeforeMount,
3
+ onMounted,
4
+ onBeforeUnmount,
5
+ getCurrentInstance,
6
+ ref,
7
+ reactive,
8
+ onUpdated,
9
+ computed,
10
+ watch,
11
+ } from 'vue'
12
+
13
+ export function usePinegrow() {
14
+ const initCache = () => {
15
+ // conditional
16
+ const winObj = window
17
+
18
+ if (!(winObj?.process?.client && winObj.process.client !== true)) {
19
+ if (!winObj.pinegrow) {
20
+ // conditional
21
+ // console.log('Cache initialized by Pinegrow Vue Plugin!')
22
+ const elCache = reactive(new Map())
23
+
24
+ const enrichWithComponentName = (elCacheObj, localFile) => {
25
+ return {
26
+ name: elCacheObj.instance.type.__name || '',
27
+ localFile,
28
+ ...elCacheObj,
29
+ }
30
+ }
31
+
32
+ winObj.pinegrow = {
33
+ elCache,
34
+ watchFromContext: watch,
35
+ computedFromContext: computed,
36
+ // // Uncomment these two to test locally
37
+ // elCacheErrHandlerFn,
38
+ // elUpdateHanderFn,
39
+ // rootFragmentToPgIdComputed,
40
+ // pgIdToElComputed,
41
+ // localComponentToElComputed,
42
+ // appTree,
43
+ }
44
+ }
45
+ }
46
+ }
47
+
48
+ // pgId & key can be optional
49
+ const pgUpdateElCache = (hook, pgId, rootEl, key, localFile) => async vnode => {
50
+ if (!vnode) return
51
+ if (window?.process?.client && process?.client !== true) return
52
+ if (!window.pinegrow) initCache()
53
+
54
+ let el = vnode.el
55
+
56
+ const instance = vnode.component || vnode.ctx || el.__vueParentComponent
57
+
58
+ if (!el || !instance) return
59
+
60
+ try {
61
+ if ((key !== null && key !== undefined) || (vnode.key !== null && vnode.key !== undefined)) {
62
+ key = vnode.key || key
63
+ }
64
+
65
+ localFile = localFile || vnode.type.__file
66
+
67
+ let isRootFragment = false
68
+ let isFragment = el.nodeType !== 1
69
+ let firstEl,
70
+ lastEl,
71
+ isIsland = false,
72
+ childVNodes = []
73
+
74
+ // May be an iles Island that wraps components with client directives
75
+ if (localFile) {
76
+ if (localFile.includes('node_modules/iles') && localFile.includes('Island.vue')) {
77
+ // Retain localFiles of iles island to apply to child elements
78
+ isIsland = true
79
+ }
80
+
81
+ if (localFile.includes('node_modules')) {
82
+ // Ignore SFCs from node_modules
83
+ localFile = null
84
+ }
85
+ }
86
+
87
+ const localFileFromInstance = instance.type.__file
88
+ if (
89
+ localFileFromInstance &&
90
+ localFileFromInstance.includes('node_modules/iles') &&
91
+ localFileFromInstance.includes('Island.vue')
92
+ ) {
93
+ // Retain localFiles of iles island to apply to child elements
94
+ isIsland = true
95
+
96
+ localFile = instance.props.component?.__file || instance.props.importFrom
97
+ }
98
+
99
+ // // Computed props anyway filters out unmounted ones, and we use the local components unmounted hooks to cleanup unmounted nodes. Using the unmounted hook seems to be out of sync when el is reused but instance is remounted.
100
+ // if (hook === 'unmounted') {
101
+ // if (pinegrow.elCache.has(el)) {
102
+ // pinegrow.elCache.delete(el)
103
+ // }
104
+ // for (let [key, value] of pinegrow.elCache.entries()) {
105
+ // if (value.rootEl === rootEl) {
106
+ // pinegrow.elCache.delete(key)
107
+ // }
108
+ // }
109
+ // return
110
+ // }
111
+
112
+ // Text/comment node
113
+ if (isFragment) {
114
+ if (!rootEl) {
115
+ // root Fragment
116
+ isRootFragment = true
117
+ }
118
+
119
+ function isFragmentEl(instance) {
120
+ // return appRecord.options.types.Fragment === instance.subTree?.type
121
+ return instance.subTree.el.nodeType !== 1
122
+ }
123
+
124
+ function getRootVNodesFromComponentInstance(instance) {
125
+ if (isFragmentEl(instance)) {
126
+ return getFragmentRootVNodes(instance.subTree)
127
+ }
128
+ if (!instance.subTree) return []
129
+ return [instance.subTree]
130
+ }
131
+
132
+ function getFragmentRootVNodes(vnode) {
133
+ if (!vnode.children) return []
134
+ // children is v-if when the vnode has a condition
135
+ if (!Array.isArray(vnode.children)) return []
136
+
137
+ const list = []
138
+
139
+ for (let i = 0, l = vnode.children.length; i < l; i++) {
140
+ const childVnode = vnode.children[i]
141
+ if (childVnode.component) {
142
+ list.push(...getRootVNodesFromComponentInstance(childVnode.component))
143
+ } else if (childVnode) {
144
+ list.push(childVnode)
145
+ }
146
+ }
147
+
148
+ return list
149
+ }
150
+
151
+ childVNodes = getRootVNodesFromComponentInstance(instance)
152
+
153
+ if (!childVNodes.length) {
154
+ // For NuxtLayout, no childVNodes are returned, the subTree.children is in fact an object {ctx: {}, default: f}
155
+ if (el.nextElementSibling) {
156
+ const childEl = el.nextElementSibling
157
+ firstEl = lastEl = childEl
158
+ const childInstance = childEl.$ || childEl.__vueParentComponent
159
+ const childVNode = childInstance?.vnode // or subTree?
160
+ if (childVNode) {
161
+ childVNodes.push(childVNode)
162
+ }
163
+ }
164
+ }
165
+
166
+ if (childVNodes.length) {
167
+ // Filter out recursive vnodes text1 -> div, text1 (happens when text1 is the closest to a fragment with div & slot)
168
+ childVNodes = childVNodes.filter(childVNode => childVNode.el !== el)
169
+
170
+ if (childVNodes.length) {
171
+ if (childVNodes.length === 1) {
172
+ firstEl = lastEl = childVNodes[0].el
173
+ } else {
174
+ firstEl = childVNodes[0].el
175
+ lastEl = childVNodes[childVNodes.length - 1].el
176
+ }
177
+
178
+ if (firstEl && firstEl.nodeType !== 1) {
179
+ firstEl = firstEl.nextElementSibling
180
+ }
181
+ if (lastEl && lastEl.nodeType !== 1) {
182
+ lastEl = lastEl.nextElementSibling
183
+ }
184
+ }
185
+ }
186
+ }
187
+
188
+ if (isIsland && !isRootFragment) {
189
+ return
190
+ }
191
+
192
+ let elCacheObj = {
193
+ el,
194
+ isRootFragment,
195
+ rootEl,
196
+ vnode,
197
+ instance,
198
+ isFragment,
199
+ firstEl,
200
+ lastEl,
201
+ pgId,
202
+ key,
203
+ localFile,
204
+ isIsland,
205
+ }
206
+
207
+ let prevElCacheNodes = pinegrow.elCache.get(el)
208
+
209
+ if (prevElCacheNodes) {
210
+ let index = prevElCacheNodes.findIndex(elCacheObj => elCacheObj.instance.uid === instance.uid)
211
+
212
+ if (index > -1) {
213
+ const prevElCacheObj = prevElCacheNodes[index]
214
+ elCacheObj.localFile = elCacheObj.localFile || prevElCacheObj.localFile
215
+ elCacheObj.pgId = elCacheObj.pgId || prevElCacheObj.pgId
216
+ prevElCacheNodes[index] = elCacheObj
217
+ } else {
218
+ prevElCacheNodes.push(elCacheObj)
219
+ }
220
+ pinegrow.elCache.set(el, prevElCacheNodes)
221
+ } else {
222
+ pinegrow.elCache.set(el, [elCacheObj])
223
+ childVNodes.forEach(childVNode => {
224
+ pgUpdateElCache(hook, pgId, isRootFragment ? el : rootEl, key)(childVNode)
225
+ })
226
+ }
227
+
228
+ if (pinegrow.elUpdateHanderFn) {
229
+ pinegrow.elUpdateHanderFn(el)
230
+ }
231
+ } catch (err) {
232
+ console.log(err)
233
+ if (pinegrow.elCacheErrHandlerFn) {
234
+ pinegrow.elCacheErrHandlerFn(vnode, hook, rootEl, pgId, key, el, instance, err.message)
235
+ }
236
+ }
237
+ }
238
+
239
+ const elUpdateHanderFn = el => {
240
+ // if (pinegrow.elCache.has(el)) {
241
+ // const { pgId } = pinegrow.elCache.get(el)
242
+ // if (pgId) {
243
+ // // console.log(`Reselect ${pgId}`)
244
+ // }
245
+ // }
246
+ }
247
+
248
+ const elCacheErrHandlerFn = () => {
249
+ if (message) {
250
+ // console.log(message)
251
+ }
252
+ }
253
+
254
+ const cleanupCache = () => {
255
+ // for (let [key, value] of pinegrow.elCache.entries()) {
256
+ // if (value.isFragment && !value.firstEl) {
257
+ // console.log(value)
258
+ // }
259
+ // }
260
+ for (let [el, elCacheNodes] of pinegrow.elCache.entries()) {
261
+ // if (!el.isConnected) {
262
+ // pinegrow.elCache.delete(el)
263
+ // continue
264
+ // }
265
+ const cleanedUpElCacheNodes = elCacheNodes.filter(
266
+ elCacheObj => !elCacheObj.instance.isUnmounted // || elCacheObj.localFile
267
+ )
268
+ if (cleanedUpElCacheNodes.length) {
269
+ if (cleanedUpElCacheNodes.length !== elCacheNodes.length) {
270
+ pinegrow.elCache.set(el, cleanedUpElCacheNodes)
271
+ }
272
+ } else {
273
+ pinegrow.elCache.delete(el)
274
+ }
275
+ }
276
+ }
277
+
278
+ // Local Component
279
+ const rootVNode = ref(null)
280
+
281
+ const mountLocalComponent = () => {
282
+ const instance = getCurrentInstance()
283
+ const vnode = instance?.vnode
284
+ const el = vnode?.el
285
+ const localFile = instance.type.__file && !instance.type.__file.includes('node_modules') && instance.type.__file
286
+ if (instance && vnode && el) {
287
+ rootVNode.value = vnode
288
+ pgUpdateElCache('mounted', null, null, null, localFile)(vnode)
289
+ }
290
+ }
291
+
292
+ const unmountLocalComponent = () => {
293
+ if (rootVNode.value) {
294
+ pgUpdateElCache('unmounted')(rootVNode.value)
295
+ }
296
+ cleanupCache()
297
+ }
298
+
299
+ onBeforeMount(() => initCache())
300
+ onMounted(() => {
301
+ mountLocalComponent()
302
+ })
303
+ onBeforeUnmount(() => unmountLocalComponent())
304
+ onUpdated(() => {
305
+ mountLocalComponent()
306
+ })
307
+
308
+ return { pgUpdateElCache }
309
+ }
310
+