@pixodesk/svg-animator-core 1.0.45 → 1.0.46
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 +12 -0
- package/dist/{PxDocumentDiagnostic-CBhVyNEi.d.cts → PxDocumentDiagnostic-DX8w42-I.d.cts} +364 -207
- package/dist/{PxDocumentDiagnostic-CBhVyNEi.d.ts → PxDocumentDiagnostic-DX8w42-I.d.ts} +364 -207
- package/dist/{chunk-YVKMPBHE.js → chunk-37OFJ3RX.js} +139 -78
- package/dist/chunk-37OFJ3RX.js.map +1 -0
- package/dist/chunk-K2732IVS.min.js +1 -0
- package/dist/index.cjs +141 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/internal.cjs +137 -76
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +4 -5
- package/dist/internal.d.ts +4 -5
- package/dist/internal.js +3 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.min.cjs +1 -1
- package/dist/internal.min.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5HEVTP2N.min.js +0 -1
- package/dist/chunk-YVKMPBHE.js.map +0 -1
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PX_DEFAULT_DURATION_MS as n,PX_TIMELINE_SHARED_KEYS as e,PX_TIME_ONLY_TIMELINE_KEYS as t,PX_TRANSFORM_PART_KEYS as i,PX_TRIGGER_DEFAULTS as o,PX_WIRE_BASELINE_VERSION as r,PX_WIRE_SCHEMA_VERSION as l,PX_WIRE_STEPS as a,PX_WIRE_VERSION as s,PX_WIRE_VERSION_KEY as u,PxAlongPathMode as c,PxAnimatedSvgDocumentSchema as f,PxAnimatorConfigSchema as d,PxAttrValueSchema as m,PxBezierPathSchema as v,PxClipPathEffectSchema as g,PxCloneEffectSchema as y,PxCloneWithout as b,PxControlMode as p,PxDefinitionsSchema as h,PxDiagnosticCode as w,PxDiagnosticKind as F,PxEffectsSchema as N,PxElementAnimationSchema as j,PxFillGradientEffectSchema as k,PxFillMode as A,PxFinishAction as T,PxGradientSpreadMethod as C,PxGradientStopSchema as O,PxGradientType as P,PxKeyframeSchema as R,PxKeyframeValueSchema as D,PxLengthAdjust as S,PxLoopDirection as E,PxLoopRepeatAt as M,PxLoopSchema as q,PxMaskType as x,PxMaskedByEffectSchema as J,PxMouseOutAction as z,PxNodeBaseSchema as H,PxNodeSchema as V,PxOffScreenAction as B,PxPathOverflow as G,PxPinAlign as I,PxPlaybackDirection as K,PxPropertyAnimationSchema as L,PxRepeaterEffectSchema as Q,PxRetimeEffectSchema as U,PxScrollAxis as W,PxScrollKind as X,PxScrollPhase as Y,PxScrollRangePointSchema as Z,PxScrollRangeSchema as $,PxScrollSchema as _,PxScrollSource as nn,PxStrokeTrimEffectSchema as en,PxStrokeTrimSubPaths as tn,PxSvgNodeRootSchema as on,PxTextEffectSchema as rn,PxTextPathEffectSchema as ln,PxTextPathMethod as an,PxTextPathSpacing as sn,PxTimelineEngine as un,PxTimelineEngineSetting as cn,PxTimelineSchema as fn,PxTransformByEffectSchema as dn,PxTransformPartsSchema as mn,PxTransformValueSchema as vn,PxTriggerSchema as gn,PxTriggerStart as yn,PxUnits as bn,PxWireStepKind as pn,PxWireVersionRelation as hn,__spreadProps as wn,__spreadValues as Fn,applyWireSteps as Nn,calcAnimationValues as jn,clamp as kn,compareWireVersion as An,controlModeTakesOverTrigger as Tn,convertWireDocument as Cn,describeSchema as On,diagnoseDocument as Pn,downgradeWireDocument as Rn,flattenAnimatorTimeline as Dn,formatWireVersion as Sn,generateNewIds as En,getAnimatorConfig as Mn,getBindings as qn,getChildren as xn,getDefinitions as Jn,isNativeForced as zn,isPxDocument as Hn,isValidPxDocument as Vn,materializeAllInTree as Bn,materializeNodeEffects as Gn,mayUseNativeScrollTimeline as In,nestAnimatorTimeline as Kn,normalizeBindings as Ln,parseWireVersion as Qn,px as Un,readWireVersion as Wn,resolveControlMode as Xn,resolveTimelineEngine as Yn,resolveTrigger as Zn,schemaKeys as $n,toDomProps as _n,validateDocument as ne,validateNodeEffects as ee,wireVersionAdvice as te}from"./chunk-5HEVTP2N.min.js";var ie="setPlaybackRate: rate must be finite and non-zero";function oe(n){return Number.isFinite(n)&&0!==n}function re(n,e){return n>0?e===1/0?1/0:n*(e>0?e:1):0}function le(n,e){return n>0?e===1/0?n:n*(e>0?e:1):0}function ae(n,e){return Number.isNaN(n)||n<0?0:Number.isFinite(e)?n>e?e:n:Number.isFinite(n)?n:0}function se(n,e,t){const i=le(e,t);return i>0&&Number.isFinite(n)?n<=0?0:t===1/0?n%i/i:n>=i?1:n/i:0}function ue(n,e,t){const i=le(e,t);return i>0&&Number.isFinite(n)?n<=0?0:n>=1?i:n*i:0}function ce(n,e=Date.now){let t=0,i=0,o=!1,r=1;const l=()=>ae(o?t+(e()-i)*r:t,n);return{now:l,isRunning:()=>o,start:(a,s)=>{t=ae(null!=s?s:l(),n),r=oe(a)?a:1,i=e(),o=!0},stop:()=>{t=l(),i=0,o=!1},seek:r=>{t=ae(r,n),o&&(i=e())}}}function fe(n){const e=globalThis;"function"!=typeof e.cancelAnimationFrame?e.clearTimeout(n):e.cancelAnimationFrame(n)}function de(e,t,i){var o;const r=Mn(e)||{},l=Ln(e,un.js),a=r.iterations;let s=1;"number"==typeof a&&(s=a||1),"infinite"===a&&(s=1/0),s<1&&(s=1);const u=+(r.duration||n),c=u&&s?u*(s===1/0?1/0:s):u?(null!=s?s:1)*u:0,f=r.direction||"normal",d=null!=(o=r.fill)?o:"forwards",m="forwards"===d||"both"===d,v="backwards"===d||"both"===d;let g=null,y=!1,b=-(r.delay||0),p=0,h=1,w=!1;const F=r.frameRate,N=F&&F>0?1e3/F:0;let j=0;const k=()=>{const n=p?(Date.now()-p)*h:0;return b+n},A=()=>{let n=k();return Number.isFinite(c)&&n>c&&(n=c),n<0&&(n=0),n};function T(n){let e=function(){const e=u>0?u:1;let t=0,i=0;if(u>0){n=kn(n,0,s*e),i=Math.max(0,Math.ceil(n/e)-1),i=Math.min(i,s-1);t=kn((n-i*e)/e,0,1)}else t=n;const o=f||"normal";let r=t;return"reverse"===o?r=1-t:"alternate"===o?i%2==1&&(r=1-t):"alternate-reverse"===o&&i%2==0&&(r=1-t),r}();for(const n of l||[]){const i=n.animate;if(!i||"object"!=typeof i||Array.isArray(i)){console.warn("Empty or unresolved binding",n);continue}const o=jn(i,e*u);for(const[e,i]of Object.entries(o))t.setAttribute(n.id,e,i)}}r.delay&&(r.delay<0?T(A()):v&&T(0));const C=()=>!!y&&(!!t.isConnected()&&(h<0?k()>0:!(Number.isFinite(c)&&A()>=c))),O=n=>{null!==g&&(fe(g),g=null),(n||C())&&(g=function(n){const e=globalThis;return"function"==typeof e.requestAnimationFrame?e.requestAnimationFrame(n):e.setTimeout(n,16)}(()=>{g=null,(()=>{var n,e;if(!t.isConnected())return void P();const o=A(),r=k();if(r<0&&h>0)v&&T(0);else{if(h<0&&r<=0)return P(),T(0),void(w||(w=!0,null==(n=null==i?void 0:i.onFinish)||n.call(i)));if(h>0&&c&&Number.isFinite(c)&&o>=c)return P(),T(m?c:0),void(w||(w=!0,null==(e=null==i?void 0:i.onFinish)||e.call(i)));if(N>0){const n=Date.now();if(j&&n-j<N)return;j=n}T(o)}})(),O()}))},P=()=>{if(!y)return;let n=k();Number.isFinite(c)&&n>c&&(n=c),b=n,p=0,y=!1,null!==g&&(fe(g),g=null),n>=0?T(n):v&&T(0)},R={isReady:()=>!0,getRootElement:()=>null,isPlaying:()=>C(),play:()=>{var n;(()=>{if(!y){if(h>=0)Number.isFinite(c)&&b>=c&&(b=0);else if(b<=0){if(!Number.isFinite(c))return void console.warn("play: cannot start reverse playback of an infinite animation from time 0");b=c}w=!1,y=!0,p=Date.now(),O(!0)}})(),null==(n=null==i?void 0:i.onPlay)||n.call(i)},pause:()=>{var n;P(),null==(n=null==i?void 0:i.onPause)||n.call(i)},cancel:()=>{var n;P(),b=0,p=0,y=!1,w=!1,T(b),null==(n=null==i?void 0:i.onCancel)||n.call(i)},finish:()=>{((n=!0)=>{var e;b=Number.isFinite(c)?c:A(),p=0,y=!1,null!==g&&(fe(g),g=null),T(m?b:0),n&&!w&&(w=!0,null==(e=null==i?void 0:i.onFinish)||e.call(i))})(!0)},setPlaybackRate:n=>{if(!oe(n))return void console.warn(ie);let e=k();Number.isFinite(c)&&e>c&&(e=c),n<0!=h<0&&(w=!1),h=n,b=e,y&&(p=Date.now())},getCurrentTime:()=>A(),setCurrentTime:n=>{n=ae(n,c),b=n,y&&(p=Date.now()),(!Number.isFinite(c)||n<c)&&(w=!1),T(A())},getCurrentProgress:()=>se(A(),u,s),setCurrentProgress:n=>{R.setCurrentTime(ue(n,u,s))},destroy:()=>{var n;R.cancel(),null==(n=null==i?void 0:i.onRemove)||n.call(i)}};return R}var me=["timelineSource","scroll","trigger","delay","iterations","direction","fill","resetOnFinish","duration","mode","frameRate"],ve=["definitions","bindings"],ge=n=>!!n&&"object"==typeof n&&!Array.isArray(n);function ye(n,e){const t=ge(n)?Fn({},n):{};for(const n of Object.keys(e)){const i=e[n];null!==i?ge(i)?t[n]=ye(t[n],i):t[n]=i:delete t[n]}return t}function be(n,i,o){const r=ge(l=n)&&"string"==typeof l.type?l.type:"time";var l;const a=ge(i)&&"string"==typeof i.type?String(i.type):r;let s;if(a!==r){const t={};if(ge(n))for(const i of e)void 0!==n[i]&&(t[i]=n[i]);s=ye(t,i)}else s=ye(n,i);if("scroll"===(u=a)||"view"===u){for(const n of t)void 0!==s[n]&&(o("animator.timeline."+n+": no slot on a '"+a+"' timeline — dropped"),delete s[n]);"infinite"===s.iterations&&(o("animator.timeline.iterations: 'infinite' cannot map onto a scroll range — dropped"),delete s.iterations)}var u;return s}function pe(n,e){let t;if("string"==typeof n)try{t=JSON.parse(n)}catch(n){console.warn("timeline override: not valid JSON — ignored",n),t=void 0}else t=null!=n?n:void 0;const{duration:i,delay:o,iterations:r,start:l}=e;if(void 0===i&&void 0===o&&void 0===r&&void 0===l)return void 0===t?void 0:{timeline:t};const a=ge(t)?Fn({},t):{};return void 0!==i&&(a.duration=i),void 0!==o&&(a.delay=o),void 0!==r&&(a.iterations=r),void 0!==l&&(a.trigger=wn(Fn({},a.trigger),{start:l})),{timeline:a}}function he(n,e){const t=[],i=n=>t.push(n);if(null===e)return{config:void 0,warnings:t};if(!ge(e)||0===Object.keys(e).length)return{config:n,warnings:t};const o=ge(n)?me.filter(e=>void 0!==n[e]):[];o.length&&i("animator: the base carries the flat runtime spelling ("+o.join(", ")+"); the patch merges the wire spelling only");const r=ge(n)?Fn({},n):{};for(const n of Object.keys(e)){const t=e[n];null!==t?"timeline"!==n?ge(t)?r[n]=ye(r[n],t):r[n]=t:r.timeline=ge(t)?be(r.timeline,t,i):t:delete r[n]}return{config:r,warnings:t}}function we(n,e,t){var i,o;const r=!!(null==t?void 0:t.resetTimeline);if(!(n&&void 0!==e&&(r||null!==e&&ge(e)&&Object.keys(e).length)))return{doc:n,warnings:[]};const l=n,a=ge(l.animator),s=!a&&ge(null==(i=l.meta)?void 0:i.animator),u=a?l.animator:s?l.meta.animator:void 0,c=[];a&&ge(null==(o=l.meta)?void 0:o.animator)&&c.push("animator: doc.meta.animator is shadowed by doc.animator and was not patched");let f=u;if(r){const n={};for(const e of ve)ge(u)&&void 0!==u[e]&&(n[e]=u[e]);f=n}const d=he(f,null!=e?e:{});return c.push(...d.warnings),d.config===u?{doc:n,warnings:c}:s?{doc:wn(Fn({},l),{meta:wn(Fn({},l.meta),{animator:d.config})}),warnings:c}:{doc:wn(Fn({},l),{animator:d.config}),warnings:c}}export{ie as PX_RATE_REJECTED,i as PX_TRANSFORM_PART_KEYS,o as PX_TRIGGER_DEFAULTS,r as PX_WIRE_BASELINE_VERSION,l as PX_WIRE_SCHEMA_VERSION,a as PX_WIRE_STEPS,s as PX_WIRE_VERSION,u as PX_WIRE_VERSION_KEY,c as PxAlongPathMode,f as PxAnimatedSvgDocumentSchema,d as PxAnimatorConfigSchema,m as PxAttrValueSchema,v as PxBezierPathSchema,g as PxClipPathEffectSchema,y as PxCloneEffectSchema,b as PxCloneWithout,p as PxControlMode,h as PxDefinitionsSchema,w as PxDiagnosticCode,F as PxDiagnosticKind,N as PxEffectsSchema,j as PxElementAnimationSchema,k as PxFillGradientEffectSchema,A as PxFillMode,T as PxFinishAction,C as PxGradientSpreadMethod,O as PxGradientStopSchema,P as PxGradientType,R as PxKeyframeSchema,D as PxKeyframeValueSchema,S as PxLengthAdjust,E as PxLoopDirection,M as PxLoopRepeatAt,q as PxLoopSchema,x as PxMaskType,J as PxMaskedByEffectSchema,z as PxMouseOutAction,H as PxNodeBaseSchema,V as PxNodeSchema,B as PxOffScreenAction,G as PxPathOverflow,I as PxPinAlign,K as PxPlaybackDirection,L as PxPropertyAnimationSchema,Q as PxRepeaterEffectSchema,U as PxRetimeEffectSchema,W as PxScrollAxis,X as PxScrollKind,Y as PxScrollPhase,Z as PxScrollRangePointSchema,$ as PxScrollRangeSchema,_ as PxScrollSchema,nn as PxScrollSource,en as PxStrokeTrimEffectSchema,tn as PxStrokeTrimSubPaths,on as PxSvgNodeRootSchema,rn as PxTextEffectSchema,ln as PxTextPathEffectSchema,an as PxTextPathMethod,sn as PxTextPathSpacing,un as PxTimelineEngine,cn as PxTimelineEngineSetting,fn as PxTimelineSchema,dn as PxTransformByEffectSchema,mn as PxTransformPartsSchema,vn as PxTransformValueSchema,gn as PxTriggerSchema,yn as PxTriggerStart,bn as PxUnits,pn as PxWireStepKind,hn as PxWireVersionRelation,we as applyAnimatorConfig,Nn as applyWireSteps,jn as calcAnimationValues,ae as clampSeekMs,An as compareWireVersion,Tn as controlModeTakesOverTrigger,Cn as convertWireDocument,de as createAdapterAnimator,ce as createRunClock,On as describeSchema,Pn as diagnoseDocument,Rn as downgradeWireDocument,Dn as flattenAnimatorTimeline,pe as foldTimelineOverride,Sn as formatWireVersion,En as generateNewIds,Mn as getAnimatorConfig,qn as getBindings,xn as getChildren,Jn as getDefinitions,zn as isNativeForced,Hn as isPxDocument,oe as isValidPlaybackRate,Vn as isValidPxDocument,Bn as materializeAllInTree,Gn as materializeNodeEffects,In as mayUseNativeScrollTimeline,he as mergeAnimatorConfig,Kn as nestAnimatorTimeline,Ln as normalizeBindings,Qn as parseWireVersion,le as progressSpanMs,ue as progressToTimeMs,Un as px,Wn as readWireVersion,Xn as resolveControlMode,Yn as resolveTimelineEngine,Zn as resolveTrigger,$n as schemaKeys,re as seekCeilingMs,se as timeToProgress,_n as toDomProps,ne as validateDocument,ee as validateNodeEffects,te as wireVersionAdvice};
|
|
1
|
+
import{PX_DEFAULT_DURATION_MS as n,PX_DEFAULT_ITERATIONS as e,PX_TIMELINE_SHARED_KEYS as t,PX_TIME_ONLY_TIMELINE_KEYS as i,PX_TRANSFORM_PART_KEYS as o,PX_TRIGGER_DEFAULTS as r,PX_WIRE_BASELINE_VERSION as l,PX_WIRE_SCHEMA_VERSION as a,PX_WIRE_STEPS as s,PX_WIRE_VERSION as u,PX_WIRE_VERSION_KEY as c,PxAlongPathMode as f,PxAnimatedSvgDocumentSchema as d,PxAnimatorConfigSchema as m,PxAttrValueSchema as v,PxBezierPathSchema as g,PxClipPathEffectSchema as y,PxCloneEffectSchema as b,PxCloneWithout as p,PxControlMode as h,PxDefinitionsSchema as w,PxDiagnosticCode as F,PxDiagnosticKind as N,PxEffectsSchema as j,PxElementAnimationSchema as k,PxFillGradientEffectSchema as A,PxFillMode as C,PxFinishAction as O,PxGradientSpreadMethod as R,PxGradientStopSchema as T,PxGradientType as P,PxKeyframeSchema as D,PxKeyframeValueSchema as S,PxLengthAdjust as M,PxLoopDirection as q,PxLoopRepeatAt as x,PxLoopSchema as E,PxMaskType as J,PxMaskedByEffectSchema as z,PxMouseOutAction as I,PxNodeBaseSchema as K,PxNodeSchema as V,PxOffScreenAction as B,PxPathOverflow as G,PxPinAlign as H,PxPlaybackDirection as L,PxPropertyAnimationSchema as Q,PxRepeaterEffectSchema as U,PxRetimeEffectSchema as W,PxScrollAxis as X,PxScrollKind as Y,PxScrollPhase as Z,PxScrollRangePointSchema as $,PxScrollRangeSchema as _,PxScrollSchema as nn,PxScrollSource as en,PxStrokeTrimEffectSchema as tn,PxStrokeTrimSubPaths as on,PxSvgNodeRootSchema as rn,PxTextEffectSchema as ln,PxTextPathEffectSchema as an,PxTextPathMethod as sn,PxTextPathSpacing as un,PxTimeTimelineSchema as cn,PxTimelineEngine as fn,PxTimelineEngineSetting as dn,PxTimelineSchema as mn,PxTransformByEffectSchema as vn,PxTransformPartsSchema as gn,PxTransformValueSchema as yn,PxTriggerSchema as bn,PxTriggerStart as pn,PxUnits as hn,PxWireStepKind as wn,PxWireVersionRelation as Fn,__spreadProps as Nn,__spreadValues as jn,applyWireSteps as kn,calcAnimationValues as An,clamp as Cn,compareWireVersion as On,controlModeTakesOverTrigger as Rn,convertWireDocument as Tn,describeSchema as Pn,diagnoseDocument as Dn,downgradeWireDocument as Sn,flattenAnimatorTimeline as Mn,formatWireVersion as qn,generateNewIds as xn,getAnimatorConfig as En,getBindings as Jn,getChildren as zn,getDefinitions as In,isNativeForced as Kn,isPxDocument as Vn,isValidPxDocument as Bn,materializeAllInTree as Gn,materializeNodeEffects as Hn,mayUseNativeScrollTimeline as Ln,nestAnimatorTimeline as Qn,normalizeBindings as Un,parseWireVersion as Wn,px as Xn,readWireVersion as Yn,resolveControlMode as Zn,resolveTimelineEngine as $n,resolveTrigger as _n,schemaKeys as ne,toDomProps as ee,validateDocument as te,validateNodeEffects as ie,wireVersionAdvice as oe}from"./chunk-K2732IVS.min.js";var re="setPlaybackRate: rate must be finite and non-zero";function le(n){return Number.isFinite(n)&&0!==n}function ae(n,e){return n>0?e===1/0?1/0:n*(e>0?e:1):0}function se(n,e){return n>0?e===1/0?n:n*(e>0?e:1):0}function ue(n,e){return Number.isNaN(n)||n<0?0:Number.isFinite(e)?n>e?e:n:Number.isFinite(n)?n:0}function ce(n,e,t){const i=se(e,t);return i>0&&Number.isFinite(n)?n<=0?0:t===1/0?n%i/i:n>=i?1:n/i:0}function fe(n,e,t){const i=se(e,t);return i>0&&Number.isFinite(n)?n<=0?0:n>=1?i:n*i:0}function de(n,e=Date.now){let t=0,i=0,o=!1,r=1;const l=()=>ue(o?t+(e()-i)*r:t,n);return{now:l,isRunning:()=>o,start:(a,s)=>{t=ue(null!=s?s:l(),n),r=le(a)?a:1,i=e(),o=!0},stop:()=>{t=l(),i=0,o=!1},seek:r=>{t=ue(r,n),o&&(i=e())}}}function me(n){const e=globalThis;"function"!=typeof e.cancelAnimationFrame?e.clearTimeout(n):e.cancelAnimationFrame(n)}function ve(t,i,o){var r;const l=En(t)||{},a=Un(t,fn.js),s=l.iterations;let u=1;"number"==typeof s&&(u=s||e),"infinite"===s&&(u=1/0),u<1&&(u=1);const c=+(l.duration||n),f=c&&u?c*(u===1/0?1/0:u):c?(null!=u?u:e)*c:0,d=l.direction||cn.defaults.direction,m=null!=(r=l.fill)?r:cn.defaults.fillMode,v="forwards"===m||"both"===m,g="backwards"===m||"both"===m;let y=null,b=!1,p=-(l.delay||0),h=0,w=1,F=!1;const N=l.frameRate,j=N&&N>0?1e3/N:0;let k=0;const A=()=>{const n=h?(Date.now()-h)*w:0;return p+n},C=()=>{let n=A();return Number.isFinite(f)&&n>f&&(n=f),n<0&&(n=0),n};function O(n){let e=function(){const e=c>0?c:1;let t=0,i=0;if(c>0){n=Cn(n,0,u*e),i=Math.max(0,Math.ceil(n/e)-1),i=Math.min(i,u-1);t=Cn((n-i*e)/e,0,1)}else t=n;const o=d||"normal";let r=t;return"reverse"===o?r=1-t:"alternate"===o?i%2==1&&(r=1-t):"alternate-reverse"===o&&i%2==0&&(r=1-t),r}();for(const n of a||[]){const t=n.animate;if(!t||"object"!=typeof t||Array.isArray(t)){console.warn("Empty or unresolved binding",n);continue}const o=An(t,e*c);for(const[e,t]of Object.entries(o))i.setAttribute(n.id,e,t)}}l.delay&&(l.delay<0?O(C()):g&&O(0));const R=()=>!!b&&(!!i.isConnected()&&(w<0?A()>0:!(Number.isFinite(f)&&C()>=f))),T=n=>{null!==y&&(me(y),y=null),(n||R())&&(y=function(n){const e=globalThis;return"function"==typeof e.requestAnimationFrame?e.requestAnimationFrame(n):e.setTimeout(n,16)}(()=>{y=null,(()=>{var n,e;if(!i.isConnected())return void P();const t=C(),r=A();if(r<0&&w>0)g&&O(0);else{if(w<0&&r<=0)return P(),O(0),void(F||(F=!0,null==(n=null==o?void 0:o.onFinish)||n.call(o)));if(w>0&&f&&Number.isFinite(f)&&t>=f)return P(),O(v?f:0),void(F||(F=!0,null==(e=null==o?void 0:o.onFinish)||e.call(o)));if(j>0){const n=Date.now();if(k&&n-k<j)return;k=n}O(t)}})(),T()}))},P=()=>{if(!b)return;let n=A();Number.isFinite(f)&&n>f&&(n=f),p=n,h=0,b=!1,null!==y&&(me(y),y=null),n>=0?O(n):g&&O(0)},D={isReady:()=>!0,getRootElement:()=>null,isPlaying:()=>R(),play:()=>{var n;(()=>{if(!b){if(w>=0)Number.isFinite(f)&&p>=f&&(p=0);else if(p<=0){if(!Number.isFinite(f))return void console.warn("play: cannot start reverse playback of an infinite animation from time 0");p=f}F=!1,b=!0,h=Date.now(),T(!0)}})(),null==(n=null==o?void 0:o.onPlay)||n.call(o)},pause:()=>{var n;P(),null==(n=null==o?void 0:o.onPause)||n.call(o)},cancel:()=>{var n;P(),p=0,h=0,b=!1,F=!1,O(p),null==(n=null==o?void 0:o.onCancel)||n.call(o)},finish:()=>{((n=!0)=>{var e;p=Number.isFinite(f)?f:C(),h=0,b=!1,null!==y&&(me(y),y=null),O(v?p:0),n&&!F&&(F=!0,null==(e=null==o?void 0:o.onFinish)||e.call(o))})(!0)},setPlaybackRate:n=>{if(!le(n))return void console.warn(re);let e=A();Number.isFinite(f)&&e>f&&(e=f),n<0!=w<0&&(F=!1),w=n,p=e,b&&(h=Date.now())},getCurrentTime:()=>C(),setCurrentTime:n=>{n=ue(n,f),p=n,b&&(h=Date.now()),(!Number.isFinite(f)||n<f)&&(F=!1),O(C())},getCurrentProgress:()=>ce(C(),c,u),setCurrentProgress:n=>{D.setCurrentTime(fe(n,c,u))},destroy:()=>{var n;D.cancel(),null==(n=null==o?void 0:o.onRemove)||n.call(o)}};return D}var ge=["timelineSource","scroll","trigger","delay","iterations","direction","fill","resetOnFinish","duration","mode","frameRate"],ye=["definitions","bindings"],be=n=>!!n&&"object"==typeof n&&!Array.isArray(n);function pe(n,e){const t=be(n)?jn({},n):{};for(const n of Object.keys(e)){const i=e[n];null!==i?be(i)?t[n]=pe(t[n],i):t[n]=i:delete t[n]}return t}function he(n,e,o){const r=be(l=n)&&"string"==typeof l.type?l.type:"time";var l;const a=be(e)&&"string"==typeof e.type?String(e.type):r;let s;if(a!==r){const i={};if(be(n))for(const e of t)void 0!==n[e]&&(i[e]=n[e]);s=pe(i,e)}else s=pe(n,e);if("scroll"===(u=a)||"view"===u){for(const n of i)void 0!==s[n]&&(o("animator.timeline."+n+": no slot on a '"+a+"' timeline — dropped"),delete s[n]);"infinite"===s.iterations&&(o("animator.timeline.iterations: 'infinite' cannot map onto a scroll range — dropped"),delete s.iterations)}var u;return s}function we(n,e){let t;if("string"==typeof n)try{t=JSON.parse(n)}catch(n){console.warn("timeline override: not valid JSON — ignored",n),t=void 0}else t=null!=n?n:void 0;const{duration:i,delay:o,iterations:r,start:l}=e;if(void 0===i&&void 0===o&&void 0===r&&void 0===l)return void 0===t?void 0:{timeline:t};const a=be(t)?jn({},t):{};return void 0!==i&&(a.duration=i),void 0!==o&&(a.delay=o),void 0!==r&&(a.iterations=r),void 0!==l&&(a.trigger=Nn(jn({},a.trigger),{start:l})),{timeline:a}}function Fe(n,e){const t=[],i=n=>t.push(n);if(null===e)return{config:void 0,warnings:t};if(!be(e)||0===Object.keys(e).length)return{config:n,warnings:t};const o=be(n)?ge.filter(e=>void 0!==n[e]):[];o.length&&i("animator: the base carries the flat runtime spelling ("+o.join(", ")+"); the patch merges the wire spelling only");const r=be(n)?jn({},n):{};for(const n of Object.keys(e)){const t=e[n];null!==t?"timeline"!==n?be(t)?r[n]=pe(r[n],t):r[n]=t:r.timeline=be(t)?he(r.timeline,t,i):t:delete r[n]}return{config:r,warnings:t}}function Ne(n,e,t){var i,o;const r=!!(null==t?void 0:t.resetTimeline);if(!(n&&void 0!==e&&(r||null!==e&&be(e)&&Object.keys(e).length)))return{doc:n,warnings:[]};const l=n,a=be(l.animator),s=!a&&be(null==(i=l.meta)?void 0:i.animator),u=a?l.animator:s?l.meta.animator:void 0,c=[];a&&be(null==(o=l.meta)?void 0:o.animator)&&c.push("animator: doc.meta.animator is shadowed by doc.animator and was not patched");let f=u;if(r){const n={};for(const e of ye)be(u)&&void 0!==u[e]&&(n[e]=u[e]);f=n}const d=Fe(f,null!=e?e:{});return c.push(...d.warnings),d.config===u?{doc:n,warnings:c}:s?{doc:Nn(jn({},l),{meta:Nn(jn({},l.meta),{animator:d.config})}),warnings:c}:{doc:Nn(jn({},l),{animator:d.config}),warnings:c}}export{re as PX_RATE_REJECTED,o as PX_TRANSFORM_PART_KEYS,r as PX_TRIGGER_DEFAULTS,l as PX_WIRE_BASELINE_VERSION,a as PX_WIRE_SCHEMA_VERSION,s as PX_WIRE_STEPS,u as PX_WIRE_VERSION,c as PX_WIRE_VERSION_KEY,f as PxAlongPathMode,d as PxAnimatedSvgDocumentSchema,m as PxAnimatorConfigSchema,v as PxAttrValueSchema,g as PxBezierPathSchema,y as PxClipPathEffectSchema,b as PxCloneEffectSchema,p as PxCloneWithout,h as PxControlMode,w as PxDefinitionsSchema,F as PxDiagnosticCode,N as PxDiagnosticKind,j as PxEffectsSchema,k as PxElementAnimationSchema,A as PxFillGradientEffectSchema,C as PxFillMode,O as PxFinishAction,R as PxGradientSpreadMethod,T as PxGradientStopSchema,P as PxGradientType,D as PxKeyframeSchema,S as PxKeyframeValueSchema,M as PxLengthAdjust,q as PxLoopDirection,x as PxLoopRepeatAt,E as PxLoopSchema,J as PxMaskType,z as PxMaskedByEffectSchema,I as PxMouseOutAction,K as PxNodeBaseSchema,V as PxNodeSchema,B as PxOffScreenAction,G as PxPathOverflow,H as PxPinAlign,L as PxPlaybackDirection,Q as PxPropertyAnimationSchema,U as PxRepeaterEffectSchema,W as PxRetimeEffectSchema,X as PxScrollAxis,Y as PxScrollKind,Z as PxScrollPhase,$ as PxScrollRangePointSchema,_ as PxScrollRangeSchema,nn as PxScrollSchema,en as PxScrollSource,tn as PxStrokeTrimEffectSchema,on as PxStrokeTrimSubPaths,rn as PxSvgNodeRootSchema,ln as PxTextEffectSchema,an as PxTextPathEffectSchema,sn as PxTextPathMethod,un as PxTextPathSpacing,cn as PxTimeTimelineSchema,fn as PxTimelineEngine,dn as PxTimelineEngineSetting,mn as PxTimelineSchema,vn as PxTransformByEffectSchema,gn as PxTransformPartsSchema,yn as PxTransformValueSchema,bn as PxTriggerSchema,pn as PxTriggerStart,hn as PxUnits,wn as PxWireStepKind,Fn as PxWireVersionRelation,Ne as applyAnimatorConfig,kn as applyWireSteps,An as calcAnimationValues,ue as clampSeekMs,On as compareWireVersion,Rn as controlModeTakesOverTrigger,Tn as convertWireDocument,ve as createAdapterAnimator,de as createRunClock,Pn as describeSchema,Dn as diagnoseDocument,Sn as downgradeWireDocument,Mn as flattenAnimatorTimeline,we as foldTimelineOverride,qn as formatWireVersion,xn as generateNewIds,En as getAnimatorConfig,Jn as getBindings,zn as getChildren,In as getDefinitions,Kn as isNativeForced,Vn as isPxDocument,le as isValidPlaybackRate,Bn as isValidPxDocument,Gn as materializeAllInTree,Hn as materializeNodeEffects,Ln as mayUseNativeScrollTimeline,Fe as mergeAnimatorConfig,Qn as nestAnimatorTimeline,Un as normalizeBindings,Wn as parseWireVersion,se as progressSpanMs,fe as progressToTimeMs,Xn as px,Yn as readWireVersion,Zn as resolveControlMode,$n as resolveTimelineEngine,_n as resolveTrigger,ne as schemaKeys,ae as seekCeilingMs,ce as timeToProgress,ee as toDomProps,te as validateDocument,ie as validateNodeEffects,oe as wireVersionAdvice};
|
package/dist/internal.cjs
CHANGED
|
@@ -55,6 +55,7 @@ __export(internal_exports, {
|
|
|
55
55
|
PX_COLOR_ATTR_NAMES: () => PX_COLOR_ATTR_NAMES,
|
|
56
56
|
PX_CSS_ONLY_STYLE_PROPS: () => PX_CSS_ONLY_STYLE_PROPS,
|
|
57
57
|
PX_DEFAULT_DURATION_MS: () => PX_DEFAULT_DURATION_MS,
|
|
58
|
+
PX_DEFAULT_ITERATIONS: () => PX_DEFAULT_ITERATIONS,
|
|
58
59
|
PX_DISALLOWED_SVG_TAGS_LOWER: () => PX_DISALLOWED_SVG_TAGS_LOWER,
|
|
59
60
|
PX_LOOP_JUMP_SHIFT_MS: () => PX_LOOP_JUMP_SHIFT_MS,
|
|
60
61
|
PX_PCT_BASED_ATTR_NAMES: () => PX_PCT_BASED_ATTR_NAMES,
|
|
@@ -115,19 +116,31 @@ function pathStr(path) {
|
|
|
115
116
|
return result;
|
|
116
117
|
}
|
|
117
118
|
var Base = class {
|
|
119
|
+
/** Structural schemas (objects, arrays, unions of objects…) pass `false`: they state no scalar default. */
|
|
120
|
+
constructor(_statesDefault) {
|
|
121
|
+
this._statesDefault = _statesDefault;
|
|
122
|
+
}
|
|
118
123
|
_canSanitize(raw) {
|
|
119
124
|
return this.isValid(raw);
|
|
120
125
|
}
|
|
126
|
+
/** A REQUIRED field is never absent; its default is the repair value. */
|
|
127
|
+
absentDefault() {
|
|
128
|
+
return this._default;
|
|
129
|
+
}
|
|
121
130
|
optional() {
|
|
122
131
|
return new Optional(this);
|
|
123
132
|
}
|
|
124
133
|
};
|
|
125
134
|
var Optional = class extends Base {
|
|
126
135
|
constructor(inner) {
|
|
127
|
-
super();
|
|
136
|
+
super(inner._statesDefault);
|
|
128
137
|
this.inner = inner;
|
|
129
138
|
this._default = void 0;
|
|
130
139
|
}
|
|
140
|
+
/** Absent means the inner schema's STATED default — or nothing at all when it states none. */
|
|
141
|
+
absentDefault() {
|
|
142
|
+
return this.inner._statesDefault ? this.inner._default : void 0;
|
|
143
|
+
}
|
|
131
144
|
sanitize(raw) {
|
|
132
145
|
if (raw === void 0 || raw === null) return void 0;
|
|
133
146
|
return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
|
|
@@ -141,8 +154,8 @@ var Optional = class extends Base {
|
|
|
141
154
|
}
|
|
142
155
|
};
|
|
143
156
|
var Str = class extends Base {
|
|
144
|
-
constructor(_default
|
|
145
|
-
super();
|
|
157
|
+
constructor(_default, statesDefault) {
|
|
158
|
+
super(statesDefault);
|
|
146
159
|
this._default = _default;
|
|
147
160
|
}
|
|
148
161
|
sanitize(raw) {
|
|
@@ -155,8 +168,8 @@ var Str = class extends Base {
|
|
|
155
168
|
}
|
|
156
169
|
};
|
|
157
170
|
var Num = class extends Base {
|
|
158
|
-
constructor(_default
|
|
159
|
-
super();
|
|
171
|
+
constructor(_default, statesDefault) {
|
|
172
|
+
super(statesDefault);
|
|
160
173
|
this._default = _default;
|
|
161
174
|
}
|
|
162
175
|
sanitize(raw) {
|
|
@@ -169,8 +182,8 @@ var Num = class extends Base {
|
|
|
169
182
|
}
|
|
170
183
|
};
|
|
171
184
|
var Bool = class extends Base {
|
|
172
|
-
constructor(_default
|
|
173
|
-
super();
|
|
185
|
+
constructor(_default, statesDefault) {
|
|
186
|
+
super(statesDefault);
|
|
174
187
|
this._default = _default;
|
|
175
188
|
}
|
|
176
189
|
sanitize(raw) {
|
|
@@ -183,8 +196,9 @@ var Bool = class extends Base {
|
|
|
183
196
|
}
|
|
184
197
|
};
|
|
185
198
|
var Literal = class extends Base {
|
|
199
|
+
/** A literal IS its own value: absent means it. */
|
|
186
200
|
constructor(value) {
|
|
187
|
-
super();
|
|
201
|
+
super(true);
|
|
188
202
|
this.value = value;
|
|
189
203
|
this._default = value;
|
|
190
204
|
}
|
|
@@ -198,8 +212,8 @@ var Literal = class extends Base {
|
|
|
198
212
|
}
|
|
199
213
|
};
|
|
200
214
|
var Enum = class extends Base {
|
|
201
|
-
constructor(values, defaultVal) {
|
|
202
|
-
super();
|
|
215
|
+
constructor(values, defaultVal, statesDefault) {
|
|
216
|
+
super(statesDefault);
|
|
203
217
|
this.values = values;
|
|
204
218
|
this._default = defaultVal != null ? defaultVal : values[0];
|
|
205
219
|
}
|
|
@@ -214,8 +228,8 @@ var Enum = class extends Base {
|
|
|
214
228
|
};
|
|
215
229
|
var UNION_MEMBER_ERROR_LIMIT = 4;
|
|
216
230
|
var Union = class extends Base {
|
|
217
|
-
constructor(schemas, defaultVal) {
|
|
218
|
-
super();
|
|
231
|
+
constructor(schemas, defaultVal, statesDefault) {
|
|
232
|
+
super(statesDefault);
|
|
219
233
|
this.schemas = schemas;
|
|
220
234
|
/** Structural tag read by {@link describeSchema} — `schemas` alone cannot tell Union from Tuple. */
|
|
221
235
|
this._kind = "union";
|
|
@@ -269,7 +283,7 @@ var Union = class extends Base {
|
|
|
269
283
|
var DiscriminatedUnion = class extends Base {
|
|
270
284
|
constructor(_key, _schemas, defaultVal) {
|
|
271
285
|
var _a2;
|
|
272
|
-
super();
|
|
286
|
+
super(false);
|
|
273
287
|
this._key = _key;
|
|
274
288
|
this._schemas = _schemas;
|
|
275
289
|
/** Structural tag read by {@link describeSchema}. */
|
|
@@ -309,13 +323,19 @@ var DiscriminatedUnion = class extends Base {
|
|
|
309
323
|
return schema ? schema._canSanitize(raw) : this._schemas[0]._canSanitize(raw);
|
|
310
324
|
}
|
|
311
325
|
};
|
|
326
|
+
function statedDefaults(shape) {
|
|
327
|
+
const out = {};
|
|
328
|
+
for (const key of Object.keys(shape)) if (shape[key]._statesDefault) out[key] = shape[key].absentDefault();
|
|
329
|
+
return Object.freeze(out);
|
|
330
|
+
}
|
|
312
331
|
var Obj = class extends Base {
|
|
313
332
|
constructor(_shape) {
|
|
314
|
-
super();
|
|
333
|
+
super(false);
|
|
315
334
|
this._shape = _shape;
|
|
316
335
|
const d = {};
|
|
317
336
|
for (const key of Object.keys(_shape)) d[key] = _shape[key]._default;
|
|
318
337
|
this._default = d;
|
|
338
|
+
this.defaults = statedDefaults(_shape);
|
|
319
339
|
}
|
|
320
340
|
sanitize(raw) {
|
|
321
341
|
const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
@@ -357,12 +377,13 @@ var Obj = class extends Base {
|
|
|
357
377
|
};
|
|
358
378
|
var OpenObj = class extends Base {
|
|
359
379
|
constructor(_shape, _openSchema) {
|
|
360
|
-
super();
|
|
380
|
+
super(false);
|
|
361
381
|
this._shape = _shape;
|
|
362
382
|
this._openSchema = _openSchema;
|
|
363
383
|
const d = {};
|
|
364
384
|
for (const key of Object.keys(_shape)) d[key] = _shape[key]._default;
|
|
365
385
|
this._default = d;
|
|
386
|
+
this.defaults = statedDefaults(_shape);
|
|
366
387
|
}
|
|
367
388
|
sanitize(raw) {
|
|
368
389
|
const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
@@ -407,7 +428,7 @@ var OpenObj = class extends Base {
|
|
|
407
428
|
};
|
|
408
429
|
var Arr = class extends Base {
|
|
409
430
|
constructor(item) {
|
|
410
|
-
super();
|
|
431
|
+
super(false);
|
|
411
432
|
this.item = item;
|
|
412
433
|
this._default = [];
|
|
413
434
|
}
|
|
@@ -439,7 +460,7 @@ var Arr = class extends Base {
|
|
|
439
460
|
};
|
|
440
461
|
var Rec = class extends Base {
|
|
441
462
|
constructor(value) {
|
|
442
|
-
super();
|
|
463
|
+
super(false);
|
|
443
464
|
this.value = value;
|
|
444
465
|
/** Structural tag read by {@link describeSchema}. */
|
|
445
466
|
this._kind = "record";
|
|
@@ -473,7 +494,7 @@ var Rec = class extends Base {
|
|
|
473
494
|
};
|
|
474
495
|
var Any = class extends Base {
|
|
475
496
|
constructor() {
|
|
476
|
-
super(
|
|
497
|
+
super(false);
|
|
477
498
|
this._default = void 0;
|
|
478
499
|
}
|
|
479
500
|
sanitize(raw) {
|
|
@@ -488,7 +509,7 @@ var Any = class extends Base {
|
|
|
488
509
|
};
|
|
489
510
|
var Defined = class extends Base {
|
|
490
511
|
constructor() {
|
|
491
|
-
super(
|
|
512
|
+
super(false);
|
|
492
513
|
this._default = void 0;
|
|
493
514
|
}
|
|
494
515
|
sanitize(raw) {
|
|
@@ -505,7 +526,7 @@ var Defined = class extends Base {
|
|
|
505
526
|
};
|
|
506
527
|
var Lazy = class extends Base {
|
|
507
528
|
constructor(fn, _default) {
|
|
508
|
-
super();
|
|
529
|
+
super(false);
|
|
509
530
|
this.fn = fn;
|
|
510
531
|
this._default = _default;
|
|
511
532
|
this.resolved = null;
|
|
@@ -526,7 +547,7 @@ var Lazy = class extends Base {
|
|
|
526
547
|
};
|
|
527
548
|
var Tuple = class extends Base {
|
|
528
549
|
constructor(schemas) {
|
|
529
|
-
super();
|
|
550
|
+
super(false);
|
|
530
551
|
this.schemas = schemas;
|
|
531
552
|
/** Structural tag read by {@link describeSchema} — `schemas` alone cannot tell Tuple from Union. */
|
|
532
553
|
this._kind = "tuple";
|
|
@@ -577,22 +598,29 @@ function describeSchema(schema) {
|
|
|
577
598
|
if ("fn" in s) return { kind: "lazy", resolved: (_a2 = s.resolved) != null ? _a2 : s.resolved = s.fn() };
|
|
578
599
|
return { kind: "leaf" };
|
|
579
600
|
}
|
|
601
|
+
function string(defaultVal) {
|
|
602
|
+
return defaultVal === void 0 ? new Str("", false) : new Str(defaultVal, true);
|
|
603
|
+
}
|
|
604
|
+
function number(defaultVal) {
|
|
605
|
+
return defaultVal === void 0 ? new Num(0, false) : new Num(defaultVal, true);
|
|
606
|
+
}
|
|
607
|
+
function boolean(defaultVal) {
|
|
608
|
+
return defaultVal === void 0 ? new Bool(false, false) : new Bool(defaultVal, true);
|
|
609
|
+
}
|
|
610
|
+
function oneOf(values, defaultVal) {
|
|
611
|
+
return defaultVal === void 0 ? new Enum(values, void 0, false) : new Enum(values, defaultVal, true);
|
|
612
|
+
}
|
|
613
|
+
function unionOf(schemas, defaultVal) {
|
|
614
|
+
return defaultVal === void 0 ? new Union(schemas, void 0, false) : new Union(schemas, defaultVal, true);
|
|
615
|
+
}
|
|
580
616
|
var px = {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
/** Matches a boolean. Default: false or provided value. */
|
|
586
|
-
boolean: (defaultVal = false) => new Bool(defaultVal),
|
|
587
|
-
/** Matches one exact primitive value; its default is the value itself. */
|
|
617
|
+
string,
|
|
618
|
+
number,
|
|
619
|
+
boolean,
|
|
620
|
+
/** Matches one exact primitive value; absent means the value itself. */
|
|
588
621
|
literal: (value) => new Literal(value),
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Returns the first schema whose isValid passes.
|
|
593
|
-
* TypeScript infers the union of all member types automatically.
|
|
594
|
-
*/
|
|
595
|
-
union: (schemas, defaultVal) => new Union(schemas, defaultVal),
|
|
622
|
+
enum: oneOf,
|
|
623
|
+
union: unionOf,
|
|
596
624
|
/**
|
|
597
625
|
* Discriminated union — reads `raw[key]`, finds the member schema whose
|
|
598
626
|
* literal at `key` matches, then delegates sanitize/isValid to that member.
|
|
@@ -600,7 +628,8 @@ var px = {
|
|
|
600
628
|
* TypeScript infers the union of all member types automatically.
|
|
601
629
|
*/
|
|
602
630
|
discriminatedUnion: (key, schemas) => new DiscriminatedUnion(key, schemas),
|
|
603
|
-
/** Typed object — unknown keys are stripped. Required fields fall back to their default.
|
|
631
|
+
/** Typed object — unknown keys are stripped. Required fields fall back to their default.
|
|
632
|
+
* Its `defaults` say what each stated field means when a document leaves it out. */
|
|
604
633
|
object: (shape) => new Obj(shape),
|
|
605
634
|
/**
|
|
606
635
|
* Open object — validates known keys; passes unknown keys through as-is,
|
|
@@ -721,8 +750,11 @@ var PX_TRIGGER_DEFAULTS = {
|
|
|
721
750
|
offScreen: "pause",
|
|
722
751
|
mouseOut: "continue",
|
|
723
752
|
visibilityThreshold: 0.5,
|
|
724
|
-
visibilityDebounce: 150
|
|
753
|
+
visibilityDebounce: 150,
|
|
754
|
+
finish: "hold"
|
|
725
755
|
};
|
|
756
|
+
var PX_DEFAULT_DURATION_MS = 1e3;
|
|
757
|
+
var PX_DEFAULT_ITERATIONS = 1;
|
|
726
758
|
var PxLoopRepeatAt = {
|
|
727
759
|
/** Segment from the START; the repetition runs BEFORE the first keyframe
|
|
728
760
|
* (intro loops that play until the main timeline begins). */
|
|
@@ -935,15 +967,15 @@ var keyframeTangentIn = (kf) => anyKf(kf).tangentIn;
|
|
|
935
967
|
var keyframeTangentOut = (kf) => anyKf(kf).tangentOut;
|
|
936
968
|
var PxLoopSchema = implementsInterface()(px.object({
|
|
937
969
|
segmentCount: px.number().optional(),
|
|
938
|
-
repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
|
|
939
|
-
direction: px.enum([PxLoopDirection.normal, PxLoopDirection.alternate]).optional()
|
|
970
|
+
repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end], PxLoopRepeatAt.end).optional(),
|
|
971
|
+
direction: px.enum([PxLoopDirection.normal, PxLoopDirection.alternate], PxLoopDirection.normal).optional()
|
|
940
972
|
}));
|
|
941
973
|
var PxPropertyAnimationSchema = implementsInterface()(px.object({
|
|
942
974
|
value: PxKeyframeValueSchema.optional(),
|
|
943
975
|
keyframes: px.array(PxKeyframeSchema).optional(),
|
|
944
976
|
loop: px.union([PxLoopSchema, px.boolean()]).optional(),
|
|
945
977
|
autoOrient: px.boolean().optional(),
|
|
946
|
-
alongPathMode: px.enum([PxAlongPathMode.sampled, PxAlongPathMode.offsetPath]).optional()
|
|
978
|
+
alongPathMode: px.enum([PxAlongPathMode.sampled, PxAlongPathMode.offsetPath], PxAlongPathMode.sampled).optional()
|
|
947
979
|
}));
|
|
948
980
|
var PxTransformPartsSchema = implementsInterface()(px.object({
|
|
949
981
|
translate: px.tuple([px.number(), px.number()]).optional(),
|
|
@@ -973,9 +1005,9 @@ var PxTriggerSchema = implementsInterface()(px.object({
|
|
|
973
1005
|
// What happens after a NATURAL finish — `'hold'` (default: keep the end state per
|
|
974
1006
|
// `fill`) or `'reset'` (snap back to the start state). One of four occasion keys
|
|
975
1007
|
// (`start`, `offScreen`, `mouseOut`, `finish`), all named the same way.
|
|
976
|
-
finish: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
|
|
977
|
-
visibilityThreshold: px.number().optional(),
|
|
978
|
-
visibilityDebounce: px.number().optional()
|
|
1008
|
+
finish: px.enum([PxFinishAction.hold, PxFinishAction.reset], PX_TRIGGER_DEFAULTS.finish).optional(),
|
|
1009
|
+
visibilityThreshold: px.number(PX_TRIGGER_DEFAULTS.visibilityThreshold).optional(),
|
|
1010
|
+
visibilityDebounce: px.number(PX_TRIGGER_DEFAULTS.visibilityDebounce).optional()
|
|
979
1011
|
}));
|
|
980
1012
|
var PxGlyphSchema = implementsInterface()(px.object({
|
|
981
1013
|
width: px.number(),
|
|
@@ -1001,7 +1033,7 @@ var PxScrollRangePointSchema = implementsInterface()(px.object({
|
|
|
1001
1033
|
PxScrollPhase.exit,
|
|
1002
1034
|
PxScrollPhase.entryCrossing,
|
|
1003
1035
|
PxScrollPhase.exitCrossing
|
|
1004
|
-
]).optional(),
|
|
1036
|
+
], PxScrollPhase.cover).optional(),
|
|
1005
1037
|
fraction: px.number().optional()
|
|
1006
1038
|
}));
|
|
1007
1039
|
var PxScrollRangeSchema = px.object({
|
|
@@ -1009,37 +1041,37 @@ var PxScrollRangeSchema = px.object({
|
|
|
1009
1041
|
end: PxScrollRangePointSchema.optional()
|
|
1010
1042
|
});
|
|
1011
1043
|
var PxScrollSchema = implementsInterface()(px.object({
|
|
1012
|
-
kind: px.enum([PxScrollKind.view, PxScrollKind.scroll]).optional(),
|
|
1013
|
-
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
|
|
1014
|
-
source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
|
|
1044
|
+
kind: px.enum([PxScrollKind.view, PxScrollKind.scroll], PxScrollKind.view).optional(),
|
|
1045
|
+
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y], PxScrollAxis.block).optional(),
|
|
1046
|
+
source: px.enum([PxScrollSource.nearest, PxScrollSource.root], PxScrollSource.nearest).optional(),
|
|
1015
1047
|
// Free-form: the two keywords `parent`/`scroller` plus any CSS selector.
|
|
1016
1048
|
subject: px.string().optional(),
|
|
1017
1049
|
smoothing: px.number().optional(),
|
|
1018
|
-
pin: px.boolean().optional(),
|
|
1019
|
-
pinAlign: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
|
|
1050
|
+
pin: px.boolean(false).optional(),
|
|
1051
|
+
pinAlign: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom], PxPinAlign.top).optional(),
|
|
1020
1052
|
pinOffset: px.number().optional(),
|
|
1021
1053
|
pinDistance: px.number().optional(),
|
|
1022
1054
|
range: PxScrollRangeSchema.optional()
|
|
1023
1055
|
}));
|
|
1024
1056
|
var PxTimelinePinSchema = implementsInterface()(px.object({
|
|
1025
|
-
align: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
|
|
1057
|
+
align: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom], PxPinAlign.top).optional(),
|
|
1026
1058
|
offset: px.number().optional(),
|
|
1027
1059
|
distance: px.number().optional()
|
|
1028
1060
|
}));
|
|
1029
|
-
var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js]).optional();
|
|
1061
|
+
var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js], PxTimelineEngineSetting.auto).optional();
|
|
1030
1062
|
var PxTimeTimelineSchema = implementsInterface()(px.object({
|
|
1031
1063
|
type: px.literal("time").optional(),
|
|
1032
1064
|
engine: PxTimelineEngineSchema,
|
|
1033
1065
|
frameRate: px.number().optional(),
|
|
1034
1066
|
// §2.8: duration is a property of the TIMELINE — how long one pass takes.
|
|
1035
|
-
duration: px.number().optional(),
|
|
1067
|
+
duration: px.number(PX_DEFAULT_DURATION_MS).optional(),
|
|
1036
1068
|
trigger: PxTriggerSchema.optional(),
|
|
1037
|
-
delay: px.number().optional(),
|
|
1038
|
-
iterations: px.union([px.number(), px.literal("infinite")]).optional(),
|
|
1069
|
+
delay: px.number(0).optional(),
|
|
1070
|
+
iterations: px.union([px.number(PX_DEFAULT_ITERATIONS), px.literal("infinite")], PX_DEFAULT_ITERATIONS).optional(),
|
|
1039
1071
|
// `fillMode` on the wire (CSS `animation-fill-mode`; the runtime view calls it `fill`)
|
|
1040
1072
|
// — never `fill`, which is paint everywhere else in the format.
|
|
1041
|
-
fillMode: px.enum([PxFillMode.forwards, PxFillMode.backwards, PxFillMode.both, PxFillMode.none]).optional(),
|
|
1042
|
-
direction: px.enum([PxPlaybackDirection.normal, PxPlaybackDirection.reverse, PxPlaybackDirection.alternate, PxPlaybackDirection.alternateReverse]).optional()
|
|
1073
|
+
fillMode: px.enum([PxFillMode.forwards, PxFillMode.backwards, PxFillMode.both, PxFillMode.none], PxFillMode.forwards).optional(),
|
|
1074
|
+
direction: px.enum([PxPlaybackDirection.normal, PxPlaybackDirection.reverse, PxPlaybackDirection.alternate, PxPlaybackDirection.alternateReverse], PxPlaybackDirection.normal).optional()
|
|
1043
1075
|
}));
|
|
1044
1076
|
var scrollishTimelineShape = {
|
|
1045
1077
|
// §2.8: duration is a property of the TIMELINE — under scrubbing it is the keyframe
|
|
@@ -1050,8 +1082,8 @@ var scrollishTimelineShape = {
|
|
|
1050
1082
|
iterations: px.number().optional(),
|
|
1051
1083
|
engine: PxTimelineEngineSchema,
|
|
1052
1084
|
frameRate: px.number().optional(),
|
|
1053
|
-
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
|
|
1054
|
-
source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
|
|
1085
|
+
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y], PxScrollAxis.block).optional(),
|
|
1086
|
+
source: px.enum([PxScrollSource.nearest, PxScrollSource.root], PxScrollSource.nearest).optional(),
|
|
1055
1087
|
subject: px.string().optional(),
|
|
1056
1088
|
// 'parent' | 'scroller' | any CSS selector
|
|
1057
1089
|
smoothing: px.number().optional(),
|
|
@@ -1131,9 +1163,10 @@ var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
|
1131
1163
|
}));
|
|
1132
1164
|
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
1133
1165
|
source: px.string().optional(),
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1166
|
+
// SVG's own initial values — what a <mask> does when the attribute is not there.
|
|
1167
|
+
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha], PxMaskType.luminance).optional(),
|
|
1168
|
+
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.objectBoundingBox).optional(),
|
|
1169
|
+
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.userSpaceOnUse).optional(),
|
|
1137
1170
|
x: px.number().optional(),
|
|
1138
1171
|
y: px.number().optional(),
|
|
1139
1172
|
width: px.number().optional(),
|
|
@@ -1145,7 +1178,7 @@ var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
|
1145
1178
|
var PxStrokeTrimEffectSchema = implementsInterface()(px.object({
|
|
1146
1179
|
offset: PxAnimatableNumberSchema.optional(),
|
|
1147
1180
|
range: PxAnimatableVec2Schema.optional(),
|
|
1148
|
-
subPaths: px.enum([PxStrokeTrimSubPaths.separate, PxStrokeTrimSubPaths.combined]).optional()
|
|
1181
|
+
subPaths: px.enum([PxStrokeTrimSubPaths.separate, PxStrokeTrimSubPaths.combined], PxStrokeTrimSubPaths.separate).optional()
|
|
1149
1182
|
}));
|
|
1150
1183
|
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
1151
1184
|
start: px.number().optional(),
|
|
@@ -1177,17 +1210,20 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
|
1177
1210
|
radius: PxAnimatableNumberSchema.optional(),
|
|
1178
1211
|
focal: PxAnimatableVec2Schema.optional(),
|
|
1179
1212
|
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
1180
|
-
|
|
1181
|
-
|
|
1213
|
+
// SVG's own initial values — what a gradient does when the attribute is not there.
|
|
1214
|
+
gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.objectBoundingBox).optional(),
|
|
1215
|
+
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat], PxGradientSpreadMethod.pad).optional(),
|
|
1182
1216
|
gradientTransform: px.string().optional()
|
|
1183
1217
|
}));
|
|
1184
1218
|
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
1185
1219
|
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
1186
1220
|
pathData: px.string(),
|
|
1187
|
-
pathOverflow
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1221
|
+
// `extend` is what an omitted pathOverflow means (glyphs continue along the tangent); the
|
|
1222
|
+
// other three are SVG's own initial values for the native <textPath> attributes.
|
|
1223
|
+
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend], PxPathOverflow.extend).optional(),
|
|
1224
|
+
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs], PxLengthAdjust.spacing).optional(),
|
|
1225
|
+
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch], PxTextPathMethod.align).optional(),
|
|
1226
|
+
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact], PxTextPathSpacing.exact).optional(),
|
|
1191
1227
|
startOffset: PxAnimatableNumberSchema.optional(),
|
|
1192
1228
|
textLength: PxAnimatableNumberSchema.optional()
|
|
1193
1229
|
}));
|
|
@@ -1634,7 +1670,6 @@ function parseTransformParts(str2) {
|
|
|
1634
1670
|
return Object.keys(out).length ? out : void 0;
|
|
1635
1671
|
}
|
|
1636
1672
|
var PX_STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
1637
|
-
var PX_DEFAULT_DURATION_MS = 1e3;
|
|
1638
1673
|
function kebabToCamelCaseWord(kebab) {
|
|
1639
1674
|
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
1640
1675
|
}
|
|
@@ -6058,9 +6093,10 @@ function replaceUrlRefs(value, idMap) {
|
|
|
6058
6093
|
// src/materialize/PxRestPose.ts
|
|
6059
6094
|
var TRANSFORM_CHANNEL = "transform";
|
|
6060
6095
|
var REVERSED_DIRECTIONS = /* @__PURE__ */ new Set(["reverse", "alternate-reverse"]);
|
|
6096
|
+
var VERIFY_SAMPLE_FRACTIONS = [0, 0.25, 0.5, 0.75, 1];
|
|
6061
6097
|
var SCRATCH_ID_PREFIX = "__px_rest_";
|
|
6062
6098
|
function materializeRestPosesInTree(root, engine) {
|
|
6063
|
-
var _a2;
|
|
6099
|
+
var _a2, _b;
|
|
6064
6100
|
const out = deepClone(root);
|
|
6065
6101
|
const config = getAnimatorConfig(out) || {};
|
|
6066
6102
|
const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
|
|
@@ -6072,18 +6108,27 @@ function materializeRestPosesInTree(root, engine) {
|
|
|
6072
6108
|
for (const [key, animate] of before) {
|
|
6073
6109
|
const node = nodes.get(key);
|
|
6074
6110
|
if (!node) continue;
|
|
6075
|
-
|
|
6111
|
+
const channels = Object.keys(animate);
|
|
6112
|
+
for (const channel of channels) {
|
|
6113
|
+
if (PX_TRANSFORM_FN_NAMES.has(channel)) continue;
|
|
6076
6114
|
if (!mayCarryRestPose(node, channel)) continue;
|
|
6077
6115
|
const value = firstFrameValue(animate, channel, firstFrameTime);
|
|
6078
6116
|
if (value === void 0) continue;
|
|
6079
6117
|
node[channel] = value;
|
|
6080
6118
|
added.set(key, [...(_a2 = added.get(key)) != null ? _a2 : [], channel]);
|
|
6081
6119
|
}
|
|
6120
|
+
if (channels.some((channel) => PX_TRANSFORM_FN_NAMES.has(channel)) && mayCarryTransformRestPose(node)) {
|
|
6121
|
+
const parts = firstFrameTransformParts(animate, firstFrameTime);
|
|
6122
|
+
if (parts) {
|
|
6123
|
+
node[TRANSFORM_CHANNEL] = parts;
|
|
6124
|
+
added.set(key, [...(_b = added.get(key)) != null ? _b : [], TRANSFORM_CHANNEL]);
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6082
6127
|
}
|
|
6083
6128
|
if (added.size) {
|
|
6084
6129
|
const after = bindingsOf(out, engine);
|
|
6085
6130
|
for (const [key, channels] of added) {
|
|
6086
|
-
if (
|
|
6131
|
+
if (writesTheSameFrames(before.get(key), after.get(key), duration)) continue;
|
|
6087
6132
|
const node = nodes.get(key);
|
|
6088
6133
|
if (node) for (const channel of channels) delete node[channel];
|
|
6089
6134
|
}
|
|
@@ -6092,16 +6137,31 @@ function materializeRestPosesInTree(root, engine) {
|
|
|
6092
6137
|
}
|
|
6093
6138
|
function mayCarryRestPose(node, channel) {
|
|
6094
6139
|
if (node[channel] !== void 0) return false;
|
|
6095
|
-
if (
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6140
|
+
if (channel === TRANSFORM_CHANNEL) return mayCarryTransformRestPose(node);
|
|
6141
|
+
return true;
|
|
6142
|
+
}
|
|
6143
|
+
function mayCarryTransformRestPose(node) {
|
|
6144
|
+
if (node[TRANSFORM_CHANNEL] !== void 0) return false;
|
|
6145
|
+
for (const part of PX_TRANSFORM_FN_NAMES) if (node[part] !== void 0) return false;
|
|
6099
6146
|
return true;
|
|
6100
6147
|
}
|
|
6101
6148
|
function firstFrameValue(animate, channel, timeMs) {
|
|
6102
6149
|
const values = Object.values(calcAnimationValues({ [channel]: animate[channel] }, timeMs));
|
|
6103
6150
|
return values.length === 1 && values[0] !== "" ? values[0] : void 0;
|
|
6104
6151
|
}
|
|
6152
|
+
function firstFrameTransformParts(animate, timeMs) {
|
|
6153
|
+
const family = {};
|
|
6154
|
+
for (const channel of Object.keys(animate)) if (PX_TRANSFORM_FN_NAMES.has(channel)) family[channel] = animate[channel];
|
|
6155
|
+
const written = calcAnimationValues(family, timeMs)[TRANSFORM_CHANNEL];
|
|
6156
|
+
if (!written) return void 0;
|
|
6157
|
+
const parts = parseTransformParts(written.replace(/(px|deg)\b/g, ""));
|
|
6158
|
+
return parts && Object.keys(parts).length ? parts : void 0;
|
|
6159
|
+
}
|
|
6160
|
+
function writesTheSameFrames(a, b, durationMs) {
|
|
6161
|
+
if (!a || !b) return a === b;
|
|
6162
|
+
const frame = (animate, t) => JSON.stringify(calcAnimationValues(animate, t)).replace(/\s+/g, "");
|
|
6163
|
+
return VERIFY_SAMPLE_FRACTIONS.every((fraction) => frame(a, fraction * durationMs) === frame(b, fraction * durationMs));
|
|
6164
|
+
}
|
|
6105
6165
|
function bindingsOf(tree, engine) {
|
|
6106
6166
|
const scratch = deepClone(tree);
|
|
6107
6167
|
const keyById = /* @__PURE__ */ new Map();
|
|
@@ -6544,6 +6604,7 @@ function releaseLogProblems(releases, steps, declared, baseline) {
|
|
|
6544
6604
|
PX_COLOR_ATTR_NAMES,
|
|
6545
6605
|
PX_CSS_ONLY_STYLE_PROPS,
|
|
6546
6606
|
PX_DEFAULT_DURATION_MS,
|
|
6607
|
+
PX_DEFAULT_ITERATIONS,
|
|
6547
6608
|
PX_DISALLOWED_SVG_TAGS_LOWER,
|
|
6548
6609
|
PX_LOOP_JUMP_SHIFT_MS,
|
|
6549
6610
|
PX_PCT_BASED_ATTR_NAMES,
|