@doubao-dev/taro-runtime 0.9.1 → 0.10.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.
Files changed (185) hide show
  1. package/README.md +117 -0
  2. package/assets/refresh-loading.png +0 -0
  3. package/dist/api/base/can-i-use.d.ts +3 -0
  4. package/dist/api/base/can-i-use.js +12 -0
  5. package/dist/api/base/event-center.d.ts +12 -0
  6. package/dist/api/base/event-center.js +52 -0
  7. package/dist/api/base/index.d.ts +1 -1
  8. package/dist/api/base/index.js +1 -1
  9. package/dist/api/base/next-tick.d.ts +3 -0
  10. package/dist/api/base/next-tick.js +11 -0
  11. package/dist/api/canvas/index.d.ts +17 -0
  12. package/dist/api/canvas/index.js +29 -0
  13. package/dist/api/create-animation.d.ts +47 -0
  14. package/dist/api/create-animation.js +98 -0
  15. package/dist/api/create-intersection-observer/index.d.ts +7 -0
  16. package/dist/api/create-intersection-observer/index.js +126 -0
  17. package/dist/api/create-selector-query/index.js +284 -109
  18. package/dist/api/device/accelerometer.js +1 -1
  19. package/dist/api/device/accessibility.js +1 -1
  20. package/dist/api/device/battery.js +1 -1
  21. package/dist/api/device/beacon.js +1 -1
  22. package/dist/api/device/bluetooth.js +1 -1
  23. package/dist/api/device/clipboard.js +1 -1
  24. package/dist/api/device/compass.js +1 -1
  25. package/dist/api/device/crypto.js +1 -1
  26. package/dist/api/device/device-motion.js +1 -1
  27. package/dist/api/device/gyroscope.js +1 -1
  28. package/dist/api/device/keyboard.js +1 -1
  29. package/dist/api/device/scan.js +1 -1
  30. package/dist/api/device/screen.js +1 -1
  31. package/dist/api/device/sms.js +1 -1
  32. package/dist/api/device/vibration.js +1 -1
  33. package/dist/api/device/wifi.js +1 -1
  34. package/dist/api/index.d.ts +8 -1
  35. package/dist/api/index.js +8 -1
  36. package/dist/api/interaction/index.js +1 -1
  37. package/dist/api/location/index.d.ts +2 -2
  38. package/dist/api/location/index.js +1 -1
  39. package/dist/api/media/image.d.ts +9 -0
  40. package/dist/api/media/image.js +21 -1
  41. package/dist/api/media/index.d.ts +2 -0
  42. package/dist/api/media/index.js +2 -0
  43. package/dist/api/media/inner-audio.d.ts +5 -0
  44. package/dist/api/media/inner-audio.js +7 -0
  45. package/dist/api/media/media.d.ts +6 -0
  46. package/dist/api/media/media.js +9 -0
  47. package/dist/api/px-transform.d.ts +11 -0
  48. package/dist/api/px-transform.js +31 -0
  49. package/dist/api/request/index.js +1 -1
  50. package/dist/api/request/websocket.js +1 -1
  51. package/dist/api/router/current-instance.d.ts +17 -0
  52. package/dist/api/router/current-instance.js +28 -0
  53. package/dist/api/router/exit-mini-program.js +1 -1
  54. package/dist/api/router/get-current-pages.d.ts +13 -1
  55. package/dist/api/router/get-current-pages.js +5 -3
  56. package/dist/api/router/index.d.ts +1 -0
  57. package/dist/api/router/index.js +1 -0
  58. package/dist/api/router/navigate-back.js +1 -1
  59. package/dist/api/router/navigate-to.js +1 -1
  60. package/dist/api/router/re-launch.js +1 -1
  61. package/dist/api/router/redirect-to.js +1 -1
  62. package/dist/api/runtime/download.d.ts +11 -0
  63. package/dist/api/runtime/download.js +18 -0
  64. package/dist/api/runtime/resize.d.ts +7 -0
  65. package/dist/api/runtime/resize.js +26 -0
  66. package/dist/api/runtime/system.d.ts +8 -0
  67. package/dist/api/runtime/system.js +10 -0
  68. package/dist/api/show-toast/index.js +1 -1
  69. package/dist/api/storage/index.d.ts +1 -1
  70. package/dist/api/storage/index.js +1 -1
  71. package/dist/api/system/index.js +1 -1
  72. package/dist/components/Block/index.d.ts +3 -0
  73. package/dist/components/Block/index.jsx +4 -0
  74. package/dist/components/Button/index.d.ts +7 -0
  75. package/dist/components/Button/index.jsx +28 -0
  76. package/dist/components/Canvas/index.d.ts +4 -0
  77. package/dist/components/Canvas/index.jsx +25 -0
  78. package/dist/components/Checkbox/index.d.ts +3 -0
  79. package/dist/components/Checkbox/index.jsx +17 -0
  80. package/dist/components/CheckboxGroup/index.d.ts +3 -0
  81. package/dist/components/CheckboxGroup/index.jsx +13 -0
  82. package/dist/components/CoverView/index.d.ts +6 -1
  83. package/dist/components/CoverView/index.js +5 -1
  84. package/dist/components/Form/index.d.ts +4 -0
  85. package/dist/components/Form/index.jsx +39 -0
  86. package/dist/components/Form/use-form-field.d.ts +5 -0
  87. package/dist/components/Form/use-form-field.js +40 -0
  88. package/dist/components/Icon/index.d.ts +3 -0
  89. package/dist/components/Icon/index.jsx +40 -0
  90. package/dist/components/Image/index.d.ts +3 -1
  91. package/dist/components/Image/index.jsx +15 -4
  92. package/dist/components/Input/index.d.ts +1 -1
  93. package/dist/components/Input/index.jsx +9 -5
  94. package/dist/components/Input/map.d.ts +1 -1
  95. package/dist/components/Label/control.d.ts +6 -0
  96. package/dist/components/Label/control.js +29 -0
  97. package/dist/components/Label/index.d.ts +3 -0
  98. package/dist/components/Label/index.jsx +15 -0
  99. package/dist/components/LivePlayer/index.d.ts +3 -0
  100. package/dist/components/LivePlayer/index.jsx +8 -0
  101. package/dist/components/Map/bridge.d.ts +1 -1
  102. package/dist/components/Map/index.jsx +10 -6
  103. package/dist/components/Movable/index.d.ts +4 -0
  104. package/dist/components/Movable/index.jsx +26 -0
  105. package/dist/components/NavigationBar/index.d.ts +3 -0
  106. package/dist/components/NavigationBar/index.jsx +16 -0
  107. package/dist/components/Navigator/index.d.ts +3 -0
  108. package/dist/components/Navigator/index.jsx +32 -0
  109. package/dist/components/OpenData/index.d.ts +3 -0
  110. package/dist/components/OpenData/index.js +4 -0
  111. package/dist/components/Picker/index.d.ts +6 -0
  112. package/dist/components/Picker/index.jsx +155 -0
  113. package/dist/components/Picker/popup.d.ts +18 -0
  114. package/dist/components/Picker/popup.jsx +105 -0
  115. package/dist/components/PickerView/index.d.ts +1 -1
  116. package/dist/components/PickerView/index.jsx +1 -1
  117. package/dist/components/PickerView/map.d.ts +1 -1
  118. package/dist/components/Progress/index.d.ts +3 -0
  119. package/dist/components/Progress/index.jsx +14 -0
  120. package/dist/components/Radio/index.jsx +9 -5
  121. package/dist/components/Radio/shared.d.ts +1 -1
  122. package/dist/components/RadioGroup/context.js +1 -1
  123. package/dist/components/RadioGroup/index.jsx +8 -4
  124. package/dist/components/RadioGroup/map.d.ts +1 -1
  125. package/dist/components/RichText/index.d.ts +3 -0
  126. package/dist/components/RichText/index.jsx +7 -0
  127. package/dist/components/ScrollView/index.d.ts +4 -1
  128. package/dist/components/ScrollView/index.jsx +44 -14
  129. package/dist/components/ScrollView/map.d.ts +4 -2
  130. package/dist/components/ScrollView/map.js +19 -1
  131. package/dist/components/ScrollView/refresh-types.d.ts +25 -0
  132. package/dist/components/ScrollView/refresh-types.js +2 -0
  133. package/dist/components/ScrollView/refresh.d.ts +10 -0
  134. package/dist/components/ScrollView/refresh.jsx +29 -0
  135. package/dist/components/ScrollView/use-refresher.d.ts +19 -0
  136. package/dist/components/ScrollView/use-refresher.js +214 -0
  137. package/dist/components/Slider/index.d.ts +3 -0
  138. package/dist/components/Slider/index.jsx +13 -0
  139. package/dist/components/Swiper/index.d.ts +3 -0
  140. package/dist/components/Swiper/index.jsx +79 -0
  141. package/dist/components/SwiperItem/index.d.ts +3 -0
  142. package/dist/components/SwiperItem/index.jsx +18 -0
  143. package/dist/components/Switch/index.d.ts +3 -0
  144. package/dist/components/Switch/index.jsx +32 -0
  145. package/dist/components/Text/format.d.ts +5 -0
  146. package/dist/components/Text/format.js +51 -0
  147. package/dist/components/Text/index.d.ts +4 -3
  148. package/dist/components/Text/index.jsx +3 -2
  149. package/dist/components/Text/map.js +9 -4
  150. package/dist/components/Textarea/index.d.ts +3 -0
  151. package/dist/components/Textarea/index.jsx +30 -0
  152. package/dist/components/Video/index.d.ts +3 -0
  153. package/dist/components/Video/index.jsx +22 -0
  154. package/dist/components/View/index.d.ts +5 -5
  155. package/dist/components/View/index.jsx +11 -13
  156. package/dist/components/View/map.js +5 -0
  157. package/dist/components/base/change-event.d.ts +18 -0
  158. package/dist/components/base/change-event.js +13 -0
  159. package/dist/components/base/wrap-text-node.d.ts +3 -0
  160. package/dist/components/base/wrap-text-node.jsx +34 -0
  161. package/dist/components/index.d.ts +24 -1
  162. package/dist/components/index.js +24 -1
  163. package/dist/exports/app.d.ts +2 -1
  164. package/dist/exports/app.js +3 -1
  165. package/dist/exports/common.d.ts +1 -0
  166. package/dist/exports/common.js +1 -0
  167. package/dist/exports/view-core.d.ts +2 -1
  168. package/dist/exports/view-core.js +2 -1
  169. package/dist/exports/view.d.ts +2 -1
  170. package/dist/exports/view.js +3 -1
  171. package/dist/hooks/lifecycle/app.js +1 -1
  172. package/dist/hooks/use-animation.d.ts +9 -0
  173. package/dist/hooks/use-animation.js +151 -0
  174. package/dist/internal/class-components.d.ts +11 -0
  175. package/dist/internal/class-components.js +42 -0
  176. package/dist/internal/index.d.ts +1 -0
  177. package/dist/internal/index.js +1 -0
  178. package/dist/internal/map-context/index.d.ts +1 -1
  179. package/dist/internal/query-node.d.ts +9 -0
  180. package/dist/internal/query-node.js +35 -0
  181. package/dist/internal/selector-id.d.ts +6 -0
  182. package/dist/internal/selector-id.js +18 -0
  183. package/dist/react.d.ts +4 -0
  184. package/dist/react.js +4 -0
  185. package/package.json +23 -1
@@ -1,16 +1,14 @@
1
+ import { forwardRef } from '@doubao-dev/framework';
2
+ import { useAnimation } from '../../hooks/use-animation.js';
3
+ import { useQueryNodeProps } from '../../internal/query-node.js';
4
+ import { wrapTextNode } from '../base/wrap-text-node.jsx';
1
5
  import { mapViewProps } from './map.js';
2
- import { Text } from '../Text/index.jsx';
3
- function wrapTextNode(child) {
4
- if (typeof child === 'string' || typeof child === 'number') {
5
- return <Text>{child}</Text>;
6
- }
7
- if (Array.isArray(child)) {
8
- return child.map((item) => wrapTextNode(item));
9
- }
10
- return child;
11
- }
12
- export function View({ children, ...rest }) {
6
+ export const View = forwardRef(function View({ children, animation, ...rest }, ref) {
7
+ useQueryNodeProps(rest.id, rest);
8
+ const animationBindings = useAnimation(animation);
13
9
  const mapped = mapViewProps(rest);
14
- return <view {...mapped}>{wrapTextNode(children)}</view>;
15
- }
10
+ return (<view {...mapped} {...animationBindings} ref={ref}>
11
+ {wrapTextNode(children)}
12
+ </view>);
13
+ });
16
14
  //# sourceMappingURL=index.jsx.map
@@ -7,6 +7,11 @@ export function mapViewProps(props) {
7
7
  }
8
8
  const mapped = { ...props };
9
9
  Object.keys(mapped).forEach((key) => {
10
+ if (key.startsWith('mark:')) {
11
+ mapped[`data-taro-mark-${key.slice(5)}`] = mapped[key];
12
+ delete mapped[key];
13
+ return;
14
+ }
10
15
  const target = VIEW_PROP_MAP[key];
11
16
  if (target) {
12
17
  mapped[target] = mapped[key];
@@ -0,0 +1,18 @@
1
+ export declare function changeEvent<T>(tagName: string, id: string | undefined, detail: T, type?: string): {
2
+ type: string;
3
+ timeStamp: number;
4
+ target: {
5
+ id: string;
6
+ tagName: string;
7
+ dataset: {};
8
+ };
9
+ currentTarget: {
10
+ id: string;
11
+ tagName: string;
12
+ dataset: {};
13
+ };
14
+ detail: T;
15
+ preventDefault(): void;
16
+ stopPropagation(): void;
17
+ };
18
+ //# sourceMappingURL=change-event.d.ts.map
@@ -0,0 +1,13 @@
1
+ export function changeEvent(tagName, id, detail, type = 'change') {
2
+ const target = { id: id ?? '', tagName, dataset: {} };
3
+ return {
4
+ type,
5
+ timeStamp: Date.now(),
6
+ target,
7
+ currentTarget: target,
8
+ detail,
9
+ preventDefault() { },
10
+ stopPropagation() { }
11
+ };
12
+ }
13
+ //# sourceMappingURL=change-event.js.map
@@ -0,0 +1,3 @@
1
+ import type { ReactNode } from '@doubao-dev/framework';
2
+ export declare function wrapTextNode(child: ReactNode): ReactNode;
3
+ //# sourceMappingURL=wrap-text-node.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { Text } from '../Text/index.jsx';
2
+ export function wrapTextNode(child) {
3
+ if (typeof child === 'string' || typeof child === 'number') {
4
+ return <Text>{child}</Text>;
5
+ }
6
+ if (Array.isArray(child)) {
7
+ const children = [];
8
+ let text;
9
+ let textIndex = 0;
10
+ function flushText() {
11
+ if (text === undefined) {
12
+ return;
13
+ }
14
+ children.push(<Text key={`text-${textIndex}`}>{text}</Text>);
15
+ text = undefined;
16
+ }
17
+ for (const [index, item] of child.entries()) {
18
+ if (typeof item === 'string' || typeof item === 'number') {
19
+ if (text === undefined) {
20
+ textIndex = index;
21
+ }
22
+ text = (text ?? '') + item;
23
+ }
24
+ else if (item != null && typeof item !== 'boolean') {
25
+ flushText();
26
+ children.push(wrapTextNode(item));
27
+ }
28
+ }
29
+ flushText();
30
+ return children;
31
+ }
32
+ return child;
33
+ }
34
+ //# sourceMappingURL=wrap-text-node.jsx.map
@@ -9,6 +9,29 @@ export * from './RadioGroup/index.jsx';
9
9
  export * from './ScrollView/index.jsx';
10
10
  export * from './Map/index.jsx';
11
11
  export * from './WebView/index.jsx';
12
- export { Button, Slider, Swiper, SwiperItem, TextArea } from '@byted-doubao-apps/components';
12
+ export * from './Button/index.jsx';
13
+ export { TextArea } from '@doubao-dev/framework/components';
13
14
  export * from './PickerView/index.jsx';
15
+ export { SwiperItem } from './SwiperItem/index.jsx';
16
+ export { Swiper } from './Swiper/index.jsx';
17
+ export { Canvas } from './Canvas/index.jsx';
18
+ export { Checkbox } from './Checkbox/index.jsx';
19
+ export { Picker } from './Picker/index.jsx';
20
+ export { RichText } from './RichText/index.jsx';
21
+ export { Switch } from './Switch/index.jsx';
22
+ export { Textarea } from './Textarea/index.jsx';
23
+ export { Block } from './Block/index.jsx';
24
+ export { Progress } from './Progress/index.jsx';
25
+ export { CheckboxGroup } from './CheckboxGroup/index.jsx';
26
+ export { Navigator } from './Navigator/index.jsx';
27
+ export { NavigationBar } from './NavigationBar/index.jsx';
28
+ export { MovableArea, MovableView } from './Movable/index.jsx';
29
+ export { Form } from './Form/index.jsx';
30
+ export { Label } from './Label/index.jsx';
31
+ export { OpenData } from './OpenData/index.js';
32
+ export { Slider } from './Slider/index.jsx';
33
+ export { View as CustomWrapper } from './View/index.jsx';
34
+ export { Icon } from './Icon/index.jsx';
35
+ export { Video } from './Video/index.jsx';
36
+ export { LivePlayer } from './LivePlayer/index.jsx';
14
37
  //# sourceMappingURL=index.d.ts.map
@@ -9,6 +9,29 @@ export * from './RadioGroup/index.jsx';
9
9
  export * from './ScrollView/index.jsx';
10
10
  export * from './Map/index.jsx';
11
11
  export * from './WebView/index.jsx';
12
- export { Button, Slider, Swiper, SwiperItem, TextArea } from '@byted-doubao-apps/components';
12
+ export * from './Button/index.jsx';
13
+ export { TextArea } from '@doubao-dev/framework/components';
13
14
  export * from './PickerView/index.jsx';
15
+ export { SwiperItem } from './SwiperItem/index.jsx';
16
+ export { Swiper } from './Swiper/index.jsx';
17
+ export { Canvas } from './Canvas/index.jsx';
18
+ export { Checkbox } from './Checkbox/index.jsx';
19
+ export { Picker } from './Picker/index.jsx';
20
+ export { RichText } from './RichText/index.jsx';
21
+ export { Switch } from './Switch/index.jsx';
22
+ export { Textarea } from './Textarea/index.jsx';
23
+ export { Block } from './Block/index.jsx';
24
+ export { Progress } from './Progress/index.jsx';
25
+ export { CheckboxGroup } from './CheckboxGroup/index.jsx';
26
+ export { Navigator } from './Navigator/index.jsx';
27
+ export { NavigationBar } from './NavigationBar/index.jsx';
28
+ export { MovableArea, MovableView } from './Movable/index.jsx';
29
+ export { Form } from './Form/index.jsx';
30
+ export { Label } from './Label/index.jsx';
31
+ export { OpenData } from './OpenData/index.js';
32
+ export { Slider } from './Slider/index.jsx';
33
+ export { View as CustomWrapper } from './View/index.jsx';
34
+ export { Icon } from './Icon/index.jsx';
35
+ export { Video } from './Video/index.jsx';
36
+ export { LivePlayer } from './LivePlayer/index.jsx';
14
37
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  export * from './app-core.js';
2
2
  import * as Taro from './app-core.js';
3
- export default Taro;
3
+ declare const runtime: typeof Taro;
4
+ export default runtime;
4
5
  //# sourceMappingURL=app.d.ts.map
@@ -1,4 +1,6 @@
1
1
  export * from './app-core.js';
2
2
  import * as Taro from './app-core.js';
3
- export default Taro;
3
+ // Taro UI attaches extension APIs such as atMessage to the default export.
4
+ const runtime = { ...Taro };
5
+ export default runtime;
4
6
  //# sourceMappingURL=app.js.map
@@ -1,3 +1,4 @@
1
1
  export * from '../api/index.js';
2
2
  export type * from '../types/index.js';
3
+ export { __configurePxTransform, initPxTransform, pxTransform } from '../api/px-transform.js';
3
4
  //# sourceMappingURL=common.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export * from '../api/index.js';
2
+ export { __configurePxTransform, initPxTransform, pxTransform } from '../api/px-transform.js';
2
3
  //# sourceMappingURL=common.js.map
@@ -1,4 +1,5 @@
1
1
  export * from './common.js';
2
+ export { onWindowResize, offWindowResize, useResize } from '../api/runtime/resize.js';
2
3
  export { useError, useLaunch, usePageNotFound, useDidHide, useDidShow } from '../hooks/lifecycle/app.js';
3
- export { useCreated as useLoad, useMounted as useReady, useDestroy as useUnload } from '@byted-doubao-apps/framework';
4
+ export { useCreated as useLoad, useMounted as useReady, useDestroy as useUnload } from '@doubao-dev/framework';
4
5
  //# sourceMappingURL=view-core.d.ts.map
@@ -1,4 +1,5 @@
1
1
  export * from './common.js';
2
+ export { onWindowResize, offWindowResize, useResize } from '../api/runtime/resize.js';
2
3
  export { useError, useLaunch, usePageNotFound, useDidHide, useDidShow } from '../hooks/lifecycle/app.js';
3
- export { useCreated as useLoad, useMounted as useReady, useDestroy as useUnload } from '@byted-doubao-apps/framework';
4
+ export { useCreated as useLoad, useMounted as useReady, useDestroy as useUnload } from '@doubao-dev/framework';
4
5
  //# sourceMappingURL=view-core.js.map
@@ -1,4 +1,5 @@
1
1
  export * from './view-core.js';
2
2
  import * as Taro from './view-core.js';
3
- export default Taro;
3
+ declare const runtime: typeof Taro;
4
+ export default runtime;
4
5
  //# sourceMappingURL=view.d.ts.map
@@ -1,4 +1,6 @@
1
1
  export * from './view-core.js';
2
2
  import * as Taro from './view-core.js';
3
- export default Taro;
3
+ // Taro UI attaches extension APIs such as atMessage to the default export.
4
+ const runtime = { ...Taro };
5
+ export default runtime;
4
6
  //# sourceMappingURL=view.js.map
@@ -1,4 +1,4 @@
1
- import { useError as useViewError, useHide as useViewDidHide, useShow as useViewDidShow } from '@byted-doubao-apps/framework';
1
+ import { useError as useViewError, useHide as useViewDidHide, useShow as useViewDidShow } from '@doubao-dev/framework';
2
2
  import { APP_ID, getCurrentId, registerLifecycle } from '../../internal/lifecycle/index.js';
3
3
  import { warnUnsupported } from '../../utils/warn-unsupported.js';
4
4
  export function useLaunch(callback) {
@@ -0,0 +1,9 @@
1
+ import type { MainThread } from '@lynx-js/types';
2
+ export declare function useAnimation(value?: unknown): {
3
+ 'main-thread:ref': import("react").RefObject<MainThread.Element>;
4
+ 'main-thread:bindanimationend': (event: MainThread.AnimationEvent) => void;
5
+ } | {
6
+ 'main-thread:ref'?: undefined;
7
+ 'main-thread:bindanimationend'?: undefined;
8
+ };
9
+ //# sourceMappingURL=use-animation.d.ts.map
@@ -0,0 +1,151 @@
1
+ import { useEffect, useRef } from '@doubao-dev/framework';
2
+ import { runOnBackground, runOnMainThread, useMainThreadRef } from '@lynx-js/react';
3
+ let nextAnimationId = 0;
4
+ export function useAnimation(value) {
5
+ const animation = value && Array.isArray(value.steps) ? value : undefined;
6
+ const element = useMainThreadRef(null);
7
+ const activeAnimation = useMainThreadRef(null);
8
+ const pendingEnd = useRef(null);
9
+ function resolveAnimationEnd(name) {
10
+ const pending = pendingEnd.current;
11
+ if (pending?.name === name) {
12
+ pending.resolve();
13
+ }
14
+ }
15
+ function onAnimationEnd(event) {
16
+ 'main thread';
17
+ const name = event.params?.animation_name;
18
+ if (name && name === activeAnimation.current?.name) {
19
+ void runOnBackground(resolveAnimationEnd)(name);
20
+ }
21
+ }
22
+ useEffect(() => {
23
+ if (!animation) {
24
+ void runOnMainThread(() => {
25
+ 'main thread';
26
+ activeAnimation.current?.handle.cancel();
27
+ activeAnimation.current = null;
28
+ })();
29
+ return;
30
+ }
31
+ const steps = animation.steps.map(({ styles, options }) => ({
32
+ styles: Object.fromEntries(Object.entries(styles).map(([key, value]) => [key, String(value)])),
33
+ duration: options.duration ?? 400,
34
+ delay: options.delay ?? 0,
35
+ timingFunction: options.timingFunction ?? 'linear',
36
+ transformOrigin: options.transformOrigin ?? '50% 50% 0'
37
+ }));
38
+ if (steps.some(({ duration, delay }) => !Number.isFinite(duration) || duration < 0 || !Number.isFinite(delay))) {
39
+ console.warn('Taro View animation requires a finite delay and a finite non-negative duration');
40
+ return;
41
+ }
42
+ const sequence = ++nextAnimationId;
43
+ let cancelled = false;
44
+ let timeout;
45
+ let finishWait;
46
+ const startStep = runOnMainThread((step, name) => {
47
+ 'main thread';
48
+ const target = element.current;
49
+ if (typeof target?.animate !== 'function') {
50
+ return false;
51
+ }
52
+ const previous = activeAnimation.current;
53
+ const from = {};
54
+ if (previous) {
55
+ // A replacement sequence starts at the displayed frame.
56
+ const current = {};
57
+ const computed = target;
58
+ for (const key of Object.keys(previous.finalStyles)) {
59
+ const value = computed.getComputedStyleProperty(key === 'backgroundColor' ? 'background-color' : key);
60
+ if (value) {
61
+ current[key] = value;
62
+ if (key in step.styles) {
63
+ from[key] = value;
64
+ }
65
+ }
66
+ }
67
+ target.setStyleProperties(current);
68
+ previous.handle.cancel();
69
+ activeAnimation.current = null;
70
+ }
71
+ if (Object.keys(step.styles).length === 0) {
72
+ return true;
73
+ }
74
+ if ('transform' in step.styles) {
75
+ target.setStyleProperties({ transformOrigin: step.transformOrigin });
76
+ }
77
+ // Web Core reads the legacy option names when forwarding to the DOM.
78
+ const timing = {
79
+ fillMode: 'forwards',
80
+ timingFunction: step.timingFunction,
81
+ name,
82
+ duration: step.duration,
83
+ delay: step.delay,
84
+ easing: step.timingFunction,
85
+ fill: 'forwards'
86
+ };
87
+ const handle = target.animate([from, step.styles], timing);
88
+ activeAnimation.current = { name, handle, finalStyles: step.styles };
89
+ return true;
90
+ });
91
+ const commitStep = runOnMainThread((name) => {
92
+ 'main thread';
93
+ const active = activeAnimation.current;
94
+ if (!active || active.name !== name) {
95
+ return;
96
+ }
97
+ active.handle.cancel();
98
+ element.current?.setStyleProperties(active.finalStyles);
99
+ activeAnimation.current = null;
100
+ });
101
+ async function play() {
102
+ for (const [index, step] of steps.entries()) {
103
+ const name = `taro-view-animation-${sequence}-${index}`;
104
+ if (cancelled) {
105
+ return;
106
+ }
107
+ const finished = new Promise((resolve) => {
108
+ finishWait = resolve;
109
+ pendingEnd.current = { name, resolve };
110
+ });
111
+ try {
112
+ if (!(await startStep(step, name)) || cancelled) {
113
+ return;
114
+ }
115
+ // Web Core's imperative animations do not emit Lynx animationend.
116
+ // Give native completion a chance to arrive before using the fallback.
117
+ const grace = Object.keys(step.styles).length ? 100 : 0;
118
+ timeout = setTimeout(finishWait, Math.max(0, step.duration + step.delay) + grace);
119
+ await finished;
120
+ if (cancelled) {
121
+ return;
122
+ }
123
+ }
124
+ finally {
125
+ clearTimeout(timeout);
126
+ if (pendingEnd.current?.name === name) {
127
+ pendingEnd.current = null;
128
+ }
129
+ }
130
+ await commitStep(name);
131
+ }
132
+ }
133
+ void play().catch((error) => console.warn('Taro View animation failed', error));
134
+ return () => {
135
+ cancelled = true;
136
+ clearTimeout(timeout);
137
+ finishWait?.();
138
+ };
139
+ }, [animation, element, activeAnimation]);
140
+ useEffect(() => {
141
+ return () => {
142
+ void runOnMainThread(() => {
143
+ 'main thread';
144
+ activeAnimation.current?.handle.cancel();
145
+ activeAnimation.current = null;
146
+ })();
147
+ };
148
+ }, [activeAnimation]);
149
+ return animation ? { 'main-thread:ref': element, 'main-thread:bindanimationend': onAnimationEnd } : {};
150
+ }
151
+ //# sourceMappingURL=use-animation.js.map
@@ -0,0 +1,11 @@
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ type LifecycleProps = {
3
+ instance: object;
4
+ children: ReactNode;
5
+ };
6
+ /** Called by compiled render methods. Hooks own subscription setup and unmount cleanup. */
7
+ export declare function renderClassComponent(instance: object, children: ReactNode): import("react").FunctionComponentElement<LifecycleProps>;
8
+ /** Only the page root receives onReady; show/hide are handled in each class render. */
9
+ export declare function adaptPage(Page: ComponentType<any>): ComponentType<any>;
10
+ export {};
11
+ //# sourceMappingURL=class-components.d.ts.map
@@ -0,0 +1,42 @@
1
+ import { createContext, createElement, useContext, useHide, useMounted, useRef, useShow } from '@doubao-dev/framework';
2
+ const LifecycleOwner = createContext(undefined);
3
+ /** Calls a lifecycle method with the instance as `this`; fields of other types are ignored. */
4
+ function invoke(instance, name) {
5
+ const method = instance[name];
6
+ if (typeof method === 'function') {
7
+ method.call(instance);
8
+ }
9
+ }
10
+ function ClassEvents({ instance, children }) {
11
+ useShow(() => invoke(instance, 'componentDidShow'));
12
+ useHide(() => invoke(instance, 'componentDidHide'));
13
+ return children;
14
+ }
15
+ function ClassLifecycle({ instance, children }) {
16
+ const owner = useContext(LifecycleOwner);
17
+ // A subclass can return super.render(). Subscribe once for that same instance.
18
+ if (owner === instance) {
19
+ return children;
20
+ }
21
+ return createElement(LifecycleOwner.Provider, { value: instance }, createElement(ClassEvents, { instance, children }));
22
+ }
23
+ /** Called by compiled render methods. Hooks own subscription setup and unmount cleanup. */
24
+ export function renderClassComponent(instance, children) {
25
+ return createElement(ClassLifecycle, { instance, children });
26
+ }
27
+ /** Only the page root receives onReady; show/hide are handled in each class render. */
28
+ export function adaptPage(Page) {
29
+ if (!Page.prototype?.isReactComponent && !Page.prototype?.render) {
30
+ return Page;
31
+ }
32
+ return function TaroClassPage(props) {
33
+ const instance = useRef(null);
34
+ useMounted(() => {
35
+ if (instance.current) {
36
+ invoke(instance.current, 'onReady');
37
+ }
38
+ });
39
+ return createElement(Page, { ...props, ref: instance });
40
+ };
41
+ }
42
+ //# sourceMappingURL=class-components.js.map
@@ -1,2 +1,3 @@
1
1
  export * from './lifecycle/index.js';
2
+ export { adaptPage, renderClassComponent } from './class-components.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export * from './lifecycle/index.js';
2
+ export { adaptPage, renderClassComponent } from './class-components.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { MapRef } from '@byted-doubao-apps/components';
1
+ import type { MapRef } from '@doubao-dev/framework/components';
2
2
  import type { MapProps } from '@tarojs/components';
3
3
  export interface MapPoint {
4
4
  latitude: number;
@@ -0,0 +1,9 @@
1
+ import type { CanvasRef } from '@doubao-dev/framework/components';
2
+ export declare function useQueryNodeProps(id: unknown, props: Record<string, unknown>): void;
3
+ export declare function getQueryNodeProperties(id: string, names: string[]): {
4
+ [k: string]: unknown;
5
+ };
6
+ export declare function setQueryCanvas(id: string, canvas: CanvasRef): void;
7
+ export declare function clearQueryCanvas(id: string, canvas: CanvasRef): void;
8
+ export declare function getQueryCanvas(id: string): CanvasRef | undefined;
9
+ //# sourceMappingURL=query-node.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { useEffect } from '@doubao-dev/framework';
2
+ const propsById = new Map();
3
+ const canvasById = new Map();
4
+ export function useQueryNodeProps(id, props) {
5
+ useEffect(() => {
6
+ if (typeof id !== 'string' || !id) {
7
+ return;
8
+ }
9
+ propsById.set(id, props);
10
+ return () => {
11
+ if (propsById.get(id) === props) {
12
+ propsById.delete(id);
13
+ }
14
+ };
15
+ }, [id, props]);
16
+ }
17
+ export function getQueryNodeProperties(id, names) {
18
+ const props = propsById.get(id);
19
+ if (!props) {
20
+ return {};
21
+ }
22
+ return Object.fromEntries(names.flatMap((name) => Object.hasOwn(props, name) && typeof props[name] !== 'function' ? [[name, props[name]]] : []));
23
+ }
24
+ export function setQueryCanvas(id, canvas) {
25
+ canvasById.set(id, canvas);
26
+ }
27
+ export function clearQueryCanvas(id, canvas) {
28
+ if (canvasById.get(id) === canvas) {
29
+ canvasById.delete(id);
30
+ }
31
+ }
32
+ export function getQueryCanvas(id) {
33
+ return canvasById.get(id);
34
+ }
35
+ //# sourceMappingURL=query-node.js.map
@@ -0,0 +1,6 @@
1
+ export declare function withSelectorId(className: string | undefined, id: string | undefined): string | undefined;
2
+ export declare function getSelectorIdFallback(selector: string): {
3
+ id: string;
4
+ selector: string;
5
+ } | undefined;
6
+ //# sourceMappingURL=selector-id.d.ts.map
@@ -0,0 +1,18 @@
1
+ function selectorIdClass(id) {
2
+ return `__doubao_taro_node_id_${id}`;
3
+ }
4
+ export function withSelectorId(className, id) {
5
+ if (!id || !/^[\w-]+$/.test(id)) {
6
+ return className;
7
+ }
8
+ const marker = selectorIdClass(id);
9
+ return className ? `${className} ${marker}` : marker;
10
+ }
11
+ export function getSelectorIdFallback(selector) {
12
+ if (!/^#[\w-]+$/.test(selector)) {
13
+ return;
14
+ }
15
+ const id = selector.slice(1);
16
+ return { id, selector: `.${selectorIdClass(id)}` };
17
+ }
18
+ //# sourceMappingURL=selector-id.js.map
@@ -0,0 +1,4 @@
1
+ export * from '@doubao-dev/framework';
2
+ /** ReactLynx background effects are asynchronous; no new host export is required. */
3
+ export { useEffect as useLayoutEffect } from '@doubao-dev/framework';
4
+ //# sourceMappingURL=react.d.ts.map
package/dist/react.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from '@doubao-dev/framework';
2
+ /** ReactLynx background effects are asynchronous; no new host export is required. */
3
+ export { useEffect as useLayoutEffect } from '@doubao-dev/framework';
4
+ //# sourceMappingURL=react.js.map
package/package.json CHANGED
@@ -24,10 +24,29 @@
24
24
  "import": "./dist/components/index.js",
25
25
  "require": "./dist/components/index.js"
26
26
  },
27
+ "./react": {
28
+ "types": "./dist/react.d.ts",
29
+ "import": "./dist/react.js",
30
+ "require": "./dist/react.js"
31
+ },
27
32
  "./package.json": "./package.json"
28
33
  },
34
+ "peerDependencies": {
35
+ "@doubao-dev/framework": "^0.10.0",
36
+ "@tarojs/components": "4.1.9",
37
+ "@tarojs/taro": "4.1.9"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "@tarojs/components": {
41
+ "optional": true
42
+ },
43
+ "@tarojs/taro": {
44
+ "optional": true
45
+ }
46
+ },
29
47
  "files": [
30
48
  "dist",
49
+ "assets",
31
50
  "README.md",
32
51
  "LICENCE",
33
52
  "!dist/**/*.map",
@@ -37,7 +56,10 @@
37
56
  "access": "public",
38
57
  "registry": "https://registry.npmjs.org/"
39
58
  },
40
- "version": "0.9.1",
59
+ "version": "0.10.0",
60
+ "dependencies": {
61
+ "@lynx-js/lynx-ui-form": "3.139.0"
62
+ },
41
63
  "scripts": {
42
64
  "dev": "npm run build -- -w",
43
65
  "build": "rimraf dist bundle && tsc -p tsconfig.build.json",