@unif/react-native-design 0.31.3 → 0.32.0
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/README.md +6 -0
- package/lib/module/components/ui/Avatar/Avatar.js +2 -1
- package/lib/module/components/ui/Avatar/Avatar.js.map +1 -1
- package/lib/module/components/ui/Avatar/geometry.js +43 -0
- package/lib/module/components/ui/Avatar/geometry.js.map +1 -0
- package/lib/module/components/ui/Avatar/styles.js +1 -41
- package/lib/module/components/ui/Avatar/styles.js.map +1 -1
- package/lib/module/components/ui/AvatarGroup/AvatarGroup.js +1 -1
- package/lib/module/components/ui/AvatarGroup/AvatarGroup.js.map +1 -1
- package/lib/module/components/ui/CircularProgress/CircularProgress.js +14 -25
- package/lib/module/components/ui/CircularProgress/CircularProgress.js.map +1 -1
- package/lib/module/components/ui/CircularProgress/normalizeCircularProgress.js.map +1 -1
- package/lib/module/components/ui/CircularProgress/styles.js +24 -0
- package/lib/module/components/ui/CircularProgress/styles.js.map +1 -0
- package/lib/module/components/ui/Pulse/PulseDot.js +5 -5
- package/lib/module/components/ui/Pulse/PulseDot.js.map +1 -1
- package/lib/module/components/ui/Pulse/constants.js +15 -0
- package/lib/module/components/ui/Pulse/constants.js.map +1 -0
- package/lib/module/components/ui/Pulse/usePulse.js +4 -62
- package/lib/module/components/ui/Pulse/usePulse.js.map +1 -1
- package/lib/module/components/ui/Skeleton/Skeleton.js +6 -2
- package/lib/module/components/ui/Skeleton/Skeleton.js.map +1 -1
- package/lib/module/components/ui/Skeleton/constants.js +9 -0
- package/lib/module/components/ui/Skeleton/constants.js.map +1 -0
- package/lib/module/components/ui/TextField/TextFieldBase.js +21 -4
- package/lib/module/components/ui/TextField/TextFieldBase.js.map +1 -1
- package/lib/module/components/ui/TextField/constants.js +7 -0
- package/lib/module/components/ui/TextField/constants.js.map +1 -0
- package/lib/module/components/ui/TextField/styles.js +10 -2
- package/lib/module/components/ui/TextField/styles.js.map +1 -1
- package/lib/module/components/ui/TextField/useMultilineLayout.js +18 -0
- package/lib/module/components/ui/TextField/useMultilineLayout.js.map +1 -0
- package/lib/module/components/ui/TextField/useMultilineLayout.web.js +44 -0
- package/lib/module/components/ui/TextField/useMultilineLayout.web.js.map +1 -0
- package/lib/module/components/ui/Thumbnail/Thumbnail.js +13 -6
- package/lib/module/components/ui/Thumbnail/Thumbnail.js.map +1 -1
- package/lib/module/components/ui/Thumbnail/constants.js +22 -0
- package/lib/module/components/ui/Thumbnail/constants.js.map +1 -0
- package/lib/module/components/ui/Thumbnail/normalize.js +30 -1
- package/lib/module/components/ui/Thumbnail/normalize.js.map +1 -1
- package/lib/module/components/ui/Thumbnail/styles.js +5 -28
- package/lib/module/components/ui/Thumbnail/styles.js.map +1 -1
- package/lib/module/components/ui/index.js.map +1 -1
- package/lib/module/components/ui/shared/pulse/constants.js +5 -0
- package/lib/module/components/ui/shared/pulse/constants.js.map +1 -0
- package/lib/module/components/ui/{Pulse → shared/pulse}/normalizePulseOptions.js +2 -12
- package/lib/module/components/ui/shared/pulse/normalizePulseOptions.js.map +1 -0
- package/lib/module/components/ui/shared/pulse/types.js +2 -0
- package/lib/module/components/ui/shared/pulse/types.js.map +1 -0
- package/lib/module/components/ui/shared/pulse/usePulseAnimation.js +30 -0
- package/lib/module/components/ui/shared/pulse/usePulseAnimation.js.map +1 -0
- package/lib/module/components/ui/{Pulse → shared/pulse}/usePulseDriver.js +1 -1
- package/lib/module/components/ui/shared/pulse/usePulseDriver.js.map +1 -0
- package/lib/module/components/ui/{Pulse → shared/pulse}/usePulseDriver.web.js +2 -17
- package/lib/module/components/ui/shared/pulse/usePulseDriver.web.js.map +1 -0
- package/lib/typescript/src/components/ui/Avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Avatar/geometry.d.ts +7 -0
- package/lib/typescript/src/components/ui/Avatar/geometry.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Avatar/styles.d.ts +1 -9
- package/lib/typescript/src/components/ui/Avatar/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Avatar/types.d.ts +7 -2
- package/lib/typescript/src/components/ui/Avatar/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/CircularProgress/CircularProgress.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/CircularProgress/normalizeCircularProgress.d.ts +2 -14
- package/lib/typescript/src/components/ui/CircularProgress/normalizeCircularProgress.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/CircularProgress/styles.d.ts +19 -0
- package/lib/typescript/src/components/ui/CircularProgress/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/CircularProgress/types.d.ts +17 -2
- package/lib/typescript/src/components/ui/CircularProgress/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/PulseDot.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/constants.d.ts +4 -0
- package/lib/typescript/src/components/ui/Pulse/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Pulse/types.d.ts +6 -6
- package/lib/typescript/src/components/ui/Pulse/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Pulse/usePulse.d.ts +0 -9
- package/lib/typescript/src/components/ui/Pulse/usePulse.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Skeleton/Skeleton.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Skeleton/constants.d.ts +3 -0
- package/lib/typescript/src/components/ui/Skeleton/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Skeleton/types.d.ts +2 -2
- package/lib/typescript/src/components/ui/Skeleton/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/TextFieldBase.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/constants.d.ts +4 -0
- package/lib/typescript/src/components/ui/TextField/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/styles.d.ts +6 -0
- package/lib/typescript/src/components/ui/TextField/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/types.d.ts +36 -11
- package/lib/typescript/src/components/ui/TextField/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/TextField/useMultilineLayout.d.ts +4 -0
- package/lib/typescript/src/components/ui/TextField/useMultilineLayout.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/TextField/useMultilineLayout.web.d.ts +4 -0
- package/lib/typescript/src/components/ui/TextField/useMultilineLayout.web.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Textarea/types.d.ts +4 -2
- package/lib/typescript/src/components/ui/Textarea/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/constants.d.ts +4 -0
- package/lib/typescript/src/components/ui/Thumbnail/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/Thumbnail/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/normalize.d.ts +2 -6
- package/lib/typescript/src/components/ui/Thumbnail/normalize.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/styles.d.ts +9 -8
- package/lib/typescript/src/components/ui/Thumbnail/styles.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/Thumbnail/types.d.ts +23 -5
- package/lib/typescript/src/components/ui/Thumbnail/types.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/index.d.ts +1 -1
- package/lib/typescript/src/components/ui/index.d.ts.map +1 -1
- package/lib/typescript/src/components/ui/shared/pulse/constants.d.ts +2 -0
- package/lib/typescript/src/components/ui/shared/pulse/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/pulse/normalizePulseOptions.d.ts +7 -0
- package/lib/typescript/src/components/ui/shared/pulse/normalizePulseOptions.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/pulse/types.d.ts +17 -0
- package/lib/typescript/src/components/ui/shared/pulse/types.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/pulse/usePulseAnimation.d.ts +8 -0
- package/lib/typescript/src/components/ui/shared/pulse/usePulseAnimation.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/{Pulse → shared/pulse}/usePulseDriver.d.ts +1 -1
- package/lib/typescript/src/components/ui/shared/pulse/usePulseDriver.d.ts.map +1 -0
- package/lib/typescript/src/components/ui/shared/pulse/usePulseDriver.web.d.ts +7 -0
- package/lib/typescript/src/components/ui/shared/pulse/usePulseDriver.web.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/ui/Avatar/Avatar.tsx +2 -6
- package/src/components/ui/Avatar/geometry.ts +30 -0
- package/src/components/ui/Avatar/styles.ts +2 -30
- package/src/components/ui/Avatar/types.ts +8 -2
- package/src/components/ui/AvatarGroup/AvatarGroup.tsx +1 -1
- package/src/components/ui/CircularProgress/CircularProgress.tsx +20 -26
- package/src/components/ui/CircularProgress/normalizeCircularProgress.ts +7 -15
- package/src/components/ui/CircularProgress/styles.ts +13 -0
- package/src/components/ui/CircularProgress/types.ts +19 -2
- package/src/components/ui/Pulse/PulseDot.tsx +6 -5
- package/src/components/ui/Pulse/constants.ts +14 -0
- package/src/components/ui/Pulse/types.ts +6 -6
- package/src/components/ui/Pulse/usePulse.ts +4 -81
- package/src/components/ui/Skeleton/Skeleton.tsx +6 -6
- package/src/components/ui/Skeleton/constants.ts +8 -0
- package/src/components/ui/Skeleton/types.ts +2 -2
- package/src/components/ui/TextField/TextFieldBase.tsx +28 -4
- package/src/components/ui/TextField/constants.ts +6 -0
- package/src/components/ui/TextField/styles.ts +8 -2
- package/src/components/ui/TextField/types.ts +41 -11
- package/src/components/ui/TextField/useMultilineLayout.ts +20 -0
- package/src/components/ui/TextField/useMultilineLayout.web.ts +59 -0
- package/src/components/ui/Textarea/types.ts +9 -6
- package/src/components/ui/Thumbnail/Thumbnail.tsx +19 -5
- package/src/components/ui/Thumbnail/constants.ts +24 -0
- package/src/components/ui/Thumbnail/index.ts +1 -0
- package/src/components/ui/Thumbnail/normalize.ts +38 -19
- package/src/components/ui/Thumbnail/styles.ts +6 -17
- package/src/components/ui/Thumbnail/types.ts +27 -5
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/shared/pulse/constants.ts +2 -0
- package/src/components/ui/shared/pulse/normalizePulseOptions.ts +48 -0
- package/src/components/ui/shared/pulse/types.ts +18 -0
- package/src/components/ui/shared/pulse/usePulseAnimation.ts +29 -0
- package/src/components/ui/{Pulse → shared/pulse}/usePulseDriver.ts +2 -2
- package/src/components/ui/{Pulse → shared/pulse}/usePulseDriver.web.ts +4 -19
- package/lib/module/components/ui/Pulse/normalizePulseOptions.js.map +0 -1
- package/lib/module/components/ui/Pulse/usePulseDriver.js.map +0 -1
- package/lib/module/components/ui/Pulse/usePulseDriver.web.js.map +0 -1
- package/lib/typescript/src/components/ui/Pulse/normalizePulseOptions.d.ts +0 -32
- package/lib/typescript/src/components/ui/Pulse/normalizePulseOptions.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.d.ts.map +0 -1
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.web.d.ts +0 -18
- package/lib/typescript/src/components/ui/Pulse/usePulseDriver.web.d.ts.map +0 -1
- package/src/components/ui/Pulse/normalizePulseOptions.ts +0 -76
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import type { createLogger } from '../../../../utils/logger';
|
|
3
|
+
import type { PulseOptions } from '../../Pulse/types';
|
|
4
|
+
import type { PulseDefaults } from './types';
|
|
5
|
+
import { normalizePulseOptions } from './normalizePulseOptions';
|
|
6
|
+
import { usePulseDriver } from './usePulseDriver';
|
|
7
|
+
|
|
8
|
+
/** 共享参数解释与平台驱动;默认值和诊断 scope 由所属组件交付。 */
|
|
9
|
+
export function usePulseAnimation(
|
|
10
|
+
{ duration, delay, from, to }: PulseOptions = {},
|
|
11
|
+
defaults: Readonly<PulseDefaults>,
|
|
12
|
+
log: ReturnType<typeof createLogger>
|
|
13
|
+
) {
|
|
14
|
+
// 各组件交付自己的固定默认值;内联 options 的新引用不重启动效。
|
|
15
|
+
const normalized = useMemo(
|
|
16
|
+
() => normalizePulseOptions({ duration, delay, from, to }, defaults),
|
|
17
|
+
[duration, delay, from, to, defaults]
|
|
18
|
+
);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (__DEV__) {
|
|
21
|
+
for (const item of normalized.diagnostics) {
|
|
22
|
+
log.warn(
|
|
23
|
+
`${item.field}=${String(item.received)} 无效,已回退为 ${item.fallback}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [normalized.diagnostics, log]);
|
|
28
|
+
return usePulseDriver(normalized);
|
|
29
|
+
}
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
withSequence,
|
|
9
9
|
withTiming,
|
|
10
10
|
} from 'react-native-reanimated';
|
|
11
|
-
import { usePrefersReducedMotion } from '
|
|
11
|
+
import { usePrefersReducedMotion } from '../../../../theme';
|
|
12
12
|
import { shouldAnimatePulse } from './normalizePulseOptions';
|
|
13
|
-
import type { NormalizedPulseOptions } from './
|
|
13
|
+
import type { NormalizedPulseOptions } from './types';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* native Pulse driver —— reanimated 4 worklet,整个动画在 UI 线程跑、不占 JS 桥。
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { usePrefersReducedMotion } from '../../../theme';
|
|
2
|
+
import { usePrefersReducedMotion } from '../../../../theme';
|
|
4
3
|
import { shouldAnimatePulse } from './normalizePulseOptions';
|
|
5
|
-
import type { NormalizedPulseOptions } from './
|
|
4
|
+
import type { NormalizedPulseOptions } from './types';
|
|
6
5
|
|
|
7
|
-
/**
|
|
8
|
-
* Web Pulse driver —— RN-Web 上 reanimated 的 `useAnimatedStyle` 链路会在
|
|
9
|
-
* `_updatePropsJS` 里对 undefined 取 `Object.keys` 而抛 TypeError,pulse 卡死在初始值。
|
|
10
|
-
* 故 web 走 **CSS transition 降级**(零 rAF JS 帧):
|
|
11
|
-
*
|
|
12
|
-
* - `setInterval` 每隔 `duration` ms 只在 from / to 两档翻转 opacity
|
|
13
|
-
* —— setState 频率从 ~60fps 降到 1 次/duration ms(参 ToastHost.web.tsx)
|
|
14
|
-
* - 补间交给浏览器 CSS transition,JS 侧零插值
|
|
15
|
-
*
|
|
16
|
-
* **只接受归一化产物**:duration 已被验证在 `[1, 2^31)`,不会出现 `setInterval(0)`
|
|
17
|
-
* 那种「每帧触发」的退化。web 端**不跑 worklet** —— 别在文档里宣称它跑。
|
|
18
|
-
*/
|
|
6
|
+
/** Web 由 CSS 补间,timer 只按归一化后的半周期切换透明度;每个实例独立释放。 */
|
|
19
7
|
export function usePulseDriver(options: NormalizedPulseOptions) {
|
|
20
8
|
const reduced = usePrefersReducedMotion();
|
|
21
9
|
const animate = shouldAnimatePulse(options, reduced);
|
|
@@ -54,13 +42,10 @@ export function usePulseDriver(options: NormalizedPulseOptions) {
|
|
|
54
42
|
};
|
|
55
43
|
}, [animate, from, to, duration, delay]);
|
|
56
44
|
|
|
57
|
-
// RN-Web 把 transition 字段透传到 DOM style,实现 CSS 级平滑过渡。
|
|
58
|
-
// RN 的 style typedef 没有 transition 字段,故用交叉类型补一个窄声明 ——
|
|
59
|
-
// 比整块 `as any` 精确:仍然保留 opacity 的类型检查。
|
|
60
45
|
return {
|
|
61
46
|
opacity,
|
|
62
47
|
...(animate
|
|
63
48
|
? { transition: `opacity ${duration}ms ease-in-out` }
|
|
64
49
|
: undefined),
|
|
65
|
-
}
|
|
50
|
+
};
|
|
66
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MAX_TIMER","normalizePulseOptions","input","defaults","diagnostics","pick","field","valid","received","undefined","push","fallback","duration","value","Number","isFinite","delay","from","to","isStatic","shouldAnimatePulse","options","reducedMotion"],"sourceRoot":"../../../../../src","sources":["components/ui/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,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,IAAIA,KAAK,IAAI,CAAC,IAAIA,KAAK,IAAI,CAC9D,CAAC;EACD,OAAO;IAAED,QAAQ;IAAEI,KAAK;IAAEC,IAAI;IAAEC,EAAE;IAAEC,QAAQ,EAAEF,IAAI,KAAKC,EAAE;IAAEd;EAAY,CAAC;AAC1E;;AAEA;AACA,OAAO,MAAMgB,kBAAkB,GAAGA,CAChCC,OAA+B,EAC/BC,aAAsB,KACV,CAACA,aAAa,IAAI,CAACD,OAAO,CAACF,QAAQ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","cancelAnimation","useAnimatedStyle","useSharedValue","withDelay","withRepeat","withSequence","withTiming","usePrefersReducedMotion","shouldAnimatePulse","usePulseDriver","options","reduced","animate","from","to","duration","delay","op","value","cycle","opacity"],"sourceRoot":"../../../../../src","sources":["components/ui/Pulse/usePulseDriver.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SACEC,eAAe,EACfC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,UAAU,QACL,yBAAyB;AAChC,SAASC,uBAAuB,QAAQ,yBAAgB;AACxD,SAASC,kBAAkB,QAAQ,4BAAyB;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,OAA+B,EAAE;EAC9D,MAAMC,OAAO,GAAGJ,uBAAuB,CAAC,CAAC;EACzC,MAAMK,OAAO,GAAGJ,kBAAkB,CAACE,OAAO,EAAEC,OAAO,CAAC;EACpD,MAAM;IAAEE,IAAI;IAAEC,EAAE;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGN,OAAO;EAC7C,MAAMO,EAAE,GAAGf,cAAc,CAACU,OAAO,GAAGC,IAAI,GAAGC,EAAE,CAAC;EAE9Cf,SAAS,CAAC,MAAM;IACd,IAAI,CAACa,OAAO,EAAE;MACZ;MACAZ,eAAe,CAACiB,EAAE,CAAC;MACnBA,EAAE,CAACC,KAAK,GAAGJ,EAAE;MACb;IACF;IACA;IACAG,EAAE,CAACC,KAAK,GAAGL,IAAI;IACf,MAAMM,KAAK,GAAGf,UAAU,CACtBC,YAAY,CACVC,UAAU,CAACQ,EAAE,EAAE;MAAEC;IAAS,CAAC,CAAC,EAC5BT,UAAU,CAACO,IAAI,EAAE;MAAEE;IAAS,CAAC,CAC/B,CAAC,EACD,CAAC,CAAC,EACF,KACF,CAAC;IACDE,EAAE,CAACC,KAAK,GAAGF,KAAK,GAAG,CAAC,GAAGb,SAAS,CAACa,KAAK,EAAEG,KAAK,CAAC,GAAGA,KAAK;IACtD,OAAO,MAAMnB,eAAe,CAACiB,EAAE,CAAC;EAClC,CAAC,EAAE,CAACA,EAAE,EAAEL,OAAO,EAAEC,IAAI,EAAEC,EAAE,EAAEC,QAAQ,EAAEC,KAAK,CAAC,CAAC;EAE5C,OAAOf,gBAAgB,CAAC,OAAO;IAAEmB,OAAO,EAAEH,EAAE,CAACC;EAAM,CAAC,CAAC,CAAC;AACxD","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","usePrefersReducedMotion","shouldAnimatePulse","usePulseDriver","options","reduced","animate","from","to","duration","delay","opacity","setOpacity","timer","delayTimer","current","start","setInterval","setTimeout","clearTimeout","clearInterval","transition","undefined"],"sourceRoot":"../../../../../src","sources":["components/ui/Pulse/usePulseDriver.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,SAASC,uBAAuB,QAAQ,yBAAgB;AACxD,SAASC,kBAAkB,QAAQ,4BAAyB;AAG5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,OAA+B,EAAE;EAC9D,MAAMC,OAAO,GAAGJ,uBAAuB,CAAC,CAAC;EACzC,MAAMK,OAAO,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
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { PulseOptions } from './types';
|
|
2
|
-
export type { PulseOptions };
|
|
3
|
-
/**
|
|
4
|
-
* Pulse 参数的**唯一**归一化入口 —— 公共 hook 先跑完这里,平台 driver 只消费产物。
|
|
5
|
-
*
|
|
6
|
-
* 为什么要单独一层:此前 native / web 两份 `usePulse` 各自读原始 props 并各自解释
|
|
7
|
-
* 默认值,web 侧甚至把未校验的 `duration` 直接喂给 `setInterval`(0 或 2^31 会退化成
|
|
8
|
-
* 「每帧触发」)。归一化收口后,两端拿到的一定是同一组已验证数值。
|
|
9
|
-
*
|
|
10
|
-
* 纪律:**不做 clamp、不做取整**。非法值一律整体回退到 defaults 并记一条诊断 ——
|
|
11
|
-
* 悄悄把 `duration: 0` 夹成 `1` 会让调用方永远发现不了自己传错了。
|
|
12
|
-
*/
|
|
13
|
-
export type PulseDefaults = {
|
|
14
|
-
duration: number;
|
|
15
|
-
delay: number;
|
|
16
|
-
from: number;
|
|
17
|
-
to: number;
|
|
18
|
-
};
|
|
19
|
-
export type PulseDiagnostic = {
|
|
20
|
-
field: keyof PulseDefaults;
|
|
21
|
-
received: unknown;
|
|
22
|
-
fallback: number;
|
|
23
|
-
};
|
|
24
|
-
export type NormalizedPulseOptions = PulseDefaults & {
|
|
25
|
-
/** 两端相等 —— 没有可播的动画,driver 直接停在 `to`。 */
|
|
26
|
-
isStatic: boolean;
|
|
27
|
-
diagnostics: readonly PulseDiagnostic[];
|
|
28
|
-
};
|
|
29
|
-
export declare function normalizePulseOptions(input: PulseOptions | undefined, defaults: PulseDefaults): NormalizedPulseOptions;
|
|
30
|
-
/** driver 是否应当启动循环。静态或系统开启减弱动效时都不启动。 */
|
|
31
|
-
export declare const shouldAnimatePulse: (options: NormalizedPulseOptions, reducedMotion: boolean) => boolean;
|
|
32
|
-
//# sourceMappingURL=normalizePulseOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizePulseOptions.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ui/Pulse/normalizePulseOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B;;;;;;;;;GASG;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,aAAa,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,wCAAwC;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;CACzC,CAAC;AAKF,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,YAAK,EACxB,QAAQ,EAAE,aAAa,GACtB,sBAAsB,CA6BxB;AAED,wCAAwC;AACxC,eAAO,MAAM,kBAAkB,GAC7B,SAAS,sBAAsB,EAC/B,eAAe,OAAO,KACrB,OAA8C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePulseDriver.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ui/Pulse/usePulseDriver.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,sBAAsB;;GA4B7D"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
-
import type { NormalizedPulseOptions } from './normalizePulseOptions';
|
|
3
|
-
/**
|
|
4
|
-
* Web Pulse driver —— RN-Web 上 reanimated 的 `useAnimatedStyle` 链路会在
|
|
5
|
-
* `_updatePropsJS` 里对 undefined 取 `Object.keys` 而抛 TypeError,pulse 卡死在初始值。
|
|
6
|
-
* 故 web 走 **CSS transition 降级**(零 rAF JS 帧):
|
|
7
|
-
*
|
|
8
|
-
* - `setInterval` 每隔 `duration` ms 只在 from / to 两档翻转 opacity
|
|
9
|
-
* —— setState 频率从 ~60fps 降到 1 次/duration ms(参 ToastHost.web.tsx)
|
|
10
|
-
* - 补间交给浏览器 CSS transition,JS 侧零插值
|
|
11
|
-
*
|
|
12
|
-
* **只接受归一化产物**:duration 已被验证在 `[1, 2^31)`,不会出现 `setInterval(0)`
|
|
13
|
-
* 那种「每帧触发」的退化。web 端**不跑 worklet** —— 别在文档里宣称它跑。
|
|
14
|
-
*/
|
|
15
|
-
export declare function usePulseDriver(options: NormalizedPulseOptions): (ViewStyle | TextStyle | ImageStyle) & {
|
|
16
|
-
transition?: string;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=usePulseDriver.web.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePulseDriver.web.d.ts","sourceRoot":"","sources":["../../../../../../src/components/ui/Pulse/usePulseDriver.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,sBAAsB,GA8CvD,CAAC,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CACpE"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { PulseOptions } from './types';
|
|
2
|
-
|
|
3
|
-
export type { PulseOptions };
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Pulse 参数的**唯一**归一化入口 —— 公共 hook 先跑完这里,平台 driver 只消费产物。
|
|
7
|
-
*
|
|
8
|
-
* 为什么要单独一层:此前 native / web 两份 `usePulse` 各自读原始 props 并各自解释
|
|
9
|
-
* 默认值,web 侧甚至把未校验的 `duration` 直接喂给 `setInterval`(0 或 2^31 会退化成
|
|
10
|
-
* 「每帧触发」)。归一化收口后,两端拿到的一定是同一组已验证数值。
|
|
11
|
-
*
|
|
12
|
-
* 纪律:**不做 clamp、不做取整**。非法值一律整体回退到 defaults 并记一条诊断 ——
|
|
13
|
-
* 悄悄把 `duration: 0` 夹成 `1` 会让调用方永远发现不了自己传错了。
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
export type PulseDefaults = {
|
|
17
|
-
duration: number;
|
|
18
|
-
delay: number;
|
|
19
|
-
from: number;
|
|
20
|
-
to: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type PulseDiagnostic = {
|
|
24
|
-
field: keyof PulseDefaults;
|
|
25
|
-
received: unknown;
|
|
26
|
-
fallback: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type NormalizedPulseOptions = PulseDefaults & {
|
|
30
|
-
/** 两端相等 —— 没有可播的动画,driver 直接停在 `to`。 */
|
|
31
|
-
isStatic: boolean;
|
|
32
|
-
diagnostics: readonly PulseDiagnostic[];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// setTimeout / setInterval 内部用 int32 存时长,>= 2^31 会溢出成 0 变「每帧触发」。
|
|
36
|
-
const MAX_TIMER = 2 ** 31;
|
|
37
|
-
|
|
38
|
-
export function normalizePulseOptions(
|
|
39
|
-
input: PulseOptions = {},
|
|
40
|
-
defaults: PulseDefaults
|
|
41
|
-
): NormalizedPulseOptions {
|
|
42
|
-
const diagnostics: PulseDiagnostic[] = [];
|
|
43
|
-
const pick = (
|
|
44
|
-
field: keyof PulseDefaults,
|
|
45
|
-
valid: (value: number) => boolean
|
|
46
|
-
): number => {
|
|
47
|
-
const received = input[field];
|
|
48
|
-
if (received === undefined) return defaults[field];
|
|
49
|
-
if (typeof received === 'number' && valid(received)) return received;
|
|
50
|
-
diagnostics.push({ field, received, fallback: defaults[field] });
|
|
51
|
-
return defaults[field];
|
|
52
|
-
};
|
|
53
|
-
const duration = pick(
|
|
54
|
-
'duration',
|
|
55
|
-
(value) => Number.isFinite(value) && value >= 1 && value < MAX_TIMER
|
|
56
|
-
);
|
|
57
|
-
const delay = pick(
|
|
58
|
-
'delay',
|
|
59
|
-
(value) => Number.isFinite(value) && value >= 0 && value < MAX_TIMER
|
|
60
|
-
);
|
|
61
|
-
const from = pick(
|
|
62
|
-
'from',
|
|
63
|
-
(value) => Number.isFinite(value) && value >= 0 && value <= 1
|
|
64
|
-
);
|
|
65
|
-
const to = pick(
|
|
66
|
-
'to',
|
|
67
|
-
(value) => Number.isFinite(value) && value >= 0 && value <= 1
|
|
68
|
-
);
|
|
69
|
-
return { duration, delay, from, to, isStatic: from === to, diagnostics };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** driver 是否应当启动循环。静态或系统开启减弱动效时都不启动。 */
|
|
73
|
-
export const shouldAnimatePulse = (
|
|
74
|
-
options: NormalizedPulseOptions,
|
|
75
|
-
reducedMotion: boolean
|
|
76
|
-
): boolean => !reducedMotion && !options.isStatic;
|