Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add annotations for tree shaking #2199

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useInView.native.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useResize.native.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useScroll.native.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
10 changes: 5 additions & 5 deletions packages/parallax/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
config as configs,
} from '@react-spring/web'

const ParentContext = React.createContext<any>(null)
const ParentContext = /* @__PURE__ */ React.createContext<any>(null)

function getScrollType(horizontal: boolean) {
return horizontal ? 'scrollLeft' : 'scrollTop'
Expand Down Expand Up @@ -75,8 +75,8 @@ export interface ParallaxLayerProps extends ViewProps {
sticky?: StickyConfig
}

export const ParallaxLayer = React.memo(
React.forwardRef<IParallaxLayer, ParallaxLayerProps>(
export const ParallaxLayer = /* @__PURE__ */ React.memo(
/* @__PURE__ */ React.forwardRef<IParallaxLayer, ParallaxLayerProps>(
(
{ horizontal, factor = 1, offset = 0, speed = 0, sticky, ...rest },
ref
Expand Down Expand Up @@ -216,8 +216,8 @@ export interface ParallaxProps extends ViewProps {
children: React.ReactNode
}

export const Parallax = React.memo(
React.forwardRef<IParallax, ParallaxProps>((props, ref) => {
export const Parallax = /* @__PURE__ */ React.memo(
/* @__PURE__ */ React.forwardRef<IParallax, ParallaxProps>((props, ref) => {
const [ready, setReady] = useState(false)
const {
pages,
Expand Down
10 changes: 5 additions & 5 deletions packages/rafz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import type {

export type { FrameFn, FrameUpdateFn, Timeout, Throttled, Rafz }

let updateQueue = makeQueue<FrameUpdateFn>()
let updateQueue = /* @__PURE__ */ makeQueue<FrameUpdateFn>()

/**
* Schedule an update for next frame.
* Your function can return `true` to repeat next frame.
*/
export const raf: Rafz = fn => schedule(fn, updateQueue)

let writeQueue = makeQueue<FrameFn>()
let writeQueue = /* @__PURE__ */ makeQueue<FrameFn>()
raf.write = fn => schedule(fn, writeQueue)

let onStartQueue = makeQueue<FrameFn>()
let onStartQueue = /* @__PURE__ */ makeQueue<FrameFn>()
raf.onStart = fn => schedule(fn, onStartQueue)

let onFrameQueue = makeQueue<FrameFn>()
let onFrameQueue = /* @__PURE__ */ makeQueue<FrameFn>()
raf.onFrame = fn => schedule(fn, onFrameQueue)

let onFinishQueue = makeQueue<FrameFn>()
let onFinishQueue = /* @__PURE__ */ makeQueue<FrameFn>()
raf.onFinish = fn => schedule(fn, onFinishQueue)

let timeouts: Timeout[] = []
Expand Down
14 changes: 10 additions & 4 deletions packages/shared/src/colorMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/deprecations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const once = <TFunc extends (...args: any) => 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`
Expand Down
Loading