Socket
Socket
Sign inDemoInstall

@react-spring/shared

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-spring/shared - npm Package Compare versions

Comparing version 9.7.3 to 9.7.4

198

dist/react-spring_shared.legacy-esm.js

@@ -17,161 +17,4 @@ var __defProp = Object.defineProperty;

});
import { raf } from "@react-spring/rafz";
// ../rafz/dist/react-spring_rafz.modern.mjs
var updateQueue = makeQueue();
var raf = (fn) => schedule(fn, updateQueue);
var writeQueue = makeQueue();
raf.write = (fn) => schedule(fn, writeQueue);
var onStartQueue = makeQueue();
raf.onStart = (fn) => schedule(fn, onStartQueue);
var onFrameQueue = makeQueue();
raf.onFrame = (fn) => schedule(fn, onFrameQueue);
var onFinishQueue = makeQueue();
raf.onFinish = (fn) => schedule(fn, onFinishQueue);
var timeouts = [];
raf.setTimeout = (handler, ms) => {
const time = raf.now() + ms;
const cancel = () => {
const i = timeouts.findIndex((t) => t.cancel == cancel);
if (~i)
timeouts.splice(i, 1);
pendingCount -= ~i ? 1 : 0;
};
const timeout = { time, handler, cancel };
timeouts.splice(findTimeout(time), 0, timeout);
pendingCount += 1;
start();
return timeout;
};
var findTimeout = (time) => ~(~timeouts.findIndex((t) => t.time > time) || ~timeouts.length);
raf.cancel = (fn) => {
onStartQueue.delete(fn);
onFrameQueue.delete(fn);
onFinishQueue.delete(fn);
updateQueue.delete(fn);
writeQueue.delete(fn);
};
raf.sync = (fn) => {
sync = true;
raf.batchedUpdates(fn);
sync = false;
};
raf.throttle = (fn) => {
let lastArgs;
function queuedFn() {
try {
fn(...lastArgs);
} finally {
lastArgs = null;
}
}
function throttled(...args) {
lastArgs = args;
raf.onStart(queuedFn);
}
throttled.handler = fn;
throttled.cancel = () => {
onStartQueue.delete(queuedFn);
lastArgs = null;
};
return throttled;
};
var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : (
// eslint-disable-next-line @typescript-eslint/no-empty-function
() => {
}
);
raf.use = (impl) => nativeRaf = impl;
raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now;
raf.batchedUpdates = (fn) => fn();
raf.catch = console.error;
raf.frameLoop = "always";
raf.advance = () => {
if (raf.frameLoop !== "demand") {
console.warn(
"Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"
);
} else {
update();
}
};
var ts = -1;
var pendingCount = 0;
var sync = false;
function schedule(fn, queue) {
if (sync) {
queue.delete(fn);
fn(0);
} else {
queue.add(fn);
start();
}
}
function start() {
if (ts < 0) {
ts = 0;
if (raf.frameLoop !== "demand") {
nativeRaf(loop);
}
}
}
function stop() {
ts = -1;
}
function loop() {
if (~ts) {
nativeRaf(loop);
raf.batchedUpdates(update);
}
}
function update() {
const prevTs = ts;
ts = raf.now();
const count = findTimeout(ts);
if (count) {
eachSafely(timeouts.splice(0, count), (t) => t.handler());
pendingCount -= count;
}
if (!pendingCount) {
stop();
return;
}
onStartQueue.flush();
updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667);
onFrameQueue.flush();
writeQueue.flush();
onFinishQueue.flush();
}
function makeQueue() {
let next = /* @__PURE__ */ new Set();
let current = next;
return {
add(fn) {
pendingCount += current == next && !next.has(fn) ? 1 : 0;
next.add(fn);
},
delete(fn) {
pendingCount -= current == next && next.has(fn) ? 1 : 0;
return next.delete(fn);
},
flush(arg) {
if (current.size) {
next = /* @__PURE__ */ new Set();
pendingCount -= current.size;
eachSafely(current, (fn) => fn(arg) && next.add(fn));
pendingCount += next.size;
current = next;
}
}
};
}
function eachSafely(values, each2) {
values.forEach((value) => {
try {
each2(value);
} catch (e) {
raf.catch(e);
}
});
}
// src/helpers.ts

@@ -254,2 +97,3 @@ function noop() {

// src/FrameLoop.ts
import { raf as raf2 } from "@react-spring/rafz";
var startQueue = /* @__PURE__ */ new Set();

@@ -267,6 +111,6 @@ var currentFrame = [];

startQueue.add(animation);
raf.onStart(flushStartQueue);
raf2.onStart(flushStartQueue);
} else {
startSafely(animation);
raf(advance);
raf2(advance);
}

@@ -279,3 +123,3 @@ },

if (priority) {
raf.onFrame(() => frameLoop.sort(animation));
raf2.onFrame(() => frameLoop.sort(animation));
} else {

@@ -302,3 +146,3 @@ const prevIndex = currentFrame.indexOf(animation);

startQueue.clear();
raf(advance);
raf2(advance);
}

@@ -959,2 +803,5 @@ function startSafely(animation) {

// src/dom-events/scroll/index.ts
import { raf as raf3 } from "@react-spring/rafz";
// src/dom-events/resize/resizeElement.ts

@@ -1057,3 +904,3 @@ var observer;

axis.current = this.container[`scroll${position}`];
axis.scrollLength = this.container["scroll" + length] - this.container["client" + length];
axis.scrollLength = this.container[`scroll${length}`] - this.container[`client${length}`];
axis.progress = progress(0, axis.scrollLength, axis.current);

@@ -1109,5 +956,5 @@ };

const animateScroll = scrollListeners.get(container);
raf(animateScroll);
raf3(animateScroll);
return () => {
raf.cancel(animateScroll);
raf3.cancel(animateScroll);
const containerHandlers2 = onScrollHandlers.get(container);

@@ -1163,7 +1010,7 @@ if (!containerHandlers2)

function useForceUpdate() {
const update2 = useState()[1];
const update = useState()[1];
const isMounted = useIsMounted();
return () => {
if (isMounted.current) {
update2(Math.random());
update(Math.random());
}

@@ -1246,5 +1093,13 @@ };

handleMediaChange(mql);
mql.addEventListener("change", handleMediaChange);
if (mql.addEventListener) {
mql.addEventListener("change", handleMediaChange);
} else {
mql.addListener(handleMediaChange);
}
return () => {
mql.removeEventListener("change", handleMediaChange);
if (mql.removeEventListener) {
mql.removeEventListener("change", handleMediaChange);
} else {
mql.removeListener(handleMediaChange);
}
};

@@ -1254,2 +1109,5 @@ }, []);

};
// src/index.ts
import { raf as raf4 } from "@react-spring/rafz";
export {

@@ -1293,3 +1151,3 @@ FluidValue,

prefix,
raf,
raf4 as raf,
removeFluidObserver,

@@ -1296,0 +1154,0 @@ rgb,

6

dist/react-spring_shared.modern.d.ts
import { raf, Rafz } from '@react-spring/rafz';
export { Timeout, raf } from '@react-spring/rafz';
import { InterpolatorConfig, OneOrMore, InterpolatorArgs, InterpolatorFactory, EasingFunction, Lookup, AnyFn, Any } from '@react-spring/types';
import { InterpolatorConfig, OneOrMore, InterpolatorArgs, InterpolatorFactory, EasingFunction, Lookup, Arrify, AnyFn, Any } from '@react-spring/types';
import { EffectCallback, useEffect } from 'react';

@@ -416,3 +416,3 @@

declare function eachProp<T extends object, This>(obj: T, fn: (this: This, value: T extends any[] ? T[number] : T[keyof T], key: string) => void, ctx?: This): void;
declare const toArray: <T>(a: T) => Exclude<T, void> extends infer T_1 ? T_1 extends Exclude<T, void> ? T_1 extends readonly any[] ? T_1[number][] extends T_1 ? readonly (Exclude<T, void> extends infer T_2 ? T_2 extends Exclude<T, void> ? T_2 extends readonly (infer U)[] ? U : T_2 : never : never)[] : T_1 : readonly (Exclude<T, void> extends infer T_3 ? T_3 extends Exclude<T, void> ? T_3 extends readonly (infer U_1)[] ? U_1 : T_3 : never : never)[] : never : never;
declare const toArray: <T>(a: T) => Arrify<Exclude<T, void>>;
/** Copy the `queue`, then iterate it after the `queue` is cleared */

@@ -422,3 +422,3 @@ declare function flush<P, T>(queue: Map<P, T>, iterator: (entry: [P, T]) => void): void;

/** Call every function in the queue with the same arguments. */
declare const flushCalls: <T extends AnyFn<any[], any>>(queue: Set<T>, ...args: Parameters<T>) => void;
declare const flushCalls: <T extends AnyFn>(queue: Set<T>, ...args: Parameters<T>) => void;
declare const isSSR: () => boolean;

@@ -425,0 +425,0 @@

{
"name": "@react-spring/shared",
"version": "9.7.3",
"version": "9.7.4",
"description": "Globals and shared modules",

@@ -40,3 +40,4 @@ "module": "./dist/react-spring_shared.legacy-esm.js",

"dependencies": {
"@react-spring/types": "~9.7.3"
"@react-spring/rafz": "~9.7.4",
"@react-spring/types": "~9.7.4"
},

@@ -43,0 +44,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc