@lynx-js/react 0.105.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 (337) hide show
  1. package/CHANGELOG.md +250 -0
  2. package/LICENSE +202 -0
  3. package/README.md +20 -0
  4. package/components/lib/Page.d.ts +3 -0
  5. package/components/lib/Page.js +56 -0
  6. package/components/lib/Page.js.map +1 -0
  7. package/components/lib/index.d.ts +1 -0
  8. package/components/lib/index.js +5 -0
  9. package/components/lib/index.js.map +1 -0
  10. package/components/src/Page.ts +75 -0
  11. package/components/src/index.ts +5 -0
  12. package/package.json +162 -0
  13. package/refresh/.gitignore +1 -0
  14. package/refresh/.npmignore +3 -0
  15. package/refresh/.turbo/turbo-build.log +8 -0
  16. package/refresh/dist/index.js +311 -0
  17. package/refresh/package.json +21 -0
  18. package/refresh/src/index.ts +6 -0
  19. package/refresh/src/prefresh.d.ts +11 -0
  20. package/refresh/tsconfig.json +4 -0
  21. package/refresh/turbo.json +15 -0
  22. package/runtime/jsx-dev-runtime/index.d.ts +5 -0
  23. package/runtime/jsx-dev-runtime/index.js +4 -0
  24. package/runtime/jsx-runtime/index.d.ts +4 -0
  25. package/runtime/jsx-runtime/index.js +4 -0
  26. package/runtime/lazy/import.d.ts +1 -0
  27. package/runtime/lazy/import.js +55 -0
  28. package/runtime/lazy/internal.js +39 -0
  29. package/runtime/lazy/jsx-dev-runtime.js +12 -0
  30. package/runtime/lazy/jsx-runtime.js +12 -0
  31. package/runtime/lazy/legacy-react-runtime.js +20 -0
  32. package/runtime/lazy/react-lepus.js +9 -0
  33. package/runtime/lazy/react.js +46 -0
  34. package/runtime/lazy/target.js +11 -0
  35. package/runtime/lepus/index.d.ts +4 -0
  36. package/runtime/lepus/index.js +43 -0
  37. package/runtime/lepus/jsx-dev-runtime/index.js +4 -0
  38. package/runtime/lepus/jsx-runtime/index.js +66 -0
  39. package/runtime/lib/backgroundSnapshot.d.ts +23 -0
  40. package/runtime/lib/backgroundSnapshot.js +348 -0
  41. package/runtime/lib/backgroundSnapshot.js.map +1 -0
  42. package/runtime/lib/compat/componentIs.d.ts +4 -0
  43. package/runtime/lib/compat/componentIs.js +20 -0
  44. package/runtime/lib/compat/componentIs.js.map +1 -0
  45. package/runtime/lib/compat/initData.d.ts +43 -0
  46. package/runtime/lib/compat/initData.js +93 -0
  47. package/runtime/lib/compat/initData.js.map +1 -0
  48. package/runtime/lib/compat/lynxComponent.d.ts +5 -0
  49. package/runtime/lib/compat/lynxComponent.js +71 -0
  50. package/runtime/lib/compat/lynxComponent.js.map +1 -0
  51. package/runtime/lib/debug/debug.d.ts +2 -0
  52. package/runtime/lib/debug/debug.js +9 -0
  53. package/runtime/lib/debug/debug.js.map +1 -0
  54. package/runtime/lib/debug/printSnapshot.d.ts +3 -0
  55. package/runtime/lib/debug/printSnapshot.js +21 -0
  56. package/runtime/lib/debug/printSnapshot.js.map +1 -0
  57. package/runtime/lib/debug/profile.d.ts +1 -0
  58. package/runtime/lib/debug/profile.js +51 -0
  59. package/runtime/lib/debug/profile.js.map +1 -0
  60. package/runtime/lib/document.d.ts +4 -0
  61. package/runtime/lib/document.js +49 -0
  62. package/runtime/lib/document.js.map +1 -0
  63. package/runtime/lib/gesture/processGesture.d.ts +4 -0
  64. package/runtime/lib/gesture/processGesture.js +48 -0
  65. package/runtime/lib/gesture/processGesture.js.map +1 -0
  66. package/runtime/lib/gesture/processGestureBagkround.d.ts +2 -0
  67. package/runtime/lib/gesture/processGestureBagkround.js +16 -0
  68. package/runtime/lib/gesture/processGestureBagkround.js.map +1 -0
  69. package/runtime/lib/gesture/types.d.ts +34 -0
  70. package/runtime/lib/gesture/types.js +13 -0
  71. package/runtime/lib/gesture/types.js.map +1 -0
  72. package/runtime/lib/hooks/react.d.ts +26 -0
  73. package/runtime/lib/hooks/react.js +35 -0
  74. package/runtime/lib/hooks/react.js.map +1 -0
  75. package/runtime/lib/hooks/useLynxGlobalEventListener.d.ts +29 -0
  76. package/runtime/lib/hooks/useLynxGlobalEventListener.js +53 -0
  77. package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +1 -0
  78. package/runtime/lib/hydrate.d.ts +18 -0
  79. package/runtime/lib/hydrate.js +271 -0
  80. package/runtime/lib/hydrate.js.map +1 -0
  81. package/runtime/lib/index.d.ts +9 -0
  82. package/runtime/lib/index.js +46 -0
  83. package/runtime/lib/index.js.map +1 -0
  84. package/runtime/lib/internal.d.ts +26 -0
  85. package/runtime/lib/internal.js +41 -0
  86. package/runtime/lib/internal.js.map +1 -0
  87. package/runtime/lib/legacy-react-runtime/index.d.ts +7 -0
  88. package/runtime/lib/legacy-react-runtime/index.js +34 -0
  89. package/runtime/lib/legacy-react-runtime/index.js.map +1 -0
  90. package/runtime/lib/lifecycle/delayUnmount.d.ts +8 -0
  91. package/runtime/lib/lifecycle/delayUnmount.js +68 -0
  92. package/runtime/lib/lifecycle/delayUnmount.js.map +1 -0
  93. package/runtime/lib/lifecycle/destroy.d.ts +2 -0
  94. package/runtime/lib/lifecycle/destroy.js +21 -0
  95. package/runtime/lib/lifecycle/destroy.js.map +1 -0
  96. package/runtime/lib/lifecycle/pass.d.ts +3 -0
  97. package/runtime/lib/lifecycle/pass.js +12 -0
  98. package/runtime/lib/lifecycle/pass.js.map +1 -0
  99. package/runtime/lib/lifecycle/patchUpdate.d.ts +23 -0
  100. package/runtime/lib/lifecycle/patchUpdate.js +179 -0
  101. package/runtime/lib/lifecycle/patchUpdate.js.map +1 -0
  102. package/runtime/lib/lifecycle/reload.d.ts +3 -0
  103. package/runtime/lib/lifecycle/reload.js +63 -0
  104. package/runtime/lib/lifecycle/reload.js.map +1 -0
  105. package/runtime/lib/lifecycle/render.d.ts +2 -0
  106. package/runtime/lib/lifecycle/render.js +44 -0
  107. package/runtime/lib/lifecycle/render.js.map +1 -0
  108. package/runtime/lib/lifecycleConstant.d.ts +12 -0
  109. package/runtime/lib/lifecycleConstant.js +17 -0
  110. package/runtime/lib/lifecycleConstant.js.map +1 -0
  111. package/runtime/lib/list.d.ts +40 -0
  112. package/runtime/lib/list.js +305 -0
  113. package/runtime/lib/list.js.map +1 -0
  114. package/runtime/lib/lynx/calledByNative.d.ts +2 -0
  115. package/runtime/lib/lynx/calledByNative.js +113 -0
  116. package/runtime/lib/lynx/calledByNative.js.map +1 -0
  117. package/runtime/lib/lynx/component.d.ts +1 -0
  118. package/runtime/lib/lynx/component.js +69 -0
  119. package/runtime/lib/lynx/component.js.map +1 -0
  120. package/runtime/lib/lynx/dynamic-js.d.ts +2 -0
  121. package/runtime/lib/lynx/dynamic-js.js +31 -0
  122. package/runtime/lib/lynx/dynamic-js.js.map +1 -0
  123. package/runtime/lib/lynx/env.d.ts +1 -0
  124. package/runtime/lib/lynx/env.js +92 -0
  125. package/runtime/lib/lynx/env.js.map +1 -0
  126. package/runtime/lib/lynx/injectLepusMethods.d.ts +2 -0
  127. package/runtime/lib/lynx/injectLepusMethods.js +50 -0
  128. package/runtime/lib/lynx/injectLepusMethods.js.map +1 -0
  129. package/runtime/lib/lynx/lazy-bundle.d.ts +9 -0
  130. package/runtime/lib/lynx/lazy-bundle.js +119 -0
  131. package/runtime/lib/lynx/lazy-bundle.js.map +1 -0
  132. package/runtime/lib/lynx/performance.d.ts +29 -0
  133. package/runtime/lib/lynx/performance.js +100 -0
  134. package/runtime/lib/lynx/performance.js.map +1 -0
  135. package/runtime/lib/lynx/tt.d.ts +4 -0
  136. package/runtime/lib/lynx/tt.js +193 -0
  137. package/runtime/lib/lynx/tt.js.map +1 -0
  138. package/runtime/lib/lynx-api.d.ts +311 -0
  139. package/runtime/lib/lynx-api.js +116 -0
  140. package/runtime/lib/lynx-api.js.map +1 -0
  141. package/runtime/lib/lynx.d.ts +2 -0
  142. package/runtime/lib/lynx.js +91 -0
  143. package/runtime/lib/lynx.js.map +1 -0
  144. package/runtime/lib/opcodes.d.ts +2 -0
  145. package/runtime/lib/opcodes.js +59 -0
  146. package/runtime/lib/opcodes.js.map +1 -0
  147. package/runtime/lib/renderToOpcodes/constants.d.ts +17 -0
  148. package/runtime/lib/renderToOpcodes/constants.js +23 -0
  149. package/runtime/lib/renderToOpcodes/constants.js.map +1 -0
  150. package/runtime/lib/renderToOpcodes/index.d.ts +13 -0
  151. package/runtime/lib/renderToOpcodes/index.js +227 -0
  152. package/runtime/lib/renderToOpcodes/index.js.map +1 -0
  153. package/runtime/lib/root.d.ts +7 -0
  154. package/runtime/lib/root.js +17 -0
  155. package/runtime/lib/root.js.map +1 -0
  156. package/runtime/lib/snapshot/event.d.ts +3 -0
  157. package/runtime/lib/snapshot/event.js +24 -0
  158. package/runtime/lib/snapshot/event.js.map +1 -0
  159. package/runtime/lib/snapshot/gesture.d.ts +2 -0
  160. package/runtime/lib/snapshot/gesture.js +18 -0
  161. package/runtime/lib/snapshot/gesture.js.map +1 -0
  162. package/runtime/lib/snapshot/platformInfo.d.ts +4 -0
  163. package/runtime/lib/snapshot/platformInfo.js +35 -0
  164. package/runtime/lib/snapshot/platformInfo.js.map +1 -0
  165. package/runtime/lib/snapshot/ref.d.ts +10 -0
  166. package/runtime/lib/snapshot/ref.js +119 -0
  167. package/runtime/lib/snapshot/ref.js.map +1 -0
  168. package/runtime/lib/snapshot/spread.d.ts +5 -0
  169. package/runtime/lib/snapshot/spread.js +289 -0
  170. package/runtime/lib/snapshot/spread.js.map +1 -0
  171. package/runtime/lib/snapshot/workletEvent.d.ts +3 -0
  172. package/runtime/lib/snapshot/workletEvent.js +22 -0
  173. package/runtime/lib/snapshot/workletEvent.js.map +1 -0
  174. package/runtime/lib/snapshot/workletRef.d.ts +5 -0
  175. package/runtime/lib/snapshot/workletRef.js +52 -0
  176. package/runtime/lib/snapshot/workletRef.js.map +1 -0
  177. package/runtime/lib/snapshot.d.ts +81 -0
  178. package/runtime/lib/snapshot.js +477 -0
  179. package/runtime/lib/snapshot.js.map +1 -0
  180. package/runtime/lib/snapshotPatch.d.ts +14 -0
  181. package/runtime/lib/snapshotPatch.js +31 -0
  182. package/runtime/lib/snapshotPatch.js.map +1 -0
  183. package/runtime/lib/snapshotPatchApply.d.ts +2 -0
  184. package/runtime/lib/snapshotPatchApply.js +110 -0
  185. package/runtime/lib/snapshotPatchApply.js.map +1 -0
  186. package/runtime/lib/utils.d.ts +4 -0
  187. package/runtime/lib/utils.js +32 -0
  188. package/runtime/lib/utils.js.map +1 -0
  189. package/runtime/lib/worklet/ctx.d.ts +1 -0
  190. package/runtime/lib/worklet/ctx.js +17 -0
  191. package/runtime/lib/worklet/ctx.js.map +1 -0
  192. package/runtime/lib/worklet/execMap.d.ts +1 -0
  193. package/runtime/lib/worklet/execMap.js +42 -0
  194. package/runtime/lib/worklet/execMap.js.map +1 -0
  195. package/runtime/lib/worklet/functionality.d.ts +1 -0
  196. package/runtime/lib/worklet/functionality.js +11 -0
  197. package/runtime/lib/worklet/functionality.js.map +1 -0
  198. package/runtime/lib/worklet/hmr.d.ts +1 -0
  199. package/runtime/lib/worklet/hmr.js +21 -0
  200. package/runtime/lib/worklet/hmr.js.map +1 -0
  201. package/runtime/lib/worklet/indexMap.d.ts +8 -0
  202. package/runtime/lib/worklet/indexMap.js +17 -0
  203. package/runtime/lib/worklet/indexMap.js.map +1 -0
  204. package/runtime/lib/worklet/jsImpl.d.ts +11 -0
  205. package/runtime/lib/worklet/jsImpl.js +68 -0
  206. package/runtime/lib/worklet/jsImpl.js.map +1 -0
  207. package/runtime/lib/worklet/runWorklet.d.ts +14 -0
  208. package/runtime/lib/worklet/runWorklet.js +82 -0
  209. package/runtime/lib/worklet/runWorklet.js.map +1 -0
  210. package/runtime/lib/worklet/workletRef.d.ts +131 -0
  211. package/runtime/lib/worklet/workletRef.js +96 -0
  212. package/runtime/lib/worklet/workletRef.js.map +1 -0
  213. package/runtime/lib/worklet/workletRefPool.d.ts +2 -0
  214. package/runtime/lib/worklet/workletRefPool.js +22 -0
  215. package/runtime/lib/worklet/workletRefPool.js.map +1 -0
  216. package/runtime/src/backgroundSnapshot.ts +452 -0
  217. package/runtime/src/compat/componentIs.ts +30 -0
  218. package/runtime/src/compat/initData.ts +140 -0
  219. package/runtime/src/compat/lynxComponent.ts +80 -0
  220. package/runtime/src/debug/debug.ts +9 -0
  221. package/runtime/src/debug/printSnapshot.ts +28 -0
  222. package/runtime/src/debug/profile.ts +54 -0
  223. package/runtime/src/document.ts +53 -0
  224. package/runtime/src/gesture/processGesture.ts +77 -0
  225. package/runtime/src/gesture/processGestureBagkround.ts +15 -0
  226. package/runtime/src/gesture/types.ts +39 -0
  227. package/runtime/src/hooks/react.ts +62 -0
  228. package/runtime/src/hooks/useLynxGlobalEventListener.ts +59 -0
  229. package/runtime/src/hydrate.ts +364 -0
  230. package/runtime/src/index.ts +89 -0
  231. package/runtime/src/internal.ts +60 -0
  232. package/runtime/src/legacy-react-runtime/index.ts +40 -0
  233. package/runtime/src/lifecycle/delayUnmount.ts +77 -0
  234. package/runtime/src/lifecycle/destroy.ts +26 -0
  235. package/runtime/src/lifecycle/pass.ts +14 -0
  236. package/runtime/src/lifecycle/patchUpdate.ts +240 -0
  237. package/runtime/src/lifecycle/reload.ts +79 -0
  238. package/runtime/src/lifecycle/render.ts +46 -0
  239. package/runtime/src/lifecycleConstant.ts +16 -0
  240. package/runtime/src/list.ts +375 -0
  241. package/runtime/src/lynx/calledByNative.ts +132 -0
  242. package/runtime/src/lynx/component.ts +116 -0
  243. package/runtime/src/lynx/dynamic-js.ts +33 -0
  244. package/runtime/src/lynx/env.ts +110 -0
  245. package/runtime/src/lynx/injectLepusMethods.ts +53 -0
  246. package/runtime/src/lynx/lazy-bundle.ts +126 -0
  247. package/runtime/src/lynx/performance.ts +117 -0
  248. package/runtime/src/lynx/tt.ts +212 -0
  249. package/runtime/src/lynx-api.ts +374 -0
  250. package/runtime/src/lynx.ts +105 -0
  251. package/runtime/src/opcodes.ts +64 -0
  252. package/runtime/src/renderToOpcodes/constants.ts +24 -0
  253. package/runtime/src/renderToOpcodes/index.ts +301 -0
  254. package/runtime/src/root.ts +19 -0
  255. package/runtime/src/snapshot/event.ts +33 -0
  256. package/runtime/src/snapshot/gesture.ts +25 -0
  257. package/runtime/src/snapshot/platformInfo.ts +48 -0
  258. package/runtime/src/snapshot/ref.ts +151 -0
  259. package/runtime/src/snapshot/spread.ts +287 -0
  260. package/runtime/src/snapshot/workletEvent.ts +33 -0
  261. package/runtime/src/snapshot/workletRef.ts +63 -0
  262. package/runtime/src/snapshot.ts +576 -0
  263. package/runtime/src/snapshotPatch.ts +56 -0
  264. package/runtime/src/snapshotPatchApply.ts +117 -0
  265. package/runtime/src/utils.ts +35 -0
  266. package/runtime/src/worklet/ctx.ts +22 -0
  267. package/runtime/src/worklet/execMap.ts +50 -0
  268. package/runtime/src/worklet/functionality.ts +12 -0
  269. package/runtime/src/worklet/hmr.ts +26 -0
  270. package/runtime/src/worklet/indexMap.ts +20 -0
  271. package/runtime/src/worklet/jsImpl.ts +86 -0
  272. package/runtime/src/worklet/runWorklet.ts +88 -0
  273. package/runtime/src/worklet/workletRef.ts +229 -0
  274. package/runtime/src/worklet/workletRefPool.ts +25 -0
  275. package/transform/cjs/main.cjs +6 -0
  276. package/transform/cjs/main.d.cts +3 -0
  277. package/transform/cjs/package.json +3 -0
  278. package/transform/dist/wasm.cjs +8478 -0
  279. package/transform/index.d.ts +187 -0
  280. package/transform/main.js +15 -0
  281. package/types/react.d.ts +147 -0
  282. package/types/react.docs.d.ts +74 -0
  283. package/worklet-runtime/dist/dev.js +414 -0
  284. package/worklet-runtime/dist/dev.js.map +8 -0
  285. package/worklet-runtime/dist/main.js +414 -0
  286. package/worklet-runtime/dist/main.js.map +8 -0
  287. package/worklet-runtime/lib/api/element.d.ts +14 -0
  288. package/worklet-runtime/lib/api/element.js +71 -0
  289. package/worklet-runtime/lib/api/element.js.map +1 -0
  290. package/worklet-runtime/lib/api/lepusQuerySelector.d.ts +3 -0
  291. package/worklet-runtime/lib/api/lepusQuerySelector.js +23 -0
  292. package/worklet-runtime/lib/api/lepusQuerySelector.js.map +1 -0
  293. package/worklet-runtime/lib/api/lynxApi.d.ts +2 -0
  294. package/worklet-runtime/lib/api/lynxApi.js +35 -0
  295. package/worklet-runtime/lib/api/lynxApi.js.map +1 -0
  296. package/worklet-runtime/lib/bindings/bindings.d.ts +14 -0
  297. package/worklet-runtime/lib/bindings/bindings.js +61 -0
  298. package/worklet-runtime/lib/bindings/bindings.js.map +1 -0
  299. package/worklet-runtime/lib/bindings/events.d.ts +7 -0
  300. package/worklet-runtime/lib/bindings/events.js +9 -0
  301. package/worklet-runtime/lib/bindings/events.js.map +1 -0
  302. package/worklet-runtime/lib/bindings/index.d.ts +4 -0
  303. package/worklet-runtime/lib/bindings/index.js +7 -0
  304. package/worklet-runtime/lib/bindings/index.js.map +1 -0
  305. package/worklet-runtime/lib/bindings/loadRuntime.d.ts +8 -0
  306. package/worklet-runtime/lib/bindings/loadRuntime.js +25 -0
  307. package/worklet-runtime/lib/bindings/loadRuntime.js.map +1 -0
  308. package/worklet-runtime/lib/bindings/types.d.ts +35 -0
  309. package/worklet-runtime/lib/bindings/types.js +2 -0
  310. package/worklet-runtime/lib/bindings/types.js.map +1 -0
  311. package/worklet-runtime/lib/delayWorkletEvent.d.ts +11 -0
  312. package/worklet-runtime/lib/delayWorkletEvent.js +49 -0
  313. package/worklet-runtime/lib/delayWorkletEvent.js.map +1 -0
  314. package/worklet-runtime/lib/global.d.ts +15 -0
  315. package/worklet-runtime/lib/global.js +2 -0
  316. package/worklet-runtime/lib/global.js.map +1 -0
  317. package/worklet-runtime/lib/index.d.ts +1 -0
  318. package/worklet-runtime/lib/index.js +12 -0
  319. package/worklet-runtime/lib/index.js.map +1 -0
  320. package/worklet-runtime/lib/jsFunctionLifecycle.d.ts +18 -0
  321. package/worklet-runtime/lib/jsFunctionLifecycle.js +55 -0
  322. package/worklet-runtime/lib/jsFunctionLifecycle.js.map +1 -0
  323. package/worklet-runtime/lib/listeners.d.ts +2 -0
  324. package/worklet-runtime/lib/listeners.js +17 -0
  325. package/worklet-runtime/lib/listeners.js.map +1 -0
  326. package/worklet-runtime/lib/utils/profile.d.ts +1 -0
  327. package/worklet-runtime/lib/utils/profile.js +20 -0
  328. package/worklet-runtime/lib/utils/profile.js.map +1 -0
  329. package/worklet-runtime/lib/utils/version.d.ts +1 -0
  330. package/worklet-runtime/lib/utils/version.js +10 -0
  331. package/worklet-runtime/lib/utils/version.js.map +1 -0
  332. package/worklet-runtime/lib/workletRef.d.ts +12 -0
  333. package/worklet-runtime/lib/workletRef.js +50 -0
  334. package/worklet-runtime/lib/workletRef.js.map +1 -0
  335. package/worklet-runtime/lib/workletRuntime.d.ts +2 -0
  336. package/worklet-runtime/lib/workletRuntime.js +128 -0
  337. package/worklet-runtime/lib/workletRuntime.js.map +1 -0
@@ -0,0 +1,43 @@
1
+ import type { ComponentClass, Consumer, Context, FC, ReactNode } from 'react';
2
+ import { useLynxGlobalEventListener } from '../hooks/useLynxGlobalEventListener.js';
3
+ type Getter<T> = {
4
+ [key in keyof T]: () => T[key];
5
+ };
6
+ export declare function factory<Data>({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }: typeof import('react') & {
7
+ useLynxGlobalEventListener: typeof useLynxGlobalEventListener;
8
+ }, prop: '__globalProps' | '__initData', eventName: string): Getter<{
9
+ Context: Context<Data>;
10
+ Provider: FC<{
11
+ children?: ReactNode | undefined;
12
+ }>;
13
+ Consumer: Consumer<Data>;
14
+ use: () => Data;
15
+ useChanged: (callback: (data: Data) => void) => void;
16
+ }>;
17
+ /**
18
+ * Higher-Order Component (HOC) that injects `initData` into the state of the given class component.
19
+ *
20
+ * This HOC checks if the provided component is a class component. If it is, it wraps the component
21
+ * and injects the `initData` into its state. It also adds a listener
22
+ * to update the state when data changes, and removes the listener when the component unmounts.
23
+ *
24
+ * @typeParam P - The type of the props of the wrapped component.
25
+ * @typeParam S - The type of the state of the wrapped component.
26
+ *
27
+ * @param App - The class component to be wrapped by the HOC.
28
+ *
29
+ * @returns The original component if it is not a class component, otherwise a new class component
30
+ * with `initData` injection and state update functionality.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * class App extends React.Component<MyProps, MyState> {
35
+ * // component implementation
36
+ * }
37
+ *
38
+ * export default withInitDataInState(App);
39
+ * ```
40
+ * @public
41
+ */
42
+ export declare function withInitDataInState<P, S>(App: ComponentClass<P, S>): ComponentClass<P, S>;
43
+ export {};
@@ -0,0 +1,93 @@
1
+ import { useLynxGlobalEventListener } from '../hooks/useLynxGlobalEventListener.js';
2
+ // for better reuse if runtime is changed
3
+ export function factory({ createContext, useState, createElement, useLynxGlobalEventListener: useListener }, prop, eventName) {
4
+ const Context = createContext({});
5
+ const Provider = ({ children }) => {
6
+ const [__, set] = useState(lynx[prop]);
7
+ const handleChange = () => {
8
+ set(lynx[prop]);
9
+ };
10
+ useChanged(handleChange);
11
+ return createElement(Context.Provider, {
12
+ value: __,
13
+ }, children);
14
+ };
15
+ const Consumer = Context.Consumer;
16
+ const use = () => {
17
+ const [__, set] = useState(lynx[prop]);
18
+ useChanged(() => {
19
+ set(lynx[prop]);
20
+ });
21
+ return __;
22
+ };
23
+ const useChanged = (callback) => {
24
+ if (!__LEPUS__) {
25
+ // @ts-ignore
26
+ useListener(eventName, callback);
27
+ }
28
+ };
29
+ return {
30
+ Context: () => Context,
31
+ Provider: () => Provider,
32
+ Consumer: () => Consumer,
33
+ use: () => use,
34
+ useChanged: () => useChanged,
35
+ };
36
+ }
37
+ /**
38
+ * Higher-Order Component (HOC) that injects `initData` into the state of the given class component.
39
+ *
40
+ * This HOC checks if the provided component is a class component. If it is, it wraps the component
41
+ * and injects the `initData` into its state. It also adds a listener
42
+ * to update the state when data changes, and removes the listener when the component unmounts.
43
+ *
44
+ * @typeParam P - The type of the props of the wrapped component.
45
+ * @typeParam S - The type of the state of the wrapped component.
46
+ *
47
+ * @param App - The class component to be wrapped by the HOC.
48
+ *
49
+ * @returns The original component if it is not a class component, otherwise a new class component
50
+ * with `initData` injection and state update functionality.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * class App extends React.Component<MyProps, MyState> {
55
+ * // component implementation
56
+ * }
57
+ *
58
+ * export default withInitDataInState(App);
59
+ * ```
60
+ * @public
61
+ */
62
+ export function withInitDataInState(App) {
63
+ const isClassComponent = 'prototype' in App && App.prototype.render;
64
+ if (!isClassComponent) {
65
+ // return as-is when not class component
66
+ return App;
67
+ }
68
+ class C extends App {
69
+ h;
70
+ constructor(props) {
71
+ super(props);
72
+ this.state = {
73
+ ...this.state,
74
+ ...lynx.__initData,
75
+ };
76
+ if (!__LEPUS__) {
77
+ // @ts-ignore
78
+ lynx.getJSModule('GlobalEventEmitter').addListener('onDataChanged', this.h = () => {
79
+ this.setState(lynx.__initData);
80
+ });
81
+ }
82
+ }
83
+ componentWillUnmount() {
84
+ super.componentWillUnmount?.();
85
+ if (!__LEPUS__) {
86
+ // @ts-ignore
87
+ lynx.getJSModule('GlobalEventEmitter').removeListener('onDataChanged', this.h);
88
+ }
89
+ }
90
+ }
91
+ return C;
92
+ }
93
+ //# sourceMappingURL=initData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initData.js","sourceRoot":"","sources":["../../src/compat/initData.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAMpF,yCAAyC;AACzC,MAAM,UAAU,OAAO,CACrB,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,0BAA0B,EAAE,WAAW,EAEhF,EACD,IAAoC,EACpC,SAAiB;IAUjB,MAAM,OAAO,GAAG,aAAa,CAAC,EAAU,CAAC,CAAC;IAE1C,MAAM,QAAQ,GAA0B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvD,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAO,IAAI,CAAC,IAAI,CAAS,CAAC,CAAC;QAErD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAS,CAAC,CAAC;QAC1B,CAAC,CAAC;QAEF,UAA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AAK,CAAC,KAAK,CAAC,CAAC;YACb,IAAI,CAAC,KAAK,GAAG;gBACX,GAAG,IAAI,CAAC,KAAK;gBACb,GAAG,IAAI,CAAC,UAAU;aACnB,CAAC;YAEF,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,aAAa;gBACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAChD,eAAe,EACf,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE;oBACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACjC,CAAC,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAEQ,oBAAoB;YAC3B,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,aAAa;gBACb,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,cAAc,CACnD,eAAe,EACf,IAAI,CAAC,CAAC,CACP,CAAC;YACJ,CAAC;QACH,CAAC;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Component } from 'preact';
2
+ import type { ReactNode } from 'react';
3
+ export declare function wrapWithLynxComponent(jsxSnapshot: (c: ReactNode, spread?: Record<string, any>) => ReactNode, jsxComponent: any): ReactNode;
4
+ export declare class ComponentFromReactRuntime extends Component {
5
+ }
@@ -0,0 +1,71 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { Component } from 'preact';
5
+ export function wrapWithLynxComponent(jsxSnapshot, jsxComponent) {
6
+ const C = jsxComponent.type;
7
+ if (typeof C === 'function') {
8
+ if (C === ComponentFromReactRuntime || C.prototype instanceof ComponentFromReactRuntime) {
9
+ if (jsxSnapshot.length === 1) {
10
+ return jsxSnapshot(jsxComponent);
11
+ }
12
+ else {
13
+ // spread
14
+ if (!jsxComponent.props.removeComponentElement) {
15
+ return jsxSnapshot(jsxComponent, takeComponentAttributes(jsxComponent));
16
+ }
17
+ }
18
+ }
19
+ }
20
+ return jsxComponent;
21
+ }
22
+ // @ts-expect-error
23
+ export class ComponentFromReactRuntime extends Component {
24
+ }
25
+ const __COMPONENT_ATTRIBUTES__ = /* @__PURE__ */ new Set([
26
+ 'name',
27
+ 'style',
28
+ 'class',
29
+ 'flatten',
30
+ 'clip-radius',
31
+ 'overlap',
32
+ 'user-interaction-enabled',
33
+ 'native-interaction-enabled',
34
+ 'block-native-event',
35
+ 'enableLayoutOnly',
36
+ 'cssAlignWithLegacyW3C',
37
+ 'intersection-observers',
38
+ 'trigger-global-event',
39
+ 'exposure-scene',
40
+ 'exposure-id',
41
+ 'exposure-screen-margin-top',
42
+ 'exposure-screen-margin-bottom',
43
+ 'exposure-screen-margin-left',
44
+ 'exposure-screen-margin-right',
45
+ 'focusable',
46
+ 'focus-index',
47
+ 'accessibility-label',
48
+ 'accessibility-element',
49
+ 'accessibility-traits',
50
+ 'enable-new-animator',
51
+ ]);
52
+ function takeComponentAttributes(jsxComponent) {
53
+ const attributes = {};
54
+ Object.keys(jsxComponent.props).forEach((k) => {
55
+ // let re1 = Regex::new(r"^(global-bind|bind|catch|capture-bind|capture-catch)([A-Za-z]+)$").unwrap();
56
+ // let re2 = Regex::new(r"^data-([A-Za-z]+)$").unwrap();
57
+ if (__COMPONENT_ATTRIBUTES__.has(k)
58
+ || k === 'id'
59
+ || k === 'className'
60
+ || k === 'dataSet'
61
+ || k === 'data-set'
62
+ || k === 'removeComponentElement'
63
+ || k.match(/^(global-bind|bind|catch|capture-bind|capture-catch)([A-Za-z]+)$/)
64
+ || k.match(/^data-([A-Za-z]+)$/)) {
65
+ attributes[k] = jsxComponent.props[k];
66
+ delete jsxComponent.props[k];
67
+ }
68
+ });
69
+ return attributes;
70
+ }
71
+ //# sourceMappingURL=lynxComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lynxComponent.js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C,YAAiB;IAChD,MAAM,UAAU,GAAwB,EAAE,CAAC;IAC3C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5C,sGAAsG;QACtG,wDAAwD;QACxD,IACE,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC;eAC5B,CAAC,KAAK,IAAI;eACV,CAAC,KAAK,WAAW;eACjB,CAAC,KAAK,SAAS;eACf,CAAC,KAAK,UAAU;eAChB,CAAC,KAAK,wBAAwB;eAC9B,CAAC,CAAC,KAAK,CAAC,kEAAkE,CAAC;eAC3E,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAChC,CAAC;YACD,UAAU,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const logDebug: (...args: any[]) => void;
2
+ export {};
@@ -0,0 +1,9 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ const logDebug = console.debug;
5
+ /**
6
+ * @internal
7
+ */
8
+ export { logDebug };
9
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/debug/debug.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,QAAQ,GAA6B,OAAO,CAAC,KAAK,CAAC;AAEzD;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { BackgroundSnapshotInstance } from '../backgroundSnapshot.js';
2
+ import { SnapshotInstance } from '../snapshot.js';
3
+ export declare function printSnapshotInstance(instance: BackgroundSnapshotInstance | SnapshotInstance, log?: (...data: any[]) => void): void;
@@ -0,0 +1,21 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { BackgroundSnapshotInstance } from '../backgroundSnapshot.js';
5
+ import { SnapshotInstance } from '../snapshot.js';
6
+ import { logDebug } from './debug.js';
7
+ export function printSnapshotInstance(instance, log) {
8
+ const impl = (instance, level) => {
9
+ let msg = '';
10
+ for (let i = 0; i < level; ++i) {
11
+ msg += ' ';
12
+ }
13
+ msg += `| ${instance.__id}(${instance.type}): ${JSON.stringify(instance.__values)}`;
14
+ (log ?? logDebug)(msg);
15
+ for (const c of instance.childNodes) {
16
+ impl(c, level + 1);
17
+ }
18
+ };
19
+ impl(instance, 0);
20
+ }
21
+ //# sourceMappingURL=printSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"printSnapshot.js","sourceRoot":"","sources":["../../src/debug/printSnapshot.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,qBAAqB,CACnC,QAAuD,EACvD,GAA8B;IAE9B,MAAM,IAAI,GAAG,CACX,QAAuD,EACvD,KAAa,EACb,EAAE;QACF,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;YAC/B,GAAG,IAAI,IAAI,CAAC;QACd,CAAC;QACD,GAAG,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpF,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YACpC,IAAI,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function initProfileHook(): void;
@@ -0,0 +1,51 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { options } from 'preact';
5
+ import { COMPONENT, DIFF, DIFFED, RENDER } from '../renderToOpcodes/constants.js';
6
+ export function initProfileHook() {
7
+ const oldDiff = options[DIFF];
8
+ options[DIFF] = function (vnode) {
9
+ // This __PROFILE__ is used for DCE testing
10
+ if (__PROFILE__ && typeof vnode.type === 'function') {
11
+ // We only add profiling trace for Component
12
+ console.profile(`diff::${getDisplayName(vnode.type)}`);
13
+ }
14
+ oldDiff?.(vnode);
15
+ };
16
+ const oldDiffed = options[DIFFED];
17
+ options[DIFFED] = function (vnode) {
18
+ // This __PROFILE__ is used for DCE testing
19
+ if (__PROFILE__ && typeof vnode.type === 'function') {
20
+ console.profileEnd(); // for options[DIFF]
21
+ }
22
+ oldDiffed?.(vnode);
23
+ };
24
+ // Profile the user-provided `render`.
25
+ const oldRender = options[RENDER];
26
+ options[RENDER] = function (vnode) {
27
+ const displayName = getDisplayName(vnode.type);
28
+ const originalRender = vnode[COMPONENT].render;
29
+ vnode[COMPONENT].render = function render(props, state, context) {
30
+ // This __PROFILE__ is used for DCE testing
31
+ if (__PROFILE__) {
32
+ console.profile(`render::${displayName}`);
33
+ }
34
+ try {
35
+ return originalRender.call(this, props, state, context);
36
+ }
37
+ finally {
38
+ // This __PROFILE__ is used for DCE testing
39
+ if (__PROFILE__) {
40
+ console.profileEnd();
41
+ }
42
+ vnode[COMPONENT].render = originalRender;
43
+ }
44
+ };
45
+ oldRender?.(vnode);
46
+ };
47
+ }
48
+ function getDisplayName(type) {
49
+ return type.displayName ?? type.name;
50
+ }
51
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/debug/profile.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,UAAS,KAAY;QACnC,2CAA2C;QAC3C,IAAI,WAAW,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACpD,4CAA4C;YAC5C,OAAO,CAAC,OAAO,CAAC,SAAS,cAAc,CAAC,KAAK,CAAC,IAAsB,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAC,GAAG,UAAS,KAAK;QAC9B,2CAA2C;QAC3C,IAAI,WAAW,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACpD,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,oBAAoB;QAC5C,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,sCAAsC;IACtC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAC,GAAG,UAAS,KAAyC;QAClE,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,IAAsB,CAAC,CAAC;QACjE,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;QAC/C,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,SAAS,MAAM,CAAO,KAAK,EAAE,KAAK,EAAE,OAAO;YACnE,2CAA2C;YAC3C,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,OAAO,CAAC,WAAW,WAAW,EAAE,CAAC,CAAC;YAC5C,CAAC;YACD,IAAI,CAAC;gBACH,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAC1D,CAAC;oBAAS,CAAC;gBACT,2CAA2C;gBAC3C,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,CAAC;gBACD,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,cAAc,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;QACF,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,IAAoB;IAC1C,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC;AACvC,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const document: any;
2
+ declare function setupBackgroundDocument(): void;
3
+ declare function setupDocument(): void;
4
+ export { setupBackgroundDocument, setupDocument, document };
@@ -0,0 +1,49 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { BackgroundSnapshotInstance } from './backgroundSnapshot.js';
5
+ import { SnapshotInstance } from './snapshot.js';
6
+ const document = {};
7
+ function setupBackgroundDocument() {
8
+ document.createElement = function (type) {
9
+ return new BackgroundSnapshotInstance(type);
10
+ };
11
+ document.createElementNS = function (_ns, type) {
12
+ return new BackgroundSnapshotInstance(type);
13
+ };
14
+ document.createTextNode = function (text) {
15
+ const i = new BackgroundSnapshotInstance(null);
16
+ i.setAttribute(0, text);
17
+ Object.defineProperty(i, 'data', {
18
+ set(v) {
19
+ i.setAttribute(0, v);
20
+ },
21
+ });
22
+ return i;
23
+ };
24
+ }
25
+ function setupDocument() {
26
+ document.createElement = function (type) {
27
+ return new SnapshotInstance(type);
28
+ };
29
+ document.createElementNS = function (_ns, type) {
30
+ return new SnapshotInstance(type);
31
+ };
32
+ document.createTextNode = function (text) {
33
+ const i = new SnapshotInstance(null);
34
+ i.setAttribute(0, text);
35
+ Object.defineProperty(i, 'data', {
36
+ set(v) {
37
+ i.setAttribute(0, v);
38
+ },
39
+ });
40
+ return i;
41
+ };
42
+ }
43
+ // if (__JS__) {
44
+ // setupBackgroundDocument();
45
+ // } else if (__LEPUS__) {
46
+ // setupDocument();
47
+ // }
48
+ export { setupBackgroundDocument, setupDocument, document };
49
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,QAAQ,GAAQ,EAAE,CAAC;AAEzB,SAAS,uBAAuB;IAC9B,QAAQ,CAAC,aAAa,GAAG,UAAS,IAAY;QAC5C,OAAO,IAAI,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC;IACF,QAAQ,CAAC,eAAe,GAAG,UAAS,GAAW,EAAE,IA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E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type GestureKind } from './types.js';
2
+ export declare function processGesture(dom: FiberElement, gesture: GestureKind, gestureOptions?: {
3
+ domSet: boolean;
4
+ }): void;
@@ -0,0 +1,48 @@
1
+ import { GestureTypeInner, } from './types.js';
2
+ import { onWorkletCtxUpdate } from '@lynx-js/react/worklet-runtime/bindings';
3
+ function isSerializedGesture(gesture) {
4
+ return gesture.__isSerialized ?? false;
5
+ }
6
+ function getGestureInfo(gesture, dom) {
7
+ const config = {
8
+ callbacks: [],
9
+ };
10
+ const baseGesture = gesture;
11
+ for (const key of Object.keys(baseGesture.callbacks)) {
12
+ const callback = baseGesture.callbacks[key];
13
+ onWorkletCtxUpdate(callback, dom);
14
+ config.callbacks.push({
15
+ name: key,
16
+ callback: callback,
17
+ });
18
+ }
19
+ const relationMap = {
20
+ waitFor: baseGesture?.waitFor?.map(subGesture => subGesture.id) ?? [],
21
+ simultaneous: baseGesture?.simultaneousWith?.map(subGesture => subGesture.id) ?? [],
22
+ continueWith: baseGesture?.continueWith?.map(subGesture => subGesture.id) ?? [],
23
+ };
24
+ return {
25
+ config,
26
+ relationMap,
27
+ };
28
+ }
29
+ export function processGesture(dom, gesture, gestureOptions) {
30
+ if (!gesture || !isSerializedGesture(gesture)) {
31
+ return;
32
+ }
33
+ if (!(gestureOptions && gestureOptions.domSet)) {
34
+ __SetAttribute(dom, 'has-react-gesture', true);
35
+ __SetAttribute(dom, 'flatten', false);
36
+ }
37
+ if (gesture.type === GestureTypeInner.COMPOSED) {
38
+ for (const subGesture of gesture.gestures) {
39
+ processGesture(dom, subGesture, { domSet: true });
40
+ }
41
+ }
42
+ else {
43
+ const baseGesture = gesture;
44
+ const { config, relationMap } = getGestureInfo(baseGesture, dom);
45
+ __SetGestureDetector(dom, baseGesture.id, baseGesture.type, config, relationMap);
46
+ }
47
+ }
48
+ //# sourceMappingURL=processGesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processGesture.js","sourceRo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AO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9C,OAAO;IACT,CAAC;IAED,IAAI,CAAC,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,cAAc,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,CAAC;QAC/C,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC/C,KAAK,MAAM,UAAU,IAAK,OAA2B,CAAC,QAAQ,EAAE,CAAC;YAC/D,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAG,OAAsB,CAAC;QAE3C,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACjE,oBAAoB,CAClB,GAAG,EACH,WAAW,CAAC,EAAE,EACd,WAAW,CAAC,IAAI,EAChB,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { type GestureKind } from './types.js';
2
+ export declare function processGestureBackground(gesture: GestureKind): void;
@@ -0,0 +1,16 @@
1
+ import { onPostWorkletCtx } from '../worklet/ctx.js';
2
+ import { GestureTypeInner } from './types.js';
3
+ export function processGestureBackground(gesture) {
4
+ if (gesture.type === GestureTypeInner.COMPOSED) {
5
+ for (const subGesture of gesture.gestures) {
6
+ processGestureBackground(subGesture);
7
+ }
8
+ }
9
+ else {
10
+ const baseGesture = gesture;
11
+ for (const [name, value] of Object.entries(baseGesture.callbacks)) {
12
+ baseGesture.callbacks[name] = onPostWorkletCtx(value);
13
+ }
14
+ }
15
+ }
16
+ //# sourceMappingURL=processGestureBagkround.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processGestureBagkround.js","sourceRoot":"","sources":["../../src/gesture/processGestureBagkround.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAoB,gBAAgB,EAA0C,MAAM,YAAY,CAAC;AAExG,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,IAAI,OAAO,CAAC,IAAI,KAAK,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC/C,KAAK,MAAM,UAAU,IAAK,OAA2B,CAAC,QAAQ,EAAE,CAAC;YAC/D,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAG,OAAsB,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,CAAC;YAClE,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAE,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { Worklet } from '@lynx-js/react/worklet-runtime/bindings';
2
+ export declare enum GestureTypeInner {
3
+ COMPOSED = -1,
4
+ PAN = 0,
5
+ FLING = 1,
6
+ DEFAULT = 2,
7
+ TAP = 3,
8
+ LONGPRESS = 4,
9
+ ROTATION = 5,
10
+ PINCH = 6,
11
+ NATIVE = 7
12
+ }
13
+ export interface GestureKind {
14
+ type: GestureTypeInner;
15
+ __isSerialized?: boolean;
16
+ __isGesture?: boolean;
17
+ }
18
+ export interface ComposedGesture extends GestureKind {
19
+ type: GestureTypeInner.COMPOSED;
20
+ gestures: GestureKind[];
21
+ }
22
+ export interface BaseGesture extends GestureKind {
23
+ id: number;
24
+ callbacks: Record<string, Worklet>;
25
+ waitFor: BaseGesture[];
26
+ simultaneousWith: BaseGesture[];
27
+ continueWith: BaseGesture[];
28
+ }
29
+ export interface GestureConfig {
30
+ callbacks: {
31
+ name: string;
32
+ callback: Worklet;
33
+ }[];
34
+ }
@@ -0,0 +1,13 @@
1
+ export var GestureTypeInner;
2
+ (function (GestureTypeInner) {
3
+ GestureTypeInner[GestureTypeInner["COMPOSED"] = -1] = "COMPOSED";
4
+ GestureTypeInner[GestureTypeInner["PAN"] = 0] = "PAN";
5
+ GestureTypeInner[GestureTypeInner["FLING"] = 1] = "FLING";
6
+ GestureTypeInner[GestureTypeInner["DEFAULT"] = 2] = "DEFAULT";
7
+ GestureTypeInner[GestureTypeInner["TAP"] = 3] = "TAP";
8
+ GestureTypeInner[GestureTypeInner["LONGPRESS"] = 4] = "LONGPRESS";
9
+ GestureTypeInner[GestureTypeInner["ROTATION"] = 5] = "ROTATION";
10
+ GestureTypeInner[GestureTypeInner["PINCH"] = 6] = "PINCH";
11
+ GestureTypeInner[GestureTypeInner["NATIVE"] = 7] = "NATIVE";
12
+ })(GestureTypeInner || (GestureTypeInner = {}));
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/gesture/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,gEAAa,CAAA;IACb,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,6DAAW,CAAA;IACX,qDAAO,CAAA;IACP,iEAAa,CAAA;IACb,+DAAY,CAAA;IACZ,yDAAS,CAAA;IACT,2DAAU,CAAA;AACZ,CAAC,EAVW,gBAAgB,KAAhB,gBAAgB,QAU3B"}
@@ -0,0 +1,26 @@
1
+ import { useCallback, useContext, useDebugValue, useErrorBoundary, useId, useImperativeHandle, useMemo, useReducer, useRef, useState } from 'preact/hooks';
2
+ import type { DependencyList, EffectCallback } from 'react';
3
+ /**
4
+ * `useLayoutEffect` is now an alias of `useEffect`. Use `useEffect` instead.
5
+ *
6
+ * Accepts a function that contains imperative, possibly effectful code. The effects run after main thread dom update without blocking it.
7
+ *
8
+ * @param effect - Imperative function that can return a cleanup function
9
+ * @param deps - If present, effect will only activate if the values in the list change (using ===).
10
+ *
11
+ * @public
12
+ *
13
+ * @deprecated `useLayoutEffect` in the background thread cannot offer the precise timing for reading layout information and synchronously re-render, which is different from React.
14
+ */
15
+ declare function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
16
+ /**
17
+ * Accepts a function that contains imperative, possibly effectful code.
18
+ * The effects run after main thread dom update without blocking it.
19
+ *
20
+ * @param effect - Imperative function that can return a cleanup function
21
+ * @param deps - If present, effect will only activate if the values in the list change (using ===).
22
+ *
23
+ * @public
24
+ */
25
+ declare function useEffect(effect: EffectCallback, deps?: DependencyList): void;
26
+ export { useState, useReducer, useRef, useImperativeHandle, useLayoutEffect, useEffect, useCallback, useMemo, useContext, useDebugValue, useErrorBoundary, useId, };
@@ -0,0 +1,35 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { useCallback, useContext, useDebugValue, useErrorBoundary, useId, useImperativeHandle, useMemo, useLayoutEffect as usePreactLayoutEffect, useReducer, useRef, useState, } from 'preact/hooks';
5
+ /**
6
+ * `useLayoutEffect` is now an alias of `useEffect`. Use `useEffect` instead.
7
+ *
8
+ * Accepts a function that contains imperative, possibly effectful code. The effects run after main thread dom update without blocking it.
9
+ *
10
+ * @param effect - Imperative function that can return a cleanup function
11
+ * @param deps - If present, effect will only activate if the values in the list change (using ===).
12
+ *
13
+ * @public
14
+ *
15
+ * @deprecated `useLayoutEffect` in the background thread cannot offer the precise timing for reading layout information and synchronously re-render, which is different from React.
16
+ */
17
+ function useLayoutEffect(effect, deps) {
18
+ return usePreactLayoutEffect(effect, deps);
19
+ }
20
+ /**
21
+ * Accepts a function that contains imperative, possibly effectful code.
22
+ * The effects run after main thread dom update without blocking it.
23
+ *
24
+ * @param effect - Imperative function that can return a cleanup function
25
+ * @param deps - If present, effect will only activate if the values in the list change (using ===).
26
+ *
27
+ * @public
28
+ */
29
+ function useEffect(effect, deps) {
30
+ return usePreactLayoutEffect(effect, deps);
31
+ }
32
+ export {
33
+ // preact
34
+ useState, useReducer, useRef, useImperativeHandle, useLayoutEffect, useEffect, useCallback, useMemo, useContext, useDebugValue, useErrorBoundary, useId, };
35
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/hooks/react.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,eAAe,IAAI,qBAAqB,EACxC,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;GAWG;AACH,SAAS,eAAe,CAAC,MAAsB,EAAE,IAAqB;IACpE,OAAO,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,MAAsB,EAAE,IAAqB;IAC9D,OAAO,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO;AACL,SAAS;AACT,QAAQ,EACR,UAAU,EACV,MAAM,EACN,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,GACN,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `useLynxGlobalEventListener` help you `addListener` as early as possible.
3
+ *
4
+ * @example
5
+ *
6
+ * Use this hooks to listen to event 'exposure' and event 'disexposure'
7
+ *
8
+ * ```jsx
9
+ * function App() {
10
+ * useLynxGlobalEventListener('exposure', (e) => {
11
+ * console.log("exposure", e)
12
+ * })
13
+ * useLynxGlobalEventListener('disexposure', (e) => {
14
+ * console.log("disexposure", e)
15
+ * })
16
+ * return (
17
+ * <view
18
+ * style='width: 100px; height: 100px; background-color: red;'
19
+ * exposure-id='a'
20
+ * />
21
+ * )
22
+ * }
23
+ * ```
24
+ *
25
+ * @param eventName - Event name to listen
26
+ * @param listener - Event handler
27
+ * @public
28
+ */
29
+ export declare function useLynxGlobalEventListener<T extends (...args: unknown[]) => void>(eventName: string, listener: T): void;