@pinegrow/vite-plugin 3.0.0-beta.26 → 3.0.0-beta.27

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.
@@ -1 +1 @@
1
- import{onBeforeMount,onMounted,onBeforeUnmount,getCurrentInstance,ref,reactive,computed}from"vue";export function usePinegrow(){const e=()=>{const e=window;if(!(e?.process?.client&&!0!==e.process.client||e.pinegrow)){console.log("Cache initialized by Pinegrow Vue Plugin!");const n=reactive(new Map),o=computed((()=>{const e=new Map;for(let[o,t]of n.entries())t.instance.isMounted&&!t.instance.isUnmounted&&t.isRootFragment&&e.set(o,t);return e})),t=computed((()=>{const e={};for(let[o,t]of n.entries())!t.instance.isMounted||t.instance.isUnmounted||!t.pgId||t.rootEl&&!t.isRootFragment||(e[t.pgId]||(e[t.pgId]=[]),e[t.pgId].push(t));return e})),l=computed((()=>{const e={};for(let[o,t]of n.entries())!t.instance.isMounted||t.instance.isUnmounted||!t.localFile||t.rootEl&&!t.isRootFragment||(e[t.localFile]||(e[t.localFile]=[]),e[t.localFile].push(t));return e}));e.pinegrow={elCache:n,elCacheErrHandlerFn:(...e)=>{console.log(e.pop())},elUpdateHanderFn:e=>{if(this.elCache.has(e)){const{pgId:n}=this.elCache.get(e);n&&n===pinegrow.getSelectedElement()?.pgId&&console.log(`Reselect ${n}`)}},rootFragmentToPgIdComputed:o,pgIdToElComputed:t,localComponentToElComputed:l}}},n=(t,l,r,i,c)=>async s=>{if(!s)return;if(window?.process?.client&&!0!==process?.client)return;window.pinegrow||e();const a=s.el,p=s.component||s.ctx||a.__vueParentComponent;try{i=i||s.key,c=c||s.type.__file&&!s.type.__file.includes("node_modules")&&s.type.__file;let e=!1;const u=1!==a.nodeType;let d,g;if("unmounted"===t){pinegrow.elCache.has(a)&&pinegrow.elCache.delete(a);for(let[e,n]of pinegrow.elCache.entries())n.rootEl===r&&pinegrow.elCache.delete(e);return}if(pinegrow.elCache.has(a))l&&(pinegrow.elCache.get(a).pgId=l),i&&(pinegrow.elCache.get(a).key=i),c&&(pinegrow.elCache.get(a).localFile=c);else{if(u){r||(e=!0);const o=Array.isArray(p.subTree.children)?p.subTree.children:[];o.length&&(1===o.length?d=g=o[0].el:(d=o[0].el,g=o[o.length-1].el),o.forEach((o=>{n(t,l,e?a:r,i)(o)})))}pinegrow.elCache.set(a,{el:a,isRootFragment:e,rootEl:r,vnode:s,instance:p,isFragment:u,firstEl:d,lastEl:g,pgId:l,key:i,localFile:c})}o(a)}catch(e){pinegrow.elCacheErrHandlerFn&&pinegrow.elCacheErrHandlerFn(s,t,r,l,i,a,p,e.message)}},o=e=>{},t=ref(null);return onBeforeMount((()=>e())),onMounted((()=>{(()=>{const e=getCurrentInstance(),o=e?.vnode,l=o?.el,r=e.type.__file&&!e.type.__file.includes("node_modules")&&e.type.__file;e&&o&&l&&(t.value=o,n("mounted",null,null,null,r)(o))})()})),onBeforeUnmount((()=>{t.value&&n("unmounted")(t.value)})),{pgUpdateElCache:n}}
1
+ import{onBeforeMount,onMounted,onBeforeUnmount,getCurrentInstance,ref,reactive,computed}from"vue";export function usePinegrow(){const e=()=>{const e=window;if(!(e?.process?.client&&!0!==e.process.client||e.pinegrow)){const n=reactive(new Map),o=computed((()=>{const e=new Map;for(let[o,t]of n.entries())t.instance.isMounted&&!t.instance.isUnmounted&&t.isRootFragment&&e.set(o,t);return e})),t=computed((()=>{const e={};for(let[o,t]of n.entries())!t.instance.isMounted||t.instance.isUnmounted||!t.pgId||t.rootEl&&!t.isRootFragment||(e[t.pgId]||(e[t.pgId]=[]),e[t.pgId].push(t));return e})),l=computed((()=>{const e={};for(let[o,t]of n.entries())!t.instance.isMounted||t.instance.isUnmounted||!t.localFile||t.rootEl&&!t.isRootFragment||(e[t.localFile]||(e[t.localFile]=[]),e[t.localFile].push(t));return e}));e.pinegrow={elCache:n,elCacheErrHandlerFn:(...e)=>{console.log(e.pop())},elUpdateHanderFn:e=>{if(this.elCache.has(e)){const{pgId:n}=this.elCache.get(e);n&&n===pinegrow.getSelectedElement()?.pgId&&console.log(`Reselect ${n}`)}},rootFragmentToPgIdComputed:o,pgIdToElComputed:t,localComponentToElComputed:l}}},n=(t,l,r,i,c)=>async s=>{if(!s)return;if(window?.process?.client&&!0!==process?.client)return;window.pinegrow||e();const a=s.el,p=s.component||s.ctx||a.__vueParentComponent;try{i=i||s.key,c=c||s.type.__file&&!s.type.__file.includes("node_modules")&&s.type.__file;let e=!1;const u=1!==a.nodeType;let d,g;if("unmounted"===t){pinegrow.elCache.has(a)&&pinegrow.elCache.delete(a);for(let[e,n]of pinegrow.elCache.entries())n.rootEl===r&&pinegrow.elCache.delete(e);return}if(pinegrow.elCache.has(a))l&&(pinegrow.elCache.get(a).pgId=l),i&&(pinegrow.elCache.get(a).key=i),c&&(pinegrow.elCache.get(a).localFile=c);else{if(u){r||(e=!0);const o=Array.isArray(p.subTree.children)?p.subTree.children:[];o.length&&(1===o.length?d=g=o[0].el:(d=o[0].el,g=o[o.length-1].el),o.forEach((o=>{n(t,l,e?a:r,i)(o)})))}pinegrow.elCache.set(a,{el:a,isRootFragment:e,rootEl:r,vnode:s,instance:p,isFragment:u,firstEl:d,lastEl:g,pgId:l,key:i,localFile:c})}o(a)}catch(e){pinegrow.elCacheErrHandlerFn&&pinegrow.elCacheErrHandlerFn(s,t,r,l,i,a,p,e.message)}},o=e=>{},t=ref(null);return onBeforeMount((()=>e())),onMounted((()=>{(()=>{const e=getCurrentInstance(),o=e?.vnode,l=o?.el,r=e.type.__file&&!e.type.__file.includes("node_modules")&&e.type.__file;e&&o&&l&&(t.value=o,n("mounted",null,null,null,r)(o))})()})),onBeforeUnmount((()=>{t.value&&n("unmounted")(t.value)})),{pgUpdateElCache:n}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinegrow/vite-plugin",
3
- "version": "3.0.0-beta.26",
3
+ "version": "3.0.0-beta.27",
4
4
  "description": "Pinegrow Vite Plugin",
5
5
  "type": "module",
6
6
  "files": [
@@ -8,6 +8,7 @@
8
8
  ],
9
9
  "main": "./dist/index.cjs",
10
10
  "module": "./dist/index.cjs",
11
+ "types": "./types.d.ts",
11
12
  "exports": {
12
13
  ".": {
13
14
  "import": "./dist/index.cjs",