@rootnative/web 0.0.0-alpha.5 → 0.0.0-alpha.6

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/_virtual/_rolldown/runtime.js +12 -0
  3. package/dist/apis/Animated/AnimatedEvent.d.ts +19 -0
  4. package/dist/apis/Animated/AnimatedEvent.js +52 -0
  5. package/dist/apis/Animated/AnimatedEvent.js.map +1 -0
  6. package/dist/apis/Animated/AnimatedExports.d.ts +20 -0
  7. package/dist/apis/Animated/AnimatedExports.js +32 -0
  8. package/dist/apis/Animated/AnimatedExports.js.map +1 -0
  9. package/dist/apis/Animated/AnimatedImplementation.d.ts +18 -0
  10. package/dist/apis/Animated/AnimatedImplementation.js +79 -0
  11. package/dist/apis/Animated/AnimatedImplementation.js.map +1 -0
  12. package/dist/apis/Animated/animations/Animation.d.ts +29 -0
  13. package/dist/apis/Animated/animations/Animation.js +31 -0
  14. package/dist/apis/Animated/animations/Animation.js.map +1 -0
  15. package/dist/apis/Animated/animations/SpringAnimation.d.ts +17 -0
  16. package/dist/apis/Animated/animations/SpringAnimation.js +132 -0
  17. package/dist/apis/Animated/animations/SpringAnimation.js.map +1 -0
  18. package/dist/apis/Animated/animations/TimingAnimation.d.ts +8 -0
  19. package/dist/apis/Animated/animations/TimingAnimation.js +55 -0
  20. package/dist/apis/Animated/animations/TimingAnimation.js.map +1 -0
  21. package/dist/apis/Animated/animations/springConfig.js +37 -0
  22. package/dist/apis/Animated/animations/springConfig.js.map +1 -0
  23. package/dist/apis/Animated/createAnimatedComponent.d.ts +27 -0
  24. package/dist/apis/Animated/createAnimatedComponent.js +43 -0
  25. package/dist/apis/Animated/createAnimatedComponent.js.map +1 -0
  26. package/dist/apis/Animated/nodes/AnimatedAddition.d.ts +14 -0
  27. package/dist/apis/Animated/nodes/AnimatedAddition.js +36 -0
  28. package/dist/apis/Animated/nodes/AnimatedAddition.js.map +1 -0
  29. package/dist/apis/Animated/nodes/AnimatedInterpolation.d.ts +26 -0
  30. package/dist/apis/Animated/nodes/AnimatedInterpolation.js +171 -0
  31. package/dist/apis/Animated/nodes/AnimatedInterpolation.js.map +1 -0
  32. package/dist/apis/Animated/nodes/AnimatedMultiplication.d.ts +14 -0
  33. package/dist/apis/Animated/nodes/AnimatedMultiplication.js +36 -0
  34. package/dist/apis/Animated/nodes/AnimatedMultiplication.js.map +1 -0
  35. package/dist/apis/Animated/nodes/AnimatedNode.d.ts +29 -0
  36. package/dist/apis/Animated/nodes/AnimatedNode.js +47 -0
  37. package/dist/apis/Animated/nodes/AnimatedNode.js.map +1 -0
  38. package/dist/apis/Animated/nodes/AnimatedObject.js +66 -0
  39. package/dist/apis/Animated/nodes/AnimatedObject.js.map +1 -0
  40. package/dist/apis/Animated/nodes/AnimatedProps.js +88 -0
  41. package/dist/apis/Animated/nodes/AnimatedProps.js.map +1 -0
  42. package/dist/apis/Animated/nodes/AnimatedStyle.js +65 -0
  43. package/dist/apis/Animated/nodes/AnimatedStyle.js.map +1 -0
  44. package/dist/apis/Animated/nodes/AnimatedTransform.js +64 -0
  45. package/dist/apis/Animated/nodes/AnimatedTransform.js.map +1 -0
  46. package/dist/apis/Animated/nodes/AnimatedValue.d.ts +26 -0
  47. package/dist/apis/Animated/nodes/AnimatedValue.js +81 -0
  48. package/dist/apis/Animated/nodes/AnimatedValue.js.map +1 -0
  49. package/dist/apis/Animated/nodes/AnimatedWithChildren.d.ts +9 -0
  50. package/dist/apis/Animated/nodes/AnimatedWithChildren.js +37 -0
  51. package/dist/apis/Animated/nodes/AnimatedWithChildren.js.map +1 -0
  52. package/dist/apis/Animated/useAnimatedProps.js +93 -0
  53. package/dist/apis/Animated/useAnimatedProps.js.map +1 -0
  54. package/dist/apis/Easing/bezier.js +69 -0
  55. package/dist/apis/Easing/bezier.js.map +1 -0
  56. package/dist/apis/Easing/index.d.ts +21 -0
  57. package/dist/apis/Easing/index.js +43 -0
  58. package/dist/apis/Easing/index.js.map +1 -0
  59. package/dist/index.d.ts +24 -22
  60. package/dist/index.js +4 -2
  61. package/llms.txt +39 -13
  62. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ // src/apis/Animated/animations/springConfig.ts
2
+ /**
3
+ * @license MIT
4
+ * A port of `Libraries/Animated/SpringConfig.js` of React Native, Copyright (c) Meta Platforms,
5
+ * Inc. and affiliates.
6
+ */
7
+ const stiffnessFromOrigamiValue = (value) => (value - 30) * 3.62 + 194;
8
+ const dampingFromOrigamiValue = (value) => (value - 8) * 3 + 25;
9
+ const fromOrigamiTensionAndFriction = (tension, friction) => ({
10
+ stiffness: stiffnessFromOrigamiValue(tension),
11
+ damping: dampingFromOrigamiValue(friction)
12
+ });
13
+ const normalize = (value, start, end) => (value - start) / (end - start);
14
+ const projectNormal = (n, start, end) => start + n * (end - start);
15
+ const linearInterpolation = (t, start, end) => t * end + (1 - t) * start;
16
+ const quadraticOutInterpolation = (t, start, end) => linearInterpolation(2 * t - t * t, start, end);
17
+ const b3Friction1 = (x) => 7e-4 * Math.pow(x, 3) - .031 * Math.pow(x, 2) + .64 * x + 1.28;
18
+ const b3Friction2 = (x) => 44e-6 * Math.pow(x, 3) - .006 * Math.pow(x, 2) + .36 * x + 2;
19
+ const b3Friction3 = (x) => 45e-8 * Math.pow(x, 3) - 332e-6 * Math.pow(x, 2) + .1078 * x + 5.84;
20
+ const b3Nobounce = (tension) => {
21
+ if (tension <= 18) return b3Friction1(tension);
22
+ if (tension <= 44) return b3Friction2(tension);
23
+ return b3Friction3(tension);
24
+ };
25
+ const fromBouncinessAndSpeed = (bounciness, speed) => {
26
+ const b = projectNormal(normalize(bounciness / 1.7, 0, 20), 0, .8);
27
+ const s = normalize(speed / 1.7, 0, 20);
28
+ const bouncyTension = projectNormal(s, .5, 200);
29
+ const bouncyFriction = quadraticOutInterpolation(b, b3Nobounce(bouncyTension), .01);
30
+ return {
31
+ stiffness: stiffnessFromOrigamiValue(bouncyTension),
32
+ damping: dampingFromOrigamiValue(bouncyFriction)
33
+ };
34
+ };
35
+ export { fromBouncinessAndSpeed, fromOrigamiTensionAndFriction };
36
+
37
+ //# sourceMappingURL=springConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"springConfig.js","names":[],"sources":["../../../../src/apis/Animated/animations/springConfig.ts"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/SpringConfig.js` of React Native, Copyright (c) Meta Platforms,\n * Inc. and affiliates.\n */\n\nexport type SpringConfigType = { stiffness: number; damping: number }\n\n// The Origami (Facebook's prototyping tool) units of tension and friction.\nconst stiffnessFromOrigamiValue = (value: number): number => (value - 30) * 3.62 + 194\n\nconst dampingFromOrigamiValue = (value: number): number => (value - 8) * 3 + 25\n\nexport const fromOrigamiTensionAndFriction = (\n tension: number,\n friction: number,\n): SpringConfigType => ({\n stiffness: stiffnessFromOrigamiValue(tension),\n damping: dampingFromOrigamiValue(friction),\n})\n\nconst normalize = (value: number, start: number, end: number): number =>\n (value - start) / (end - start)\n\nconst projectNormal = (n: number, start: number, end: number): number => start + n * (end - start)\n\nconst linearInterpolation = (t: number, start: number, end: number): number =>\n t * end + (1 - t) * start\n\nconst quadraticOutInterpolation = (t: number, start: number, end: number): number =>\n linearInterpolation(2 * t - t * t, start, end)\n\nconst b3Friction1 = (x: number): number =>\n 0.0007 * Math.pow(x, 3) - 0.031 * Math.pow(x, 2) + 0.64 * x + 1.28\n\nconst b3Friction2 = (x: number): number =>\n 0.000044 * Math.pow(x, 3) - 0.006 * Math.pow(x, 2) + 0.36 * x + 2\n\nconst b3Friction3 = (x: number): number =>\n 0.00000045 * Math.pow(x, 3) - 0.000332 * Math.pow(x, 2) + 0.1078 * x + 5.84\n\nconst b3Nobounce = (tension: number): number => {\n if (tension <= 18) return b3Friction1(tension)\n if (tension <= 44) return b3Friction2(tension)\n return b3Friction3(tension)\n}\n\nexport const fromBouncinessAndSpeed = (bounciness: number, speed: number): SpringConfigType => {\n const b = projectNormal(normalize(bounciness / 1.7, 0, 20), 0, 0.8)\n const s = normalize(speed / 1.7, 0, 20)\n const bouncyTension = projectNormal(s, 0.5, 200)\n const bouncyFriction = quadraticOutInterpolation(b, b3Nobounce(bouncyTension), 0.01)\n return {\n stiffness: stiffnessFromOrigamiValue(bouncyTension),\n damping: dampingFromOrigamiValue(bouncyFriction),\n }\n}\n"],"mappings":";;;;;;AASA,MAAM,6BAA6B,WAA2B,QAAQ,MAAM,OAAO;AAEnF,MAAM,2BAA2B,WAA2B,QAAQ,KAAK,IAAI;AAE7E,MAAa,iCACX,SACA,cACsB;CACtB,WAAW,0BAA0B,OAAO;CAC5C,SAAS,wBAAwB,QAAQ;AAC3C;AAEA,MAAM,aAAa,OAAe,OAAe,SAC9C,QAAQ,UAAU,MAAM;AAE3B,MAAM,iBAAiB,GAAW,OAAe,QAAwB,QAAQ,KAAK,MAAM;AAE5F,MAAM,uBAAuB,GAAW,OAAe,QACrD,IAAI,OAAO,IAAI,KAAK;AAEtB,MAAM,6BAA6B,GAAW,OAAe,QAC3D,oBAAoB,IAAI,IAAI,IAAI,GAAG,OAAO,GAAG;AAE/C,MAAM,eAAe,MACnB,OAAS,KAAK,IAAI,GAAG,CAAC,IAAI,OAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,MAAO,IAAI;AAEhE,MAAM,eAAe,MACnB,QAAW,KAAK,IAAI,GAAG,CAAC,IAAI,OAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,MAAO,IAAI;AAElE,MAAM,eAAe,MACnB,QAAa,KAAK,IAAI,GAAG,CAAC,IAAI,SAAW,KAAK,IAAI,GAAG,CAAC,IAAI,QAAS,IAAI;AAEzE,MAAM,cAAc,YAA4B;CAC9C,IAAI,WAAW,IAAI,OAAO,YAAY,OAAO;CAC7C,IAAI,WAAW,IAAI,OAAO,YAAY,OAAO;CAC7C,OAAO,YAAY,OAAO;AAC5B;AAEA,MAAa,0BAA0B,YAAoB,UAAoC;CAC7F,MAAM,IAAI,cAAc,UAAU,aAAa,KAAK,GAAG,EAAE,GAAG,GAAG,EAAG;CAClE,MAAM,IAAI,UAAU,QAAQ,KAAK,GAAG,EAAE;CACtC,MAAM,gBAAgB,cAAc,GAAG,IAAK,GAAG;CAC/C,MAAM,iBAAiB,0BAA0B,GAAG,WAAW,aAAa,GAAG,GAAI;CACnF,OAAO;EACL,WAAW,0BAA0B,aAAa;EAClD,SAAS,wBAAwB,cAAc;CACjD;AACF"}
@@ -0,0 +1,27 @@
1
+ import { ViewProps } from "../../components/View/types.js";
2
+ import { NativeColorValue } from "../StyleSheet/types.js";
3
+ import { AnimatedAddition } from "./nodes/AnimatedAddition.js";
4
+ import { AnimatedInterpolation } from "./nodes/AnimatedInterpolation.js";
5
+ import { AnimatedMultiplication } from "./nodes/AnimatedMultiplication.js";
6
+ import { AnimatedNode } from "./nodes/AnimatedNode.js";
7
+ import { AnimatedValue } from "./nodes/AnimatedValue.js";
8
+ import { ComponentType, ReactNode, Ref } from "react";
9
+ type Nullable = void | null;
10
+ type Primitive = string | number | boolean | symbol | void;
11
+ type Builtin = (...args: readonly never[]) => unknown | Date | Error | RegExp;
12
+ export type WithAnimatedValue<T> = T extends Builtin | Nullable ? T : T extends Primitive ? T | AnimatedNode | AnimatedAddition | AnimatedMultiplication | AnimatedValue | AnimatedInterpolation<number | string> | AnimatedInterpolation<number> | AnimatedInterpolation<string> | AnimatedInterpolation<NativeColorValue> : T extends ReadonlyArray<infer P> ? ReadonlyArray<WithAnimatedValue<P>> : T extends object ? { readonly [K in keyof T]: WithAnimatedValue<T[K]>; } : T;
13
+ type NonAnimatedProps = "ref" | "innerViewRef" | "scrollViewRef" | "testID" | "disabled" | "accessibilityLabel";
14
+ type PassThroughProps = Readonly<{
15
+ passthroughAnimatedPropExplicitValues?: ViewProps | null | undefined;
16
+ }>;
17
+ type LooseOmit<O extends object, K extends PropertyKey> = Pick<O, Exclude<keyof O, K>>;
18
+ export type AnimatedProps<Props extends object> = LooseOmit<{ [K in keyof Props]: K extends NonAnimatedProps ? Props[K] : WithAnimatedValue<Props[K]>; }, "ref"> & PassThroughProps;
19
+ export type AnimatedComponentType<Props extends object, Instance = unknown> = (props: Omit<AnimatedProps<Props>, "ref"> & {
20
+ ref?: Ref<Instance> | undefined;
21
+ }) => ReactNode;
22
+ type InstanceOf<Props> = Props extends {
23
+ ref?: Ref<infer Instance> | undefined;
24
+ } ? Instance : unknown;
25
+ export declare function createAnimatedComponent<Props extends object>(Component: ComponentType<Props>): AnimatedComponentType<Props, InstanceOf<Props>>;
26
+ export {};
27
+ //# sourceMappingURL=createAnimatedComponent.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { useAnimatedProps } from "./useAnimatedProps.js";
2
+ import { useCallback, useImperativeHandle, useRef } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/apis/Animated/createAnimatedComponent.tsx
5
+ /**
6
+ * @license MIT
7
+ * A port of `Libraries/Animated/createAnimatedComponent.js` of React Native, Copyright (c) Meta
8
+ * Platforms, Inc. and affiliates.
9
+ */
10
+ const composeStyles = (style, passthrough) => {
11
+ if (passthrough === null || passthrough === void 0) return style;
12
+ if (style === null || style === void 0) return passthrough;
13
+ return [style, passthrough];
14
+ };
15
+ function createAnimatedComponent(Component) {
16
+ function AnimatedComponent(props) {
17
+ const Base = Component;
18
+ const { ref: forwardedRef, ...rest } = props;
19
+ const [reducedProps, animatedRef] = useAnimatedProps(rest);
20
+ const instance = useRef(null);
21
+ useImperativeHandle(forwardedRef, () => instance.current, []);
22
+ const ref = useCallback((current) => {
23
+ instance.current = current;
24
+ const cleanUp = animatedRef(current);
25
+ return () => {
26
+ instance.current = null;
27
+ if (typeof cleanUp === "function") cleanUp();
28
+ };
29
+ }, [animatedRef]);
30
+ const { passthroughAnimatedPropExplicitValues: passthrough, ...componentProps } = reducedProps;
31
+ return /* @__PURE__ */ jsx(Base, {
32
+ ...componentProps,
33
+ ...passthrough,
34
+ style: composeStyles(componentProps["style"], passthrough?.style),
35
+ ref
36
+ });
37
+ }
38
+ AnimatedComponent.displayName = `Animated(${Component.displayName || Component.name || "Anonymous"})`;
39
+ return AnimatedComponent;
40
+ }
41
+ export { createAnimatedComponent };
42
+
43
+ //# sourceMappingURL=createAnimatedComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAnimatedComponent.js","names":[],"sources":["../../../src/apis/Animated/createAnimatedComponent.tsx"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/createAnimatedComponent.js` of React Native, Copyright (c) Meta\n * Platforms, Inc. and affiliates.\n */\n\nimport {\n useCallback,\n useImperativeHandle,\n useRef,\n type ComponentType,\n type ReactNode,\n type Ref,\n} from 'react'\n\nimport type { ViewProps } from '../../components/View/types'\nimport type { NativeColorValue } from '../StyleSheet/types'\nimport type { AnimatedAddition } from './nodes/AnimatedAddition'\nimport type { AnimatedInterpolation } from './nodes/AnimatedInterpolation'\nimport type { AnimatedMultiplication } from './nodes/AnimatedMultiplication'\nimport type { AnimatedNode } from './nodes/AnimatedNode'\nimport type { AnimatedValue } from './nodes/AnimatedValue'\nimport { useAnimatedProps } from './useAnimatedProps'\n\ntype Nullable = void | null\ntype Primitive = string | number | boolean | symbol | void\ntype Builtin = (...args: readonly never[]) => unknown | Date | Error | RegExp\n\nexport type WithAnimatedValue<T> = T extends Builtin | Nullable\n ? T\n : T extends Primitive\n ? | T\n | AnimatedNode\n | AnimatedAddition\n | AnimatedMultiplication\n | AnimatedValue\n | AnimatedInterpolation<number | string>\n | AnimatedInterpolation<number>\n | AnimatedInterpolation<string>\n | AnimatedInterpolation<NativeColorValue>\n : T extends ReadonlyArray<infer P>\n ? ReadonlyArray<WithAnimatedValue<P>>\n : T extends object\n ? { readonly [K in keyof T]: WithAnimatedValue<T[K]> }\n : T\n\ntype NonAnimatedProps =\n 'ref' | 'innerViewRef' | 'scrollViewRef' | 'testID' | 'disabled' | 'accessibilityLabel'\n\ntype PassThroughProps = Readonly<{\n passthroughAnimatedPropExplicitValues?: ViewProps | null | undefined\n}>\n\ntype LooseOmit<O extends object, K extends PropertyKey> = Pick<O, Exclude<keyof O, K>>\n\nexport type AnimatedProps<Props extends object> = LooseOmit<\n { [K in keyof Props]: K extends NonAnimatedProps ? Props[K] : WithAnimatedValue<Props[K]> },\n 'ref'\n> &\n PassThroughProps\n\nexport type AnimatedComponentType<Props extends object, Instance = unknown> = (\n props: Omit<AnimatedProps<Props>, 'ref'> & { ref?: Ref<Instance> | undefined },\n) => ReactNode\n\n// The instance that the `ref` prop of a component gives.\ntype InstanceOf<Props> = Props extends { ref?: Ref<infer Instance> | undefined }\n ? Instance\n : unknown\n\nconst composeStyles = (style: unknown, passthrough: unknown): unknown => {\n if (passthrough === null || passthrough === undefined) return style\n if (style === null || style === undefined) return passthrough\n return [style, passthrough]\n}\n\nexport function createAnimatedComponent<Props extends object>(\n Component: ComponentType<Props>,\n): AnimatedComponentType<Props, InstanceOf<Props>> {\n function AnimatedComponent(props: Readonly<Record<string, unknown>>): ReactNode {\n const Base = Component as unknown as ComponentType<Record<string, unknown>>\n const { ref: forwardedRef, ...rest } = props\n const [reducedProps, animatedRef] = useAnimatedProps<unknown>(rest)\n\n // The `ref` prop gets the instance of the inner component.\n const instance = useRef<unknown>(null)\n useImperativeHandle(forwardedRef as Ref<unknown> | undefined, () => instance.current, [])\n const ref = useCallback(\n (current: unknown) => {\n instance.current = current\n const cleanUp = animatedRef(current)\n return () => {\n instance.current = null\n if (typeof cleanUp === 'function') cleanUp()\n }\n },\n [animatedRef],\n )\n\n const { passthroughAnimatedPropExplicitValues: passthrough, ...componentProps } =\n reducedProps as Record<string, unknown> & {\n passthroughAnimatedPropExplicitValues?: ViewProps | null\n }\n return (\n <Base\n {...componentProps}\n {...passthrough}\n style={composeStyles(componentProps['style'], passthrough?.style)}\n ref={ref}\n />\n )\n }\n AnimatedComponent.displayName = `Animated(${Component.displayName || Component.name || 'Anonymous'})`\n\n return AnimatedComponent as unknown as AnimatedComponentType<Props, InstanceOf<Props>>\n}\n"],"mappings":";;;;;;;;;AAsEA,MAAM,iBAAiB,OAAgB,gBAAkC;CACvE,IAAI,gBAAgB,QAAQ,gBAAgB,KAAA,GAAW,OAAO;CAC9D,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAClD,OAAO,CAAC,OAAO,WAAW;AAC5B;AAEA,SAAgB,wBACd,WACiD;CACjD,SAAS,kBAAkB,OAAqD;EAC9E,MAAM,OAAO;EACb,MAAM,EAAE,KAAK,cAAc,GAAG,SAAS;EACvC,MAAM,CAAC,cAAc,eAAe,iBAA0B,IAAI;EAGlE,MAAM,WAAW,OAAgB,IAAI;EACrC,oBAAoB,oBAAgD,SAAS,SAAS,CAAC,CAAC;EACxF,MAAM,MAAM,aACT,YAAqB;GACpB,SAAS,UAAU;GACnB,MAAM,UAAU,YAAY,OAAO;GACnC,aAAa;IACX,SAAS,UAAU;IACnB,IAAI,OAAO,YAAY,YAAY,QAAQ;GAC7C;EACF,GACA,CAAC,WAAW,CACd;EAEA,MAAM,EAAE,uCAAuC,aAAa,GAAG,mBAC7D;EAGF,OACE,oBAAC,MAAD;GACE,GAAI;GACJ,GAAI;GACJ,OAAO,cAAc,eAAe,UAAU,aAAa,KAAK;GAC3D;EACN,CAAA;CAEL;CACA,kBAAkB,cAAc,YAAY,UAAU,eAAe,UAAU,QAAQ,YAAY;CAEnG,OAAO;AACT"}
@@ -0,0 +1,14 @@
1
+ import { AnimatedInterpolation, InterpolationConfigType } from "./AnimatedInterpolation.js";
2
+ import { AnimatedNode } from "./AnimatedNode.js";
3
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
4
+ export declare class AnimatedAddition extends AnimatedWithChildren {
5
+ private readonly a;
6
+ private readonly b;
7
+ constructor(a: AnimatedNode | number, b: AnimatedNode | number);
8
+ override __getValue(): number;
9
+ interpolate<OutputT extends number | string>(config: InterpolationConfigType<OutputT>): AnimatedInterpolation<OutputT>;
10
+ override __attach(): void;
11
+ override __detach(): void;
12
+ }
13
+ export declare const add: (a: AnimatedNode | number, b: AnimatedNode | number) => AnimatedAddition;
14
+ //# sourceMappingURL=AnimatedAddition.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { AnimatedInterpolation } from "./AnimatedInterpolation.js";
2
+ import { AnimatedValue } from "./AnimatedValue.js";
3
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
4
+ // src/apis/Animated/nodes/AnimatedAddition.ts
5
+ /**
6
+ * @license MIT
7
+ * A port of `Libraries/Animated/nodes/AnimatedAddition.js` of React Native, Copyright (c) Meta
8
+ * Platforms, Inc. and affiliates.
9
+ */
10
+ var AnimatedAddition = class extends AnimatedWithChildren {
11
+ constructor(a, b) {
12
+ super();
13
+ this.a = typeof a === "number" ? new AnimatedValue(a) : a;
14
+ this.b = typeof b === "number" ? new AnimatedValue(b) : b;
15
+ }
16
+ __getValue() {
17
+ return this.a.__getValue() + this.b.__getValue();
18
+ }
19
+ interpolate(config) {
20
+ return new AnimatedInterpolation(this, config);
21
+ }
22
+ __attach() {
23
+ this.a.__addChild(this);
24
+ this.b.__addChild(this);
25
+ super.__attach();
26
+ }
27
+ __detach() {
28
+ this.a.__removeChild(this);
29
+ this.b.__removeChild(this);
30
+ super.__detach();
31
+ }
32
+ };
33
+ const add = (a, b) => new AnimatedAddition(a, b);
34
+ export { AnimatedAddition, add };
35
+
36
+ //# sourceMappingURL=AnimatedAddition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedAddition.js","names":[],"sources":["../../../../src/apis/Animated/nodes/AnimatedAddition.ts"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/nodes/AnimatedAddition.js` of React Native, Copyright (c) Meta\n * Platforms, Inc. and affiliates.\n */\n\nimport { AnimatedInterpolation } from './AnimatedInterpolation'\nimport type { InterpolationConfigType } from './AnimatedInterpolation'\nimport type { AnimatedNode } from './AnimatedNode'\nimport { AnimatedValue } from './AnimatedValue'\nimport { AnimatedWithChildren } from './AnimatedWithChildren'\n\nexport class AnimatedAddition extends AnimatedWithChildren {\n private readonly a: AnimatedNode\n private readonly b: AnimatedNode\n\n constructor(a: AnimatedNode | number, b: AnimatedNode | number) {\n super()\n this.a = typeof a === 'number' ? new AnimatedValue(a) : a\n this.b = typeof b === 'number' ? new AnimatedValue(b) : b\n }\n\n // `+` as in React Native: a node with a string output joins the two as text.\n override __getValue(): number {\n return (this.a.__getValue() as number) + (this.b.__getValue() as number)\n }\n\n interpolate<OutputT extends number | string>(\n config: InterpolationConfigType<OutputT>,\n ): AnimatedInterpolation<OutputT> {\n return new AnimatedInterpolation(this, config)\n }\n\n override __attach(): void {\n this.a.__addChild(this)\n this.b.__addChild(this)\n super.__attach()\n }\n\n override __detach(): void {\n this.a.__removeChild(this)\n this.b.__removeChild(this)\n super.__detach()\n }\n}\n\nexport const add = (a: AnimatedNode | number, b: AnimatedNode | number): AnimatedAddition =>\n new AnimatedAddition(a, b)\n"],"mappings":";;;;;;;;;AAYA,IAAa,mBAAb,cAAsC,qBAAqB;CAIzD,YAAY,GAA0B,GAA0B;EAC9D,MAAM;EACN,KAAK,IAAI,OAAO,MAAM,WAAW,IAAI,cAAc,CAAC,IAAI;EACxD,KAAK,IAAI,OAAO,MAAM,WAAW,IAAI,cAAc,CAAC,IAAI;CAC1D;CAGA,aAA8B;EAC5B,OAAQ,KAAK,EAAE,WAAW,IAAgB,KAAK,EAAE,WAAW;CAC9D;CAEA,YACE,QACgC;EAChC,OAAO,IAAI,sBAAsB,MAAM,MAAM;CAC/C;CAEA,WAA0B;EACxB,KAAK,EAAE,WAAW,IAAI;EACtB,KAAK,EAAE,WAAW,IAAI;EACtB,MAAM,SAAS;CACjB;CAEA,WAA0B;EACxB,KAAK,EAAE,cAAc,IAAI;EACzB,KAAK,EAAE,cAAc,IAAI;EACzB,MAAM,SAAS;CACjB;AACF;AAEA,MAAa,OAAO,GAA0B,MAC5C,IAAI,iBAAiB,GAAG,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { NativeColorValue } from "../../StyleSheet/types.js";
2
+ import { AnimatedNode, AnimatedNodeConfig } from "./AnimatedNode.js";
3
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
4
+ type ExtrapolateType = "extend" | "identity" | "clamp";
5
+ export type InterpolationConfigSupportedOutputType = number | string | NativeColorValue;
6
+ export type InterpolationConfigType<OutputT extends InterpolationConfigSupportedOutputType> = Readonly<AnimatedNodeConfig & {
7
+ inputRange: readonly number[];
8
+ outputRange: readonly OutputT[];
9
+ easing?: ((input: number) => number) | undefined;
10
+ extrapolate?: ExtrapolateType | undefined;
11
+ extrapolateLeft?: ExtrapolateType | undefined;
12
+ extrapolateRight?: ExtrapolateType | undefined;
13
+ }>;
14
+ export declare class AnimatedInterpolation<OutputT extends InterpolationConfigSupportedOutputType> extends AnimatedWithChildren {
15
+ private readonly parent;
16
+ private readonly config;
17
+ private interpolation;
18
+ constructor(parent: AnimatedNode, config: InterpolationConfigType<OutputT>);
19
+ private getInterpolation;
20
+ override __getValue(): OutputT;
21
+ interpolate<NewOutputT extends number | string>(config: InterpolationConfigType<NewOutputT>): AnimatedInterpolation<NewOutputT>;
22
+ override __attach(): void;
23
+ override __detach(): void;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=AnimatedInterpolation.d.ts.map
@@ -0,0 +1,171 @@
1
+ import { isProductionEnv } from "../../../utils/env.js";
2
+ import { warnOnce } from "../../../utils/warn.js";
3
+ import { Easing } from "../../Easing/index.js";
4
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
5
+ import normalizeColor from "@react-native/normalize-colors";
6
+ // src/apis/Animated/nodes/AnimatedInterpolation.ts
7
+ /**
8
+ * @license MIT
9
+ * A port of `Libraries/Animated/nodes/AnimatedInterpolation.js` of React Native, Copyright (c) Meta
10
+ * Platforms, Inc. and affiliates.
11
+ */
12
+ const fail = (message) => {
13
+ throw new Error(message);
14
+ };
15
+ const interpolateSegment = (input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight) => {
16
+ let result = input;
17
+ if (result < inputMin) {
18
+ if (extrapolateLeft === "identity") return result;
19
+ if (extrapolateLeft === "clamp") result = inputMin;
20
+ }
21
+ if (result > inputMax) {
22
+ if (extrapolateRight === "identity") return result;
23
+ if (extrapolateRight === "clamp") result = inputMax;
24
+ }
25
+ if (outputMin === outputMax) return outputMin;
26
+ if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax;
27
+ if (inputMin === -Infinity) result = -result;
28
+ else if (inputMax === Infinity) result = result - inputMin;
29
+ else result = (result - inputMin) / (inputMax - inputMin);
30
+ result = easing(result);
31
+ if (outputMin === -Infinity) result = -result;
32
+ else if (outputMax === Infinity) result = result + outputMin;
33
+ else result = result * (outputMax - outputMin) + outputMin;
34
+ return result;
35
+ };
36
+ const findRange = (input, inputRange) => {
37
+ let i = 1;
38
+ for (; i < inputRange.length - 1; i++) if ((inputRange[i] ?? 0) >= input) break;
39
+ return i - 1;
40
+ };
41
+ const createNumericInterpolation = (config) => {
42
+ const { inputRange, outputRange } = config;
43
+ const easing = config.easing ?? Easing.linear;
44
+ const extrapolateLeft = config.extrapolateLeft ?? config.extrapolate ?? "extend";
45
+ const extrapolateRight = config.extrapolateRight ?? config.extrapolate ?? "extend";
46
+ return (input) => {
47
+ if (typeof input !== "number") fail("Cannot interpolate an input which is not a number");
48
+ const range = findRange(input, inputRange);
49
+ return interpolateSegment(input, inputRange[range] ?? 0, inputRange[range + 1] ?? 0, outputRange[range] ?? 0, outputRange[range + 1] ?? 0, easing, extrapolateLeft, extrapolateRight);
50
+ };
51
+ };
52
+ const createPlatformColorInterpolation = (config) => {
53
+ const { outputRange } = config;
54
+ const interpolateIndex = createNumericInterpolation({
55
+ ...config,
56
+ outputRange: outputRange.map((_, index) => index)
57
+ });
58
+ return (input) => {
59
+ const index = interpolateIndex(input);
60
+ if (!Number.isInteger(index)) warnOnce("animated-platform-color", "Animated: the web can't interpolate between two PlatformColor values. It uses the nearest color.");
61
+ return outputRange[Math.floor(index)];
62
+ };
63
+ };
64
+ const NUMBER = /[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g;
65
+ const toStringShape = (input) => {
66
+ const color = normalizeColor(input);
67
+ if (typeof color === "number") return {
68
+ isColor: true,
69
+ components: [
70
+ (color & 4278190080) >>> 24,
71
+ (color & 16711680) >>> 16,
72
+ (color & 65280) >>> 8,
73
+ (color & 255) / 255
74
+ ]
75
+ };
76
+ const components = [];
77
+ let lastMatchEnd = 0;
78
+ for (const match of input.matchAll(NUMBER)) {
79
+ if (match.index > lastMatchEnd) components.push(input.slice(lastMatchEnd, match.index));
80
+ components.push(Number.parseFloat(match[0]));
81
+ lastMatchEnd = match.index + match[0].length;
82
+ }
83
+ if (components.length === 0) fail("outputRange must contain color or value with numeric component");
84
+ if (lastMatchEnd < input.length) components.push(input.slice(lastMatchEnd));
85
+ return {
86
+ isColor: false,
87
+ components
88
+ };
89
+ };
90
+ const checkStringShapes = (shapes) => {
91
+ const [first] = shapes;
92
+ if (first === void 0) return;
93
+ if (!shapes.every((shape) => shape.isColor === first.isColor)) fail("All elements of output range should either be a color or a string with numeric components");
94
+ if (!shapes.every((shape) => shape.components.length === first.components.length)) fail("All elements of output range should have the same number of components");
95
+ if (!shapes.every((shape) => shape.components.every((component, i) => typeof component === "number" || component === first.components[i]))) fail("All elements of output range should have the same non-numeric components");
96
+ };
97
+ const createStringInterpolation = (config) => {
98
+ if (config.outputRange.length < 2) fail("Bad output range");
99
+ const shapes = config.outputRange.map(toStringShape);
100
+ if (!isProductionEnv()) checkStringShapes(shapes);
101
+ const [first] = shapes;
102
+ const isColor = first?.isColor === true;
103
+ const numbers = shapes.map((shape) => shape.components.filter((component) => typeof component === "number"));
104
+ const interpolations = (numbers[0] ?? []).map((_, i) => createNumericInterpolation({
105
+ ...config,
106
+ outputRange: numbers.map((list) => list[i] ?? 0)
107
+ }));
108
+ if (isColor) return (input) => {
109
+ const [r, g, b, a] = interpolations.map((interpolation, i) => {
110
+ const value = interpolation(input);
111
+ return i < 3 ? Math.round(value) : Math.round(value * 1e3) / 1e3;
112
+ });
113
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
114
+ };
115
+ const template = first?.components ?? [];
116
+ return (input) => {
117
+ const values = interpolations.map((interpolation) => interpolation(input));
118
+ let i = 0;
119
+ return template.map((component) => typeof component === "number" ? values[i++] : component).join("");
120
+ };
121
+ };
122
+ const createInterpolation = (config) => {
123
+ const first = config.outputRange[0];
124
+ if (typeof first === "string") return createStringInterpolation(config);
125
+ if (typeof first === "object") return createPlatformColorInterpolation(config);
126
+ return createNumericInterpolation(config);
127
+ };
128
+ const checkInfiniteRange = (name, range) => {
129
+ if (range.length < 2) fail(`${name} must have at least 2 elements`);
130
+ if (range.length === 2 && range[0] === -Infinity && range[1] === Infinity) fail(`${name} cannot be ]-infinity;+infinity[ ${String(range)}`);
131
+ };
132
+ const checkValidRanges = (inputRange, outputRange) => {
133
+ checkInfiniteRange("outputRange", outputRange);
134
+ checkInfiniteRange("inputRange", inputRange);
135
+ for (let i = 1; i < inputRange.length; i++) if ((inputRange[i] ?? 0) < (inputRange[i - 1] ?? 0)) fail(`inputRange must be monotonically non-decreasing ${String(inputRange)}`);
136
+ if (inputRange.length !== outputRange.length) fail(`inputRange (${inputRange.length}) and outputRange (${outputRange.length}) must have the same length`);
137
+ };
138
+ var AnimatedInterpolation = class AnimatedInterpolation extends AnimatedWithChildren {
139
+ constructor(parent, config) {
140
+ super();
141
+ this.parent = parent;
142
+ this.config = config;
143
+ if (!isProductionEnv()) {
144
+ checkValidRanges(config.inputRange, config.outputRange);
145
+ this.getInterpolation();
146
+ }
147
+ }
148
+ getInterpolation() {
149
+ this.interpolation ??= createInterpolation(this.config);
150
+ return this.interpolation;
151
+ }
152
+ __getValue() {
153
+ const parentValue = this.parent.__getValue();
154
+ if (typeof parentValue !== "number") fail("Cannot interpolate an input which is not a number.");
155
+ return this.getInterpolation()(parentValue);
156
+ }
157
+ interpolate(config) {
158
+ return new AnimatedInterpolation(this, config);
159
+ }
160
+ __attach() {
161
+ this.parent.__addChild(this);
162
+ super.__attach();
163
+ }
164
+ __detach() {
165
+ this.parent.__removeChild(this);
166
+ super.__detach();
167
+ }
168
+ };
169
+ export { AnimatedInterpolation };
170
+
171
+ //# sourceMappingURL=AnimatedInterpolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedInterpolation.js","names":[],"sources":["../../../../src/apis/Animated/nodes/AnimatedInterpolation.ts"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/nodes/AnimatedInterpolation.js` of React Native, Copyright (c) Meta\n * Platforms, Inc. and affiliates.\n */\n\nimport normalizeColor from '@react-native/normalize-colors'\n\nimport { isProductionEnv } from '../../../utils/env'\nimport { warnOnce } from '../../../utils/warn'\nimport { Easing } from '../../Easing'\nimport type { NativeColorValue } from '../../StyleSheet/types'\nimport type { AnimatedNode, AnimatedNodeConfig } from './AnimatedNode'\nimport { AnimatedWithChildren } from './AnimatedWithChildren'\n\ntype ExtrapolateType = 'extend' | 'identity' | 'clamp'\n\nexport type InterpolationConfigSupportedOutputType = number | string | NativeColorValue\n\nexport type InterpolationConfigType<OutputT extends InterpolationConfigSupportedOutputType> =\n Readonly<\n AnimatedNodeConfig & {\n inputRange: readonly number[]\n outputRange: readonly OutputT[]\n easing?: ((input: number) => number) | undefined\n extrapolate?: ExtrapolateType | undefined\n extrapolateLeft?: ExtrapolateType | undefined\n extrapolateRight?: ExtrapolateType | undefined\n }\n >\n\ntype Interpolation<OutputT> = (input: number) => OutputT\n\nconst fail: (message: string) => never = (message) => {\n throw new Error(message)\n}\n\nconst interpolateSegment = (\n input: number,\n inputMin: number,\n inputMax: number,\n outputMin: number,\n outputMax: number,\n easing: (input: number) => number,\n extrapolateLeft: ExtrapolateType,\n extrapolateRight: ExtrapolateType,\n): number => {\n let result = input\n\n if (result < inputMin) {\n if (extrapolateLeft === 'identity') return result\n if (extrapolateLeft === 'clamp') result = inputMin\n }\n if (result > inputMax) {\n if (extrapolateRight === 'identity') return result\n if (extrapolateRight === 'clamp') result = inputMax\n }\n\n if (outputMin === outputMax) return outputMin\n if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax\n\n if (inputMin === -Infinity) result = -result\n else if (inputMax === Infinity) result = result - inputMin\n else result = (result - inputMin) / (inputMax - inputMin)\n\n result = easing(result)\n\n if (outputMin === -Infinity) result = -result\n else if (outputMax === Infinity) result = result + outputMin\n else result = result * (outputMax - outputMin) + outputMin\n\n return result\n}\n\n// The index of the segment of `inputRange` that holds `input`. Out of the range, the first or the\n// last segment.\nconst findRange = (input: number, inputRange: readonly number[]): number => {\n let i = 1\n for (; i < inputRange.length - 1; i++) {\n if ((inputRange[i] ?? 0) >= input) break\n }\n return i - 1\n}\n\nconst createNumericInterpolation = (\n config: InterpolationConfigType<number>,\n): Interpolation<number> => {\n const { inputRange, outputRange } = config\n const easing = config.easing ?? Easing.linear\n const extrapolateLeft = config.extrapolateLeft ?? config.extrapolate ?? 'extend'\n const extrapolateRight = config.extrapolateRight ?? config.extrapolate ?? 'extend'\n\n return (input) => {\n if (typeof input !== 'number') fail('Cannot interpolate an input which is not a number')\n const range = findRange(input, inputRange)\n return interpolateSegment(\n input,\n inputRange[range] ?? 0,\n inputRange[range + 1] ?? 0,\n outputRange[range] ?? 0,\n outputRange[range + 1] ?? 0,\n easing,\n extrapolateLeft,\n extrapolateRight,\n )\n }\n}\n\n// The web has no `PlatformColor`, so this runs only for a color object that a library makes. As in\n// React Native's JavaScript driver, the output steps to the nearest color.\nconst createPlatformColorInterpolation = (\n config: InterpolationConfigType<NativeColorValue>,\n): Interpolation<NativeColorValue> => {\n const { outputRange } = config\n const interpolateIndex = createNumericInterpolation({\n ...config,\n outputRange: outputRange.map((_, index) => index),\n })\n return (input) => {\n const index = interpolateIndex(input)\n if (!Number.isInteger(index)) {\n warnOnce(\n 'animated-platform-color',\n \"Animated: the web can't interpolate between two PlatformColor values. It uses the nearest color.\",\n )\n }\n return outputRange[Math.floor(index)] as NativeColorValue\n }\n}\n\ntype StringShape = { isColor: boolean; components: readonly (number | string)[] }\n\nconst NUMBER = /[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?/g\n\n// A color becomes its four channels. Any other string becomes its numbers and the text between\n// them, so `'-45deg'` is `[-45, 'deg']`.\nconst toStringShape = (input: string): StringShape => {\n const color = normalizeColor(input)\n if (typeof color === 'number') {\n const r = (color & 0xff000000) >>> 24\n const g = (color & 0x00ff0000) >>> 16\n const b = (color & 0x0000ff00) >>> 8\n const a = (color & 0x000000ff) / 255\n return { isColor: true, components: [r, g, b, a] }\n }\n\n const components: (number | string)[] = []\n let lastMatchEnd = 0\n for (const match of input.matchAll(NUMBER)) {\n if (match.index > lastMatchEnd) components.push(input.slice(lastMatchEnd, match.index))\n components.push(Number.parseFloat(match[0]))\n lastMatchEnd = match.index + match[0].length\n }\n if (components.length === 0) {\n fail('outputRange must contain color or value with numeric component')\n }\n if (lastMatchEnd < input.length) components.push(input.slice(lastMatchEnd))\n return { isColor: false, components }\n}\n\nconst checkStringShapes = (shapes: readonly StringShape[]): void => {\n const [first] = shapes\n if (first === undefined) return\n if (!shapes.every((shape) => shape.isColor === first.isColor)) {\n fail(\n 'All elements of output range should either be a color or a string with numeric components',\n )\n }\n if (!shapes.every((shape) => shape.components.length === first.components.length)) {\n fail('All elements of output range should have the same number of components')\n }\n const sameText = shapes.every((shape) =>\n shape.components.every(\n (component, i) => typeof component === 'number' || component === first.components[i],\n ),\n )\n if (!sameText) fail('All elements of output range should have the same non-numeric components')\n}\n\n// Interpolates each number of a string on its own and puts the string back together: colors such\n// as `'rgba(123, 42, 99, 0.36)'` and values with units such as `'-45deg'`.\nconst createStringInterpolation = (\n config: InterpolationConfigType<string>,\n): Interpolation<string> => {\n if (config.outputRange.length < 2) fail('Bad output range')\n const shapes = config.outputRange.map(toStringShape)\n if (!isProductionEnv()) checkStringShapes(shapes)\n\n const [first] = shapes\n const isColor = first?.isColor === true\n const numbers = shapes.map((shape) =>\n shape.components.filter((component): component is number => typeof component === 'number'),\n )\n const interpolations = (numbers[0] ?? []).map((_, i) =>\n createNumericInterpolation({ ...config, outputRange: numbers.map((list) => list[i] ?? 0) }),\n )\n\n if (isColor) {\n return (input) => {\n const [r, g, b, a] = interpolations.map((interpolation, i) => {\n const value = interpolation(input)\n return i < 3 ? Math.round(value) : Math.round(value * 1000) / 1000\n })\n return `rgba(${r}, ${g}, ${b}, ${a})`\n }\n }\n\n const template = first?.components ?? []\n return (input) => {\n const values = interpolations.map((interpolation) => interpolation(input))\n let i = 0\n return template\n .map((component) => (typeof component === 'number' ? values[i++] : component))\n .join('')\n }\n}\n\nconst createInterpolation = <OutputT extends InterpolationConfigSupportedOutputType>(\n config: InterpolationConfigType<OutputT>,\n): Interpolation<OutputT> => {\n const first = config.outputRange[0]\n if (typeof first === 'string') {\n return createStringInterpolation(\n config as InterpolationConfigType<string>,\n ) as Interpolation<OutputT>\n }\n if (typeof first === 'object') {\n return createPlatformColorInterpolation(\n config as InterpolationConfigType<NativeColorValue>,\n ) as Interpolation<OutputT>\n }\n return createNumericInterpolation(\n config as InterpolationConfigType<number>,\n ) as Interpolation<OutputT>\n}\n\nconst checkInfiniteRange = (name: string, range: readonly unknown[]): void => {\n if (range.length < 2) fail(`${name} must have at least 2 elements`)\n if (range.length === 2 && range[0] === -Infinity && range[1] === Infinity) {\n fail(`${name} cannot be ]-infinity;+infinity[ ${String(range)}`)\n }\n}\n\nconst checkValidRanges = (inputRange: readonly number[], outputRange: readonly unknown[]): void => {\n checkInfiniteRange('outputRange', outputRange)\n checkInfiniteRange('inputRange', inputRange)\n for (let i = 1; i < inputRange.length; i++) {\n if ((inputRange[i] ?? 0) < (inputRange[i - 1] ?? 0)) {\n fail(`inputRange must be monotonically non-decreasing ${String(inputRange)}`)\n }\n }\n if (inputRange.length !== outputRange.length) {\n fail(\n `inputRange (${inputRange.length}) and outputRange (${outputRange.length}) must have the same length`,\n )\n }\n}\n\nexport class AnimatedInterpolation<\n OutputT extends InterpolationConfigSupportedOutputType,\n> extends AnimatedWithChildren {\n private readonly parent: AnimatedNode\n private readonly config: InterpolationConfigType<OutputT>\n private interpolation: Interpolation<OutputT> | undefined\n\n constructor(parent: AnimatedNode, config: InterpolationConfigType<OutputT>) {\n super()\n this.parent = parent\n this.config = config\n // React Native checks the ranges only in development, and builds the function at once there.\n if (!isProductionEnv()) {\n checkValidRanges(config.inputRange, config.outputRange)\n this.getInterpolation()\n }\n }\n\n private getInterpolation(): Interpolation<OutputT> {\n this.interpolation ??= createInterpolation(this.config)\n return this.interpolation\n }\n\n override __getValue(): OutputT {\n const parentValue = this.parent.__getValue()\n if (typeof parentValue !== 'number') fail('Cannot interpolate an input which is not a number.')\n return this.getInterpolation()(parentValue)\n }\n\n interpolate<NewOutputT extends number | string>(\n config: InterpolationConfigType<NewOutputT>,\n ): AnimatedInterpolation<NewOutputT> {\n return new AnimatedInterpolation(this, config)\n }\n\n override __attach(): void {\n this.parent.__addChild(this)\n super.__attach()\n }\n\n override __detach(): void {\n this.parent.__removeChild(this)\n super.__detach()\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ import { AnimatedInterpolation, InterpolationConfigType } from "./AnimatedInterpolation.js";
2
+ import { AnimatedNode } from "./AnimatedNode.js";
3
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
4
+ export declare class AnimatedMultiplication extends AnimatedWithChildren {
5
+ private readonly a;
6
+ private readonly b;
7
+ constructor(a: AnimatedNode | number, b: AnimatedNode | number);
8
+ override __getValue(): number;
9
+ interpolate<OutputT extends number | string>(config: InterpolationConfigType<OutputT>): AnimatedInterpolation<OutputT>;
10
+ override __attach(): void;
11
+ override __detach(): void;
12
+ }
13
+ export declare const multiply: (a: AnimatedNode | number, b: AnimatedNode | number) => AnimatedMultiplication;
14
+ //# sourceMappingURL=AnimatedMultiplication.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { AnimatedInterpolation } from "./AnimatedInterpolation.js";
2
+ import { AnimatedValue } from "./AnimatedValue.js";
3
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
4
+ // src/apis/Animated/nodes/AnimatedMultiplication.ts
5
+ /**
6
+ * @license MIT
7
+ * A port of `Libraries/Animated/nodes/AnimatedMultiplication.js` of React Native, Copyright (c)
8
+ * Meta Platforms, Inc. and affiliates.
9
+ */
10
+ var AnimatedMultiplication = class extends AnimatedWithChildren {
11
+ constructor(a, b) {
12
+ super();
13
+ this.a = typeof a === "number" ? new AnimatedValue(a) : a;
14
+ this.b = typeof b === "number" ? new AnimatedValue(b) : b;
15
+ }
16
+ __getValue() {
17
+ return this.a.__getValue() * this.b.__getValue();
18
+ }
19
+ interpolate(config) {
20
+ return new AnimatedInterpolation(this, config);
21
+ }
22
+ __attach() {
23
+ this.a.__addChild(this);
24
+ this.b.__addChild(this);
25
+ super.__attach();
26
+ }
27
+ __detach() {
28
+ this.a.__removeChild(this);
29
+ this.b.__removeChild(this);
30
+ super.__detach();
31
+ }
32
+ };
33
+ const multiply = (a, b) => new AnimatedMultiplication(a, b);
34
+ export { AnimatedMultiplication, multiply };
35
+
36
+ //# sourceMappingURL=AnimatedMultiplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedMultiplication.js","names":[],"sources":["../../../../src/apis/Animated/nodes/AnimatedMultiplication.ts"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/nodes/AnimatedMultiplication.js` of React Native, Copyright (c)\n * Meta Platforms, Inc. and affiliates.\n */\n\nimport { AnimatedInterpolation } from './AnimatedInterpolation'\nimport type { InterpolationConfigType } from './AnimatedInterpolation'\nimport type { AnimatedNode } from './AnimatedNode'\nimport { AnimatedValue } from './AnimatedValue'\nimport { AnimatedWithChildren } from './AnimatedWithChildren'\n\nexport class AnimatedMultiplication extends AnimatedWithChildren {\n private readonly a: AnimatedNode\n private readonly b: AnimatedNode\n\n constructor(a: AnimatedNode | number, b: AnimatedNode | number) {\n super()\n this.a = typeof a === 'number' ? new AnimatedValue(a) : a\n this.b = typeof b === 'number' ? new AnimatedValue(b) : b\n }\n\n override __getValue(): number {\n return (this.a.__getValue() as number) * (this.b.__getValue() as number)\n }\n\n interpolate<OutputT extends number | string>(\n config: InterpolationConfigType<OutputT>,\n ): AnimatedInterpolation<OutputT> {\n return new AnimatedInterpolation(this, config)\n }\n\n override __attach(): void {\n this.a.__addChild(this)\n this.b.__addChild(this)\n super.__attach()\n }\n\n override __detach(): void {\n this.a.__removeChild(this)\n this.b.__removeChild(this)\n super.__detach()\n }\n}\n\nexport const multiply = (\n a: AnimatedNode | number,\n b: AnimatedNode | number,\n): AnimatedMultiplication => new AnimatedMultiplication(a, b)\n"],"mappings":";;;;;;;;;AAYA,IAAa,yBAAb,cAA4C,qBAAqB;CAI/D,YAAY,GAA0B,GAA0B;EAC9D,MAAM;EACN,KAAK,IAAI,OAAO,MAAM,WAAW,IAAI,cAAc,CAAC,IAAI;EACxD,KAAK,IAAI,OAAO,MAAM,WAAW,IAAI,cAAc,CAAC,IAAI;CAC1D;CAEA,aAA8B;EAC5B,OAAQ,KAAK,EAAE,WAAW,IAAgB,KAAK,EAAE,WAAW;CAC9D;CAEA,YACE,QACgC;EAChC,OAAO,IAAI,sBAAsB,MAAM,MAAM;CAC/C;CAEA,WAA0B;EACxB,KAAK,EAAE,WAAW,IAAI;EACtB,KAAK,EAAE,WAAW,IAAI;EACtB,MAAM,SAAS;CACjB;CAEA,WAA0B;EACxB,KAAK,EAAE,cAAc,IAAI;EACzB,KAAK,EAAE,cAAc,IAAI;EACzB,MAAM,SAAS;CACjB;AACF;AAEA,MAAa,YACX,GACA,MAC2B,IAAI,uBAAuB,GAAG,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license MIT
3
+ * A port of `Libraries/Animated/nodes/AnimatedNode.js` of React Native, Copyright (c) Meta
4
+ * Platforms, Inc. and affiliates.
5
+ */
6
+ export type ValueListenerCallback = (state: {
7
+ value: number;
8
+ }) => unknown;
9
+ export type AnimatedNodeConfig = Readonly<{
10
+ debugID?: string | undefined;
11
+ unstable_disableBatchingForNativeCreate?: boolean | undefined;
12
+ }>;
13
+ export declare class AnimatedNode {
14
+ private readonly listeners;
15
+ __attach(): void;
16
+ __detach(): void;
17
+ __getValue(): unknown;
18
+ __getAnimatedValue(): unknown;
19
+ __addChild(_child: AnimatedNode): void;
20
+ __removeChild(_child: AnimatedNode): void;
21
+ __getChildren(): readonly AnimatedNode[];
22
+ addListener(callback: ValueListenerCallback): string;
23
+ removeListener(id: string): void;
24
+ removeAllListeners(): void;
25
+ hasListeners(): boolean;
26
+ __callListeners(value: unknown): void;
27
+ toJSON(): unknown;
28
+ }
29
+ //# sourceMappingURL=AnimatedNode.d.ts.map
@@ -0,0 +1,47 @@
1
+ // src/apis/Animated/nodes/AnimatedNode.ts
2
+ /**
3
+ * @license MIT
4
+ * A port of `Libraries/Animated/nodes/AnimatedNode.js` of React Native, Copyright (c) Meta
5
+ * Platforms, Inc. and affiliates.
6
+ */
7
+ let nextListenerId = 1;
8
+ var AnimatedNode = class {
9
+ constructor() {
10
+ this.listeners = /* @__PURE__ */ new Map();
11
+ }
12
+ __attach() {}
13
+ __detach() {}
14
+ __getValue() {}
15
+ __getAnimatedValue() {
16
+ return this.__getValue();
17
+ }
18
+ __addChild(_child) {}
19
+ __removeChild(_child) {}
20
+ __getChildren() {
21
+ return [];
22
+ }
23
+ addListener(callback) {
24
+ const id = String(nextListenerId++);
25
+ this.listeners.set(id, callback);
26
+ return id;
27
+ }
28
+ removeListener(id) {
29
+ this.listeners.delete(id);
30
+ }
31
+ removeAllListeners() {
32
+ this.listeners.clear();
33
+ }
34
+ hasListeners() {
35
+ return this.listeners.size > 0;
36
+ }
37
+ __callListeners(value) {
38
+ const state = { value };
39
+ for (const listener of this.listeners.values()) listener(state);
40
+ }
41
+ toJSON() {
42
+ return this.__getValue();
43
+ }
44
+ };
45
+ export { AnimatedNode };
46
+
47
+ //# sourceMappingURL=AnimatedNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedNode.js","names":[],"sources":["../../../../src/apis/Animated/nodes/AnimatedNode.ts"],"sourcesContent":["/**\n * @license MIT\n * A port of `Libraries/Animated/nodes/AnimatedNode.js` of React Native, Copyright (c) Meta\n * Platforms, Inc. and affiliates.\n */\n\nexport type ValueListenerCallback = (state: { value: number }) => unknown\n\nexport type AnimatedNodeConfig = Readonly<{\n debugID?: string | undefined\n unstable_disableBatchingForNativeCreate?: boolean | undefined\n}>\n\nlet nextListenerId = 1\n\n// The web has no native driver, so the native half of React Native's node is left out. The methods\n// with `__` keep React Native's names, because libraries call them: react-native-svg calls\n// `__getAnimatedValue`.\nexport class AnimatedNode {\n private readonly listeners = new Map<string, ValueListenerCallback>()\n\n __attach(): void {}\n\n // React Native keeps the listeners on a detach (`animatedKeepListenersOnDetach`, on since 0.80).\n __detach(): void {}\n\n __getValue(): unknown {\n return undefined\n }\n\n __getAnimatedValue(): unknown {\n return this.__getValue()\n }\n\n __addChild(_child: AnimatedNode): void {}\n\n __removeChild(_child: AnimatedNode): void {}\n\n __getChildren(): readonly AnimatedNode[] {\n return []\n }\n\n addListener(callback: ValueListenerCallback): string {\n const id = String(nextListenerId++)\n this.listeners.set(id, callback)\n return id\n }\n\n removeListener(id: string): void {\n this.listeners.delete(id)\n }\n\n removeAllListeners(): void {\n this.listeners.clear()\n }\n\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n // An interpolation gives its listeners a string when its output is a string, as in React Native.\n __callListeners(value: unknown): void {\n const state = { value: value as number }\n for (const listener of this.listeners.values()) listener(state)\n }\n\n // Keeps `JSON.stringify` from a cycle in React DevTools.\n toJSON(): unknown {\n return this.__getValue()\n }\n}\n"],"mappings":";;;;;;AAaA,IAAI,iBAAiB;AAKrB,IAAa,eAAb,MAA0B;;EACxB,KAAiB,4BAAY,IAAI,IAAmC;;CAEpE,WAAiB,CAAC;CAGlB,WAAiB,CAAC;CAElB,aAAsB,CAEtB;CAEA,qBAA8B;EAC5B,OAAO,KAAK,WAAW;CACzB;CAEA,WAAW,QAA4B,CAAC;CAExC,cAAc,QAA4B,CAAC;CAE3C,gBAAyC;EACvC,OAAO,CAAC;CACV;CAEA,YAAY,UAAyC;EACnD,MAAM,KAAK,OAAO,gBAAgB;EAClC,KAAK,UAAU,IAAI,IAAI,QAAQ;EAC/B,OAAO;CACT;CAEA,eAAe,IAAkB;EAC/B,KAAK,UAAU,OAAO,EAAE;CAC1B;CAEA,qBAA2B;EACzB,KAAK,UAAU,MAAM;CACvB;CAEA,eAAwB;EACtB,OAAO,KAAK,UAAU,OAAO;CAC/B;CAGA,gBAAgB,OAAsB;EACpC,MAAM,QAAQ,EAAS,MAAgB;EACvC,KAAK,MAAM,YAAY,KAAK,UAAU,OAAO,GAAG,SAAS,KAAK;CAChE;CAGA,SAAkB;EAChB,OAAO,KAAK,WAAW;CACzB;AACF"}
@@ -0,0 +1,66 @@
1
+ import { AnimatedNode } from "./AnimatedNode.js";
2
+ import { AnimatedWithChildren } from "./AnimatedWithChildren.js";
3
+ import { isValidElement } from "react";
4
+ // src/apis/Animated/nodes/AnimatedObject.ts
5
+ /**
6
+ * @license MIT
7
+ * A port of `Libraries/Animated/nodes/AnimatedObject.js` of React Native, Copyright (c) Meta
8
+ * Platforms, Inc. and affiliates.
9
+ */
10
+ const MAX_DEPTH = 5;
11
+ const isPlainObject = (value) => {
12
+ if (value === null || typeof value !== "object") return false;
13
+ const proto = Object.getPrototypeOf(value);
14
+ return (proto === null || proto === Object.prototype) && !isValidElement(value);
15
+ };
16
+ const flatAnimatedNodes = (value, nodes = [], depth = 0) => {
17
+ if (depth >= MAX_DEPTH) return nodes;
18
+ if (value instanceof AnimatedNode) nodes.push(value);
19
+ else if (Array.isArray(value)) for (const element of value) flatAnimatedNodes(element, nodes, depth + 1);
20
+ else if (isPlainObject(value)) for (const key of Object.keys(value)) flatAnimatedNodes(value[key], nodes, depth + 1);
21
+ return nodes;
22
+ };
23
+ const animatedNodesIn = (value) => flatAnimatedNodes(value);
24
+ const mapAnimatedNodes = (value, fn, depth = 0) => {
25
+ if (depth >= MAX_DEPTH) return value;
26
+ if (value instanceof AnimatedNode) return fn(value);
27
+ if (Array.isArray(value)) return value.map((element) => mapAnimatedNodes(element, fn, depth + 1));
28
+ if (isPlainObject(value)) {
29
+ const result = {};
30
+ for (const key of Object.keys(value)) result[key] = mapAnimatedNodes(value[key], fn, depth + 1);
31
+ return result;
32
+ }
33
+ return value;
34
+ };
35
+ var AnimatedObject = class AnimatedObject extends AnimatedWithChildren {
36
+ static from(value) {
37
+ const nodes = flatAnimatedNodes(value);
38
+ return nodes.length === 0 ? null : new AnimatedObject(nodes, value);
39
+ }
40
+ constructor(nodes, value) {
41
+ super();
42
+ this.nodes = nodes;
43
+ this.value = value;
44
+ }
45
+ __getValue() {
46
+ return mapAnimatedNodes(this.value, (node) => node.__getValue());
47
+ }
48
+ __getValueWithStaticObject(staticObject) {
49
+ let index = 0;
50
+ return mapAnimatedNodes(staticObject, () => this.nodes[index++]?.__getValue());
51
+ }
52
+ __getAnimatedValue() {
53
+ return mapAnimatedNodes(this.value, (node) => node.__getAnimatedValue());
54
+ }
55
+ __attach() {
56
+ for (const node of this.nodes) node.__addChild(this);
57
+ super.__attach();
58
+ }
59
+ __detach() {
60
+ for (const node of this.nodes) node.__removeChild(this);
61
+ super.__detach();
62
+ }
63
+ };
64
+ export { AnimatedObject, animatedNodesIn, isPlainObject };
65
+
66
+ //# sourceMappingURL=AnimatedObject.js.map