motion-dom 12.14.0 → 12.16.0

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.
@@ -0,0 +1,31 @@
1
+ const windowCallbacks = new Set();
2
+ let windowResizeHandler;
3
+ function createWindowResizeHandler() {
4
+ windowResizeHandler = () => {
5
+ const info = {
6
+ get width() {
7
+ return window.innerWidth;
8
+ },
9
+ get height() {
10
+ return window.innerHeight;
11
+ },
12
+ };
13
+ windowCallbacks.forEach((callback) => callback(info));
14
+ };
15
+ window.addEventListener("resize", windowResizeHandler);
16
+ }
17
+ function resizeWindow(callback) {
18
+ windowCallbacks.add(callback);
19
+ if (!windowResizeHandler)
20
+ createWindowResizeHandler();
21
+ return () => {
22
+ windowCallbacks.delete(callback);
23
+ if (!windowCallbacks.size &&
24
+ typeof windowResizeHandler === "function") {
25
+ window.removeEventListener("resize", windowResizeHandler);
26
+ windowResizeHandler = undefined;
27
+ }
28
+ };
29
+ }
30
+
31
+ export { resizeWindow };
@@ -0,0 +1,8 @@
1
+ import { resizeElement } from './handle-element.mjs';
2
+ import { resizeWindow } from './handle-window.mjs';
3
+
4
+ function resize(a, b) {
5
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
6
+ }
7
+
8
+ export { resize };
package/dist/index.d.ts CHANGED
@@ -1084,9 +1084,18 @@ declare class MotionValueState {
1084
1084
  destroy(): void;
1085
1085
  }
1086
1086
 
1087
+ declare const addAttrValue: (element: HTMLElement | SVGElement, state: MotionValueState, key: string, value: MotionValue) => () => void;
1088
+ declare const attrEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1089
+
1090
+ declare const propEffect: (subject: {
1091
+ [key: string]: any;
1092
+ }, values: Record<string, MotionValue<any>>) => VoidFunction;
1093
+
1087
1094
  declare const addStyleValue: (element: HTMLElement | SVGElement, state: MotionValueState, key: string, value: MotionValue) => () => void;
1088
1095
  declare const styleEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1089
1096
 
1097
+ declare const svgEffect: (subject: ElementOrSelector, values: Record<string, MotionValue<any>>) => () => void;
1098
+
1090
1099
  declare const frame: Batcher;
1091
1100
  declare const cancelFrame: (process: Process) => void;
1092
1101
  declare const frameData: FrameData;
@@ -1262,6 +1271,16 @@ declare const transformPropOrder: string[];
1262
1271
  */
1263
1272
  declare const transformProps: Set<string>;
1264
1273
 
1274
+ interface ResizeInfo {
1275
+ width: number;
1276
+ height: number;
1277
+ }
1278
+ type ResizeHandler<I> = (element: I, info: ResizeInfo) => void;
1279
+ type WindowResizeHandler = (info: ResizeInfo) => void;
1280
+
1281
+ declare function resize(onResize: WindowResizeHandler): VoidFunction;
1282
+ declare function resize(target: ElementOrSelector, onResize: ResizeHandler<Element>): VoidFunction;
1283
+
1265
1284
  type Update = (progress: number) => void;
1266
1285
  declare function observeTimeline(update: Update, timeline: ProgressTimeline): () => void;
1267
1286
 
@@ -1845,4 +1864,4 @@ declare const sync: Batcher;
1845
1864
  */
1846
1865
  declare const cancelSync: Record<string, (process: Process) => void>;
1847
1866
 
1848
- export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, type DecayOptions, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, type InactiveStatsBuffer, type InertiaOptions, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, type MapInputRange, type Mixer, type MixerFactory, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NumberMap, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RGBA, type RepeatType, type ResolvedKeyframes, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SingleTransformer, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformProperties, type Transformer, type Transition, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, acceleratedValues, activeAnimations, addStyleValue, alpha, analyseComplexValue, animateValue, animateView, animationMapKey, applyPxDefaults, attachSpring, calcGeneratorDuration, cancelFrame, cancelMicrotask, cancelSync, collectMotionValues, color, complex, convertOffsetToTimes, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, dimensionValueTypes, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultValueType, getMixer, getValueAsType, getValueTransition, getVariableValue, hex, hover, hsla, hslaToRgba, inertia, interpolate, invisibleValues, isCSSVariableName, isCSSVariableToken, isDragActive, isDragging, isGenerator, isHTMLElement, isMotionValue, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isWaapiSupportedEasing, keyframes, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixVisibility, motionValue, number, numberValueTypes, observeTimeline, parseCSSVariable, parseValueFromTransform, percent, positionalKeys, press, progressPercentage, px, readTransformValue, recordStats, resolveElements, rgbUnit, rgba, scale, setDragLock, setStyle, spring, springValue, startWaapiAnimation, statsBuffer, styleEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, sync, testValueType, time, transform, transformPropOrder, transformProps, transformValue, transformValueTypes, vh, vw };
1867
+ export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationGeneratorType, type AnimationOptions, type AnimationOptionsWithValueOverrides, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, type DecayOptions, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, type InactiveStatsBuffer, type InertiaOptions, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, type MapInputRange, type Mixer, type MixerFactory, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NumberMap, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PassiveEffect, type PointerEventOptions, type PressGestureInfo, type Process, type ProgressTimeline, type RGBA, type RepeatType, type ResolvedKeyframes, type ResolvedValueKeyframe, type SVGAttributes, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGTransitions, type Schedule, type SelectorCache, type SingleTransformer, type SpringOptions, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type Target, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformProperties, type Transformer, type Transition, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type WithQuerySelectorAll, acceleratedValues, activeAnimations, addAttrValue, addStyleValue, alpha, analyseComplexValue, animateValue, animateView, animationMapKey, applyPxDefaults, attachSpring, attrEffect, calcGeneratorDuration, cancelFrame, cancelMicrotask, cancelSync, collectMotionValues, color, complex, convertOffsetToTimes, createGeneratorEasing, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, dimensionValueTypes, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultValueType, getMixer, getValueAsType, getValueTransition, getVariableValue, hex, hover, hsla, hslaToRgba, inertia, interpolate, invisibleValues, isCSSVariableName, isCSSVariableToken, isDragActive, isDragging, isGenerator, isHTMLElement, isMotionValue, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isWaapiSupportedEasing, keyframes, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixVisibility, motionValue, number, numberValueTypes, observeTimeline, parseCSSVariable, parseValueFromTransform, percent, positionalKeys, press, progressPercentage, propEffect, px, readTransformValue, recordStats, resize, resolveElements, rgbUnit, rgba, scale, setDragLock, setStyle, spring, springValue, startWaapiAnimation, statsBuffer, styleEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, svgEffect, sync, testValueType, time, transform, transformPropOrder, transformProps, transformValue, transformValueTypes, vh, vw };
@@ -3049,6 +3049,152 @@
3049
3049
  // "background-color"
3050
3050
  ]);
3051
3051
 
3052
+ function camelToDash(str) {
3053
+ return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
3054
+ }
3055
+
3056
+ function resolveElements(elementOrSelector, scope, selectorCache) {
3057
+ if (elementOrSelector instanceof EventTarget) {
3058
+ return [elementOrSelector];
3059
+ }
3060
+ else if (typeof elementOrSelector === "string") {
3061
+ let root = document;
3062
+ if (scope) {
3063
+ root = scope.current;
3064
+ }
3065
+ const elements = selectorCache?.[elementOrSelector] ??
3066
+ root.querySelectorAll(elementOrSelector);
3067
+ return elements ? Array.from(elements) : [];
3068
+ }
3069
+ return Array.from(elementOrSelector);
3070
+ }
3071
+
3072
+ function createSelectorEffect(subjectEffect) {
3073
+ return (subject, values) => {
3074
+ const elements = resolveElements(subject);
3075
+ const subscriptions = [];
3076
+ for (const element of elements) {
3077
+ const remove = subjectEffect(element, values);
3078
+ subscriptions.push(remove);
3079
+ }
3080
+ return () => {
3081
+ for (const remove of subscriptions)
3082
+ remove();
3083
+ };
3084
+ };
3085
+ }
3086
+
3087
+ /**
3088
+ * Provided a value and a ValueType, returns the value as that value type.
3089
+ */
3090
+ const getValueAsType = (value, type) => {
3091
+ return type && typeof value === "number"
3092
+ ? type.transform(value)
3093
+ : value;
3094
+ };
3095
+
3096
+ class MotionValueState {
3097
+ constructor() {
3098
+ this.latest = {};
3099
+ this.values = new Map();
3100
+ }
3101
+ set(name, value, render, computed, useDefaultValueType = true) {
3102
+ const existingValue = this.values.get(name);
3103
+ if (existingValue) {
3104
+ existingValue.onRemove();
3105
+ }
3106
+ const onChange = () => {
3107
+ const v = value.get();
3108
+ if (useDefaultValueType) {
3109
+ this.latest[name] = getValueAsType(v, numberValueTypes[name]);
3110
+ }
3111
+ else {
3112
+ this.latest[name] = v;
3113
+ }
3114
+ render && frame.render(render);
3115
+ };
3116
+ onChange();
3117
+ const cancelOnChange = value.on("change", onChange);
3118
+ computed && value.addDependent(computed);
3119
+ const remove = () => {
3120
+ cancelOnChange();
3121
+ render && cancelFrame(render);
3122
+ this.values.delete(name);
3123
+ computed && value.removeDependent(computed);
3124
+ };
3125
+ this.values.set(name, { value, onRemove: remove });
3126
+ return remove;
3127
+ }
3128
+ get(name) {
3129
+ return this.values.get(name)?.value;
3130
+ }
3131
+ destroy() {
3132
+ for (const value of this.values.values()) {
3133
+ value.onRemove();
3134
+ }
3135
+ }
3136
+ }
3137
+
3138
+ function createEffect(addValue) {
3139
+ const stateCache = new WeakMap();
3140
+ const subscriptions = [];
3141
+ return (subject, values) => {
3142
+ const state = stateCache.get(subject) ?? new MotionValueState();
3143
+ stateCache.set(subject, state);
3144
+ for (const key in values) {
3145
+ const value = values[key];
3146
+ const remove = addValue(subject, state, key, value);
3147
+ subscriptions.push(remove);
3148
+ }
3149
+ return () => {
3150
+ for (const cancel of subscriptions)
3151
+ cancel();
3152
+ };
3153
+ };
3154
+ }
3155
+
3156
+ function canSetAsProperty(element, name) {
3157
+ if (!(name in element))
3158
+ return false;
3159
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), name) ||
3160
+ Object.getOwnPropertyDescriptor(element, name);
3161
+ // Check if it has a setter
3162
+ return descriptor && typeof descriptor.set === "function";
3163
+ }
3164
+ const addAttrValue = (element, state, key, value) => {
3165
+ const isProp = canSetAsProperty(element, key);
3166
+ const name = isProp
3167
+ ? key
3168
+ : key.startsWith("data") || key.startsWith("aria")
3169
+ ? camelToDash(key)
3170
+ : key;
3171
+ /**
3172
+ * Set attribute directly via property if available
3173
+ */
3174
+ const render = isProp
3175
+ ? () => {
3176
+ element[name] = state.latest[key];
3177
+ }
3178
+ : () => {
3179
+ const v = state.latest[key];
3180
+ if (v === null || v === undefined) {
3181
+ element.removeAttribute(name);
3182
+ }
3183
+ else {
3184
+ element.setAttribute(name, String(v));
3185
+ }
3186
+ };
3187
+ return state.set(key, value, render);
3188
+ };
3189
+ const attrEffect = /*@__PURE__*/ createSelectorEffect(
3190
+ /*@__PURE__*/ createEffect(addAttrValue));
3191
+
3192
+ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
3193
+ return state.set(key, value, () => {
3194
+ subject[key] = state.latest[key];
3195
+ }, undefined, false);
3196
+ });
3197
+
3052
3198
  /**
3053
3199
  * Maximum time between the value of two frames, beyond which we
3054
3200
  * assume the velocity has since been 0.
@@ -3371,106 +3517,6 @@
3371
3517
  return new MotionValue(init, options);
3372
3518
  }
3373
3519
 
3374
- function resolveElements(elementOrSelector, scope, selectorCache) {
3375
- if (elementOrSelector instanceof EventTarget) {
3376
- return [elementOrSelector];
3377
- }
3378
- else if (typeof elementOrSelector === "string") {
3379
- let root = document;
3380
- if (scope) {
3381
- root = scope.current;
3382
- }
3383
- const elements = selectorCache?.[elementOrSelector] ??
3384
- root.querySelectorAll(elementOrSelector);
3385
- return elements ? Array.from(elements) : [];
3386
- }
3387
- return Array.from(elementOrSelector);
3388
- }
3389
-
3390
- function createSelectorEffect(subjectEffect) {
3391
- return (subject, values) => {
3392
- const elements = resolveElements(subject);
3393
- const subscriptions = [];
3394
- for (const element of elements) {
3395
- const remove = subjectEffect(element, values);
3396
- subscriptions.push(remove);
3397
- }
3398
- return () => {
3399
- for (const remove of subscriptions)
3400
- remove();
3401
- };
3402
- };
3403
- }
3404
-
3405
- /**
3406
- * Provided a value and a ValueType, returns the value as that value type.
3407
- */
3408
- const getValueAsType = (value, type) => {
3409
- return type && typeof value === "number"
3410
- ? type.transform(value)
3411
- : value;
3412
- };
3413
-
3414
- class MotionValueState {
3415
- constructor() {
3416
- this.latest = {};
3417
- this.values = new Map();
3418
- }
3419
- set(name, value, render, computed, useDefaultValueType = true) {
3420
- const existingValue = this.values.get(name);
3421
- if (existingValue) {
3422
- existingValue.onRemove();
3423
- }
3424
- const onChange = () => {
3425
- const v = value.get();
3426
- if (useDefaultValueType) {
3427
- this.latest[name] = getValueAsType(v, numberValueTypes[name]);
3428
- }
3429
- else {
3430
- this.latest[name] = v;
3431
- }
3432
- render && frame.render(render);
3433
- };
3434
- onChange();
3435
- const cancelOnChange = value.on("change", onChange);
3436
- computed && value.addDependent(computed);
3437
- const remove = () => {
3438
- cancelOnChange();
3439
- render && cancelFrame(render);
3440
- this.values.delete(name);
3441
- computed && value.removeDependent(computed);
3442
- };
3443
- this.values.set(name, { value, onRemove: remove });
3444
- return remove;
3445
- }
3446
- get(name) {
3447
- return this.values.get(name)?.value;
3448
- }
3449
- destroy() {
3450
- for (const value of this.values.values()) {
3451
- value.onRemove();
3452
- }
3453
- }
3454
- }
3455
-
3456
- function createEffect(addValue) {
3457
- const stateCache = new WeakMap();
3458
- const subscriptions = [];
3459
- return (subject, values) => {
3460
- const state = stateCache.get(subject) ?? new MotionValueState();
3461
- stateCache.set(subject, state);
3462
- for (const key in values) {
3463
- const value = values[key];
3464
- const remove = addValue(subject, state, key, value);
3465
- subscriptions.push(remove);
3466
- }
3467
- return () => {
3468
- for (const cancel of subscriptions)
3469
- cancel();
3470
- };
3471
- };
3472
- }
3473
-
3474
3520
  const translateAlias = {
3475
3521
  x: "translateX",
3476
3522
  y: "translateY",
@@ -3512,6 +3558,11 @@
3512
3558
  let computed = undefined;
3513
3559
  if (transformProps.has(key)) {
3514
3560
  if (!state.get("transform")) {
3561
+ // If this is an HTML element, we need to set the transform-box to fill-box
3562
+ // to normalise the transform relative to the element's bounding box
3563
+ if (!isHTMLElement(element) && !state.get("transformBox")) {
3564
+ addStyleValue(element, state, "transformBox", new MotionValue("fill-box"));
3565
+ }
3515
3566
  state.set("transform", new MotionValue("none"), () => {
3516
3567
  element.style.transform = buildTransform(state);
3517
3568
  });
@@ -3544,6 +3595,38 @@
3544
3595
  const styleEffect = /*@__PURE__*/ createSelectorEffect(
3545
3596
  /*@__PURE__*/ createEffect(addStyleValue));
3546
3597
 
3598
+ const toPx = px.transform;
3599
+ function addSVGPathValue(element, state, key, value) {
3600
+ frame.render(() => element.setAttribute("pathLength", "1"));
3601
+ if (key === "pathOffset") {
3602
+ return state.set(key, value, () => element.setAttribute("stroke-dashoffset", toPx(-state.latest[key])));
3603
+ }
3604
+ else {
3605
+ if (!state.get("stroke-dasharray")) {
3606
+ state.set("stroke-dasharray", new MotionValue("1 1"), () => {
3607
+ const { pathLength = 1, pathSpacing } = state.latest;
3608
+ element.setAttribute("stroke-dasharray", `${toPx(pathLength)} ${toPx(pathSpacing ?? 1 - Number(pathLength))}`);
3609
+ });
3610
+ }
3611
+ return state.set(key, value, undefined, state.get("stroke-dasharray"));
3612
+ }
3613
+ }
3614
+ const addSVGValue = (element, state, key, value) => {
3615
+ if (key.startsWith("path")) {
3616
+ return addSVGPathValue(element, state, key, value);
3617
+ }
3618
+ else if (key.startsWith("attr")) {
3619
+ return addAttrValue(element, state, convertAttrKey(key), value);
3620
+ }
3621
+ const handler = key in element.style ? addStyleValue : addAttrValue;
3622
+ return handler(element, state, key, value);
3623
+ };
3624
+ const svgEffect = /*@__PURE__*/ createSelectorEffect(
3625
+ /*@__PURE__*/ createEffect(addSVGValue));
3626
+ function convertAttrKey(key) {
3627
+ return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());
3628
+ }
3629
+
3547
3630
  const { schedule: microtask, cancel: cancelMicrotask } =
3548
3631
  /* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
3549
3632
 
@@ -3790,6 +3873,107 @@
3790
3873
  : computedStyle[name];
3791
3874
  }
3792
3875
 
3876
+ /**
3877
+ * Checks if an element is an SVG element in a way
3878
+ * that works across iframes
3879
+ */
3880
+ function isSVGElement(element) {
3881
+ return motionUtils.isObject(element) && "ownerSVGElement" in element;
3882
+ }
3883
+
3884
+ const resizeHandlers = new WeakMap();
3885
+ let observer;
3886
+ const getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
3887
+ if (borderBoxSize && borderBoxSize[0]) {
3888
+ return borderBoxSize[0][(borderBoxAxis + "Size")];
3889
+ }
3890
+ else if (isSVGElement(target) && "getBBox" in target) {
3891
+ return target.getBBox()[svgAxis];
3892
+ }
3893
+ else {
3894
+ return target[htmlAxis];
3895
+ }
3896
+ };
3897
+ const getWidth = /*@__PURE__*/ getSize("inline", "width", "offsetWidth");
3898
+ const getHeight = /*@__PURE__*/ getSize("block", "height", "offsetHeight");
3899
+ function notifyTarget({ target, borderBoxSize }) {
3900
+ resizeHandlers.get(target)?.forEach((handler) => {
3901
+ handler(target, {
3902
+ get width() {
3903
+ return getWidth(target, borderBoxSize);
3904
+ },
3905
+ get height() {
3906
+ return getHeight(target, borderBoxSize);
3907
+ },
3908
+ });
3909
+ });
3910
+ }
3911
+ function notifyAll(entries) {
3912
+ entries.forEach(notifyTarget);
3913
+ }
3914
+ function createResizeObserver() {
3915
+ if (typeof ResizeObserver === "undefined")
3916
+ return;
3917
+ observer = new ResizeObserver(notifyAll);
3918
+ }
3919
+ function resizeElement(target, handler) {
3920
+ if (!observer)
3921
+ createResizeObserver();
3922
+ const elements = resolveElements(target);
3923
+ elements.forEach((element) => {
3924
+ let elementHandlers = resizeHandlers.get(element);
3925
+ if (!elementHandlers) {
3926
+ elementHandlers = new Set();
3927
+ resizeHandlers.set(element, elementHandlers);
3928
+ }
3929
+ elementHandlers.add(handler);
3930
+ observer?.observe(element);
3931
+ });
3932
+ return () => {
3933
+ elements.forEach((element) => {
3934
+ const elementHandlers = resizeHandlers.get(element);
3935
+ elementHandlers?.delete(handler);
3936
+ if (!elementHandlers?.size) {
3937
+ observer?.unobserve(element);
3938
+ }
3939
+ });
3940
+ };
3941
+ }
3942
+
3943
+ const windowCallbacks = new Set();
3944
+ let windowResizeHandler;
3945
+ function createWindowResizeHandler() {
3946
+ windowResizeHandler = () => {
3947
+ const info = {
3948
+ get width() {
3949
+ return window.innerWidth;
3950
+ },
3951
+ get height() {
3952
+ return window.innerHeight;
3953
+ },
3954
+ };
3955
+ windowCallbacks.forEach((callback) => callback(info));
3956
+ };
3957
+ window.addEventListener("resize", windowResizeHandler);
3958
+ }
3959
+ function resizeWindow(callback) {
3960
+ windowCallbacks.add(callback);
3961
+ if (!windowResizeHandler)
3962
+ createWindowResizeHandler();
3963
+ return () => {
3964
+ windowCallbacks.delete(callback);
3965
+ if (!windowCallbacks.size &&
3966
+ typeof windowResizeHandler === "function") {
3967
+ window.removeEventListener("resize", windowResizeHandler);
3968
+ windowResizeHandler = undefined;
3969
+ }
3970
+ };
3971
+ }
3972
+
3973
+ function resize(a, b) {
3974
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
3975
+ }
3976
+
3793
3977
  function observeTimeline(update, timeline) {
3794
3978
  let prevProgress;
3795
3979
  const onFrame = () => {
@@ -3917,14 +4101,6 @@
3917
4101
  return reportStats;
3918
4102
  }
3919
4103
 
3920
- /**
3921
- * Checks if an element is an SVG element in a way
3922
- * that works across iframes
3923
- */
3924
- function isSVGElement(element) {
3925
- return motionUtils.isObject(element) && "ownerSVGElement" in element;
3926
- }
3927
-
3928
4104
  /**
3929
4105
  * Checks if an element is specifically an SVGSVGElement (the root SVG element)
3930
4106
  * in a way that works across iframes
@@ -4444,6 +4620,7 @@
4444
4620
  exports.ViewTransitionBuilder = ViewTransitionBuilder;
4445
4621
  exports.acceleratedValues = acceleratedValues;
4446
4622
  exports.activeAnimations = activeAnimations;
4623
+ exports.addAttrValue = addAttrValue;
4447
4624
  exports.addStyleValue = addStyleValue;
4448
4625
  exports.alpha = alpha;
4449
4626
  exports.analyseComplexValue = analyseComplexValue;
@@ -4452,6 +4629,7 @@
4452
4629
  exports.animationMapKey = animationMapKey;
4453
4630
  exports.applyPxDefaults = applyPxDefaults;
4454
4631
  exports.attachSpring = attachSpring;
4632
+ exports.attrEffect = attrEffect;
4455
4633
  exports.calcGeneratorDuration = calcGeneratorDuration;
4456
4634
  exports.cancelFrame = cancelFrame;
4457
4635
  exports.cancelMicrotask = cancelMicrotask;
@@ -4529,9 +4707,11 @@
4529
4707
  exports.positionalKeys = positionalKeys;
4530
4708
  exports.press = press;
4531
4709
  exports.progressPercentage = progressPercentage;
4710
+ exports.propEffect = propEffect;
4532
4711
  exports.px = px;
4533
4712
  exports.readTransformValue = readTransformValue;
4534
4713
  exports.recordStats = recordStats;
4714
+ exports.resize = resize;
4535
4715
  exports.resolveElements = resolveElements;
4536
4716
  exports.rgbUnit = rgbUnit;
4537
4717
  exports.rgba = rgba;
@@ -4549,6 +4729,7 @@
4549
4729
  exports.supportsLinearEasing = supportsLinearEasing;
4550
4730
  exports.supportsPartialKeyframes = supportsPartialKeyframes;
4551
4731
  exports.supportsScrollTimeline = supportsScrollTimeline;
4732
+ exports.svgEffect = svgEffect;
4552
4733
  exports.sync = sync;
4553
4734
  exports.testValueType = testValueType;
4554
4735
  exports.time = time;