From 2f43f09a8b0305c97790d1d41a6aca27479e5a66 Mon Sep 17 00:00:00 2001 From: Cody Bennett <23324155+CodyJasonBennett@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:58:39 -0500 Subject: [PATCH] fix: add annotations for tree shaking --- packages/core/src/hooks/useInView.native.ts | 2 +- packages/core/src/hooks/useResize.native.ts | 2 +- packages/core/src/hooks/useScroll.native.ts | 2 +- packages/parallax/src/index.tsx | 10 +++++----- packages/rafz/src/index.ts | 10 +++++----- packages/shared/src/colorMatchers.ts | 14 ++++++++++---- packages/shared/src/deprecations.ts | 4 ++-- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/core/src/hooks/useInView.native.ts b/packages/core/src/hooks/useInView.native.ts index 37132b4982..6d2e08e2a4 100644 --- a/packages/core/src/hooks/useInView.native.ts +++ b/packages/core/src/hooks/useInView.native.ts @@ -1,6 +1,6 @@ import { once, prefix } from '@react-spring/shared' -const warnImplementation = once(console.warn) +const warnImplementation = /* @__PURE__ */ once(console.warn) export const useInView = () => { warnImplementation( diff --git a/packages/core/src/hooks/useResize.native.ts b/packages/core/src/hooks/useResize.native.ts index 2baae3cdee..506db65a0e 100644 --- a/packages/core/src/hooks/useResize.native.ts +++ b/packages/core/src/hooks/useResize.native.ts @@ -1,6 +1,6 @@ import { once, prefix } from '@react-spring/shared' -const warnImplementation = once(console.warn) +const warnImplementation = /* @__PURE__ */ once(console.warn) export const useResize = () => { warnImplementation( diff --git a/packages/core/src/hooks/useScroll.native.ts b/packages/core/src/hooks/useScroll.native.ts index de25811591..9f6aca652a 100644 --- a/packages/core/src/hooks/useScroll.native.ts +++ b/packages/core/src/hooks/useScroll.native.ts @@ -1,6 +1,6 @@ import { once, prefix } from '@react-spring/shared' -const warnImplementation = once(console.warn) +const warnImplementation = /* @__PURE__ */ once(console.warn) export const useScroll = () => { warnImplementation( diff --git a/packages/parallax/src/index.tsx b/packages/parallax/src/index.tsx index 74e05932a5..d84056c615 100644 --- a/packages/parallax/src/index.tsx +++ b/packages/parallax/src/index.tsx @@ -8,7 +8,7 @@ import { config as configs, } from '@react-spring/web' -const ParentContext = React.createContext(null) +const ParentContext = /* @__PURE__ */ React.createContext(null) function getScrollType(horizontal: boolean) { return horizontal ? 'scrollLeft' : 'scrollTop' @@ -75,8 +75,8 @@ export interface ParallaxLayerProps extends ViewProps { sticky?: StickyConfig } -export const ParallaxLayer = React.memo( - React.forwardRef( +export const ParallaxLayer = /* @__PURE__ */ React.memo( + /* @__PURE__ */ React.forwardRef( ( { horizontal, factor = 1, offset = 0, speed = 0, sticky, ...rest }, ref @@ -216,8 +216,8 @@ export interface ParallaxProps extends ViewProps { children: React.ReactNode } -export const Parallax = React.memo( - React.forwardRef((props, ref) => { +export const Parallax = /* @__PURE__ */ React.memo( + /* @__PURE__ */ React.forwardRef((props, ref) => { const [ready, setReady] = useState(false) const { pages, diff --git a/packages/rafz/src/index.ts b/packages/rafz/src/index.ts index 42032e007d..a025bb3a38 100644 --- a/packages/rafz/src/index.ts +++ b/packages/rafz/src/index.ts @@ -9,7 +9,7 @@ import type { export type { FrameFn, FrameUpdateFn, Timeout, Throttled, Rafz } -let updateQueue = makeQueue() +let updateQueue = /* @__PURE__ */ makeQueue() /** * Schedule an update for next frame. @@ -17,16 +17,16 @@ let updateQueue = makeQueue() */ export const raf: Rafz = fn => schedule(fn, updateQueue) -let writeQueue = makeQueue() +let writeQueue = /* @__PURE__ */ makeQueue() raf.write = fn => schedule(fn, writeQueue) -let onStartQueue = makeQueue() +let onStartQueue = /* @__PURE__ */ makeQueue() raf.onStart = fn => schedule(fn, onStartQueue) -let onFrameQueue = makeQueue() +let onFrameQueue = /* @__PURE__ */ makeQueue() raf.onFrame = fn => schedule(fn, onFrameQueue) -let onFinishQueue = makeQueue() +let onFinishQueue = /* @__PURE__ */ makeQueue() raf.onFinish = fn => schedule(fn, onFinishQueue) let timeouts: Timeout[] = [] diff --git a/packages/shared/src/colorMatchers.ts b/packages/shared/src/colorMatchers.ts index 21f12de5d1..8e981b399e 100644 --- a/packages/shared/src/colorMatchers.ts +++ b/packages/shared/src/colorMatchers.ts @@ -6,11 +6,17 @@ function call(...parts: string[]) { return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)' } -export const rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)) -export const rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)) -export const hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)) +export const rgb = new RegExp( + 'rgb' + /* @__PURE__ */ call(NUMBER, NUMBER, NUMBER) +) +export const rgba = new RegExp( + 'rgba' + /* @__PURE__ */ call(NUMBER, NUMBER, NUMBER, NUMBER) +) +export const hsl = new RegExp( + 'hsl' + /* @__PURE__ */ call(NUMBER, PERCENTAGE, PERCENTAGE) +) export const hsla = new RegExp( - 'hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) + 'hsla' + /* @__PURE__ */ call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER) ) export const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/ export const hex4 = diff --git a/packages/shared/src/deprecations.ts b/packages/shared/src/deprecations.ts index e98479c552..0fb04cd03a 100644 --- a/packages/shared/src/deprecations.ts +++ b/packages/shared/src/deprecations.ts @@ -18,14 +18,14 @@ export const once = any>(fn: TFunc) => { } } -const warnInterpolate = once(console.warn) +const warnInterpolate = /* @__PURE__ */ once(console.warn) export function deprecateInterpolate() { warnInterpolate( `${prefix}The "interpolate" function is deprecated in v9 (use "to" instead)` ) } -const warnDirectCall = once(console.warn) +const warnDirectCall = /* @__PURE__ */ once(console.warn) export function deprecateDirectCall() { warnDirectCall( `${prefix}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`