@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,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 { render } from 'preact';
5
+ import { __root } from '../root.js';
6
+ import { globalCommitTaskMap } from './patchUpdate.js';
7
+ function destroyBackground() {
8
+ if (__PROFILE__) {
9
+ console.profile('destroyBackground');
10
+ }
11
+ render(null, __root);
12
+ globalCommitTaskMap.forEach(task => {
13
+ task();
14
+ });
15
+ globalCommitTaskMap.clear();
16
+ if (__PROFILE__) {
17
+ console.profileEnd();
18
+ }
19
+ }
20
+ export { destroyBackground };
21
+ //# sourceMappingURL=destroy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/lifecycle/destroy.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,SAAS,iBAAiB;IACxB,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;IAE5B,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACjC,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IACH,mBAAmB,CAAC,KAAK,EAAE,CAAC;IAE5B,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare function getReloadVersion(): number;
2
+ declare function increaseReloadVersion(): number;
3
+ export { getReloadVersion, increaseReloadVersion };
@@ -0,0 +1,12 @@
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
+ let reloadVersion = 0;
5
+ function getReloadVersion() {
6
+ return reloadVersion;
7
+ }
8
+ function increaseReloadVersion() {
9
+ return ++reloadVersion;
10
+ }
11
+ export { getReloadVersion, increaseReloadVersion };
12
+ //# sourceMappingURL=pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pass.js","sourceRoot":"","sources":["../../src/lifecycle/pass.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,SAAS,gBAAgB;IACvB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,qBAAqB;IAC5B,OAAO,EAAE,aAAa,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { SnapshotPatch } from '../snapshotPatch.js';
2
+ declare let globalFlushOptions: FlushOptions;
3
+ declare const globalCommitTaskMap: Map<number, () => void>;
4
+ declare let nextCommitTaskId: number;
5
+ declare let globalBackgroundSnapshotInstancesToRemove: number[];
6
+ interface Patch {
7
+ snapshotPatch?: SnapshotPatch;
8
+ workletRefInitValuePatch?: [id: number, value: unknown][];
9
+ flushOptions?: FlushOptions;
10
+ }
11
+ interface PatchOptions {
12
+ commitTaskId: number;
13
+ pipelineOptions?: PipelineOptions;
14
+ reloadVersion?: number;
15
+ isHydration?: boolean;
16
+ }
17
+ declare function injectUpdatePatch(): void;
18
+ declare function replaceCommitHook(): void;
19
+ declare function commitPatchUpdate(data: Patch, patchOptions: PatchOptions): Promise<void>;
20
+ declare function commitMainThreadPatchUpdate(commitTaskId?: number): void;
21
+ declare function genCommitTaskId(): number;
22
+ declare function replaceRequestAnimationFrame(): void;
23
+ export {};
@@ -0,0 +1,179 @@
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 { clearDelayedWorklets, updateWorkletRefInitValueChanges } from '@lynx-js/react/worklet-runtime/bindings';
6
+ import { LifecycleConstant } from '../lifecycleConstant.js';
7
+ import { __pendingListUpdates } from '../list.js';
8
+ import { runDelayedUnmounts, takeDelayedUnmounts } from './delayUnmount.js';
9
+ import { getReloadVersion } from './pass.js';
10
+ import { PerformanceTimingKeys, globalPipelineOptions, markTiming, markTimingLegacy, setPipeline, } from '../lynx/performance.js';
11
+ import { CATCH_ERROR, COMMIT, RENDER_CALLBACKS, VNODE } from '../renderToOpcodes/constants.js';
12
+ import { takeGlobalRefPatchMap, updateBackgroundRefs } from '../snapshot/ref.js';
13
+ import { __page, backgroundSnapshotInstanceManager } from '../snapshot.js';
14
+ import { takeGlobalSnapshotPatch } from '../snapshotPatch.js';
15
+ import { snapshotPatchApply } from '../snapshotPatchApply.js';
16
+ import { isEmptyObject } from '../utils.js';
17
+ import { takeWorkletRefInitValuePatch } from '../worklet/workletRefPool.js';
18
+ let globalFlushOptions = {};
19
+ const globalCommitTaskMap = /*@__PURE__*/ new Map();
20
+ let nextCommitTaskId = 1;
21
+ let globalBackgroundSnapshotInstancesToRemove = [];
22
+ function injectUpdatePatch() {
23
+ function updatePatch({ data, patchOptions }) {
24
+ if ((patchOptions.reloadVersion ?? 0) < getReloadVersion()) {
25
+ return;
26
+ }
27
+ setPipeline(patchOptions.pipelineOptions);
28
+ markTiming(PerformanceTimingKeys.parse_changes_start);
29
+ let { snapshotPatch, workletRefInitValuePatch, flushOptions } = JSON.parse(data);
30
+ markTiming(PerformanceTimingKeys.parse_changes_end);
31
+ markTiming(PerformanceTimingKeys.patch_changes_start);
32
+ updateWorkletRefInitValueChanges(workletRefInitValuePatch);
33
+ __pendingListUpdates.clear();
34
+ if (snapshotPatch) {
35
+ snapshotPatchApply(snapshotPatch);
36
+ }
37
+ __pendingListUpdates.flush();
38
+ // console.debug('********** Lepus updatePatch:');
39
+ // printSnapshotInstance(snapshotInstanceManager.values.get(-1)!);
40
+ commitMainThreadPatchUpdate(patchOptions.commitTaskId);
41
+ if (patchOptions.isHydration) {
42
+ clearDelayedWorklets();
43
+ }
44
+ markTiming(PerformanceTimingKeys.patch_changes_end);
45
+ flushOptions ||= {};
46
+ if (patchOptions.pipelineOptions) {
47
+ flushOptions.pipelineOptions = patchOptions.pipelineOptions;
48
+ }
49
+ // TODO: triggerDataUpdated?
50
+ __FlushElementTree(__page, flushOptions);
51
+ }
52
+ Object.assign(globalThis, { [LifecycleConstant.patchUpdate]: updatePatch });
53
+ }
54
+ function replaceCommitHook() {
55
+ const oldCommit = options[COMMIT];
56
+ options[COMMIT] = async (vnode, commitQueue) => {
57
+ if (__LEPUS__) {
58
+ // for testing only
59
+ commitQueue.length = 0;
60
+ return;
61
+ }
62
+ markTimingLegacy(PerformanceTimingKeys.update_diff_vdom_end);
63
+ markTiming(PerformanceTimingKeys.diff_vdom_end);
64
+ markTiming(PerformanceTimingKeys.pack_changes_start);
65
+ if (__PROFILE__) {
66
+ console.profile('commitChanges');
67
+ }
68
+ const renderCallbacks = commitQueue.map(component => {
69
+ const ret = {
70
+ component,
71
+ [RENDER_CALLBACKS]: component[RENDER_CALLBACKS],
72
+ [VNODE]: component[VNODE],
73
+ };
74
+ component[RENDER_CALLBACKS] = [];
75
+ return ret;
76
+ });
77
+ commitQueue.length = 0;
78
+ const delayedUnmounts = takeDelayedUnmounts();
79
+ const backgroundSnapshotInstancesToRemove = globalBackgroundSnapshotInstancesToRemove;
80
+ globalBackgroundSnapshotInstancesToRemove = [];
81
+ const commitTaskId = genCommitTaskId();
82
+ globalCommitTaskMap.set(commitTaskId, () => {
83
+ updateBackgroundRefs(commitTaskId);
84
+ runDelayedUnmounts(delayedUnmounts);
85
+ oldCommit?.(vnode, renderCallbacks);
86
+ renderCallbacks.some(wrapper => {
87
+ try {
88
+ wrapper[RENDER_CALLBACKS].some((cb) => {
89
+ cb.call(wrapper.component);
90
+ });
91
+ }
92
+ catch (e) {
93
+ options[CATCH_ERROR](e, wrapper[VNODE]);
94
+ }
95
+ });
96
+ if (backgroundSnapshotInstancesToRemove.length) {
97
+ setTimeout(() => {
98
+ backgroundSnapshotInstancesToRemove.forEach(id => {
99
+ backgroundSnapshotInstanceManager.values.delete(id);
100
+ });
101
+ }, 10000);
102
+ }
103
+ });
104
+ const snapshotPatch = takeGlobalSnapshotPatch();
105
+ const flushOptions = globalFlushOptions;
106
+ const workletRefInitValuePatch = takeWorkletRefInitValuePatch();
107
+ globalFlushOptions = {};
108
+ if (!snapshotPatch && workletRefInitValuePatch.length === 0) {
109
+ // before hydration, skip patch
110
+ if (__PROFILE__) {
111
+ console.profileEnd();
112
+ }
113
+ return;
114
+ }
115
+ const patch = {};
116
+ // TODO: check all fields in `flushOptions` from runtime3
117
+ if (snapshotPatch?.length) {
118
+ patch.snapshotPatch = snapshotPatch;
119
+ }
120
+ if (!isEmptyObject(flushOptions)) {
121
+ patch.flushOptions = flushOptions;
122
+ }
123
+ if (workletRefInitValuePatch.length) {
124
+ patch.workletRefInitValuePatch = workletRefInitValuePatch;
125
+ }
126
+ await commitPatchUpdate(patch, { commitTaskId });
127
+ const commitTask = globalCommitTaskMap.get(commitTaskId);
128
+ if (commitTask) {
129
+ commitTask();
130
+ globalCommitTaskMap.delete(commitTaskId);
131
+ }
132
+ };
133
+ }
134
+ function commitPatchUpdate(data, patchOptions) {
135
+ return new Promise(resolve => {
136
+ // console.debug('********** JS update:');
137
+ // printSnapshotInstance(
138
+ // (backgroundSnapshotInstanceManager.values.get(1) || backgroundSnapshotInstanceManager.values.get(-1))!,
139
+ // );
140
+ // console.debug('commitPatchUpdate: ', JSON.stringify(data));
141
+ const obj = {
142
+ data: JSON.stringify(data),
143
+ patchOptions: {
144
+ ...patchOptions,
145
+ reloadVersion: getReloadVersion(),
146
+ },
147
+ };
148
+ markTiming(PerformanceTimingKeys.pack_changes_end);
149
+ if (globalPipelineOptions) {
150
+ obj.patchOptions.pipelineOptions = globalPipelineOptions;
151
+ setPipeline(undefined);
152
+ }
153
+ if (__PROFILE__) {
154
+ console.profileEnd();
155
+ }
156
+ lynx.getNativeApp().callLepusMethod(LifecycleConstant.patchUpdate, obj, resolve);
157
+ });
158
+ }
159
+ function commitMainThreadPatchUpdate(commitTaskId) {
160
+ const refPatch = takeGlobalRefPatchMap();
161
+ if (!isEmptyObject(refPatch)) {
162
+ __OnLifecycleEvent([LifecycleConstant.ref, { commitTaskId, refPatch: JSON.stringify(refPatch) }]);
163
+ }
164
+ }
165
+ function genCommitTaskId() {
166
+ return nextCommitTaskId++;
167
+ }
168
+ function replaceRequestAnimationFrame() {
169
+ // to make afterPaintEffects run faster
170
+ const resolvedPromise = Promise.resolve();
171
+ options.requestAnimationFrame = (cb) => {
172
+ resolvedPromise.then(cb);
173
+ };
174
+ }
175
+ /**
176
+ * @internal
177
+ */
178
+ export { injectUpdatePatch, commitPatchUpdate, replaceCommitHook, genCommitTaskId, commitMainThreadPatchUpdate, replaceRequestAnimationFrame, globalFlushOptions, globalCommitTaskMap, globalBackgroundSnapshotInstancesToRemove, nextCommitTaskId,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B,CAAC,YAAqB;IACxD,MAAM,QAAQ,GAAG,qBAAqB,EAAE,CAAC;IACzC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACpG,CAAC;AACH,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,4BAA4B;IACnC,uCAAuC;IACvC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1C,OAAO,CAAC,qBAAqB,GAAG,CAAC,EAAc,EAAE,EAAE;QACjD,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,yCAAyC,EACzC,gBAAgB,GACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare function reloadMainThread(data: any, options: UpdatePageOption): void;
2
+ declare function reloadBackground(updateData: Record<string, any>): void;
3
+ export { reloadMainThread, reloadBackground };
@@ -0,0 +1,63 @@
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 { render } from 'preact';
5
+ import { __root, setRoot } from '../root.js';
6
+ import { SnapshotInstance, __page, snapshotInstanceManager } from '../snapshot.js';
7
+ import { isEmptyObject } from '../utils.js';
8
+ import { destroyBackground } from './destroy.js';
9
+ import { increaseReloadVersion } from './pass.js';
10
+ import { renderMainThread } from './render.js';
11
+ import { hydrate } from '../hydrate.js';
12
+ import { LifecycleConstant } from '../lifecycleConstant.js';
13
+ import { __pendingListUpdates } from '../list.js';
14
+ import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
15
+ import { deinitGlobalSnapshotPatch } from '../snapshotPatch.js';
16
+ function reloadMainThread(data, options) {
17
+ if (__PROFILE__) {
18
+ console.profile('reloadTemplate');
19
+ }
20
+ increaseReloadVersion();
21
+ if (typeof data == 'object' && !isEmptyObject(data)) {
22
+ Object.assign(lynx.__initData, data);
23
+ }
24
+ snapshotInstanceManager.clear();
25
+ __pendingListUpdates.clear();
26
+ const oldRoot = __root;
27
+ setRoot(new SnapshotInstance('root'));
28
+ __root.__jsx = oldRoot.__jsx;
29
+ renderMainThread();
30
+ hydrate(oldRoot, __root, {
31
+ skipUnRef: true,
32
+ });
33
+ // always call this before `__FlushElementTree`
34
+ __pendingListUpdates.flush();
35
+ __FlushElementTree(__page, options);
36
+ __OnLifecycleEvent([
37
+ LifecycleConstant.firstScreen, /* FIRST_SCREEN */
38
+ {
39
+ root: JSON.stringify(__root),
40
+ refPatch: JSON.stringify(takeGlobalRefPatchMap()),
41
+ },
42
+ ]);
43
+ if (__PROFILE__) {
44
+ console.profileEnd();
45
+ }
46
+ return;
47
+ }
48
+ function reloadBackground(updateData) {
49
+ if (__PROFILE__) {
50
+ console.profile('reload');
51
+ }
52
+ deinitGlobalSnapshotPatch();
53
+ destroyBackground();
54
+ increaseReloadVersion();
55
+ // COW when modify `lynx.__initData` to make sure Provider & Consumer works
56
+ lynx.__initData = Object.assign({}, lynx.__initData, updateData);
57
+ render(__root.__jsx, __root);
58
+ if (__PROFILE__) {
59
+ console.profileEnd();
60
+ }
61
+ }
62
+ export { reloadMainThread, reloadBackground };
63
+ //# sourceMappingURL=reload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/lifecycle/reload.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAA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AAC,OAA2B,EAAE,MAA0B,EAAE;QAC/D,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,+CAA+C;IAC/C,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAC7B,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC,kBAAkB,CAAC;QACjB,iBAAiB,CAAC,WAAW,EAAE,kBAAkB;QACjD;YACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC;SAClD;KACF,CAAC,CAAC;IAEH,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;IACD,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA+B;IACvD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,yBAAyB,EAAE,CAAC;IAE5B,iBAAiB,EAAE,CAAC;IAEpB,qBAAqB,EAAE,CAAC;IAExB,2EAA2E;IAC3E,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEjE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAa,CAAC,CAAC;IAEpC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare function renderMainThread(): void;
2
+ export { renderMainThread };
@@ -0,0 +1,44 @@
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 { render } from 'preact';
5
+ import { renderOpcodesInto } from '../opcodes.js';
6
+ import { render as renderToString } from '../renderToOpcodes/index.js';
7
+ import { __root } from '../root.js';
8
+ // @ts-ignore
9
+ function renderMainThread() {
10
+ /* v8 ignore start */
11
+ if (process.env['NODE_ENV'] === 'test' && typeof __TESTING_FORCE_RENDER_TO_OPCODE__ !== 'undefined'
12
+ && !__TESTING_FORCE_RENDER_TO_OPCODE__) {
13
+ render(__root.__jsx, __root);
14
+ }
15
+ else {
16
+ let opcodes;
17
+ try {
18
+ if (__PROFILE__) {
19
+ console.profile('renderToString');
20
+ }
21
+ // @ts-ignore
22
+ opcodes = renderToString(__root.__jsx);
23
+ }
24
+ catch (e) {
25
+ lynx.reportError(e);
26
+ opcodes = [];
27
+ }
28
+ finally {
29
+ if (__PROFILE__) {
30
+ console.profileEnd();
31
+ }
32
+ }
33
+ if (__PROFILE__) {
34
+ console.profile('renderOpcodesInto');
35
+ }
36
+ renderOpcodesInto(opcodes, __root);
37
+ if (__PROFILE__) {
38
+ console.profileEnd();
39
+ }
40
+ }
41
+ /* v8 ignore stop */
42
+ }
43
+ export { renderMainThread };
44
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/lifecycle/render.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,aAAa;AAEb,SAAS,gBAAgB;IACvB,qBAAqB;IACrB,IACE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,IAAI,OAAO,kCAAkC,KAAK,WAAW;WAC5F,CAAC,kCAAkC,EACtC,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAa,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,CAAC;QACZ,IAAI,CAAC;YACH,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YACpC,CAAC;YACD,aAAa;YACb,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACpB,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;gBAAS,CAAC;YACT,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,CAAC;QACH,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QACD,iBAAiB,CAAC,OAAO,EAAE,MAAa,CAAC,CAAC;QAC1C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ export declare class LifecycleConstant {
2
+ static readonly firstScreen = "rLynxFirstScreen";
3
+ static readonly updateFromRoot = "updateFromRoot";
4
+ static readonly globalEventFromLepus = "globalEventFromLepus";
5
+ static readonly ref = "rLynxRef";
6
+ static readonly jsReady = "rLynxJSReady";
7
+ static readonly patchUpdate = "rLynxChange";
8
+ }
9
+ export declare const enum NativeUpdateDataType {
10
+ UPDATE = 0,
11
+ RESET = 1
12
+ }
@@ -0,0 +1,17 @@
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
+ export class LifecycleConstant {
5
+ static firstScreen = 'rLynxFirstScreen';
6
+ static updateFromRoot = 'updateFromRoot';
7
+ static globalEventFromLepus = 'globalEventFromLepus';
8
+ static ref = 'rLynxRef';
9
+ static jsReady = 'rLynxJSReady';
10
+ static patchUpdate = 'rLynxChange';
11
+ }
12
+ export var NativeUpdateDataType;
13
+ (function (NativeUpdateDataType) {
14
+ NativeUpdateDataType[NativeUpdateDataType["UPDATE"] = 0] = "UPDATE";
15
+ NativeUpdateDataType[NativeUpdateDataType["RESET"] = 1] = "RESET";
16
+ })(NativeUpdateDataType || (NativeUpdateDataType = {}));
17
+ //# sourceMappingURL=lifecycleConstant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycleConstant.js","sourceRoot":"","sources":["../src/lifecycleConstant.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,MAAM,OAAO,iBAAiB;IACrB,MAAM,CAAU,WAAW,GAAG,kBAAkB,CAAC;IACjD,MAAM,CAAU,cAAc,GAAG,gBAAgB,CAAC;IAClD,MAAM,CAAU,oBAAoB,GAAG,sBAAsB,CAAC;IAC9D,MAAM,CAAU,GAAG,GAAG,UAAU,CAAC;IACjC,MAAM,CAAU,OAAO,GAAG,cAAc,CAAC;IACzC,MAAM,CAAU,WAAW,GAAG,aAAa,CAAC;;AAGrD,MAAM,CAAN,IAAkB,oBAGjB;AAHD,WAAkB,oBAAoB;IACpC,mEAAU,CAAA;IACV,iEAAS,CAAA;AACX,CAAC,EAHiB,oBAAoB,KAApB,oBAAoB,QAGrC"}
@@ -0,0 +1,40 @@
1
+ import type { SnapshotInstance } from './snapshot.js';
2
+ export interface ListUpdateInfo {
3
+ flush(): void;
4
+ onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void;
5
+ onRemoveChild(child: SnapshotInstance): void;
6
+ onSetAttribute(child: SnapshotInstance, attr: any, oldAttr: any): void;
7
+ }
8
+ interface UpdateAction {
9
+ insertAction: {
10
+ position: number;
11
+ type: string;
12
+ }[];
13
+ removeAction: number[];
14
+ updateAction: any[];
15
+ }
16
+ export declare class ListUpdateInfoRecording implements ListUpdateInfo {
17
+ private list;
18
+ constructor(list: SnapshotInstance);
19
+ flush(): void;
20
+ private oldChildNodes;
21
+ private removeChild;
22
+ private insertBefore;
23
+ private appendChild;
24
+ private platformInfoUpdate;
25
+ onInsertBefore(newNode: SnapshotInstance, existingNode?: SnapshotInstance): void;
26
+ onRemoveChild(child: SnapshotInstance): void;
27
+ onSetAttribute(child: SnapshotInstance, attr: any, _oldAttr: any): void;
28
+ private __toAttribute;
29
+ toJSON(): [UpdateAction];
30
+ }
31
+ export declare const __pendingListUpdates: {
32
+ values: Record<number, ListUpdateInfo>;
33
+ clear(): void;
34
+ flush(): void;
35
+ };
36
+ export declare function componentAtIndexFactory(ctx: SnapshotInstance[]): ComponentAtIndexCallback;
37
+ export declare function enqueueComponentFactory(): EnqueueComponentCallback;
38
+ export declare function snapshotCreateList(pageId: number, _ctx: SnapshotInstance, _expIndex: number): FiberElement;
39
+ export declare function snapshotDestroyList(si: SnapshotInstance): void;
40
+ export {};