@infinityfx/lively 4.0.0 → 4.0.1

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,3 +1,3 @@
1
1
  "use client";
2
- import{jsx as e}from"react/jsx-runtime";import{useRef as r,useState as n,useLayoutEffect as t,Children as o,isValidElement as i,cloneElement as c}from"react";import u from"../animatable.js";import{Groups as s}from"./morph.js";function d(e,r,n=[]){const t="nodes"in e?e.nodes:e;for(let e=0;e<t.length;e++){const o=[...n,e];let i=r(t[e],o);if(i||(i=d(t[e].nodes,r,o)),i)return i}}function l(e,r){return d(e,((e,n)=>{if(e.key===r)return n}))||null}function a(e,r){let n=e[r[0]];for(let e=1;e<r.length&&n;e++)n=n.nodes[r[e]];return n}function m(e,r,n,t){var o;const i=r[r.length-1],c=r.length>1?null===(o=a(e,r.slice(0,-1)))||void 0===o?void 0:o.nodes:e;c&&(t?c.splice(i,n,t):c.splice(i,n))}function f({tree:e,nodes:r,mounting:n,partialIndex:t=[],keys:u=new Set}){return o.forEach(r,((r,o)=>{const s=i(r),d=s&&(Array.isArray(r.props.children)||i(r.props.children)),m=s&&r.type.isLively&&"id"in r.props,p=[...t,o],h=d&&!m?c(r,void 0,[]):r,g=m?r.props.id:"$l."+p.join("");if(m){const r=l(e,g);if(null===r)n.set(g,{node:h,index:p});else{const n=a(e,r);n&&(n.node=h)}}else{const r=a(e,p);r&&r.key.startsWith("$l.")?r.node=h:n.set(g,{node:h,index:p})}d&&f({tree:e,nodes:r.props.children,mounting:n,partialIndex:p,keys:u}),u.add(g)})),u}function p(e){const r=e.map((e=>i(e.node)?e.nodes.length?c(e.node,{key:e.key},p(e.nodes)):c(e.node,{key:e.key}):e.node));return r.length>1?r:r[0]}function h({children:o,transition:i,initialMount:c=!0}){var a;const h=r(!c),g=r(null),[y,v]=n({}),k=r([]),x=r(new Map),w=r(void 0),j=r(0),E=r(new Set),z=f({tree:k.current,nodes:o,mounting:x.current});if(x.current.forEach(((e,r)=>{z.has(r)||x.current.delete(r)})),d(k.current,(e=>{z.has(e.key)||E.current.add(e.key)})),E.current.size&&g.current){for(const e of g.current.children){const r=null===(a=e.current)||void 0===a?void 0:a.id,n=E.current.has(r);if(e.current)if(n&&z.has(r))E.current.delete(r),e.current.trigger("mount",{immediate:!0}),e.current.timeline.mounted=!0;else if(n&&e.current.timeline.mounted){const r=Date.now()+1e3*e.current.trigger("unmount",{immediate:!0});if(j.current=Math.max(j.current,r),e.current.group){const r=s[e.current.group].get(e.current.timeline);r&&(r.state="unmounted")}e.current.timeline.mounted=!1}}const e=j.current-Date.now();clearTimeout(w.current);const r=(e=!0)=>{E.current.forEach((e=>{const r=l(k.current,e);r&&m(k.current,r,1)})),E.current.clear(),e&&v({})};e>0?w.current=setTimeout(r,e):r(!1)}return!E.current.size&&x.current.size&&(x.current.forEach((({node:e,index:r},n)=>{m(k.current,r,0,{key:n,node:e,nodes:[]})})),x.current.clear()),t((()=>{var e;if(!g.current)return;let r,n=g.current.children.slice();for(;r=n.pop();)h.current&&r.current&&(r.current.timeline.mounted=!0),(null===(e=r.current)||void 0===e?void 0:e.id)&&r.current.timeline.mounted&&r.current.adaptive&&null!==l(k.current,r.current.id)&&(r.current.timeline.transition(void 0,i),n.push(...r.current.children));h.current=!1})),e(u,{ref:g,passthrough:!0,cachable:[],children:p(k.current)})}export{h as default};
2
+ import{jsx as e}from"react/jsx-runtime";import{useRef as r,useState as n,useLayoutEffect as t,Children as i,isValidElement as o,cloneElement as c}from"react";import u from"../animatable.js";import{Groups as d}from"./morph.js";function s(e,r,n=[]){const t="nodes"in e?e.nodes:e;for(let e=0;e<t.length;e++){const i=[...n,e];let o=r(t[e],i);if(o||(o=s(t[e].nodes,r,i)),o)return o}}function l(e,r){return s(e,((e,n)=>{if(e.key===r)return n}))||null}function a(e,r){let n=e[r[0]];for(let e=1;e<r.length&&n;e++)n=n.nodes[r[e]];return n}function m(e,r,n,t){var i;const o=r[r.length-1],c=r.length>1?null===(i=a(e,r.slice(0,-1)))||void 0===i?void 0:i.nodes:e;c&&(t?c.splice(o,n,t):c.splice(o,n))}function p({tree:e,nodes:r,mounting:n,partialIndex:t=[],keys:u=new Set,parent:d=["",0]}){return i.forEach(r,((r,i)=>{const s=o(r),m=s&&(Array.isArray(r.props.children)||o(r.props.children)),f=s&&r.type.isLively&&"id"in r.props,h=[...t,i],g=m&&!f?c(r,void 0,[]):r,[v,y]=d,k=f?r.props.id:`$l.${v?v+".":""}${h.slice(-y).join("")}`,x=l(e,k),w=x?a(e,x):void 0;w&&(f||w.key.startsWith("$l."))?w.node=g:n.set(k,{node:g,index:h}),m&&p({tree:e,nodes:r.props.children,mounting:n,partialIndex:h,keys:u,parent:f?[k,1]:y?[v,y+1]:void 0}),u.add(k)})),u}function f(e){const r=e.map((e=>o(e.node)?e.nodes.length?c(e.node,{key:e.key},f(e.nodes)):c(e.node,{key:e.key}):e.node));return r.length>1?r:r[0]}function h({children:i,transition:o,initialMount:c=!0}){var a;const h=r(!c),g=r(null),[v,y]=n({}),k=r([]),x=r(new Map),w=r(void 0),j=r(0),E=r(new Set),$=p({tree:k.current,nodes:i,mounting:x.current});if(x.current.forEach(((e,r)=>{$.has(r)||x.current.delete(r)})),s(k.current,(e=>{$.has(e.key)||E.current.add(e.key)})),E.current.size&&g.current){for(const e of g.current.children){const r=null===(a=e.current)||void 0===a?void 0:a.id,n=E.current.has(r);if(e.current)if(n&&$.has(r))E.current.delete(r),e.current.trigger("mount",{immediate:!0}),e.current.timeline.mounted=!0;else if(n&&e.current.timeline.mounted){const r=Date.now()+1e3*e.current.trigger("unmount",{immediate:!0});if(j.current=Math.max(j.current,r),e.current.group){const r=d[e.current.group].get(e.current.timeline);r&&(r.state="unmounted")}e.current.timeline.mounted=!1}}const e=j.current-Date.now();clearTimeout(w.current);const r=(e=!0)=>{E.current.forEach((e=>{const r=l(k.current,e);r&&m(k.current,r,1)})),E.current.clear(),e&&y({})};e>0?w.current=setTimeout(r,e):r(!1)}return!E.current.size&&x.current.size&&(x.current.forEach((({node:e,index:r},n)=>{m(k.current,r,0,{key:n,node:e,nodes:[]})})),x.current.clear()),t((()=>{var e;if(!g.current)return;let r,n=g.current.children.slice();for(;r=n.pop();)h.current&&r.current&&(r.current.timeline.mounted=!0),(null===(e=r.current)||void 0===e?void 0:e.id)&&r.current.timeline.mounted&&r.current.adaptive&&null!==l(k.current,r.current.id)&&(r.current.timeline.transition(void 0,o),n.push(...r.current.children));h.current=!1})),e(u,{ref:g,passthrough:!0,cachable:[],children:f(k.current)})}export{h as default};
3
3
  //# sourceMappingURL=layout-group.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinityfx/lively",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "description": "Feature complete, lightweight react animation library.",
6
6
  "main": "dist/index.js",