@pinegrow/vite-plugin 3.0.0-beta.13 → 3.0.0-beta.131
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/README.md +67 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.LICENSE.txt +90 -84
- package/dist/vue/index.js +298 -0
- package/package.json +14 -4
- package/types.d.ts +55 -0
|
@@ -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/
|
|
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
|
-
!***
|
|
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
|
-
!***
|
|
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/
|
|
420
|
+
!*** ../../node_modules/is-glob/index.js ***!
|
|
395
421
|
\*******************************************/
|
|
396
422
|
|
|
397
423
|
/*!*******************************************!*\
|
|
398
|
-
!***
|
|
424
|
+
!*** ./node_modules/ws/lib/validation.js ***!
|
|
399
425
|
\*******************************************/
|
|
400
426
|
|
|
401
427
|
/*!********************************************!*\
|
|
@@ -419,7 +445,11 @@
|
|
|
419
445
|
\********************************************/
|
|
420
446
|
|
|
421
447
|
/*!********************************************!*\
|
|
422
|
-
!***
|
|
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
|
-
!***
|
|
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
|
-
!***
|
|
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/
|
|
680
|
+
!*** ../../node_modules/socket.io-parser/build/esm-debug/index.js ***!
|
|
667
681
|
\********************************************************************/
|
|
668
682
|
|
|
669
683
|
/*!********************************************************************!*\
|
|
670
|
-
!***
|
|
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/
|
|
728
|
+
!*** ../../node_modules/socket.io-parser/build/esm-debug/is-binary.js ***!
|
|
715
729
|
\************************************************************************/
|
|
716
730
|
|
|
717
731
|
/*!************************************************************************!*\
|
|
718
|
-
!***
|
|
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
|
-
!***
|
|
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/
|
|
756
|
+
!*** ../../node_modules/@babel/runtime/helpers/objectWithoutProperties.js ***!
|
|
739
757
|
\****************************************************************************/
|
|
740
758
|
|
|
741
|
-
|
|
742
|
-
!***
|
|
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
|
-
!***
|
|
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
|
-
!***
|
|
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
|
-
!***
|
|
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,298 @@
|
|
|
1
|
+
import { onBeforeMount, onMounted, onBeforeUnmount, getCurrentInstance, ref, reactive, computed, onUpdated } from 'vue'
|
|
2
|
+
|
|
3
|
+
export function usePinegrow() {
|
|
4
|
+
const initCache = () => {
|
|
5
|
+
// conditional
|
|
6
|
+
const winObj = window
|
|
7
|
+
|
|
8
|
+
if (!(winObj?.process?.client && winObj.process.client !== true)) {
|
|
9
|
+
if (!winObj.pinegrow) {
|
|
10
|
+
// conditional
|
|
11
|
+
// console.log('Cache initialized by Pinegrow Vue Plugin!')
|
|
12
|
+
const elCache = reactive(new Map())
|
|
13
|
+
|
|
14
|
+
const enrichWithComponentName = (elCacheObj, localFile) => {
|
|
15
|
+
return {
|
|
16
|
+
name: elCacheObj.instance.type.__name || '',
|
|
17
|
+
localFile,
|
|
18
|
+
...elCacheObj,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
winObj.pinegrow = {
|
|
23
|
+
elCache,
|
|
24
|
+
// // Uncomment these two to test locally
|
|
25
|
+
// elCacheErrHandlerFn,
|
|
26
|
+
// elUpdateHanderFn,
|
|
27
|
+
// rootFragmentToPgIdComputed,
|
|
28
|
+
// pgIdToElComputed,
|
|
29
|
+
// localComponentToElComputed,
|
|
30
|
+
// appTree,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// pgId & key can be optional
|
|
37
|
+
const pgUpdateElCache = (hook, pgId, rootEl, key, localFile) => async vnode => {
|
|
38
|
+
if (!vnode) return
|
|
39
|
+
if (window?.process?.client && process?.client !== true) return
|
|
40
|
+
if (!window.pinegrow) initCache()
|
|
41
|
+
|
|
42
|
+
let el = vnode.el
|
|
43
|
+
|
|
44
|
+
const instance = vnode.component || vnode.ctx || el.__vueParentComponent
|
|
45
|
+
|
|
46
|
+
if (!el || !instance) return
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
if ((key !== null && key !== undefined) || (vnode.key !== null && vnode.key !== undefined)) {
|
|
50
|
+
key = vnode.key || key
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
localFile = localFile || vnode.type.__file
|
|
54
|
+
|
|
55
|
+
let isRootFragment = false
|
|
56
|
+
let isFragment = el.nodeType !== 1
|
|
57
|
+
let firstEl,
|
|
58
|
+
lastEl,
|
|
59
|
+
isIsland = false,
|
|
60
|
+
childVNodes = []
|
|
61
|
+
|
|
62
|
+
// May be an iles Island that wraps components with client directives
|
|
63
|
+
if (localFile) {
|
|
64
|
+
if (localFile.includes('node_modules/iles') && localFile.includes('Island.vue')) {
|
|
65
|
+
// Retain localFiles of iles island to apply to child elements
|
|
66
|
+
isIsland = true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (localFile.includes('node_modules')) {
|
|
70
|
+
// Ignore SFCs from node_modules
|
|
71
|
+
localFile = null
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const localFileFromInstance = instance.type.__file
|
|
76
|
+
if (
|
|
77
|
+
localFileFromInstance &&
|
|
78
|
+
localFileFromInstance.includes('node_modules/iles') &&
|
|
79
|
+
localFileFromInstance.includes('Island.vue')
|
|
80
|
+
) {
|
|
81
|
+
// Retain localFiles of iles island to apply to child elements
|
|
82
|
+
isIsland = true
|
|
83
|
+
|
|
84
|
+
localFile = instance.props.component?.__file || instance.props.importFrom
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// // 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.
|
|
88
|
+
// if (hook === 'unmounted') {
|
|
89
|
+
// if (pinegrow.elCache.has(el)) {
|
|
90
|
+
// pinegrow.elCache.delete(el)
|
|
91
|
+
// }
|
|
92
|
+
// for (let [key, value] of pinegrow.elCache.entries()) {
|
|
93
|
+
// if (value.rootEl === rootEl) {
|
|
94
|
+
// pinegrow.elCache.delete(key)
|
|
95
|
+
// }
|
|
96
|
+
// }
|
|
97
|
+
// return
|
|
98
|
+
// }
|
|
99
|
+
|
|
100
|
+
// Text/comment node
|
|
101
|
+
if (isFragment) {
|
|
102
|
+
if (!rootEl) {
|
|
103
|
+
// root Fragment
|
|
104
|
+
isRootFragment = true
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isFragmentEl(instance) {
|
|
108
|
+
// return appRecord.options.types.Fragment === instance.subTree?.type
|
|
109
|
+
return instance.subTree.el.nodeType !== 1
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getRootVNodesFromComponentInstance(instance) {
|
|
113
|
+
if (isFragmentEl(instance)) {
|
|
114
|
+
return getFragmentRootVNodes(instance.subTree)
|
|
115
|
+
}
|
|
116
|
+
if (!instance.subTree) return []
|
|
117
|
+
return [instance.subTree]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getFragmentRootVNodes(vnode) {
|
|
121
|
+
if (!vnode.children) return []
|
|
122
|
+
// children is v-if when the vnode has a condition
|
|
123
|
+
if (!Array.isArray(vnode.children)) return []
|
|
124
|
+
|
|
125
|
+
const list = []
|
|
126
|
+
|
|
127
|
+
for (let i = 0, l = vnode.children.length; i < l; i++) {
|
|
128
|
+
const childVnode = vnode.children[i]
|
|
129
|
+
if (childVnode.component) {
|
|
130
|
+
list.push(...getRootVNodesFromComponentInstance(childVnode.component))
|
|
131
|
+
} else if (childVnode) {
|
|
132
|
+
list.push(childVnode)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return list
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
childVNodes = getRootVNodesFromComponentInstance(instance)
|
|
140
|
+
|
|
141
|
+
if (!childVNodes.length) {
|
|
142
|
+
// For NuxtLayout, no childVNodes are returned, the subTree.children is in fact an object {ctx: {}, default: f}
|
|
143
|
+
if (el.nextElementSibling) {
|
|
144
|
+
const childEl = el.nextElementSibling
|
|
145
|
+
firstEl = lastEl = childEl
|
|
146
|
+
const childInstance = childEl.$ || childEl.__vueParentComponent
|
|
147
|
+
const childVNode = childInstance?.vnode // or subTree?
|
|
148
|
+
if (childVNode) {
|
|
149
|
+
childVNodes.push(childVNode)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (childVNodes.length) {
|
|
155
|
+
// Filter out recursive vnodes text1 -> div, text1 (happens when text1 is the closest to a fragment with div & slot)
|
|
156
|
+
childVNodes = childVNodes.filter(childVNode => childVNode.el !== el)
|
|
157
|
+
|
|
158
|
+
if (childVNodes.length) {
|
|
159
|
+
if (childVNodes.length === 1) {
|
|
160
|
+
firstEl = lastEl = childVNodes[0].el
|
|
161
|
+
} else {
|
|
162
|
+
firstEl = childVNodes[0].el
|
|
163
|
+
lastEl = childVNodes[childVNodes.length - 1].el
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (firstEl && firstEl.nodeType !== 1) {
|
|
167
|
+
firstEl = firstEl.nextElementSibling
|
|
168
|
+
}
|
|
169
|
+
if (lastEl && lastEl.nodeType !== 1) {
|
|
170
|
+
lastEl = lastEl.nextElementSibling
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (isIsland && !isRootFragment) {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let elCacheObj = {
|
|
181
|
+
el,
|
|
182
|
+
isRootFragment,
|
|
183
|
+
rootEl,
|
|
184
|
+
vnode,
|
|
185
|
+
instance,
|
|
186
|
+
isFragment,
|
|
187
|
+
firstEl,
|
|
188
|
+
lastEl,
|
|
189
|
+
pgId,
|
|
190
|
+
key,
|
|
191
|
+
localFile,
|
|
192
|
+
isIsland,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let prevElCacheNodes = pinegrow.elCache.get(el)
|
|
196
|
+
|
|
197
|
+
if (prevElCacheNodes) {
|
|
198
|
+
let index = prevElCacheNodes.findIndex(elCacheObj => elCacheObj.instance.uid === instance.uid)
|
|
199
|
+
|
|
200
|
+
if (index > -1) {
|
|
201
|
+
const prevElCacheObj = prevElCacheNodes[index]
|
|
202
|
+
elCacheObj.localFile = elCacheObj.localFile || prevElCacheObj.localFile
|
|
203
|
+
elCacheObj.pgId = elCacheObj.pgId || prevElCacheObj.pgId
|
|
204
|
+
prevElCacheNodes[index] = elCacheObj
|
|
205
|
+
} else {
|
|
206
|
+
prevElCacheNodes.push(elCacheObj)
|
|
207
|
+
}
|
|
208
|
+
pinegrow.elCache.set(el, prevElCacheNodes)
|
|
209
|
+
} else {
|
|
210
|
+
pinegrow.elCache.set(el, [elCacheObj])
|
|
211
|
+
childVNodes.forEach(childVNode => {
|
|
212
|
+
pgUpdateElCache(hook, pgId, isRootFragment ? el : rootEl, key)(childVNode)
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (pinegrow.elUpdateHanderFn) {
|
|
217
|
+
pinegrow.elUpdateHanderFn(el)
|
|
218
|
+
}
|
|
219
|
+
} catch (err) {
|
|
220
|
+
console.log(err)
|
|
221
|
+
if (pinegrow.elCacheErrHandlerFn) {
|
|
222
|
+
pinegrow.elCacheErrHandlerFn(vnode, hook, rootEl, pgId, key, el, instance, err.message)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const elUpdateHanderFn = el => {
|
|
228
|
+
// if (pinegrow.elCache.has(el)) {
|
|
229
|
+
// const { pgId } = pinegrow.elCache.get(el)
|
|
230
|
+
// if (pgId) {
|
|
231
|
+
// // console.log(`Reselect ${pgId}`)
|
|
232
|
+
// }
|
|
233
|
+
// }
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const elCacheErrHandlerFn = () => {
|
|
237
|
+
if (message) {
|
|
238
|
+
// console.log(message)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const cleanupCache = () => {
|
|
243
|
+
// for (let [key, value] of pinegrow.elCache.entries()) {
|
|
244
|
+
// if (value.isFragment && !value.firstEl) {
|
|
245
|
+
// console.log(value)
|
|
246
|
+
// }
|
|
247
|
+
// }
|
|
248
|
+
for (let [el, elCacheNodes] of pinegrow.elCache.entries()) {
|
|
249
|
+
// if (!el.isConnected) {
|
|
250
|
+
// pinegrow.elCache.delete(el)
|
|
251
|
+
// continue
|
|
252
|
+
// }
|
|
253
|
+
const cleanedUpElCacheNodes = elCacheNodes.filter(
|
|
254
|
+
elCacheObj => !elCacheObj.instance.isUnmounted // || elCacheObj.localFile
|
|
255
|
+
)
|
|
256
|
+
if (cleanedUpElCacheNodes.length) {
|
|
257
|
+
if (cleanedUpElCacheNodes.length !== elCacheNodes.length) {
|
|
258
|
+
pinegrow.elCache.set(el, cleanedUpElCacheNodes)
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
pinegrow.elCache.delete(el)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Local Component
|
|
267
|
+
const rootVNode = ref(null)
|
|
268
|
+
|
|
269
|
+
const mountLocalComponent = () => {
|
|
270
|
+
const instance = getCurrentInstance()
|
|
271
|
+
const vnode = instance?.vnode
|
|
272
|
+
const el = vnode?.el
|
|
273
|
+
const localFile = instance.type.__file && !instance.type.__file.includes('node_modules') && instance.type.__file
|
|
274
|
+
if (instance && vnode && el) {
|
|
275
|
+
rootVNode.value = vnode
|
|
276
|
+
pgUpdateElCache('mounted', null, null, null, localFile)(vnode)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const unmountLocalComponent = () => {
|
|
281
|
+
if (rootVNode.value) {
|
|
282
|
+
pgUpdateElCache('unmounted')(rootVNode.value)
|
|
283
|
+
}
|
|
284
|
+
cleanupCache()
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
onBeforeMount(() => initCache())
|
|
288
|
+
onMounted(() => {
|
|
289
|
+
mountLocalComponent()
|
|
290
|
+
})
|
|
291
|
+
onBeforeUnmount(() => unmountLocalComponent())
|
|
292
|
+
onUpdated(() => {
|
|
293
|
+
mountLocalComponent()
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
return { pgUpdateElCache }
|
|
297
|
+
}
|
|
298
|
+
|