@lynx-js/lynx-ui-common 3.135.3 → 3.135.4
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.
- package/CHANGELOG.md +6 -0
- package/dist/const/BaseScrollEventsMapping.jsx.map +1 -1
- package/dist/const/BaseUIEventsMapping.jsx.map +1 -1
- package/dist/hooks/docs/useBounce.jsx +1 -0
- package/dist/hooks/docs/useRefresh.jsx +1 -0
- package/dist/hooks/index.jsx +9 -9
- package/dist/hooks/index.jsx.map +1 -1
- package/dist/hooks/useGCCollector.jsx.map +1 -1
- package/dist/hooks/useGlobalEventListener.jsx.map +1 -1
- package/dist/hooks/useLatest.jsx.map +1 -1
- package/dist/hooks/useMemoizedFn.jsx.map +1 -1
- package/dist/hooks/usePreCommit.jsx.map +1 -1
- package/dist/hooks/usePrevious.jsx.map +1 -1
- package/dist/hooks/useRegisteredEvents.jsx.map +1 -1
- package/dist/hooks/useUnmount.jsx.map +1 -1
- package/dist/index.jsx +2 -3
- package/dist/reactive/hooks/useReactiveValue.jsx.map +1 -1
- package/dist/reactive/hooks/useReactiveValueChange.jsx.map +1 -1
- package/dist/reactive/hooks/useReactiveValueEvent.jsx.map +1 -1
- package/dist/reactive/index.jsx +4 -5
- package/dist/reactive/types.jsx +1 -0
- package/dist/reactive/updateReactive.jsx.map +1 -1
- package/dist/types/index.jsx +1 -0
- package/dist/types/interfaces/BaseScrollEvents.jsx +1 -0
- package/dist/types/interfaces/BaseUIEvents.jsx +1 -0
- package/dist/types/interfaces/BaseUIProps.jsx +1 -0
- package/dist/types/interfaces/EventMTSInterface.jsx +1 -0
- package/dist/types/interfaces/LazyInterface.jsx +1 -0
- package/dist/types/interfaces/index.jsx +1 -0
- package/dist/utils/areDepsEqual.jsx.map +1 -1
- package/dist/utils/common.jsx.map +1 -1
- package/dist/utils/common.test.jsx.map +1 -1
- package/dist/utils/convertToPx.jsx.map +1 -1
- package/dist/utils/delayFrames.jsx.map +1 -1
- package/dist/utils/getEventDetail.jsx.map +1 -1
- package/dist/utils/index.jsx +6 -7
- package/dist/utils/interpolation.jsx +2 -2
- package/dist/utils/interpolation.jsx.map +1 -1
- package/dist/utils/interpolationJS.jsx +1 -1
- package/dist/utils/interpolationJS.jsx.map +1 -1
- package/dist/utils/log.jsx.map +1 -1
- package/dist/utils/mainThreadify.jsx.map +1 -1
- package/dist/utils/popoverUtils.jsx.map +1 -1
- package/dist/utils/renderContentWithExtraProps.jsx.map +1 -1
- package/dist/utils/selector.jsx.map +1 -1
- package/dist/utils/selector.test.jsx.map +1 -1
- package/dist/utils/version.jsx.map +1 -1
- package/dist/utils/version.test.jsx.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const/BaseScrollEventsMapping.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"const/BaseScrollEventsMapping.jsx","sources":["../../src/const/BaseScrollEventsMapping.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const ScrollEventsMapping: Record<string, string> = {\n onScroll: 'bindscroll',\n onScrollStateChange: 'bindscrollstatechange',\n onScrollToLower: 'bindscrolltolower',\n onScrollToUpper: 'bindscrolltoupper',\n onScrollEnd: 'bindscrollend',\n onScrollToUpperEdge: 'bindscrolltoupperedge',\n onScrollToLowerEdge: 'bindscrolltoloweredge',\n onScrollToNormalState: 'bindscrolltonormalstate',\n}\n"],"names":["ScrollEventsMapping"],"mappings":"AAIO,MAAMA,sBAA8C;IACzD,UAAU;IACV,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,qBAAqB;IACrB,qBAAqB;IACrB,uBAAuB;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const/BaseUIEventsMapping.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"const/BaseUIEventsMapping.jsx","sources":["../../src/const/BaseUIEventsMapping.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const ExposureEventsMapping: Record<string, string> = {\n onUIAppear: 'binduiappear',\n onUIDisappear: 'binduidisappear',\n}\nexport const LayoutEventsMapping: Record<string, string> = {\n onLayoutChange: 'bindlayoutchange',\n}\nexport const TouchEventsMapping: Record<string, string> = {\n onTouchStart: 'bindtouchstart',\n onTouchMove: 'bindtouchmove',\n onTouchEnd: 'bindtouchend',\n onTouchCancel: 'bindtouchcancel',\n onTouchTap: 'bindtap',\n onLongPress: 'bindlongpress',\n catchTouchStart: 'catchtouchstart',\n catchTouchMove: 'catchtouchmove',\n catchTouchEnd: 'catchtouchend',\n catchTouchCancel: 'catchtouchcancel',\n catchTap: 'catchtap',\n catchLongPress: 'catchlongpress',\n}\n"],"names":["ExposureEventsMapping","LayoutEventsMapping","TouchEventsMapping"],"mappings":"AAIO,MAAMA,wBAAgD;IAC3D,YAAY;IACZ,eAAe;AACjB;AACO,MAAMC,sBAA8C;IACzD,gBAAgB;AAClB;AACO,MAAMC,qBAA6C;IACxD,cAAc;IACd,aAAa;IACb,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,UAAU;IACV,gBAAgB;AAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/hooks/index.jsx
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef } from "@lynx-js/react";
|
|
2
|
-
import { useUnmount } from "./useUnmount.jsx";
|
|
3
|
-
import { useGlobalEventListener } from "./useGlobalEventListener.jsx";
|
|
4
|
-
import { useLatest } from "./useLatest.jsx";
|
|
5
|
-
import { useRegisteredEvents } from "./useRegisteredEvents.jsx";
|
|
6
|
-
import { useMemoizedFn } from "./useMemoizedFn.jsx";
|
|
7
|
-
import { usePrevious } from "./usePrevious.jsx";
|
|
8
|
-
import { supportUsePreCommit, usePreCommit } from "./usePreCommit.jsx";
|
|
9
|
-
import { useGCCollector } from "./useGCCollector.jsx";
|
|
10
2
|
function useFirstRender(cb) {
|
|
11
3
|
const isFirst = useRef(true);
|
|
12
4
|
if (isFirst.current) {
|
|
@@ -67,6 +59,14 @@ function useThrottle(fn, delay, dep = []) {
|
|
|
67
59
|
}
|
|
68
60
|
}, dep);
|
|
69
61
|
}
|
|
70
|
-
export {
|
|
62
|
+
export { useUnmount } from "./useUnmount.jsx";
|
|
63
|
+
export { useGlobalEventListener } from "./useGlobalEventListener.jsx";
|
|
64
|
+
export { useLatest } from "./useLatest.jsx";
|
|
65
|
+
export { useRegisteredEvents } from "./useRegisteredEvents.jsx";
|
|
66
|
+
export { useMemoizedFn } from "./useMemoizedFn.jsx";
|
|
67
|
+
export { usePrevious } from "./usePrevious.jsx";
|
|
68
|
+
export { supportUsePreCommit, usePreCommit } from "./usePreCommit.jsx";
|
|
69
|
+
export { useGCCollector } from "./useGCCollector.jsx";
|
|
70
|
+
export { useFirstRender, useJSFirstRender, useLepusFirstRender, usePersistCallback, useThrottle };
|
|
71
71
|
|
|
72
72
|
//# sourceMappingURL=index.jsx.map
|
package/dist/hooks/index.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/index.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/index.jsx","sources":["../../src/hooks/index.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useCallback, useEffect, useMemo, useRef } from '@lynx-js/react'\n\nexport { useUnmount } from './useUnmount'\nexport { useGlobalEventListener } from './useGlobalEventListener'\nexport { useLatest } from './useLatest'\nexport { useRegisteredEvents } from './useRegisteredEvents'\n\nexport { useMemoizedFn } from './useMemoizedFn'\nexport { usePrevious } from './usePrevious'\nexport { supportUsePreCommit, usePreCommit } from './usePreCommit'\n\nexport function useFirstRender(cb: () => void): boolean {\n const isFirst = useRef(true)\n if (isFirst.current) {\n cb?.()\n isFirst.current = false\n return true\n }\n return isFirst.current\n}\n\nexport function useJSFirstRender(cb: () => void): boolean {\n const isJSFirst = useRef(true)\n if (isJSFirst.current) {\n if (!__LEPUS__) {\n cb?.()\n }\n isJSFirst.current = false\n return true\n }\n return isJSFirst.current\n}\n\nexport function useLepusFirstRender(cb: () => void): boolean {\n const isLepusFirst = useRef(true)\n if (isLepusFirst.current) {\n if (__LEPUS__) {\n cb?.()\n }\n isLepusFirst.current = false\n return true\n }\n return isLepusFirst.current\n}\n\n/**\n * @deprecated use useMemoizedFn instead\n */\nexport function usePersistCallback(fn: (...args: unknown[]) => void) {\n const ref = useRef<(...args: unknown[]) => void>(fn)\n ref.current = useMemo(\n function() {\n return fn\n },\n [fn],\n )\n return useCallback(\n function(...arg: unknown[]) {\n const fnn: (...arg2: unknown[]) => void = ref.current\n typeof ref.current === 'function' && fnn(...arg)\n },\n [ref],\n )\n}\n\nexport { useGCCollector, type UseGCCollectorOptions } from './useGCCollector'\n\nexport function useThrottle(\n fn: (...args: unknown[]) => void,\n delay: number,\n dep = [],\n) {\n const { current } = useRef({ fn, timer: 0 })\n useEffect(\n function() {\n current.fn = fn\n },\n [fn],\n )\n\n return useCallback(function f(...args: unknown[]) {\n if (!current.timer) {\n current.timer = setTimeout(() => {\n current.timer = 0\n }, delay)\n current.fn(...args)\n }\n }, dep)\n}\n"],"names":["useFirstRender","cb","isFirst","useRef","useJSFirstRender","isJSFirst","__LEPUS__","useLepusFirstRender","isLepusFirst","usePersistCallback","fn","ref","useMemo","useCallback","arg","fnn","useThrottle","delay","dep","current","useEffect","args","setTimeout"],"mappings":";AAeO,SAASA,eAAeC,EAAc;IAC3C,MAAMC,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
+
{"version":3,"file":"hooks/useGCCollector.jsx","sources":["../../src/hooks/useGCCollector.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { runOnMainThread, useEffect, useRef } from '@lynx-js/react'\n\nimport { useMemoizedFn } from './useMemoizedFn'\n\nexport interface UseGCCollectorOptions {\n /** GC trigger interval time in milliseconds, default 1000ms */\n interval?: number\n /** Whether to enable periodic GC, default true */\n enabled?: boolean\n}\n\n/**\n * Hook for periodic garbage collection\n * @param options Configuration options\n * @returns Control function object\n */\nexport function useGCCollector(options: UseGCCollectorOptions = {}) {\n const { interval = 3000, enabled = true } = options\n const timeRef = useRef<number | null>(null)\n\n const triggerGCMT = () => {\n 'main thread'\n const globalScope = globalThis as unknown as { lepusng_gc?: () => void }\n if (typeof globalScope.lepusng_gc === 'function') {\n globalScope.lepusng_gc()\n }\n }\n\n const requestTimeout = useMemoizedFn(() => {\n if (enabled) {\n timeRef.current = setTimeout(() => {\n requestTimeout()\n runOnMainThread(triggerGCMT)()\n }, interval)\n }\n })\n\n const start = useMemoizedFn(() => {\n if (timeRef.current === null) {\n requestTimeout()\n }\n })\n\n const stop = useMemoizedFn(() => {\n if (timeRef.current !== null) {\n clearTimeout(timeRef.current)\n timeRef.current = null\n }\n })\n\n const restart = useMemoizedFn(() => {\n stop()\n start()\n })\n\n useEffect(() => {\n if (enabled) {\n start()\n }\n\n return () => {\n stop()\n }\n }, [enabled, interval])\n\n return {\n start,\n stop,\n restart,\n triggerGCMT,\n }\n}\n"],"names":["useGCCollector","options","interval","enabled","timeRef","useRef","triggerGCMT","globalScope","globalThis","requestTimeout","useMemoizedFn","setTimeout","runOnMainThread","start","stop","clearTimeout","restart","useEffect"],"mappings":";;AAoBO,SAASA,eAAeC,UAAiC,CAAC,CAAC;IAChE,MAAM,EAAEC,WAAW,IAAI,EAAEC,UAAU,IAAI,EAAE,GAAGF;IAC5C,MAAMG,UAAUC,OAAsB;IAEtC,MAAMC,cAAc;QAClB;QACA,MAAMC,cAAcC;QACpB,IAAI,AAAkC,cAAlC,OAAOD,YAAY,UAAU,EAC/BA,YAAY,UAAU;IAE1B;IAEA,MAAME,iBAAiBC,cAAc;QACnC,IAAIP,SACFC,QAAQ,OAAO,GAAGO,WAAW;YAC3BF;YACAG,gBAAgBN;QAClB,GAAGJ;IAEP;IAEA,MAAMW,QAAQH,cAAc;QAC1B,IAAIN,AAAoB,SAApBA,QAAQ,OAAO,EACjBK;IAEJ;IAEA,MAAMK,OAAOJ,cAAc;QACzB,IAAIN,AAAoB,SAApBA,QAAQ,OAAO,EAAW;YAC5BW,aAAaX,QAAQ,OAAO;YAC5BA,QAAQ,OAAO,GAAG;QACpB;IACF;IAEA,MAAMY,UAAUN,cAAc;QAC5BI;QACAD;IACF;IAEAI,UAAU;QACR,IAAId,SACFU;QAGF,OAAO;YACLC;QACF;IACF,GAAG;QAACX;QAASD;KAAS;IAEtB,OAAO;QACLW;QACAC;QACAE;QACAV;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useGlobalEventListener.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/useGlobalEventListener.jsx","sources":["../../src/hooks/useGlobalEventListener.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useCallback, useEffect, useMemo } from '@lynx-js/react'\n\n// biome-ignore lint/suspicious/noExplicitAny: generic type definition\ntype noop = (...p: any) => void\n\n/**\n * Use this hook to register events\n * Events will be registered at first render, preventing possible message missing.\n * When deps updates, handlerFunc will be updated, old event listener will be removed.\n */\nexport function useGlobalEventListener(\n eventName: string,\n handler: noop,\n deps?: readonly unknown[],\n) {\n const handlerFunc = useCallback(handler, deps ?? [])\n\n /**\n * We use useMemo to make it only run one time\n * useMemo will run at render.\n * If dependency changes, useMemo will rerun to have correct handlerFunc\n * then a new listener will be added with correct handlerFunc\n */\n useMemo(() => {\n if (!__LEPUS__) {\n lynx\n .getJSModule('GlobalEventEmitter')\n .addListener(eventName, handlerFunc)\n }\n }, [eventName, handlerFunc])\n\n /**\n * We use return value of useEffect to removeListener\n * Dependency is just the same as `useMemo` above\n * If dependency changes, useEffect's cleaning up func will be run, which is essentially\n * the cleaning up func of `addListener` run at useMemo\n */\n useEffect(\n () => () => {\n lynx\n .getJSModule('GlobalEventEmitter')\n .removeListener(eventName, handlerFunc)\n },\n [eventName, handlerFunc],\n )\n}\n"],"names":["useGlobalEventListener","eventName","handler","deps","handlerFunc","useCallback","useMemo","__LEPUS__","lynx","useEffect"],"mappings":";AAcO,SAASA,uBACdC,SAAiB,EACjBC,OAAa,EACbC,IAAyB;IAEzB,MAAMC,cAAcC,YAAYH,SAASC,QAAQ,EAAE;IAQnDG,QAAQ;QACN,IAAI,CAACC,WACHC,KACG,WAAW,CAAC,sBACZ,WAAW,CAACP,WAAWG;IAE9B,GAAG;QAACH;QAAWG;KAAY;IAQ3BK,UACE,IAAM;YACJD,KACG,WAAW,CAAC,sBACZ,cAAc,CAACP,WAAWG;QAC/B,GACA;QAACH;QAAWG;KAAY;AAE5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useLatest.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/useLatest.jsx","sources":["../../src/hooks/useLatest.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useRef } from '@lynx-js/react'\n\n/**\n * `useLatest` will be useful when you are facing dependency hell.\n * Or you want always-update ref\n */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value)\n ref.current = value\n\n return ref\n}\n"],"names":["useLatest","value","ref","useRef"],"mappings":";AAUO,SAASA,UAAaC,KAAQ;IACnC,MAAMC,MAAMC,OAAOF;IACnBC,IAAI,OAAO,GAAGD;IAEd,OAAOC;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useMemoizedFn.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/useMemoizedFn.jsx","sources":["../../src/hooks/useMemoizedFn.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo, useRef } from '@lynx-js/react'\n\n// biome-ignore lint/suspicious/noExplicitAny: generic type definition\ntype noop = (this: any, ...args: any[]) => any\n\ntype PickFunction<T extends noop> = (\n this: ThisParameterType<T>,\n ...args: Parameters<T>\n) => ReturnType<T>\n\n/**\n * Hooks for persistent functions. In general, useMemoizedFn can be used instead of useCallback.\n * In some scenarios, we need to use useCallback to cache a function, but when the second parameter deps changes, the function will be regenerated, causing the function reference to change.\n */\nfunction useMemoizedFn<T extends noop>(fn: T) {\n const fnRef = useRef<T>(fn)\n\n // why not write `fnRef.current = fn`?\n // https://github.com/alibaba/hooks/issues/728\n fnRef.current = useMemo<T>(() => fn, [fn])\n\n const memoizedFn = useRef<PickFunction<T>>()\n memoizedFn.current ??= function(this, ...args) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return fnRef.current.apply(this, args)\n }\n\n return memoizedFn.current as unknown as T\n}\n\nexport { useMemoizedFn }\n"],"names":["useMemoizedFn","fn","fnRef","useRef","useMemo","memoizedFn","args"],"mappings":";AAkBA,SAASA,cAA8BC,EAAK;IAC1C,MAAMC,QAAQC,OAAUF;IAIxBC,MAAM,OAAO,GAAGE,QAAW,IAAMH,IAAI;QAACA;KAAG;IAEzC,MAAMI,aAAaF;IACnBE,WAAW,OAAO,KAAK,SAAe,GAAGC,IAAI;QAE3C,OAAOJ,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,EAAEI;IACnC;IAEA,OAAOD,WAAW,OAAO;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/usePreCommit.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/usePreCommit.jsx","sources":["../../src/hooks/usePreCommit.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { runOnMainThread, useRef } from '@lynx-js/react'\nimport type { DependencyList } from '@lynx-js/react'\n\nimport {\n runWorkletCtx,\n setEomShouldFlushElementTree,\n} from '@lynx-js/react/worklet-runtime/bindings'\nimport type { Worklet } from '@lynx-js/react/worklet-runtime/bindings'\n\nimport { areDepsEqual } from '../utils/areDepsEqual'\n\ndeclare global {\n var __setEomShouldFlushElementTree: ((value: boolean) => void) | undefined\n var __eomFlushHoldCount: number | undefined\n}\n\nconst setEomShouldFlush = setEomShouldFlushElementTree as unknown as (\n value: boolean,\n) => void\n\nlet eomFlushHoldCount = 0\n\nfunction holdEomFlush() {\n eomFlushHoldCount += 1\n if (eomFlushHoldCount === 1) {\n setEomShouldFlush(false)\n }\n}\n\nfunction releaseEomFlush() {\n if (eomFlushHoldCount === 0) {\n return\n }\n\n eomFlushHoldCount -= 1\n if (eomFlushHoldCount === 0) {\n setEomShouldFlush(true)\n }\n}\n\n/**\n * Use this hack to prevent setEomShouldFlushElementTree being in the MTS closure\n */\nif (__MAIN_THREAD__) {\n globalThis.__setEomShouldFlushElementTree = setEomShouldFlush\n}\n\nexport function supportUsePreCommit() {\n return typeof setEomShouldFlushElementTree === 'function'\n}\n\n/**\n * An experimental hook dedicated to make MTS run on firstScreenPaint\n * Can be used starting from ReactLynx 0.113.0\n * @experimental\n * @param cb A main-thread callback to run on firstScreen\n * @param deps Dependency array - callback only executes when dependencies change\n */\nexport function usePreCommit(cb: () => void, deps?: DependencyList) {\n const prevDepsRef = useRef<DependencyList | undefined>(undefined)\n\n // Check if dependencies have changed\n const depsChanged = !areDepsEqual(prevDepsRef.current, deps)\n\n // Update the previous deps for next render\n prevDepsRef.current = deps\n\n // Only run if dependencies changed\n if (!depsChanged) {\n return\n }\n\n // For the Initial Frame Render\n if (__MAIN_THREAD__) {\n holdEomFlush()\n Promise.resolve().then(() => {\n try {\n runWorkletCtx(cb as unknown as Worklet, [])\n } catch (e) {\n console.error('Error occurred in preCommit hook', e)\n } finally {\n releaseEomFlush()\n }\n })\n } else {\n runOnMainThread(() => {\n 'main thread'\n\n globalThis.__eomFlushHoldCount = (globalThis.__eomFlushHoldCount ?? 0) + 1\n if (globalThis.__eomFlushHoldCount === 1) {\n globalThis.__setEomShouldFlushElementTree?.(false)\n }\n\n try {\n cb()\n } finally {\n globalThis.__eomFlushHoldCount = Math.max(\n (globalThis.__eomFlushHoldCount ?? 1) - 1,\n 0,\n )\n if (globalThis.__eomFlushHoldCount === 0) {\n globalThis.__setEomShouldFlushElementTree?.(true)\n }\n }\n })()\n }\n}\n"],"names":["setEomShouldFlush","setEomShouldFlushElementTree","eomFlushHoldCount","holdEomFlush","releaseEomFlush","__MAIN_THREAD__","globalThis","supportUsePreCommit","usePreCommit","cb","deps","prevDepsRef","useRef","undefined","depsChanged","areDepsEqual","Promise","runWorkletCtx","e","console","runOnMainThread","Math"],"mappings":";;;AAoBA,MAAMA,oBAAoBC;AAI1B,IAAIC,oBAAoB;AAExB,SAASC;IACPD,qBAAqB;IACrB,IAAIA,AAAsB,MAAtBA,mBACFF,kBAAkB;AAEtB;AAEA,SAASI;IACP,IAAIF,AAAsB,MAAtBA,mBACF;IAGFA,qBAAqB;IACrB,IAAIA,AAAsB,MAAtBA,mBACFF,kBAAkB;AAEtB;AAKA,IAAIK,iBACFC,WAAW,8BAA8B,GAAGN;AAGvC,SAASO;IACd,OAAO,AAAwC,cAAxC,OAAON;AAChB;AASO,SAASO,aAAaC,EAAc,EAAEC,IAAqB;IAChE,MAAMC,cAAcC,OAAmCC;IAGvD,MAAMC,cAAc,CAACC,aAAaJ,YAAY,OAAO,EAAED;IAGvDC,YAAY,OAAO,GAAGD;IAGtB,IAAI,CAACI,aACH;IAIF,IAAIT,iBAAiB;QACnBF;QACAa,QAAQ,OAAO,GAAG,IAAI,CAAC;YACrB,IAAI;gBACFC,cAAcR,IAA0B,EAAE;YAC5C,EAAE,OAAOS,GAAG;gBACVC,QAAQ,KAAK,CAAC,oCAAoCD;YACpD,SAAU;gBACRd;YACF;QACF;IACF,OACEgB,gBAAgB;QACd;QAEAd,WAAW,mBAAmB,GAAIA,AAAAA,CAAAA,WAAW,mBAAmB,IAAI,KAAK;QACzE,IAAIA,AAAmC,MAAnCA,WAAW,mBAAmB,EAChCA,WAAW,8BAA8B,GAAG;QAG9C,IAAI;YACFG;QACF,SAAU;YACRH,WAAW,mBAAmB,GAAGe,KAAK,GAAG,CACtCf,AAAAA,CAAAA,WAAW,mBAAmB,IAAI,KAAK,GACxC;YAEF,IAAIA,AAAmC,MAAnCA,WAAW,mBAAmB,EAChCA,WAAW,8BAA8B,GAAG;QAEhD;IACF;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/usePrevious.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/usePrevious.jsx","sources":["../../src/hooks/usePrevious.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useEffect, useRef } from '@lynx-js/react'\n\n/**\n * Tracks previous state of a value.\n *\n * @param value Props, state or any other calculated value.\n * @returns Value from the previous render of the enclosing component.\n *\n * @example\n * function Component() {\n * const [count, setCount] = useState(0);\n * const prevCount = usePrevious(count);\n * // ...\n * return `Now: ${count}, before: ${prevCount}`;\n * }\n */\nexport function usePrevious<T>(value: T): T | undefined {\n // Source: https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state\n const ref = useRef<T>()\n useEffect(() => {\n ref.current = value\n })\n return ref.current\n}\n"],"names":["usePrevious","value","ref","useRef","useEffect"],"mappings":";AAoBO,SAASA,YAAeC,KAAQ;IAErC,MAAMC,MAAMC;IACZC,UAAU;QACRF,IAAI,OAAO,GAAGD;IAChB;IACA,OAAOC,IAAI,OAAO;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useRegisteredEvents.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/useRegisteredEvents.jsx","sources":["../../src/hooks/useRegisteredEvents.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMainThreadRef } from '@lynx-js/react'\n\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport type { TouchEvent } from '@lynx-js/types'\n\nimport { mainThreadifyEventsMapping } from '../utils'\n\n// These standard touch callbacks are registered through useTouchEmulation to fit the base touch-style API for both touch and mouse inputs.\nconst EMULATED_TOUCH_EVENT_NAMES = new Set([\n 'onTouchStart',\n 'onTouchMove',\n 'onTouchEnd',\n 'onTouchCancel',\n])\n\nconst useMainThreadifyEvents = (\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n events: Record<string, any>,\n mainThreadEvents: Record<string, string>, // e.g.: { 'onScroll': bindscroll } -> { 'main-thread:bindscroll': main-thread:bindscroll }\n) => {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n type reducedEventsType = Record<string, any>\n const mainThreadifyEvents: reducedEventsType = {}\n // biome-ignore lint/correctness/noUnusedVariables: <explanation>\n const dummyRef = useMainThreadRef()\n for (const event of Object.keys(events)) {\n if (event in mainThreadEvents) {\n mainThreadifyEvents[mainThreadEvents[event]] = (e: unknown) => {\n 'main thread'\n if (events[event]) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n events[event](e)\n }\n }\n }\n }\n return mainThreadifyEvents\n}\n/**\n * Only bind the events that are passed in and registered in the registeredProps to improve performance.\n * @example\n * ```\n * const XXXOwnedProps: Record<string, string> = {\n * ...ScrollEvents,\n * ...ExposureEventsAndProps,\n * ...TouchEvents,\n * ...LayoutEvents,\n * };\n * const registerProps = useRegisteredEvents(props, XXXOwnedProps);\n * <XXX {...registerProps} />\n *\n * ```\n */\nexport const useRegisteredEvents = (\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n events: Record<string, any>,\n registeredEventsMapping: Record<string, string>,\n) => {\n // biome-ignore lint/suspicious/noExplicitAny: any\n type reducedEventsType = Record<string, any>\n const reducedEvents: reducedEventsType = {}\n for (const event of Object.keys(events)) {\n if (\n event in registeredEventsMapping\n && !EMULATED_TOUCH_EVENT_NAMES.has(event)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n reducedEvents[registeredEventsMapping[event]] = events[event]\n }\n }\n const touchHandlers = useTouchEmulation({\n onTouchStart: events.onTouchStart as\n | ((event: TouchEvent) => void)\n | undefined,\n onTouchMove: events.onTouchMove as\n | ((event: TouchEvent) => void)\n | undefined,\n onTouchEnd: events.onTouchEnd as\n | ((event: TouchEvent) => void)\n | undefined,\n onTouchCancel: events.onTouchCancel as\n | ((event: TouchEvent) => void)\n | undefined,\n })\n const mainThreadifyEvents = mainThreadifyEventsMapping(\n registeredEventsMapping,\n )\n const mainThreadifyEventsContents = useMainThreadifyEvents(\n events,\n mainThreadifyEvents,\n )\n return { ...reducedEvents, ...touchHandlers, ...mainThreadifyEventsContents }\n}\n"],"names":["EMULATED_TOUCH_EVENT_NAMES","Set","useMainThreadifyEvents","events","mainThreadEvents","mainThreadifyEvents","useMainThreadRef","event","Object","e","useRegisteredEvents","registeredEventsMapping","reducedEvents","touchHandlers","useTouchEmulation","mainThreadifyEventsMapping","mainThreadifyEventsContents"],"mappings":";;;AAYA,MAAMA,6BAA6B,IAAIC,IAAI;IACzC;IACA;IACA;IACA;CACD;AAED,MAAMC,yBAAyB,CAE7BC,QACAC;IAIA,MAAMC,sBAAyC,CAAC;IAE/BC;IACjB,KAAK,MAAMC,SAASC,OAAO,IAAI,CAACL,QAC9B,IAAII,SAASH,kBACXC,mBAAmB,CAACD,gBAAgB,CAACG,MAAM,CAAC,GAAG,CAACE;QAC9C;QACA,IAAIN,MAAM,CAACI,MAAM,EAEfJ,MAAM,CAACI,MAAM,CAACE;IAElB;IAGJ,OAAOJ;AACT;AAgBO,MAAMK,sBAAsB,CAEjCP,QACAQ;IAIA,MAAMC,gBAAmC,CAAC;IAC1C,KAAK,MAAML,SAASC,OAAO,IAAI,CAACL,QAC9B,IACEI,SAASI,2BACN,CAACX,2BAA2B,GAAG,CAACO,QAGnCK,aAAa,CAACD,uBAAuB,CAACJ,MAAM,CAAC,GAAGJ,MAAM,CAACI,MAAM;IAGjE,MAAMM,gBAAgBC,kBAAkB;QACtC,cAAcX,OAAO,YAAY;QAGjC,aAAaA,OAAO,WAAW;QAG/B,YAAYA,OAAO,UAAU;QAG7B,eAAeA,OAAO,aAAa;IAGrC;IACA,MAAME,sBAAsBU,2BAC1BJ;IAEF,MAAMK,8BAA8Bd,uBAClCC,QACAE;IAEF,OAAO;QAAE,GAAGO,aAAa;QAAE,GAAGC,aAAa;QAAE,GAAGG,2BAA2B;IAAC;AAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useUnmount.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"hooks/useUnmount.jsx","sources":["../../src/hooks/useUnmount.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useEffect } from '@lynx-js/react'\n\nimport { useLatest } from './useLatest'\n\nexport const useUnmount = (fn: () => void) => {\n const fnRef = useLatest(fn)\n\n useEffect(\n () => () => {\n fnRef.current()\n },\n [],\n )\n}\n"],"names":["useUnmount","fn","fnRef","useLatest","useEffect"],"mappings":";;AAQO,MAAMA,aAAa,CAACC;IACzB,MAAMC,QAAQC,UAAUF;IAExBG,UACE,IAAM;YACJF,MAAM,OAAO;QACf,GACA,EAAE;AAEN"}
|
package/dist/index.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { updateReactiveValue, useReactiveValue, useReactiveValueChange, useReactiveValueEvent } from "./reactive/index.jsx";
|
|
2
|
-
import { useMainThreadImperativeHandle } from "@lynx-js/react-use";
|
|
3
1
|
export * from "./hooks/index.jsx";
|
|
4
2
|
export * from "./utils/index.jsx";
|
|
5
3
|
export * from "./const/index.jsx";
|
|
6
|
-
export { updateReactiveValue,
|
|
4
|
+
export { updateReactiveValue, useReactiveValue, useReactiveValueChange, useReactiveValueEvent } from "./reactive/index.jsx";
|
|
5
|
+
export { useMainThreadImperativeHandle } from "@lynx-js/react-use";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive/hooks/useReactiveValue.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"reactive/hooks/useReactiveValue.jsx","sources":["../../../src/reactive/hooks/useReactiveValue.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { runOnMainThread, useMainThreadRef, useMemo } from '@lynx-js/react'\nimport type { MainThreadRef } from '@lynx-js/react'\n\nimport type {\n ReactiveValueAPI,\n ReactiveValueOptions,\n Subscriber,\n Unsubscribe,\n} from '../types'\n\nexport type ReactiveValue<T> = ReturnType<\n typeof createMainThreadReactiveValue<T>\n>\n\nexport function createMainThreadReactiveValue<T>(\n initialValue: T,\n options: ReactiveValueOptions = {},\n) {\n 'main thread'\n class ReactiveValue<T> implements ReactiveValueAPI<T> {\n _value: T\n _subscribers = new Set<Subscriber<T>>()\n _options: ReactiveValueOptions\n _isDestroyed = false\n\n constructor(initialValue: T, options: ReactiveValueOptions = {}) {\n this._value = initialValue\n this._options = options\n }\n\n get value(): T {\n return this._value\n }\n\n set value(newValue: T) {\n if (this._isDestroyed) return\n\n if (this._value !== newValue) {\n this._value = newValue\n this._notifySubscribers()\n }\n }\n\n get(): T {\n return this._value\n }\n\n set(newValue: T): void {\n this.value = newValue\n }\n\n subscribe(callback: Subscriber<T>): Unsubscribe {\n // biome-ignore lint/suspicious/noEmptyBlockStatements: As expected\n if (this._isDestroyed) return () => {}\n\n this._subscribers.add(callback)\n\n // Call immediately with current value\n callback(this._value)\n\n return () => this.unsubscribe(callback)\n }\n\n unsubscribe(callback: Subscriber<T>): void {\n this._subscribers.delete(callback)\n }\n\n addListener(callback: Subscriber<T>): Unsubscribe {\n return this.subscribe(callback)\n }\n\n removeListener(callback: Subscriber<T>): void {\n this.unsubscribe(callback)\n }\n\n removeAllListeners(): void {\n this._subscribers.clear()\n }\n\n destroy(): void {\n this._isDestroyed = true\n this._subscribers.clear()\n }\n\n _notifySubscribers(): void {\n if (this._isDestroyed) return\n\n for (const subscriber of this._subscribers) {\n try {\n subscriber(this._value)\n } catch (error) {\n if (this._options.debug) {\n console.error(\n `[ReactiveValue${\n this._options.label ? ` ${this._options.label}` : ''\n }]: Error in subscriber:`,\n error,\n )\n }\n }\n }\n }\n }\n return new ReactiveValue(initialValue, options)\n}\n\nexport function useReactiveValue<T>(\n initialValue: T,\n options: ReactiveValueOptions = {},\n): MainThreadRef<ReactiveValue<T>> {\n const mtRef = useMainThreadRef<ReactiveValue<T>>({} as ReactiveValue<T>)\n\n function initReactiveValue() {\n 'main thread'\n mtRef.current = createMainThreadReactiveValue(initialValue, options)\n }\n\n useMemo(() => {\n if (__BACKGROUND__) {\n runOnMainThread(initReactiveValue)()\n } else {\n // Kept for preventing tree shaking\n initReactiveValue\n }\n }, [])\n\n return mtRef\n}\n"],"names":["createMainThreadReactiveValue","initialValue","options","ReactiveValue","Set","newValue","callback","subscriber","error","console","useReactiveValue","mtRef","useMainThreadRef","initReactiveValue","useMemo","__BACKGROUND__","runOnMainThread"],"mappings":";AAkBO,SAASA,8BACdC,YAAe,EACfC,UAAgC,CAAC,CAAC;IAElC;IACA,MAAMC;QACJ,OAAS;QACT,eAAe,IAAIC,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I,IAAI,CAAC,QAAQ,CAAC,KAAK,EACrBC,QAAQ,KAAK,CACX,CAAC,cAAc,EACb,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,GACnD,uBAAuB,CAAC,EACzBD;YAGN;QAEJ;IACF;IACA,OAAO,IAAIL,cAAcF,cAAcC;AACzC;AAEO,SAASQ,iBACdT,YAAe,EACfC,UAAgC,CAAC,CAAC;IAElC,MAAMS,QAAQC,iBAAmC,CAAC;IAElD,SAASC;QACP;QACAF,MAAM,OAAO,GAAGX,8BAA8BC,cAAcC;IAC9D;IAEAY,QAAQ;QACN,IAAIC,gBACFC,gBAAgBH;IAKpB,GAAG,EAAE;IAEL,OAAOF;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive/hooks/useReactiveValueChange.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"reactive/hooks/useReactiveValueChange.jsx","sources":["../../../src/reactive/hooks/useReactiveValueChange.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { MainThreadRef } from '@lynx-js/react'\n\nimport { useReactiveValueEvent } from './useReactiveValueEvent'\nimport type { ReactiveValue } from '../hooks/useReactiveValue'\n\nexport function useReactiveValueChange<T>(\n valueRef: MainThreadRef<ReactiveValue<T>>,\n callback: (value: T) => void,\n) {\n return useReactiveValueEvent(valueRef, 'change', callback)\n}\n"],"names":["useReactiveValueChange","valueRef","callback","useReactiveValueEvent"],"mappings":";AASO,SAASA,uBACdC,QAAyC,EACzCC,QAA4B;IAE5B,OAAOC,sBAAsBF,UAAU,UAAUC;AACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive/hooks/useReactiveValueEvent.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"reactive/hooks/useReactiveValueEvent.jsx","sources":["../../../src/reactive/hooks/useReactiveValueEvent.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { runOnMainThread, useEffect } from '@lynx-js/react'\nimport type { MainThreadRef } from '@lynx-js/react'\n\nimport type { ReactiveValue } from '../hooks/useReactiveValue'\nimport type { ReactiveEventName } from '../types'\n\nexport function useReactiveValueEvent<T>(\n valueRef: MainThreadRef<ReactiveValue<T>>,\n event: ReactiveEventName,\n callback: (value: T) => void,\n) {\n function handleEvent() {\n 'main thread'\n valueRef.current?.subscribe?.(callback)\n }\n\n useEffect(() => {\n if (event === 'change') {\n runOnMainThread(handleEvent)()\n }\n }, [valueRef])\n}\n"],"names":["useReactiveValueEvent","valueRef","event","callback","handleEvent","useEffect","runOnMainThread"],"mappings":";AAUO,SAASA,sBACdC,QAAyC,EACzCC,KAAwB,EACxBC,QAA4B;IAE5B,SAASC;QACP;QACAH,SAAS,OAAO,EAAE,YAAYE;IAChC;IAEAE,UAAU;QACR,IAAIH,AAAU,aAAVA,OACFI,gBAAgBF;IAEpB,GAAG;QAACH;KAAS;AACf"}
|
package/dist/reactive/index.jsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { updateReactiveValue, useReactiveValue, useReactiveValueChange, useReactiveValueEvent };
|
|
1
|
+
export { useReactiveValue } from "./hooks/useReactiveValue.jsx";
|
|
2
|
+
export { useReactiveValueEvent } from "./hooks/useReactiveValueEvent.jsx";
|
|
3
|
+
export { useReactiveValueChange } from "./hooks/useReactiveValueChange.jsx";
|
|
4
|
+
export { updateReactiveValue } from "./updateReactive.jsx";
|
package/dist/reactive/types.jsx
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive/updateReactive.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"reactive/updateReactive.jsx","sources":["../../src/reactive/updateReactive.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { MainThreadRef } from '@lynx-js/react'\n\nimport type { ReactiveValue } from './hooks/useReactiveValue'\n\nexport function updateReactiveValue<T>(\n valueRef: MainThreadRef<ReactiveValue<T>>,\n value: T,\n): void {\n 'main thread'\n if (!valueRef.current) return\n valueRef.current.value = value\n}\n"],"names":["updateReactiveValue","valueRef","value"],"mappings":"AAQO,SAASA,oBACdC,QAAyC,EACzCC,KAAQ;IAER;IACA,IAAI,CAACD,SAAS,OAAO,EAAE;IACvBA,SAAS,OAAO,CAAC,KAAK,GAAGC;AAC3B"}
|
package/dist/types/index.jsx
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/areDepsEqual.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/areDepsEqual.jsx","sources":["../../src/utils/areDepsEqual.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { DependencyList } from '@lynx-js/react'\n\n/**\n * Compares two dependency arrays\n */\nexport function areDepsEqual(\n prevDeps: DependencyList | undefined,\n nextDeps: DependencyList | undefined,\n): boolean {\n if (prevDeps === undefined || nextDeps === undefined) {\n return false\n }\n if (prevDeps.length !== nextDeps.length) {\n return false\n }\n for (let i = 0; i < prevDeps.length; i++) {\n if (!Object.is(prevDeps[i], nextDeps[i])) {\n return false\n }\n }\n return true\n}\n"],"names":["areDepsEqual","prevDeps","nextDeps","undefined","i","Object"],"mappings":"AASO,SAASA,aACdC,QAAoC,EACpCC,QAAoC;IAEpC,IAAID,AAAaE,WAAbF,YAA0BC,AAAaC,WAAbD,UAC5B,OAAO;IAET,IAAID,SAAS,MAAM,KAAKC,SAAS,MAAM,EACrC,OAAO;IAET,IAAK,IAAIE,IAAI,GAAGA,IAAIH,SAAS,MAAM,EAAEG,IACnC,IAAI,CAACC,OAAO,EAAE,CAACJ,QAAQ,CAACG,EAAE,EAAEF,QAAQ,CAACE,EAAE,GACrC,OAAO;IAGX,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/common.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/common.jsx","sources":["../../src/utils/common.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nfunction _basePath(path: unknown[] | string) {\n if (Array.isArray(path)) {\n return path\n }\n return path.replace(/\\[/g, '.').replace(/\\]/g, '').split('.')\n}\n\n/**\n * Lodash like get, accessing object by path. Otherwise return defaultValue\n * Where path can be 'a[0].b.c', 'a.0.b.c' or ['a','0','b','c']\n * @param obj Object to get property from\n * @param path Path of property\n * @param defaultValue Optional. Default value\n * @returns\n */\nexport function get(obj: unknown, path: string, defaultValue?: unknown) {\n if (typeof obj !== 'object') {\n return defaultValue\n }\n // @ts-expect-error: o is unknown\n return _basePath(path).reduce((o: unknown, k: string) => o?.[k], obj)\n ?? defaultValue\n}\n\n/**\n * Empty function that does nothing.\n * Useful as a default callback or placeholder function.\n */\nexport const noop = (): void => {\n // Intentionally empty\n}\n"],"names":["_basePath","path","Array","get","obj","defaultValue","o","k","noop"],"mappings":"AAIA,SAASA,UAAUC,IAAwB;IACzC,IAAIC,MAAM,OAAO,CAACD,OAChB,OAAOA;IAET,OAAOA,KAAK,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;AAC3D;AAUO,SAASE,IAAIC,GAAY,EAAEH,IAAY,EAAEI,YAAsB;IACpE,IAAI,AAAe,YAAf,OAAOD,KACT,OAAOC;IAGT,OAAOL,UAAUC,MAAM,MAAM,CAAC,CAACK,GAAYC,IAAcD,GAAG,CAACC,EAAE,EAAEH,QAC5DC;AACP;AAMO,MAAMG,OAAO,KAEpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/common.test.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/common.test.jsx","sources":["../../src/utils/common.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect } from 'vitest'\nimport { get, noop } from './common'\n\ndescribe('common utils', () => {\n describe('get', () => {\n const testObj = {\n a: {\n b: {\n c: 'value',\n },\n arr: [{ nested: 'array-value' }],\n },\n nullValue: null,\n undefinedValue: undefined,\n }\n\n it('should return value for dot notation path', () => {\n expect(get(testObj, 'a.b.c')).toBe('value')\n })\n\n it('should return value for bracket notation path', () => {\n expect(get(testObj, 'a[b][c]')).toBe('value')\n })\n\n it('should return value for array index path', () => {\n expect(get(testObj, 'a.arr[0].nested')).toBe('array-value')\n expect(get(testObj, 'a.arr.0.nested')).toBe('array-value')\n })\n\n it('should return default value when path does not exist', () => {\n expect(get(testObj, 'a.b.d', 'default')).toBe('default')\n expect(get(testObj, 'x.y.z', 'default')).toBe('default')\n })\n\n it('should return undefined when no default value is provided and path does not exist', () => {\n expect(get(testObj, 'a.b.d')).toBeUndefined()\n })\n\n it('should handle null and undefined values', () => {\n expect(get(testObj, 'nullValue.something', 'default')).toBe('default')\n expect(get(testObj, 'undefinedValue.something', 'default')).toBe(\n 'default',\n )\n })\n\n it('should return default value when input is not an object', () => {\n expect(get(null, 'any.path', 'default')).toBe('default')\n expect(get(undefined, 'any.path', 'default')).toBe('default')\n expect(get('string', 'any.path', 'default')).toBe('default')\n expect(get(123, 'any.path', 'default')).toBe('default')\n })\n })\n\n describe('noop', () => {\n it('should be a function that returns undefined', () => {\n expect(typeof noop).toBe('function')\n expect(noop()).toBeUndefined()\n })\n })\n})\n"],"names":["describe","testObj","undefined","it","expect","get","noop"],"mappings":";;AAOAA,SAAS,gBAAgB;IACvBA,SAAS,OAAO;QACd,MAAMC,UAAU;YACd,GAAG;gBACD,GAAG;oBACD,GAAG;gBACL;gBACA,KAAK;oBAAC;wBAAE,QAAQ;oBAAc;iBAAE;YAClC;YACA,WAAW;YACX,gBAAgBC;QAClB;QAEAC,GAAG,6CAA6C;YAC9CC,OAAOC,IAAIJ,SAAS,UAAU,IAAI,CAAC;QACrC;QAEAE,GAAG,iDAAiD;YAClDC,OAAOC,IAAIJ,SAAS,YAAY,IAAI,CAAC;QACvC;QAEAE,GAAG,4CAA4C;YAC7CC,OAAOC,IAAIJ,SAAS,oBAAoB,IAAI,CAAC;YAC7CG,OAAOC,IAAIJ,SAAS,mBAAmB,IAAI,CAAC;QAC9C;QAEAE,GAAG,wDAAwD;YACzDC,OAAOC,IAAIJ,SAAS,SAAS,YAAY,IAAI,CAAC;YAC9CG,OAAOC,IAAIJ,SAAS,SAAS,YAAY,IAAI,CAAC;QAChD;QAEAE,GAAG,qFAAqF;YACtFC,OAAOC,IAAIJ,SAAS,UAAU,aAAa;QAC7C;QAEAE,GAAG,2CAA2C;YAC5CC,OAAOC,IAAIJ,SAAS,uBAAuB,YAAY,IAAI,CAAC;YAC5DG,OAAOC,IAAIJ,SAAS,4BAA4B,YAAY,IAAI,CAC9D;QAEJ;QAEAE,GAAG,2DAA2D;YAC5DC,OAAOC,IAAI,MAAM,YAAY,YAAY,IAAI,CAAC;YAC9CD,OAAOC,IAAIH,QAAW,YAAY,YAAY,IAAI,CAAC;YACnDE,OAAOC,IAAI,UAAU,YAAY,YAAY,IAAI,CAAC;YAClDD,OAAOC,IAAI,KAAK,YAAY,YAAY,IAAI,CAAC;QAC/C;IACF;IAEAL,SAAS,QAAQ;QACfG,GAAG,+CAA+C;YAChDC,OAAO,OAAOE,MAAM,IAAI,CAAC;YACzBF,OAAOE,QAAQ,aAAa;QAC9B;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/convertToPx.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/convertToPx.jsx","sources":["../../src/utils/convertToPx.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const screenWidth = SystemInfo.pixelWidth / SystemInfo.pixelRatio\nexport const screenHeight = SystemInfo.pixelHeight / SystemInfo.pixelRatio\n\nexport function convertToPx(\n value:\n | `${number}px`\n | `${number}rpx`\n | `${number}vw`\n | `${number}vh`\n | undefined,\n): number | undefined {\n if (!value) {\n return undefined\n }\n const num = Number.parseFloat(value)\n\n const unit = value.slice(String(num).length).trim()\n switch (unit) {\n case 'px':\n return num\n case 'rpx':\n return num * (screenWidth / 750)\n case 'vw':\n return num * (screenWidth / 100)\n case 'vh':\n return num * (screenHeight / 100)\n }\n}\n"],"names":["screenWidth","SystemInfo","screenHeight","convertToPx","value","num","Number","unit","String"],"mappings":"AAIO,MAAMA,cAAcC,WAAW,UAAU,GAAGA,WAAW,UAAU;AACjE,MAAMC,eAAeD,WAAW,WAAW,GAAGA,WAAW,UAAU;AAEnE,SAASE,YACdC,KAKa;IAEb,IAAI,CAACA,OACH;IAEF,MAAMC,MAAMC,OAAO,UAAU,CAACF;IAE9B,MAAMG,OAAOH,MAAM,KAAK,CAACI,OAAOH,KAAK,MAAM,EAAE,IAAI;IACjD,OAAQE;QACN,KAAK;YACH,OAAOF;QACT,KAAK;YACH,OAAOA,AAAOL,cAAc,MAArBK;QACT,KAAK;YACH,OAAOA,AAAOL,cAAc,MAArBK;QACT,KAAK;YACH,OAAOA,AAAOH,eAAe,MAAtBG;IACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/delayFrames.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/delayFrames.jsx","sources":["../../src/utils/delayFrames.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport function delayFrames(frames: number, callback: () => void): void {\n let count = 0\n\n const frameHandler = () => {\n count++\n if (count >= frames) {\n callback()\n } else {\n // (TODO) Currently the requestAnimation has bug on reactLynx 0.109.3. After it fixed, replace lynx.requestAnimationFrame with it.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n lynx.requestAnimationFrame(frameHandler)\n }\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n lynx.requestAnimationFrame(frameHandler)\n}\n"],"names":["delayFrames","frames","callback","count","frameHandler","lynx"],"mappings":"AAIO,SAASA,YAAYC,MAAc,EAAEC,QAAoB;IAC9D,IAAIC,QAAQ;IAEZ,MAAMC,eAAe;QACnBD;QACA,IAAIA,SAASF,QACXC;aAMAG,KAAK,qBAAqB,CAACD;IAE/B;IAIAC,KAAK,qBAAqB,CAACD;AAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/getEventDetail.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/getEventDetail.jsx","sources":["../../src/utils/getEventDetail.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * A type representing event details that may contain layout and positioning information.\n * It includes optional properties for dimensions and coordinates, and allows for other properties.\n */\nexport type EventDetailWithLayout = {\n left?: number\n top?: number\n right?: number\n bottom?: number\n width?: number\n height?: number\n} & Record<string, unknown>\n\n/**\n * Safely retrieves detailed information from an event object.\n * It attempts to access `event.detail` first. If `detail` is not available,\n * it falls back to `event.params`. This is useful for maintaining\n * compatibility across different event structures on different platforms and versions.\n *\n * @param event The event object, which can be of any type.\n * @returns The `detail` or `params` object from the event, or an empty object if neither is found.\n */\nexport function getEventDetail<\n T extends EventDetailWithLayout = EventDetailWithLayout,\n> // biome-ignore lint/suspicious/noExplicitAny: accept any type of events\n(event: any): T {\n if (!event) {\n return {} as T\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return (event.detail ?? event.params ?? {}) as T\n}\n"],"names":["getEventDetail","event"],"mappings":"AA0BO,SAASA,eAGfC,KAAU;IACT,IAAI,CAACA,OACH,OAAO,CAAC;IAGV,OAAQA,MAAM,MAAM,IAAIA,MAAM,MAAM,IAAI,CAAC;AAC3C"}
|
package/dist/utils/index.jsx
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { convertOverlayMode, registerOverlayMode } from "./popoverUtils.jsx";
|
|
2
|
-
import { convertToPx, screenHeight, screenWidth } from "./convertToPx.jsx";
|
|
3
|
-
import { interpolate, interpolateJS } from "./interpolation.jsx";
|
|
4
|
-
import { renderContentWithExtraProps } from "./renderContentWithExtraProps.jsx";
|
|
5
|
-
import { delayFrames } from "./delayFrames.jsx";
|
|
6
|
-
import { getEventDetail } from "./getEventDetail.jsx";
|
|
7
1
|
export * from "./common.jsx";
|
|
8
2
|
export * from "./version.jsx";
|
|
9
3
|
export * from "./selector.jsx";
|
|
10
4
|
export * from "./log.jsx";
|
|
11
5
|
export * from "./mainThreadify.jsx";
|
|
12
|
-
export { convertOverlayMode,
|
|
6
|
+
export { convertOverlayMode, registerOverlayMode } from "./popoverUtils.jsx";
|
|
7
|
+
export { convertToPx, screenHeight, screenWidth } from "./convertToPx.jsx";
|
|
8
|
+
export { interpolate, interpolateJS } from "./interpolation.jsx";
|
|
9
|
+
export { renderContentWithExtraProps } from "./renderContentWithExtraProps.jsx";
|
|
10
|
+
export { delayFrames } from "./delayFrames.jsx";
|
|
11
|
+
export { getEventDetail } from "./getEventDetail.jsx";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { interpolateJS } from "./interpolationJS.jsx";
|
|
2
1
|
var interpolation_Extrapolation = /*#__PURE__*/ function(Extrapolation) {
|
|
3
2
|
Extrapolation["IDENTITY"] = "identity";
|
|
4
3
|
Extrapolation["CLAMP"] = "clamp";
|
|
@@ -81,6 +80,7 @@ function interpolate(x, inputRange, outputRange, type) {
|
|
|
81
80
|
}
|
|
82
81
|
return internalInterpolate(x, narrowedInput, extrapolationConfig);
|
|
83
82
|
}
|
|
84
|
-
export {
|
|
83
|
+
export { interpolateJS } from "./interpolationJS.jsx";
|
|
84
|
+
export { interpolate, interpolation_Extrapolation as Extrapolation };
|
|
85
85
|
|
|
86
86
|
//# sourceMappingURL=interpolation.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/interpolation.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/interpolation.jsx","sources":["../../src/utils/interpolation.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\nimport { interpolateJS } from './interpolationJS'\n\n/**\n * Extrapolation type.\n *\n * @param IDENTITY - Returns the provided value as is.\n * @param CLAMP - Clamps the value to the edge of the output range.\n * @param EXTEND - Predicts the values beyond the output range.\n */\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\n/** Represents the possible values for extrapolation as a string. */\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend'\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number\n rightEdgeInput: number\n leftEdgeOutput: number\n rightEdgeOutput: number\n}\n\n/** Allows to specify extrapolation for left and right edge of the interpolation. */\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string\n extrapolateRight?: Extrapolation | string\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation\n extrapolateRight: Extrapolation\n}\n\n/** Configuration options for extrapolation. */\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined\n\nfunction getVal(\n type: Extrapolation,\n coefficient: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number,\n): number {\n 'main thread'\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x\n case Extrapolation.CLAMP:\n if (coefficient * val < coefficient * leftEdgeOutput) {\n return leftEdgeOutput\n }\n return rightEdgeOutput\n default:\n return val\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'main thread'\n\n return (\n /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n value === Extrapolation.EXTEND\n || value === Extrapolation.CLAMP\n || value === Extrapolation.IDENTITY\n /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */\n )\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'main thread'\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n }\n\n if (!type) {\n return extrapolationConfig\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolation.CLAMP, Extrapolation.EXTEND, Extrapolation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`,\n )\n }\n extrapolationConfig.extrapolateLeft = type\n extrapolationConfig.extrapolateRight = type\n return extrapolationConfig\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft))\n || (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolation.CLAMP, Extrapolation.EXTEND, Extrapolation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`,\n )\n }\n\n Object.assign(extrapolationConfig, type)\n return extrapolationConfig\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig,\n) {\n 'main thread'\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput)\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput)\n const coefficient = rightEdgeOutput >= leftEdgeOutput ? 1 : -1\n\n if (coefficient * val < coefficient * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coefficient,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x,\n )\n } else if (coefficient * val > coefficient * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coefficient,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x,\n )\n }\n\n return val\n}\n\n/**\n * Lets you map a value from one range to another using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to\n * the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the\n * interpolation.\n * @param outputRange - An array of numbers specifying the output range of the\n * interpolation.\n * @param extrapolate - Determines what happens when the `value` goes beyond the\n * `input` range. Defaults to `Extrapolation.EXTEND` -\n * {@link ExtrapolationType}.\n * @returns A mapped value within the output range.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate\n */\nexport function interpolate(\n x: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType,\n): number {\n 'main thread'\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n 'Interpolation input and output ranges should contain at least two values.',\n )\n }\n\n const extrapolationConfig = validateType(type)\n const length = inputRange.length\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: inputRange[0],\n rightEdgeInput: inputRange[1],\n leftEdgeOutput: outputRange[0],\n rightEdgeOutput: outputRange[1],\n }\n if (length > 2) {\n if (x > inputRange[length - 1]) {\n narrowedInput.leftEdgeInput = inputRange[length - 2]\n narrowedInput.rightEdgeInput = inputRange[length - 1]\n narrowedInput.leftEdgeOutput = outputRange[length - 2]\n narrowedInput.rightEdgeOutput = outputRange[length - 1]\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= inputRange[i]) {\n narrowedInput.leftEdgeInput = inputRange[i - 1]\n narrowedInput.rightEdgeInput = inputRange[i]\n narrowedInput.leftEdgeOutput = outputRange[i - 1]\n narrowedInput.rightEdgeOutput = outputRange[i]\n break\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig)\n}\n\nexport { interpolateJS }\n"],"names":["Extrapolation","getVal","type","coefficient","val","leftEdgeOutput","rightEdgeOutput","x","isExtrapolate","value","validateType","extrapolationConfig","Error","Object","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","inputRange","outputRange","length","i"],"mappings":"AAYO,IAAKA,8BAAaA,WAAAA,GAAAA,SAAbA,aAAa;;;;WAAbA;;AAkCZ,SAASC,OACPC,IAAmB,EACnBC,WAAmB,EACnBC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS;IAET;IAEA,OAAQL;QACN,KAAK;YACH,OAAOK;QACT,KAAK;YACH,IAAIJ,cAAcC,MAAMD,cAAc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R,aACAC,KACAC,gBACAC,iBACAC;IAIJ,OAAOH;AACT;AAiBO,SAASe,YACdZ,CAAS,EACTa,UAA6B,EAC7BC,WAA8B,EAC9BnB,IAAwB;IAExB;IACA,IAAIkB,WAAW,MAAM,GAAG,KAAKC,YAAY,MAAM,GAAG,GAChD,MAAM,IAAIT,MACR;IAIJ,MAAMD,sBAAsBD,aAAaR;IACzC,MAAMoB,SAASF,WAAW,MAAM;IAChC,MAAML,gBAA4C;QAChD,eAAeK,UAAU,CAAC,EAAE;QAC5B,gBAAgBA,UAAU,CAAC,EAAE;QAC7B,gBAAgBC,WAAW,CAAC,EAAE;QAC9B,iBAAiBA,WAAW,CAAC,EAAE;IACjC;IACA,IAAIC,SAAS,GACX;QAAA,IAAIf,IAAIa,UAAU,CAACE,SAAS,EAAE,EAAE;YAC9BP,cAAc,aAAa,GAAGK,UAAU,CAACE,SAAS,EAAE;YACpDP,cAAc,cAAc,GAAGK,UAAU,CAACE,SAAS,EAAE;YACrDP,cAAc,cAAc,GAAGM,WAAW,CAACC,SAAS,EAAE;YACtDP,cAAc,eAAe,GAAGM,WAAW,CAACC,SAAS,EAAE;QACzD,OACE,IAAK,IAAIC,IAAI,GAAGA,IAAID,QAAQ,EAAEC,EAC5B,IAAIhB,KAAKa,UAAU,CAACG,EAAE,EAAE;YACtBR,cAAc,aAAa,GAAGK,UAAU,CAACG,IAAI,EAAE;YAC/CR,cAAc,cAAc,GAAGK,UAAU,CAACG,EAAE;YAC5CR,cAAc,cAAc,GAAGM,WAAW,CAACE,IAAI,EAAE;YACjDR,cAAc,eAAe,GAAGM,WAAW,CAACE,EAAE;YAC9C;QACF;IAEJ;IAGF,OAAOT,oBAAoBP,GAAGQ,eAAeJ;AAC/C"}
|
|
@@ -75,6 +75,6 @@ function interpolateJS(x, inputRange, outputRange, type) {
|
|
|
75
75
|
}
|
|
76
76
|
return internalInterpolate(x, narrowedInput, extrapolationConfig);
|
|
77
77
|
}
|
|
78
|
-
export { interpolationJS_Extrapolation as Extrapolation
|
|
78
|
+
export { interpolateJS, interpolationJS_Extrapolation as Extrapolation };
|
|
79
79
|
|
|
80
80
|
//# sourceMappingURL=interpolationJS.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/interpolationJS.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/interpolationJS.jsx","sources":["../../src/utils/interpolationJS.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Extrapolation type.\n *\n * @param IDENTITY - Returns the provided value as is.\n * @param CLAMP - Clamps the value to the edge of the output range.\n * @param EXTEND - Predicts the values beyond the output range.\n */\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\n/** Represents the possible values for extrapolation as a string. */\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend'\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number\n rightEdgeInput: number\n leftEdgeOutput: number\n rightEdgeOutput: number\n}\n\n/** Allows to specify extrapolation for left and right edge of the interpolation. */\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string\n extrapolateRight?: Extrapolation | string\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation\n extrapolateRight: Extrapolation\n}\n\n/** Configuration options for extrapolation. */\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number,\n): number {\n switch (type) {\n case Extrapolation.IDENTITY:\n return x\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput\n }\n return rightEdgeOutput\n default:\n return val\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n return (\n /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n value === Extrapolation.EXTEND\n || value === Extrapolation.CLAMP\n || value === Extrapolation.IDENTITY\n /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */\n )\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n }\n\n if (!type) {\n return extrapolationConfig\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolation.CLAMP, Extrapolation.EXTEND, Extrapolation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`,\n )\n }\n extrapolationConfig.extrapolateLeft = type\n extrapolationConfig.extrapolateRight = type\n return extrapolationConfig\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft))\n || (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolation.CLAMP, Extrapolation.EXTEND, Extrapolation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`,\n )\n }\n\n Object.assign(extrapolationConfig, type)\n return extrapolationConfig\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig,\n) {\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput)\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput)\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x,\n )\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x,\n )\n }\n\n return val\n}\n\n/**\n * Lets you map a value from one range to another using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to\n * the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the\n * interpolation.\n * @param outputRange - An array of numbers specifying the output range of the\n * interpolation.\n * @param extrapolate - Determines what happens when the `value` goes beyond the\n * `input` range. Defaults to `Extrapolation.EXTEND` -\n * {@link ExtrapolationType}.\n * @returns A mapped value within the output range.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate\n */\nexport function interpolateJS(\n x: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType,\n): number {\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n 'Interpolation input and output ranges should contain at least two values.',\n )\n }\n\n const extrapolationConfig = validateType(type)\n const length = inputRange.length\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: inputRange[0],\n rightEdgeInput: inputRange[1],\n leftEdgeOutput: outputRange[0],\n rightEdgeOutput: outputRange[1],\n }\n if (length > 2) {\n if (x > inputRange[length - 1]) {\n narrowedInput.leftEdgeInput = inputRange[length - 2]\n narrowedInput.rightEdgeInput = inputRange[length - 1]\n narrowedInput.leftEdgeOutput = outputRange[length - 2]\n narrowedInput.rightEdgeOutput = outputRange[length - 1]\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= inputRange[i]) {\n narrowedInput.leftEdgeInput = inputRange[i - 1]\n narrowedInput.rightEdgeInput = inputRange[i]\n narrowedInput.leftEdgeOutput = outputRange[i - 1]\n narrowedInput.rightEdgeOutput = outputRange[i]\n break\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig)\n}\n"],"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","isExtrapolate","value","validateType","extrapolationConfig","Error","Object","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolateJS","inputRange","outputRange","length","i"],"mappings":"AAWO,IAAKA,gCAAaA,WAAAA,GAAAA,SAAbA,aAAa;;;;WAAbA;;AAkCZ,SAASC,OACPC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS;IAET,OAAQL;QACN,KAAK;YACH,OAAOK;QACT,KAAK;YACH,IAAIJ,OAAOC,MAAMD,OAAOE,gBACtB,OAAOA;YAET,OAAOC;QACT;YACE,OAAOF;IACX;AACF;AAEA,SAASI,cAAcC,KAAa;IAClC,OAEEA,AAAU,aAAVA,SACGA,AAAU,YAAVA,SACAA,AAAU,eAAVA;AAGP;AAIA,SAASC,aAAaR,IAAuB;IAE3C,MAAMS,sBAAmD;QACvD,iBAAiB;QACjB,kBAAkB;IACpB;IAEA,IAAI,CAACT,MACH,OAAOS;IAGT,IAAI,AAAgB,YAAhB,OAAOT,MAAmB;QAC5B,IAAI,CAACM,cAAcN,OACjB,MAAM,IAAIU,MACR,CAAC;gEACuD,CAAC;QAG7DD,oBAAoB,eAAe,GAAGT;QACtCS,oBAAoB,gBAAgB,GAAGT;QACvC,OAAOS;IACT;IAGA,IACGT,KAAK,eAAe,IAAI,CAACM,cAAcN,KAAK,eAAe,KACxDA,KAAK,gBAAgB,IAAI,CAACM,cAAcN,KAAK,gBAAgB,GAEjE,MAAM,IAAIU,MACR,CAAC;;;;SAIE,CAAC;IAIRC,OAAO,MAAM,CAACF,qBAAqBT;IACnC,OAAOS;AACT;AAEA,SAASG,oBACPP,CAAS,E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OACE,IAAK,IAAIC,IAAI,GAAGA,IAAID,QAAQ,EAAEC,EAC5B,IAAIhB,KAAKa,UAAU,CAACG,EAAE,EAAE;YACtBR,cAAc,aAAa,GAAGK,UAAU,CAACG,IAAI,EAAE;YAC/CR,cAAc,cAAc,GAAGK,UAAU,CAACG,EAAE;YAC5CR,cAAc,cAAc,GAAGM,WAAW,CAACE,IAAI,EAAE;YACjDR,cAAc,eAAe,GAAGM,WAAW,CAACE,EAAE;YAC9C;QACF;IAEJ;IAGF,OAAOT,oBAAoBP,GAAGQ,eAAeJ;AAC/C"}
|
package/dist/utils/log.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/log.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/log.jsx","sources":["../../src/utils/log.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const log = (showLog: boolean, ...data: unknown[]): void => {\n if (showLog) {\n console.info(...data)\n }\n}\n\nexport const mtsLog = (showLog: boolean, ...data: unknown[]): void => {\n 'main thread'\n if (showLog) {\n console.info(...data)\n }\n}\n"],"names":["log","showLog","data","console","mtsLog"],"mappings":"AAIO,MAAMA,MAAM,CAACC,SAAkB,GAAGC;IACvC,IAAID,SACFE,QAAQ,IAAI,IAAID;AAEpB;AAEO,MAAME,SAAS,CAACH,SAAkB,GAAGC;IAC1C;IACA,IAAID,SACFE,QAAQ,IAAI,IAAID;AAEpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/mainThreadify.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/mainThreadify.jsx","sources":["../../src/utils/mainThreadify.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport const mainThreadifyEventsMapping = (\n rawEvents: Record<string, string>,\n) => {\n let mainThreadifyEvents: Record<string, string> = {}\n mainThreadifyEvents = Object.entries(rawEvents).reduce(\n (EventsWithMainThread: Record<string, string>, [key, value]) => {\n EventsWithMainThread[`main-thread:${key}`] = `main-thread:${value}`\n return EventsWithMainThread\n },\n {},\n )\n return mainThreadifyEvents\n}\n"],"names":["mainThreadifyEventsMapping","rawEvents","mainThreadifyEvents","Object","EventsWithMainThread","key","value"],"mappings":"AAIO,MAAMA,6BAA6B,CACxCC;IAEA,IAAIC,sBAA8C,CAAC;IACnDA,sBAAsBC,OAAO,OAAO,CAACF,WAAW,MAAM,CACpD,CAACG,sBAA8C,CAACC,KAAKC,MAAM;QACzDF,oBAAoB,CAAC,CAAC,YAAY,EAAEC,KAAK,CAAC,GAAG,CAAC,YAAY,EAAEC,OAAO;QACnE,OAAOF;IACT,GACA,CAAC;IAEH,OAAOF;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/popoverUtils.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/popoverUtils.jsx","sources":["../../src/utils/popoverUtils.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nconst overlayModeMap = new Map<string, string>()\n\nexport const registerOverlayMode = (\n mode: string,\n controllerName: string,\n): void => {\n overlayModeMap.set(mode, controllerName)\n}\n\nexport const convertOverlayMode = (\n mode: string,\n): string | undefined => {\n if (!mode) {\n return undefined\n }\n // only iOS need this info\n if (overlayModeMap.has(mode)) {\n return overlayModeMap.get(mode)\n }\n return mode\n}\n"],"names":["overlayModeMap","Map","registerOverlayMode","mode","controllerName","convertOverlayMode"],"mappings":"AAIA,MAAMA,iBAAiB,IAAIC;AAEpB,MAAMC,sBAAsB,CACjCC,MACAC;IAEAJ,eAAe,GAAG,CAACG,MAAMC;AAC3B;AAEO,MAAMC,qBAAqB,CAChCF;IAEA,IAAI,CAACA,MACH;IAGF,IAAIH,eAAe,GAAG,CAACG,OACrB,OAAOH,eAAe,GAAG,CAACG;IAE5B,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/renderContentWithExtraProps.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/renderContentWithExtraProps.jsx","sources":["../../src/utils/renderContentWithExtraProps.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ReactNode } from '@lynx-js/react'\n\nexport function renderContentWithExtraProps<T, U = { active: boolean }>(\n extraProps: T,\n renderFunction: ((innerProps: T & U) => ReactNode) | ReactNode,\n) {\n const createContent = (\n extraProps: T,\n renderFunction: (innerProps: T & U) => ReactNode,\n ) =>\n (props: U) => renderFunction({ ...extraProps, ...props })\n\n return typeof renderFunction === 'function'\n ? createContent(extraProps, renderFunction)\n : renderFunction\n}\n"],"names":["renderContentWithExtraProps","extraProps","renderFunction","createContent","props"],"mappings":"AAMO,SAASA,4BACdC,UAAa,EACbC,cAA8D;IAE9D,MAAMC,gBAAgB,CACpBF,YACAC,iBAEF,CAACE,QAAaF,eAAe;gBAAE,GAAGD,UAAU;gBAAE,GAAGG,KAAK;YAAC;IAEvD,OAAO,AAA0B,cAA1B,OAAOF,iBACVC,cAAcF,YAAYC,kBAC1BA;AACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/selector.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/selector.jsx","sources":["../../src/utils/selector.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { RefObject } from '@lynx-js/react'\n\nimport type { AnyObject, MainThread, NodesRef } from '@lynx-js/types'\n\nexport class InvokeRejectError extends Error {\n errorCode: number\n detail?: object | string\n constructor(errorCode: number, errorMsg?: string) {\n super(typeof errorMsg === 'string' ? errorMsg : 'unknown error')\n this.errorCode = errorCode\n this.detail = errorMsg\n }\n}\n\nexport const setNativePropsByRef = (\n ref: RefObject<NodesRef> | undefined,\n // biome-ignore lint/suspicious/noExplicitAny: expected\n props: Record<string, any>,\n) => {\n ref?.current?.setNativeProps(props).exec()\n}\n\nexport const setNativePropsById = (\n id: string,\n // biome-ignore lint/suspicious/noExplicitAny: expected\n props: Record<string, any>,\n) => {\n lynx.createSelectorQuery().select(`#${id}`).setNativeProps(props).exec()\n}\n\nexport const setNativeProps = (\n target: {\n ref?: RefObject<NodesRef>\n id?: string\n },\n // biome-ignore lint/suspicious/noExplicitAny: expected\n props: Record<string, any>,\n) =>\n target.id\n ? setNativePropsById(target.id, props)\n : setNativePropsByRef(target.ref, props)\n\nexport const invokeByRef = (\n ref: RefObject<NodesRef> | undefined,\n method: string,\n params?: AnyObject,\n): Promise<unknown> =>\n new Promise((resolve, reject) => {\n if (!ref?.current) {\n reject(new InvokeRejectError(2, 'no node found for the ref'))\n return\n }\n ref?.current\n ?.invoke({\n method,\n params,\n success: (res) => {\n resolve(res)\n },\n // biome-ignore lint/suspicious/noExplicitAny:expected\n fail: (res: { code: number, data?: any }) => {\n reject(new InvokeRejectError(res.code, JSON.stringify(res.data)))\n },\n })\n .exec()\n })\n\nexport const invokeById = (\n id: string,\n method: string,\n params?: AnyObject,\n): Promise<unknown> =>\n new Promise((resolve, reject) => {\n lynx\n .createSelectorQuery()\n .select(`#${id}`)\n .invoke({\n method,\n params,\n success: (res) => {\n resolve(res)\n },\n // biome-ignore lint/suspicious/noExplicitAny:expected\n fail: (res: { code: number, data?: any }) => {\n reject(new InvokeRejectError(res.code, JSON.stringify(res.data)))\n },\n })\n .exec()\n })\n\nexport const invoke = (\n target: {\n ref?: RefObject<NodesRef>\n id?: string\n },\n method: string,\n params?: AnyObject,\n): Promise<unknown> =>\n target.id\n ? invokeById(target.id, method, params)\n : invokeByRef(target.ref, method, params)\n\nexport interface GetRectPromise {\n left: number\n top: number\n width: number\n height: number\n bottom: number\n right: number\n}\n\nexport const getRectByRef = (\n ref?: RefObject<NodesRef>,\n relativeToScreen = false,\n relativeTo = '',\n): Promise<GetRectPromise> =>\n new Promise((resolve, reject) => {\n invokeByRef(ref, 'boundingClientRect', {\n relativeTo: relativeToScreen ? 'screen' : relativeTo,\n // Match the standard getBoundingClientRect behavior: transforms are\n // included in the returned rect. Keep this enabled by default across\n // platforms to avoid incorrect bounds for transformed nodes, such as\n // scaled views. A few animation-related cases may opt out explicitly.\n androidEnableTransformProps: true,\n iosEnableTransformProps: true,\n harmonyEnableTransformProps: true,\n })\n .then((res) => {\n resolve(\n res as {\n left: number\n top: number\n width: number\n height: number\n bottom: number\n right: number\n },\n )\n })\n .catch((error: InvokeRejectError) => {\n reject(error)\n })\n })\n\nexport const getRootRect = (\n relativeToScreen = false,\n relativeTo = '',\n): Promise<GetRectPromise> =>\n new Promise((resolve, reject) => {\n lynx\n .createSelectorQuery()\n .selectRoot()\n .invoke({\n method: 'boundingClientRect',\n params: {\n relativeTo: relativeToScreen ? 'screen' : relativeTo,\n // Match the standard getBoundingClientRect behavior: transforms are\n // included in the returned rect. Keep this enabled by default across\n // platforms to avoid incorrect bounds for transformed nodes, such as\n // scaled views. A few animation-related cases may opt out explicitly.\n androidEnableTransformProps: true,\n iosEnableTransformProps: true,\n harmonyEnableTransformProps: true,\n },\n success: (res) => {\n resolve(\n res as {\n left: number\n top: number\n width: number\n height: number\n bottom: number\n right: number\n },\n )\n },\n fail: (res: { code: number, data?: object }) => {\n reject(new InvokeRejectError(res.code, JSON.stringify(res.data)))\n },\n })\n .exec()\n })\n\nexport const getRectById = (\n id: string,\n relativeToScreen = false,\n relativeTo = '',\n): Promise<GetRectPromise> =>\n new Promise((resolve, reject) => {\n invokeById(id, 'boundingClientRect', {\n relativeTo: relativeToScreen ? 'screen' : relativeTo,\n // Match the standard getBoundingClientRect behavior: transforms are\n // included in the returned rect. Keep this enabled by default across\n // platforms to avoid incorrect bounds for transformed nodes, such as\n // scaled views. A few animation-related cases may opt out explicitly.\n androidEnableTransformProps: true,\n iosEnableTransformProps: true,\n harmonyEnableTransformProps: true,\n })\n .then((res) => {\n resolve(\n res as {\n left: number\n top: number\n width: number\n height: number\n bottom: number\n right: number\n },\n )\n })\n .catch((error: InvokeRejectError) => {\n reject(error)\n })\n })\n\nexport const getRect = (\n target: {\n ref?: RefObject<NodesRef>\n id?: string\n },\n relativeToScreen = false,\n): Promise<GetRectPromise> =>\n target.id\n ? getRectById(target.id, relativeToScreen)\n : getRectByRef(target.ref, relativeToScreen)\n\nexport const selectorMT: (selector: string) => MainThread.Element | null = (\n selector: string,\n) => {\n 'main thread'\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n\n return lynx.querySelector(`#${selector}`)\n}\n"],"names":["InvokeRejectError","Error","errorCode","errorMsg","setNativePropsByRef","ref","props","setNativePropsById","id","lynx","setNativeProps","target","invokeByRef","method","params","Promise","resolve","reject","res","JSON","invokeById","invoke","getRectByRef","relativeToScreen","relativeTo","error","getRootRect","getRectById","getRect","selectorMT","selector"],"mappings":"AAQO,MAAMA,0BAA0BC;IACrC,UAAiB;IACjB,OAAwB;IACxB,YAAYC,SAAiB,EAAEC,QAAiB,CAAE;QAChD,KAAK,CAAC,AAAoB,YAApB,OAAOA,WAAwBA,WAAW;QAChD,IAAI,CAAC,SAAS,GAAGD;QACjB,IAAI,CAAC,MAAM,GAAGC;IAChB;AACF;AAEO,MAAMC,sBAAsB,CACjCC,KAEAC;IAEAD,KAAK,SAAS,eAAeC,OAAO;AACtC;AAEO,MAAMC,qBAAqB,CAChCC,IAEAF;IAEAG,KAAK,mBAAmB,GAAG,MAAM,CAAC,CAAC,CAAC,EAAED,IAAI,EAAE,cAAc,CAACF,OAAO,IAAI;AACxE;AAEO,MAAMI,iBAAiB,CAC5BC,QAKAL,QAEAK,OAAO,EAAE,GACLJ,mBAAmBI,OAAO,EAAE,EAA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C,SAASC;QACpBR,KACG,mBAAmB,GACnB,UAAU,GACV,MAAM,CAAC;YACN,QAAQ;YACR,QAAQ;gBACN,YAAYc,mBAAmB,WAAWC;gBAK1C,6BAA6B;gBAC7B,yBAAyB;gBACzB,6BAA6B;YAC/B;YACA,SAAS,CAACN;gBACRF,QACEE;YASJ;YACA,MAAM,CAACA;gBACLD,OAAO,IAAIjB,kBAAkBkB,IAAI,IAAI,EAAEC,KAAK,SAAS,CAACD,IAAI,IAAI;YAChE;QACF,GACC,IAAI;IACT;AAEK,MAAMS,cAAc,CACzBnB,IACAe,mBAAmB,KAAK,EACxBC,aAAa,EAAE,GAEf,IAAIT,QAAQ,CAACC,SAASC;QACpBG,WAAWZ,IAAI,sBAAsB;YACnC,YAAYe,mBAAmB,WAAWC;YAK1C,6BAA6B;YAC7B,yBAAyB;YACzB,6BAA6B;QAC/B,GACG,IAAI,CAAC,CAACN;YACLF,QACEE;QASJ,GACC,KAAK,CAAC,CAACO;YACNR,OAAOQ;QACT;IACJ;AAEK,MAAMG,UAAU,CACrBjB,QAIAY,mBAAmB,KAAK,GAExBZ,OAAO,EAAE,GACLgB,YAAYhB,OAAO,EAAE,EAAEY,oBACvBD,aAAaX,OAAO,GAAG,EAAEY;AAExB,MAAMM,aAA8D,CACzEC;IAEA;IAIA,OAAOrB,KAAK,aAAa,CAAC,CAAC,CAAC,EAAEqB,UAAU;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/selector.test.jsx","sources":["webpack://@lynx-js/lynx-ui-common/./src/utils/selector.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect, vi, beforeEach } from 'vitest'\nimport {\n InvokeRejectError,\n setNativePropsByRef,\n setNativePropsById,\n setNativeProps,\n invokeByRef,\n invokeById,\n getRectByRef,\n getRectById,\n getRect,\n} from './selector'\n\n// Mock the global lynx object\nconst mockExec = vi.fn()\nconst mockSelect = vi.fn().mockReturnThis()\nconst mockSetNativeProps = vi.fn().mockReturnThis()\nconst mockInvoke = vi.fn().mockReturnThis()\n\nglobal.lynx = {\n // @ts-expect-error expected\n createSelectorQuery: () => ({\n select: mockSelect,\n setNativeProps: mockSetNativeProps,\n invoke: mockInvoke,\n exec: mockExec,\n }),\n}\n\ndescribe('selector utils', () => {\n beforeEach(() => {\n vi.clearAllMocks()\n })\n\n describe('InvokeRejectError', () => {\n it('should create error with code and message', () => {\n const error = new InvokeRejectError(404, 'Not Found')\n expect(error.errorCode).toBe(404)\n expect(error.message).toBe('Not Found')\n })\n })\n\n describe('setNativeProps functions', () => {\n const testProps = { style: { color: 'red' } }\n\n describe('setNativePropsByRef', () => {\n it('should call setNativeProps with ref', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativePropsByRef(mockRef, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockRef.current.exec).toHaveBeenCalled()\n })\n })\n\n describe('setNativePropsById', () => {\n it('should call setNativeProps with id', () => {\n setNativePropsById('test-id', testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n expect(mockSetNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockExec).toHaveBeenCalled()\n })\n })\n\n describe('setNativeProps', () => {\n it('should use id when available', () => {\n setNativeProps({ id: 'test-id' }, testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n })\n\n it('should use ref when id is not available', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativeProps({ ref: mockRef }, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n })\n })\n })\n\n describe('invoke functions', () => {\n const method = 'testMethod'\n const params = { test: true }\n\n describe('invokeByRef', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(successResponse),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await invokeByRef(mockRef, method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject when no ref current', async () => {\n // @ts-expect-error expected\n await expect(invokeByRef({}, method, params)).rejects.toThrow(\n 'no node found for the ref',\n )\n })\n\n it('should reject on failure', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ fail }) => ({\n exec: () => fail({ code: 500, data: 'error' }),\n })),\n },\n }\n\n // @ts-expect-error expected\n await expect(invokeByRef(mockRef, method, params)).rejects.toThrow()\n })\n })\n\n describe('invokeById', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n mockInvoke.mockImplementation(({ success }) => {\n success(successResponse)\n return { exec: mockExec }\n })\n\n const result = await invokeById('test-id', method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject on failure', async () => {\n mockInvoke.mockImplementation(({ fail }) => {\n fail({ code: 500, data: 'error' })\n return { exec: mockExec }\n })\n\n await expect(invokeById('test-id', method, params)).rejects.toThrow()\n })\n })\n })\n\n describe('getRect functions', () => {\n const mockRect = {\n left: 0,\n top: 0,\n width: 100,\n height: 100,\n }\n\n describe('getRectByRef', () => {\n it('should get rect relative to viewport', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef)\n expect(result).toEqual(mockRect)\n })\n\n it('should get rect relative to screen', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success, params }) => ({\n exec: () => {\n expect(params.relativeTo).toBe('screen')\n success(mockRect)\n },\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef, true)\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRectById', () => {\n it('should get rect by id', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRectById('test-id')\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRect', () => {\n it('should use id when available', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRect({ id: 'test-id' })\n expect(result).toEqual(mockRect)\n })\n\n it('should use ref when id is not available', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRect({ ref: mockRef })\n expect(result).toEqual(mockRect)\n })\n })\n })\n})\n"],"names":["mockExec","vi","mockSelect","mockSetNativeProps","mockInvoke","global","describe","beforeEach","it","error","InvokeRejectError","expect","testProps","mockRef","setNativePropsByRef","setNativePropsById","setNativeProps","method","params","successResponse","success","result","invokeByRef","fail","invokeById","mockRect","getRectByRef","getRectById","getRect"],"mappings":";;AAkBA,MAAMA,WAAWC,GAAG,EAAE;AACtB,MAAMC,aAAaD,GAAG,EAAE,GAAG,cAAc;AACzC,MAAME,qBAAqBF,GAAG,EAAE,GAAG,cAAc;AACjD,MAAMG,aAAaH,GAAG,EAAE,GAAG,cAAc;AAEzCI,OAAO,IAAI,GAAG;IAEZ,qBAAqB,IAAO;YAC1B,QAAQH;YACR,gBAAgBC;YAChB,QAAQC;YACR,MAAMJ;QACR;AACF;AAEAM,SAAS,kBAAkB;IACzBC,WAAW;QACTN,GAAG,aAAa;IAClB;IAEAK,SAAS,qBAAqB;QAC5BE,GAAG,6CAA6C;YAC9C,MAAMC,QAAQ,IAAIC,kBAAkB,KAAK;YACzCC,OAAOF,MAAM,SAAS,EAAE,IAAI,CAAC;YAC7BE,OAAOF,MAAM,OAAO,EAAE,IAAI,CAAC;QAC7B;IACF;IAEAH,SAAS,4BAA4B;QACnC,MAAMM,YAAY;YAAE,OAAO;gBAAE,OAAO;YAAM;QAAE;QAE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BAC5CF,OAAOU,QAAQ,OAAO,CAACI;YACzB;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"utils/selector.test.jsx","sources":["../../src/utils/selector.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect, vi, beforeEach } from 'vitest'\nimport {\n InvokeRejectError,\n setNativePropsByRef,\n setNativePropsById,\n setNativeProps,\n invokeByRef,\n invokeById,\n getRectByRef,\n getRectById,\n getRect,\n} from './selector'\n\n// Mock the global lynx object\nconst mockExec = vi.fn()\nconst mockSelect = vi.fn().mockReturnThis()\nconst mockSetNativeProps = vi.fn().mockReturnThis()\nconst mockInvoke = vi.fn().mockReturnThis()\n\nglobal.lynx = {\n // @ts-expect-error expected\n createSelectorQuery: () => ({\n select: mockSelect,\n setNativeProps: mockSetNativeProps,\n invoke: mockInvoke,\n exec: mockExec,\n }),\n}\n\ndescribe('selector utils', () => {\n beforeEach(() => {\n vi.clearAllMocks()\n })\n\n describe('InvokeRejectError', () => {\n it('should create error with code and message', () => {\n const error = new InvokeRejectError(404, 'Not Found')\n expect(error.errorCode).toBe(404)\n expect(error.message).toBe('Not Found')\n })\n })\n\n describe('setNativeProps functions', () => {\n const testProps = { style: { color: 'red' } }\n\n describe('setNativePropsByRef', () => {\n it('should call setNativeProps with ref', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativePropsByRef(mockRef, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockRef.current.exec).toHaveBeenCalled()\n })\n })\n\n describe('setNativePropsById', () => {\n it('should call setNativeProps with id', () => {\n setNativePropsById('test-id', testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n expect(mockSetNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockExec).toHaveBeenCalled()\n })\n })\n\n describe('setNativeProps', () => {\n it('should use id when available', () => {\n setNativeProps({ id: 'test-id' }, testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n })\n\n it('should use ref when id is not available', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativeProps({ ref: mockRef }, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n })\n })\n })\n\n describe('invoke functions', () => {\n const method = 'testMethod'\n const params = { test: true }\n\n describe('invokeByRef', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(successResponse),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await invokeByRef(mockRef, method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject when no ref current', async () => {\n // @ts-expect-error expected\n await expect(invokeByRef({}, method, params)).rejects.toThrow(\n 'no node found for the ref',\n )\n })\n\n it('should reject on failure', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ fail }) => ({\n exec: () => fail({ code: 500, data: 'error' }),\n })),\n },\n }\n\n // @ts-expect-error expected\n await expect(invokeByRef(mockRef, method, params)).rejects.toThrow()\n })\n })\n\n describe('invokeById', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n mockInvoke.mockImplementation(({ success }) => {\n success(successResponse)\n return { exec: mockExec }\n })\n\n const result = await invokeById('test-id', method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject on failure', async () => {\n mockInvoke.mockImplementation(({ fail }) => {\n fail({ code: 500, data: 'error' })\n return { exec: mockExec }\n })\n\n await expect(invokeById('test-id', method, params)).rejects.toThrow()\n })\n })\n })\n\n describe('getRect functions', () => {\n const mockRect = {\n left: 0,\n top: 0,\n width: 100,\n height: 100,\n }\n\n describe('getRectByRef', () => {\n it('should get rect relative to viewport', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef)\n expect(result).toEqual(mockRect)\n })\n\n it('should get rect relative to screen', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success, params }) => ({\n exec: () => {\n expect(params.relativeTo).toBe('screen')\n success(mockRect)\n },\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef, true)\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRectById', () => {\n it('should get rect by id', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRectById('test-id')\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRect', () => {\n it('should use id when available', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRect({ id: 'test-id' })\n expect(result).toEqual(mockRect)\n })\n\n it('should use ref when id is not available', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRect({ ref: mockRef })\n expect(result).toEqual(mockRect)\n })\n })\n })\n})\n"],"names":["mockExec","vi","mockSelect","mockSetNativeProps","mockInvoke","global","describe","beforeEach","it","error","InvokeRejectError","expect","testProps","mockRef","setNativePropsByRef","setNativePropsById","setNativeProps","method","params","successResponse","success","result","invokeByRef","fail","invokeById","mockRect","getRectByRef","getRectById","getRect"],"mappings":";;AAkBA,MAAMA,WAAWC,GAAG,EAAE;AACtB,MAAMC,aAAaD,GAAG,EAAE,GAAG,cAAc;AACzC,MAAME,qBAAqBF,GAAG,EAAE,GAAG,cAAc;AACjD,MAAMG,aAAaH,GAAG,EAAE,GAAG,cAAc;AAEzCI,OAAO,IAAI,GAAG;IAEZ,qBAAqB,IAAO;YAC1B,QAAQH;YACR,gB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wBAAE,MAAMzB;oBAAS;gBAC1B;gBAEA,MAAMqB,SAAS,MAAMO,QAAQ;oBAAE,IAAI;gBAAU;gBAC7CjB,OAAOU,QAAQ,OAAO,CAACI;YACzB;YAEAjB,GAAG,2CAA2C;gBAC5C,MAAMK,UAAU;oBACd,SAAS;wBACP,QAAQZ,GAAG,EAAE,GAAG,kBAAkB,CAAC,CAAC,EAAEmB,OAAO,EAAE,GAAM;gCACnD,MAAM,IAAMA,QAAQK;4BACtB;oBACF;gBACF;gBAGA,MAAMJ,SAAS,MAAMO,QAAQ;oBAAE,KAAKf;gBAAQ;gBAC5CF,OAAOU,QAAQ,OAAO,CAACI;YACzB;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/version.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/version.jsx","sources":["../../src/utils/version.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport function lynxSDKVersionStringToNumber(lynxSDKVersion: string): number {\n const ver: string[] = lynxSDKVersion.split('.')\n const major: number = Number(ver[0] ? ver[0] : 0) * 10000\n const minor: number = Number(ver[1] ? ver[1] : 0) * 100\n const patch = Number(ver[2] ? ver[2] : 0)\n return major + minor + patch\n}\n\nexport function mtsLynxSDKVersionStringToNumber(\n lynxSDKVersion: string,\n): number {\n 'main thread'\n const ver: string[] = lynxSDKVersion.split('.')\n const major: number = Number(ver[0] ? ver[0] : 0) * 10000\n const minor: number = Number(ver[1] ? ver[1] : 0) * 100\n const patch = Number(ver[2] ? ver[2] : 0)\n return major + minor + patch\n}\n\nexport function nativeLynxSDKVersionGreaterThan(\n lynxSDKVersion: string,\n): boolean {\n return (\n lynxSDKVersionStringToNumber(SystemInfo.lynxSdkVersion)\n > lynxSDKVersionStringToNumber(lynxSDKVersion)\n )\n}\n\nexport function nativeLynxSDKVersionLessThan(lynxSDKVersion: string): boolean {\n return (\n lynxSDKVersionStringToNumber(SystemInfo.lynxSdkVersion)\n < lynxSDKVersionStringToNumber(lynxSDKVersion)\n )\n}\n\nexport function mtsNativeLynxSDKVersionLessThan(\n lynxSDKVersion: string,\n): boolean {\n 'main thread'\n return (\n mtsLynxSDKVersionStringToNumber(\n SystemInfo.engineVersion ?? SystemInfo.lynxSdkVersion,\n )\n < mtsLynxSDKVersionStringToNumber(lynxSDKVersion)\n )\n}\n"],"names":["lynxSDKVersionStringToNumber","lynxSDKVersion","ver","major","Number","minor","patch","mtsLynxSDKVersionStringToNumber","nativeLynxSDKVersionGreaterThan","SystemInfo","nativeLynxSDKVersionLessThan","mtsNativeLynxSDKVersionLessThan"],"mappings":"AAIO,SAASA,6BAA6BC,cAAsB;IACjE,MAAMC,MAAgBD,eAAe,KAAK,CAAC;IAC3C,MAAME,QAAgBC,AAA8B,QAA9BA,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IAC/C,MAAMG,QAAgBD,AAA8B,MAA9BA,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IAC/C,MAAMI,QAAQF,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IACvC,OAAOC,QAAQE,QAAQC;AACzB;AAEO,SAASC,gCACdN,cAAsB;IAEtB;IACA,MAAMC,MAAgBD,eAAe,KAAK,CAAC;IAC3C,MAAME,QAAgBC,AAA8B,QAA9BA,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IAC/C,MAAMG,QAAgBD,AAA8B,MAA9BA,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IAC/C,MAAMI,QAAQF,OAAOF,GAAG,CAAC,EAAE,GAAGA,GAAG,CAAC,EAAE,GAAG;IACvC,OAAOC,QAAQE,QAAQC;AACzB;AAEO,SAASE,gCACdP,cAAsB;IAEtB,OACED,6BAA6BS,WAAW,cAAc,IAClDT,6BAA6BC;AAErC;AAEO,SAASS,6BAA6BT,cAAsB;IACjE,OACED,6BAA6BS,WAAW,cAAc,IAClDT,6BAA6BC;AAErC;AAEO,SAASU,gCACdV,cAAsB;IAEtB;IACA,OACEM,gCACEE,WAAW,aAAa,IAAIA,WAAW,cAAc,IAEnDF,gCAAgCN;AAExC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/version.test.jsx","sources":["
|
|
1
|
+
{"version":3,"file":"utils/version.test.jsx","sources":["../../src/utils/version.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect, beforeEach } from 'vitest'\nimport {\n lynxSDKVersionStringToNumber,\n nativeLynxSDKVersionGreaterThan,\n nativeLynxSDKVersionLessThan,\n} from './version'\n\nfunction createMockSystemInfo(lynxSdkVersion: string): typeof SystemInfo {\n return {\n lynxSdkVersion,\n osVersion: '1.0',\n pixelHeight: 100,\n pixelWidth: 100,\n pixelRatio: 1,\n platform: 'Android',\n runtimeType: 'quickjs',\n }\n}\n\ndescribe('version utils', () => {\n describe('lynxSDKVersionStringToNumber', () => {\n it('should convert version string to number correctly', () => {\n expect(lynxSDKVersionStringToNumber('1.2.3')).toBe(10203)\n expect(lynxSDKVersionStringToNumber('2.0.0')).toBe(20000)\n expect(lynxSDKVersionStringToNumber('0.1.0')).toBe(100)\n })\n\n it('should handle missing version parts', () => {\n expect(lynxSDKVersionStringToNumber('1')).toBe(10000)\n expect(lynxSDKVersionStringToNumber('1.2')).toBe(10200)\n expect(lynxSDKVersionStringToNumber('')).toBe(0)\n })\n\n it('should handle version strings with leading zeros', () => {\n expect(lynxSDKVersionStringToNumber('01.02.03')).toBe(10203)\n })\n\n it('should handle large version numbers', () => {\n expect(lynxSDKVersionStringToNumber('99.99.99')).toBe(999999)\n })\n })\n\n describe('nativeLynxSDKVersionGreaterThan', () => {\n beforeEach(() => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n })\n\n it('should return true when native version is greater', () => {\n global.SystemInfo = createMockSystemInfo('1.2.4')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(true)\n })\n\n it('should return false when native version is equal', () => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false)\n })\n\n it('should return false when native version is less', () => {\n global.SystemInfo = createMockSystemInfo('1.2.2')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false)\n })\n })\n\n describe('nativeLynxSDKVersionLessThan', () => {\n beforeEach(() => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n })\n\n it('should return true when native version is less', () => {\n global.SystemInfo = createMockSystemInfo('1.2.2')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(true)\n })\n\n it('should return false when native version is equal', () => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false)\n })\n\n it('should return false when native version is greater', () => {\n global.SystemInfo = createMockSystemInfo('1.2.4')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false)\n })\n\n it('should handle major version differences', () => {\n global.SystemInfo = createMockSystemInfo('1.0.0')\n expect(nativeLynxSDKVersionLessThan('2.0.0')).toBe(true)\n })\n\n it('should handle minor version differences', () => {\n global.SystemInfo = createMockSystemInfo('1.1.0')\n expect(nativeLynxSDKVersionLessThan('1.2.0')).toBe(true)\n })\n })\n})\n"],"names":["createMockSystemInfo","lynxSdkVersion","describe","it","expect","lynxSDKVersionStringToNumber","beforeEach","global","nativeLynxSDKVersionGreaterThan","nativeLynxSDKVersionLessThan"],"mappings":";;AAWA,SAASA,qBAAqBC,cAAsB;IAClD,OAAO;QACLA;QACA,WAAW;QACX,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,aAAa;IACf;AACF;AAEAC,SAA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UAAU,IAAI,CAAC;QACrD;QAEAN,GAAG,2CAA2C;YAC5CI,OAAO,UAAU,GAAGP,qBAAqB;YACzCI,OAAOK,6BAA6B,UAAU,IAAI,CAAC;QACrD;QAEAN,GAAG,2CAA2C;YAC5CI,OAAO,UAAU,GAAGP,qBAAqB;YACzCI,OAAOK,6BAA6B,UAAU,IAAI,CAAC;QACrD;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-common",
|
|
3
|
-
"version": "3.135.
|
|
3
|
+
"version": "3.135.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"@lynx-js/react-use": "0.2.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@lynx-js/react": "0.
|
|
33
|
-
"@lynx-js/types": "
|
|
34
|
-
"@rslib/core": "
|
|
32
|
+
"@lynx-js/react": "0.123.1",
|
|
33
|
+
"@lynx-js/types": "4.1.0",
|
|
34
|
+
"@rslib/core": "0.23.2",
|
|
35
35
|
"@types/react": "^18.3.8",
|
|
36
|
-
"typescript": "^5.
|
|
36
|
+
"typescript": "^5.8.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@lynx-js/react": ">=0.100.0",
|