@lynx-js/react 0.111.0 → 0.111.2

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 (144) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/components/lib/DeferredListItem.d.ts +3 -1
  3. package/components/lib/DeferredListItem.jsx +4 -2
  4. package/components/lib/DeferredListItem.jsx.map +1 -1
  5. package/components/src/DeferredListItem.tsx +5 -3
  6. package/package.json +6 -1
  7. package/refresh/.turbo/turbo-build.log +7 -3
  8. package/refresh/dist/index.js +223 -284
  9. package/refresh/package.json +3 -4
  10. package/refresh/rslib.config.ts +24 -0
  11. package/runtime/debug/index.cjs +8 -0
  12. package/runtime/debug/index.d.ts +4 -0
  13. package/runtime/debug/index.js +5 -0
  14. package/runtime/lib/alog/index.d.ts +1 -0
  15. package/runtime/lib/alog/index.js +8 -0
  16. package/runtime/lib/alog/index.js.map +1 -0
  17. package/runtime/lib/alog/render.d.ts +1 -0
  18. package/runtime/lib/alog/render.js +19 -0
  19. package/runtime/lib/alog/render.js.map +1 -0
  20. package/runtime/lib/backgroundSnapshot.d.ts +1 -0
  21. package/runtime/lib/backgroundSnapshot.js +31 -17
  22. package/runtime/lib/backgroundSnapshot.js.map +1 -1
  23. package/runtime/lib/debug/component-stack.d.ts +33 -0
  24. package/runtime/lib/debug/component-stack.js +145 -0
  25. package/runtime/lib/debug/component-stack.js.map +1 -0
  26. package/runtime/lib/debug/formatPatch.d.ts +2 -0
  27. package/runtime/lib/debug/formatPatch.js +27 -0
  28. package/runtime/lib/debug/formatPatch.js.map +1 -0
  29. package/runtime/lib/debug/printSnapshot.d.ts +1 -1
  30. package/runtime/lib/debug/printSnapshot.js +0 -4
  31. package/runtime/lib/debug/printSnapshot.js.map +1 -1
  32. package/runtime/lib/debug/profile.js +1 -3
  33. package/runtime/lib/debug/profile.js.map +1 -1
  34. package/runtime/lib/hydrate.js +11 -7
  35. package/runtime/lib/hydrate.js.map +1 -1
  36. package/runtime/lib/lifecycle/patch/commit.js +1 -1
  37. package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
  38. package/runtime/lib/lifecycle/patch/snapshotPatch.d.ts +4 -0
  39. package/runtime/lib/lifecycle/patch/snapshotPatch.js +28 -0
  40. package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +1 -1
  41. package/runtime/lib/lynx.js +9 -0
  42. package/runtime/lib/lynx.js.map +1 -1
  43. package/runtime/lib/pendingListUpdates.d.ts +2 -1
  44. package/runtime/lib/pendingListUpdates.js +16 -4
  45. package/runtime/lib/pendingListUpdates.js.map +1 -1
  46. package/runtime/lib/renderToOpcodes/constants.d.ts +2 -0
  47. package/runtime/lib/renderToOpcodes/constants.js +2 -0
  48. package/runtime/lib/renderToOpcodes/constants.js.map +1 -1
  49. package/runtime/lib/root.d.ts +6 -0
  50. package/runtime/lib/root.js +4 -0
  51. package/runtime/lib/root.js.map +1 -1
  52. package/runtime/lib/snapshot/platformInfo.js +5 -3
  53. package/runtime/lib/snapshot/platformInfo.js.map +1 -1
  54. package/runtime/lib/snapshot/ref.d.ts +2 -2
  55. package/runtime/lib/snapshot/spread.js +3 -1
  56. package/runtime/lib/snapshot/spread.js.map +1 -1
  57. package/runtime/lib/snapshot.js +13 -7
  58. package/runtime/lib/snapshot.js.map +1 -1
  59. package/runtime/lib/utils.d.ts +2 -0
  60. package/runtime/lib/utils.js +23 -2
  61. package/runtime/lib/utils.js.map +1 -1
  62. package/testing-library/dist/env/vitest.js +18 -7
  63. package/testing-library/dist/pure.js +3 -1
  64. package/testing-library/dist/vitest-global-setup.js +2 -2
  65. package/transform/dist/wasm.cjs +1 -1
  66. package/types/react.d.ts +13 -1
  67. package/worklet-runtime/dist/dev.js +403 -506
  68. package/worklet-runtime/dist/main.js +1 -517
  69. package/worklet-runtime/lib/workletRuntime.js +5 -5
  70. package/worklet-runtime/lib/workletRuntime.js.map +1 -1
  71. package/runtime/src/backgroundSnapshot.ts +0 -501
  72. package/runtime/src/compat/componentIs.ts +0 -30
  73. package/runtime/src/compat/initData.ts +0 -150
  74. package/runtime/src/compat/lynxComponent.ts +0 -79
  75. package/runtime/src/debug/debug.ts +0 -9
  76. package/runtime/src/debug/printSnapshot.ts +0 -28
  77. package/runtime/src/debug/profile.ts +0 -55
  78. package/runtime/src/document.ts +0 -84
  79. package/runtime/src/gesture/processGesture.ts +0 -89
  80. package/runtime/src/gesture/processGestureBagkround.ts +0 -19
  81. package/runtime/src/gesture/types.ts +0 -44
  82. package/runtime/src/hooks/react.ts +0 -62
  83. package/runtime/src/hooks/useLynxGlobalEventListener.ts +0 -59
  84. package/runtime/src/hydrate.ts +0 -368
  85. package/runtime/src/index.ts +0 -94
  86. package/runtime/src/internal.ts +0 -63
  87. package/runtime/src/legacy-react-runtime/index.ts +0 -42
  88. package/runtime/src/lifecycle/destroy.ts +0 -34
  89. package/runtime/src/lifecycle/event/delayEvents.ts +0 -11
  90. package/runtime/src/lifecycle/event/delayLifecycleEvents.ts +0 -15
  91. package/runtime/src/lifecycle/event/jsReady.ts +0 -34
  92. package/runtime/src/lifecycle/pass.ts +0 -14
  93. package/runtime/src/lifecycle/patch/commit.ts +0 -214
  94. package/runtime/src/lifecycle/patch/error.ts +0 -61
  95. package/runtime/src/lifecycle/patch/isMainThreadHydrationFinished.ts +0 -13
  96. package/runtime/src/lifecycle/patch/snapshotPatch.ts +0 -65
  97. package/runtime/src/lifecycle/patch/snapshotPatchApply.ts +0 -145
  98. package/runtime/src/lifecycle/patch/updateMainThread.ts +0 -64
  99. package/runtime/src/lifecycle/ref/delay.ts +0 -99
  100. package/runtime/src/lifecycle/reload.ts +0 -97
  101. package/runtime/src/lifecycle/render.ts +0 -54
  102. package/runtime/src/lifecycleConstant.ts +0 -21
  103. package/runtime/src/list.ts +0 -307
  104. package/runtime/src/listUpdateInfo.ts +0 -221
  105. package/runtime/src/lynx/calledByNative.ts +0 -160
  106. package/runtime/src/lynx/component.ts +0 -113
  107. package/runtime/src/lynx/dynamic-js.ts +0 -36
  108. package/runtime/src/lynx/env.ts +0 -109
  109. package/runtime/src/lynx/injectLepusMethods.ts +0 -53
  110. package/runtime/src/lynx/lazy-bundle.ts +0 -175
  111. package/runtime/src/lynx/performance.ts +0 -148
  112. package/runtime/src/lynx/runWithForce.ts +0 -67
  113. package/runtime/src/lynx/tt.ts +0 -215
  114. package/runtime/src/lynx-api.ts +0 -455
  115. package/runtime/src/lynx.ts +0 -58
  116. package/runtime/src/opcodes.ts +0 -155
  117. package/runtime/src/pendingListUpdates.ts +0 -18
  118. package/runtime/src/renderToOpcodes/constants.ts +0 -24
  119. package/runtime/src/renderToOpcodes/index.ts +0 -306
  120. package/runtime/src/root.ts +0 -23
  121. package/runtime/src/snapshot/dynamicPartType.ts +0 -16
  122. package/runtime/src/snapshot/event.ts +0 -33
  123. package/runtime/src/snapshot/gesture.ts +0 -30
  124. package/runtime/src/snapshot/list.ts +0 -36
  125. package/runtime/src/snapshot/platformInfo.ts +0 -62
  126. package/runtime/src/snapshot/ref.ts +0 -139
  127. package/runtime/src/snapshot/spread.ts +0 -330
  128. package/runtime/src/snapshot/workletEvent.ts +0 -35
  129. package/runtime/src/snapshot/workletRef.ts +0 -88
  130. package/runtime/src/snapshot.ts +0 -634
  131. package/runtime/src/snapshotInstanceHydrationMap.ts +0 -17
  132. package/runtime/src/utils.ts +0 -44
  133. package/runtime/src/worklet/ctx.ts +0 -22
  134. package/runtime/src/worklet/destroy.ts +0 -16
  135. package/runtime/src/worklet/execMap.ts +0 -51
  136. package/runtime/src/worklet/functionCall.ts +0 -42
  137. package/runtime/src/worklet/functionality.ts +0 -29
  138. package/runtime/src/worklet/hmr.ts +0 -34
  139. package/runtime/src/worklet/indexMap.ts +0 -23
  140. package/runtime/src/worklet/runOnBackground.ts +0 -147
  141. package/runtime/src/worklet/runOnMainThread.ts +0 -50
  142. package/runtime/src/worklet/transformToWorklet.ts +0 -26
  143. package/runtime/src/worklet/workletRef.ts +0 -231
  144. package/runtime/src/worklet/workletRefPool.ts +0 -29
package/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # @lynx-js/react
2
2
 
3
+ ## 0.111.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Optimize `componentAtIndex` by a few hundreds microseconds: avoiding manipulate `__pendingListUpdates` unless SnapshotInstance tree is changed ([#1201](https://github.com/lynx-family/lynx-stack/pull/1201))
8
+
9
+ - Support alog of component rendering on production for better error reporting. Enable it by using `REACT_ALOG=true rspeedy dev/build` or defining `__ALOG__` to `true` in `lynx.config.js`: ([#1164](https://github.com/lynx-family/lynx-stack/pull/1164))
10
+
11
+ ```js
12
+ export default defineConfig({
13
+ // ...
14
+ source: {
15
+ define: {
16
+ __ALOG__: true,
17
+ },
18
+ },
19
+ });
20
+ ```
21
+
22
+ - Make `preact/debug` work with `@lynx-js/react`. ([#1222](https://github.com/lynx-family/lynx-stack/pull/1222))
23
+
24
+ - Introduce `@lynx-js/react/debug` which would include debugging warnings and error messages for common mistakes found. ([#1250](https://github.com/lynx-family/lynx-stack/pull/1250))
25
+
26
+ Add the import to `@lynx-js/react/debug` at the first line of the entry:
27
+
28
+ ```js
29
+ import '@lynx-js/react/debug';
30
+ import { root } from '@lynx-js/react';
31
+
32
+ import { App } from './App.jsx';
33
+
34
+ root.render(<App />);
35
+ ```
36
+
37
+ - `<list-item/>` deferred now accepts an object with `unmountRecycled` property to control unmounting behavior when the item is recycled. ([#1302](https://github.com/lynx-family/lynx-stack/pull/1302))
38
+
39
+ For example, you can use it like this:
40
+
41
+ ```jsx
42
+ <list-item defer={{ unmountRecycled: true }} item-key='1'>
43
+ <WillBeUnmountIfRecycled />
44
+ </list-item>;
45
+ ```
46
+
47
+ Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
48
+
49
+ - Avoid some unexpected `__SetAttribute` in hydrate when `undefined` is passed as an attribute value to intrinsic elements, for example: ([#1318](https://github.com/lynx-family/lynx-stack/pull/1318))
50
+
51
+ ```jsx
52
+ <image async-mode={undefined} />;
53
+ ```
54
+
55
+ ## 0.111.1
56
+
57
+ ### Patch Changes
58
+
59
+ - Wrap the main thread `renderPage` in preact `act` to ensure that the effects are flushed. ([#1170](https://github.com/lynx-family/lynx-stack/pull/1170))
60
+
3
61
  ## 0.111.0
4
62
 
5
63
  ### Minor Changes
@@ -1,6 +1,8 @@
1
1
  import type { FC, ReactNode } from 'react';
2
2
  export interface DeferredListItemProps {
3
- defer?: boolean;
3
+ defer?: boolean | {
4
+ unmountRecycled?: boolean;
5
+ };
4
6
  renderListItem: (children: ReactNode | undefined) => JSX.Element;
5
7
  renderChildren: () => ReactNode;
6
8
  }
@@ -16,8 +16,10 @@ export const DeferredListItem = ({ defer, renderListItem, renderChildren }) => {
16
16
  setIsReady(true);
17
17
  };
18
18
  ctx.__extraProps['onRecycleComponent'] = () => {
19
- // TODO(hzy): figure out if we need to unmount the component when recycled
20
- // setIsReady(false);
19
+ if (defer && typeof defer === 'object' && defer.unmountRecycled) {
20
+ // unmount the component when recycled
21
+ setIsReady(false);
22
+ }
21
23
  };
22
24
  return () => {
23
25
  delete ctx.__extraProps['onComponentAtIndex'];
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredListItem.jsx","sourceRoot":"","sources":["../src/DeferredListItem.tsx"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,OAAO,EAAE,YAAY,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE9F,OAAO,EAAE,YAAY,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAQ/E,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,EAAE;IACvG,MAAM,cAAc,GAAG,eAAe,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,aAAa,CAAC;IAEjF,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;I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AC,YAAa,CAAC,oBAAoB,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,cAAc,EAAE,CAAC;QACnB,IAAI,YAAY,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;YACnC,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QACD,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED,OAAO,eAAe,CAAC,OAAO;QAC5B,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;YAClE,OAAO,EAAE,CAAC,OAAO,EAAE,+CAA+C;YAClE,GAAG,EAAE,qBAAqB;SAC3B,CAAC;QACF,CAAC,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC;AACvC,CAAC,CAAC"}
@@ -9,7 +9,7 @@ import type { SnapshotInstance } from '@lynx-js/react/internal';
9
9
  import { cloneElement as _cloneElementMainThread } from '@lynx-js/react/lepus';
10
10
 
11
11
  export interface DeferredListItemProps {
12
- defer?: boolean;
12
+ defer?: boolean | { unmountRecycled?: boolean };
13
13
  renderListItem: (children: ReactNode | undefined) => JSX.Element;
14
14
  renderChildren: () => ReactNode;
15
15
  }
@@ -30,8 +30,10 @@ export const DeferredListItem: FC<DeferredListItemProps> = ({ defer, renderListI
30
30
  setIsReady(true);
31
31
  };
32
32
  ctx!.__extraProps['onRecycleComponent'] = () => {
33
- // TODO(hzy): figure out if we need to unmount the component when recycled
34
- // setIsReady(false);
33
+ if (defer && typeof defer === 'object' && defer.unmountRecycled) {
34
+ // unmount the component when recycled
35
+ setIsReady(false);
36
+ }
35
37
  };
36
38
 
37
39
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react",
3
- "version": "0.111.0",
3
+ "version": "0.111.2",
4
4
  "description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,6 +14,11 @@
14
14
  "lazy": "./runtime/lazy/react.js",
15
15
  "default": "./runtime/lib/index.js"
16
16
  },
17
+ "./debug": {
18
+ "types": "./runtime/debug/index.d.ts",
19
+ "lazy": "./runtime/debug/index.js",
20
+ "default": "./runtime/debug/index.js"
21
+ },
17
22
  "./experimental/lazy/import": {
18
23
  "types": "./runtime/lazy/import.d.ts",
19
24
  "default": "./runtime/lazy/import.js"
@@ -1,8 +1,12 @@
1
1
 
2
2
  > @lynx-js/react-refresh@0.1.0 build /home/runner/work/lynx-stack/lynx-stack/packages/react/refresh
3
- > esbuild --bundle src/index.ts --outfile=dist/index.js --external:@lynx-js/react --define:self=globalThis --format=esm --alias:preact=@lynx-js/react/internal --alias:preact/hooks=@lynx-js/react
3
+ > rslib build
4
4
 
5
+ Rslib v0.10.5
5
6
 
6
- dist/index.js 11.4kb
7
+ info build started...
8
+ ready built in 0.11 s
9
+
10
+ File (esm) Size 
11
+ dist/index.js 10.5 kB
7
12
 
8
- ⚡ Done in 25ms