@glissade/core 0.6.0-pre.0 → 0.6.0-pre.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.
package/dist/index.d.ts CHANGED
@@ -198,6 +198,37 @@ interface SpringFactory {
198
198
  retarget: typeof retarget;
199
199
  }
200
200
  declare const spring: SpringFactory;
201
+ /**
202
+ * Named spring feels (react-spring conventions, mass 1) — a vocabulary instead
203
+ * of hand-tuned stiffness/damping. Use `spring(springPresets.wobbly)` or
204
+ * `springTo(t, a, b, springPresets.gentle)`.
205
+ */
206
+ declare const springPresets: {
207
+ readonly default: {
208
+ readonly stiffness: 170;
209
+ readonly damping: 26;
210
+ };
211
+ readonly gentle: {
212
+ readonly stiffness: 120;
213
+ readonly damping: 14;
214
+ };
215
+ readonly wobbly: {
216
+ readonly stiffness: 180;
217
+ readonly damping: 12;
218
+ };
219
+ readonly stiff: {
220
+ readonly stiffness: 210;
221
+ readonly damping: 20;
222
+ };
223
+ readonly slow: {
224
+ readonly stiffness: 280;
225
+ readonly damping: 60;
226
+ };
227
+ readonly molasses: {
228
+ readonly stiffness: 280;
229
+ readonly damping: 120;
230
+ };
231
+ };
201
232
  /**
202
233
  * The spring as a normalized easing over a segment whose length must equal
203
234
  * spring.duration(cfg) (validated at the document layer, §2.7).
@@ -273,6 +304,16 @@ declare function key<T>(t: number, value: T, easeOrOpts?: EaseSpec | KeyOpts<T>)
273
304
  * track('x/width', 'number', [...springTo(beats.start('drop'), 0, 320, cfg)])
274
305
  */
275
306
  declare function springTo<T>(endT: number, from: T, to: T, cfg: SpringConfig): [Key<T>, Key<T>];
307
+ /**
308
+ * Cascade a set of tracks by shifting each one's key times — the classic
309
+ * stagger for animating a list of nodes with a delay between them. `delay` is
310
+ * the per-index gap in seconds, or a function of the index for non-linear
311
+ * cascades. Pure: returns new tracks, leaving the inputs untouched.
312
+ *
313
+ * stagger(items.map((it, i) => track(`${it.id}/opacity`, 'number',
314
+ * [key(0, 0), key(0.3, 1, 'easeOutCubic')])), 0.08)
315
+ */
316
+ declare function stagger<T>(tracks: readonly Track<T>[], delay: number | ((index: number) => number)): Track<T>[];
276
317
  declare function track<T>(target: string, type: ValueTypeId, keys: Key<T>[], opts?: {
277
318
  editable?: boolean;
278
319
  }): Track<T>;
@@ -554,4 +595,4 @@ declare function normalizeEditedKeys(keys: Key[]): Key[];
554
595
  */
555
596
  declare function mergeSidecar(code: Timeline, sidecar: SidecarDoc | null | undefined): Timeline;
556
597
  //#endregion
557
- export { type AssetRef, type AudioClip, type BakeConfig, BakeError, type BindTarget, type BindableSignal, type BoundTimeline, type CheckpointedBakeConfig, type CheckpointedSim, type ChildEntry, CircularDependencyError, ColorParseError, type CompiledTimeline, type CurveSampler, DEFAULT_EASE, type DevWarning, type EaseSpec, type EasingFn, type Equals, type GainEnvelope, type HandoffKind, type Json, type Key, type KeyOpts, type Marker, type OkLab, type PathContour, type PathValue, type Playhead, type Position, PositionError, type ReadonlySignal, type RetargetSpring, type Rgba, type Rng, type SidecarDoc, SidecarVersionError, type Signal, type SignalOptions, type SpringConfig, type SpringEase, TARGET_PATH, type TargetCarrier, type Timeline, type TimelineBuilder, type TimelineInit, TimelineValidationError, type Track, TrackValidationError, type TweenOpts, type TweenTarget, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, type ValueType, type ValueTypeId, ValueTypeInferenceError, type Vec2, type Vec2Signal, WriteDuringEvaluationError, bake, bakeCheckpointed, beginReadPhase, bindTimeline, booleanType, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, inReadPhase, inferValueType, key, lerpColor, mergeSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, parseColor, pathType, random, registerValueType, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, signal, spring, springEasing, springEasingDerivative, springTo, stringType, timeline, track, untracked, validateTrack, vec2Equals, vec2Signal, vec2Type, velocityAt };
598
+ export { type AssetRef, type AudioClip, type BakeConfig, BakeError, type BindTarget, type BindableSignal, type BoundTimeline, type CheckpointedBakeConfig, type CheckpointedSim, type ChildEntry, CircularDependencyError, ColorParseError, type CompiledTimeline, type CurveSampler, DEFAULT_EASE, type DevWarning, type EaseSpec, type EasingFn, type Equals, type GainEnvelope, type HandoffKind, type Json, type Key, type KeyOpts, type Marker, type OkLab, type PathContour, type PathValue, type Playhead, type Position, PositionError, type ReadonlySignal, type RetargetSpring, type Rgba, type Rng, type SidecarDoc, SidecarVersionError, type Signal, type SignalOptions, type SpringConfig, type SpringEase, TARGET_PATH, type TargetCarrier, type Timeline, type TimelineBuilder, type TimelineInit, TimelineValidationError, type Track, TrackValidationError, type TweenOpts, type TweenTarget, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, type ValueType, type ValueTypeId, ValueTypeInferenceError, type Vec2, type Vec2Signal, WriteDuringEvaluationError, bake, bakeCheckpointed, beginReadPhase, bindTimeline, booleanType, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, inReadPhase, inferValueType, key, lerpColor, mergeSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, parseColor, pathType, random, registerValueType, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, signal, spring, springEasing, springEasingDerivative, springPresets, springTo, stagger, stringType, timeline, track, untracked, validateTrack, vec2Equals, vec2Signal, vec2Type, velocityAt };
package/dist/index.js CHANGED
@@ -803,6 +803,37 @@ const spring = Object.assign((cfg) => {
803
803
  retarget
804
804
  });
805
805
  /**
806
+ * Named spring feels (react-spring conventions, mass 1) — a vocabulary instead
807
+ * of hand-tuned stiffness/damping. Use `spring(springPresets.wobbly)` or
808
+ * `springTo(t, a, b, springPresets.gentle)`.
809
+ */
810
+ const springPresets = {
811
+ default: {
812
+ stiffness: 170,
813
+ damping: 26
814
+ },
815
+ gentle: {
816
+ stiffness: 120,
817
+ damping: 14
818
+ },
819
+ wobbly: {
820
+ stiffness: 180,
821
+ damping: 12
822
+ },
823
+ stiff: {
824
+ stiffness: 210,
825
+ damping: 20
826
+ },
827
+ slow: {
828
+ stiffness: 280,
829
+ damping: 60
830
+ },
831
+ molasses: {
832
+ stiffness: 280,
833
+ damping: 120
834
+ }
835
+ };
836
+ /**
806
837
  * The spring as a normalized easing over a segment whose length must equal
807
838
  * spring.duration(cfg) (validated at the document layer, §2.7).
808
839
  */
@@ -876,6 +907,28 @@ function springTo(endT, from, to, cfg) {
876
907
  if (endT - d < 0) throw new TrackValidationError("springTo", `this spring needs ${d.toFixed(3)}s to settle — endT must be ≥ its duration (got ${endT})`);
877
908
  return [key(endT - d, from), key(endT, to, spring(cfg))];
878
909
  }
910
+ /**
911
+ * Cascade a set of tracks by shifting each one's key times — the classic
912
+ * stagger for animating a list of nodes with a delay between them. `delay` is
913
+ * the per-index gap in seconds, or a function of the index for non-linear
914
+ * cascades. Pure: returns new tracks, leaving the inputs untouched.
915
+ *
916
+ * stagger(items.map((it, i) => track(`${it.id}/opacity`, 'number',
917
+ * [key(0, 0), key(0.3, 1, 'easeOutCubic')])), 0.08)
918
+ */
919
+ function stagger(tracks, delay) {
920
+ const at = typeof delay === "function" ? delay : (i) => i * delay;
921
+ return tracks.map((tr, i) => {
922
+ const d = at(i);
923
+ return {
924
+ ...tr,
925
+ keys: tr.keys.map((k) => ({
926
+ ...k,
927
+ t: k.t + d
928
+ }))
929
+ };
930
+ });
931
+ }
879
932
  function track(target, type, keys, opts) {
880
933
  const tr = {
881
934
  target,
@@ -1621,4 +1674,4 @@ function mergeSidecar(code, sidecar) {
1621
1674
  return merged;
1622
1675
  }
1623
1676
  //#endregion
1624
- export { BakeError, CircularDependencyError, ColorParseError, DEFAULT_EASE, PositionError, SidecarVersionError, TARGET_PATH, TimelineValidationError, TrackValidationError, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, ValueTypeInferenceError, WriteDuringEvaluationError, bake, bakeCheckpointed, beginReadPhase, bindTimeline, booleanType, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, inReadPhase, inferValueType, key, lerpColor, mergeSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, parseColor, pathType, random, registerValueType, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, signal, spring, springEasing, springEasingDerivative, springTo, stringType, timeline, track, untracked, validateTrack, vec2Equals, vec2Signal, vec2Type, velocityAt };
1677
+ export { BakeError, CircularDependencyError, ColorParseError, DEFAULT_EASE, PositionError, SidecarVersionError, TARGET_PATH, TimelineValidationError, TrackValidationError, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, ValueTypeInferenceError, WriteDuringEvaluationError, bake, bakeCheckpointed, beginReadPhase, bindTimeline, booleanType, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, cubicBezierDerivative, easingDerivatives, easings, emitDevWarning, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, inReadPhase, inferValueType, key, lerpColor, mergeSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, parseColor, pathType, random, registerValueType, resolveEase, resolveEaseDerivative, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, signal, spring, springEasing, springEasingDerivative, springPresets, springTo, stagger, stringType, timeline, track, untracked, validateTrack, vec2Equals, vec2Signal, vec2Type, velocityAt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/core",
3
- "version": "0.6.0-pre.0",
3
+ "version": "0.6.0-pre.1",
4
4
  "description": "glissade core: signals, tracks, timeline document, evaluation, easing, springs, seeded RNG. Zero DOM/Node dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",