@infinityfx/lively 4.0.1 → 4.0.2
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 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)),
|
|
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)),h=s&&r.type.isLively&&"id"in r.props,f=(s&&r.props.cachable||[0]).length,g=[...t,i],v=m&&!r.type.isLively?c(r,void 0,[]):r,[y,k]=d,x=h?r.props.id:`$l.${y?y+".":""}${g.slice(-k).join("")}`,w=l(e,x),j=w?a(e,w):void 0;j&&(h||j.key.startsWith("$l."))?j.node=v:n.set(x,{node:v,index:g}),m&&f&&p({tree:e,nodes:r.props.children,mounting:n,partialIndex:g,keys:u,parent:h?[x,1]:k?[y,k+1]:void 0}),u.add(x)})),u}function h(e){const r=e.map((e=>o(e.node)?e.nodes.length?c(e.node,{key:e.key},h(e.nodes)):c(e.node,{key:e.key}):e.node));return r.length>1?r:r[0]}function f({children:i,transition:o,initialMount:c=!0}){var a;const f=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();)f.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));f.current=!1})),e(u,{ref:g,passthrough:!0,cachable:[],children:h(k.current)})}export{f as default};
|
|
3
3
|
//# sourceMappingURL=layout-group.js.map
|