@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.
- package/CHANGELOG.md +250 -0
- package/LICENSE +202 -0
- package/README.md +20 -0
- package/components/lib/Page.d.ts +3 -0
- package/components/lib/Page.js +56 -0
- package/components/lib/Page.js.map +1 -0
- package/components/lib/index.d.ts +1 -0
- package/components/lib/index.js +5 -0
- package/components/lib/index.js.map +1 -0
- package/components/src/Page.ts +75 -0
- package/components/src/index.ts +5 -0
- package/package.json +162 -0
- package/refresh/.gitignore +1 -0
- package/refresh/.npmignore +3 -0
- package/refresh/.turbo/turbo-build.log +8 -0
- package/refresh/dist/index.js +311 -0
- package/refresh/package.json +21 -0
- package/refresh/src/index.ts +6 -0
- package/refresh/src/prefresh.d.ts +11 -0
- package/refresh/tsconfig.json +4 -0
- package/refresh/turbo.json +15 -0
- package/runtime/jsx-dev-runtime/index.d.ts +5 -0
- package/runtime/jsx-dev-runtime/index.js +4 -0
- package/runtime/jsx-runtime/index.d.ts +4 -0
- package/runtime/jsx-runtime/index.js +4 -0
- package/runtime/lazy/import.d.ts +1 -0
- package/runtime/lazy/import.js +55 -0
- package/runtime/lazy/internal.js +39 -0
- package/runtime/lazy/jsx-dev-runtime.js +12 -0
- package/runtime/lazy/jsx-runtime.js +12 -0
- package/runtime/lazy/legacy-react-runtime.js +20 -0
- package/runtime/lazy/react-lepus.js +9 -0
- package/runtime/lazy/react.js +46 -0
- package/runtime/lazy/target.js +11 -0
- package/runtime/lepus/index.d.ts +4 -0
- package/runtime/lepus/index.js +43 -0
- package/runtime/lepus/jsx-dev-runtime/index.js +4 -0
- package/runtime/lepus/jsx-runtime/index.js +66 -0
- package/runtime/lib/backgroundSnapshot.d.ts +23 -0
- package/runtime/lib/backgroundSnapshot.js +348 -0
- package/runtime/lib/backgroundSnapshot.js.map +1 -0
- package/runtime/lib/compat/componentIs.d.ts +4 -0
- package/runtime/lib/compat/componentIs.js +20 -0
- package/runtime/lib/compat/componentIs.js.map +1 -0
- package/runtime/lib/compat/initData.d.ts +43 -0
- package/runtime/lib/compat/initData.js +93 -0
- package/runtime/lib/compat/initData.js.map +1 -0
- package/runtime/lib/compat/lynxComponent.d.ts +5 -0
- package/runtime/lib/compat/lynxComponent.js +71 -0
- package/runtime/lib/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/debug/debug.d.ts +2 -0
- package/runtime/lib/debug/debug.js +9 -0
- package/runtime/lib/debug/debug.js.map +1 -0
- package/runtime/lib/debug/printSnapshot.d.ts +3 -0
- package/runtime/lib/debug/printSnapshot.js +21 -0
- package/runtime/lib/debug/printSnapshot.js.map +1 -0
- package/runtime/lib/debug/profile.d.ts +1 -0
- package/runtime/lib/debug/profile.js +51 -0
- package/runtime/lib/debug/profile.js.map +1 -0
- package/runtime/lib/document.d.ts +4 -0
- package/runtime/lib/document.js +49 -0
- package/runtime/lib/document.js.map +1 -0
- package/runtime/lib/gesture/processGesture.d.ts +4 -0
- package/runtime/lib/gesture/processGesture.js +48 -0
- package/runtime/lib/gesture/processGesture.js.map +1 -0
- package/runtime/lib/gesture/processGestureBagkround.d.ts +2 -0
- package/runtime/lib/gesture/processGestureBagkround.js +16 -0
- package/runtime/lib/gesture/processGestureBagkround.js.map +1 -0
- package/runtime/lib/gesture/types.d.ts +34 -0
- package/runtime/lib/gesture/types.js +13 -0
- package/runtime/lib/gesture/types.js.map +1 -0
- package/runtime/lib/hooks/react.d.ts +26 -0
- package/runtime/lib/hooks/react.js +35 -0
- package/runtime/lib/hooks/react.js.map +1 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.d.ts +29 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js +53 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/hydrate.d.ts +18 -0
- package/runtime/lib/hydrate.js +271 -0
- package/runtime/lib/hydrate.js.map +1 -0
- package/runtime/lib/index.d.ts +9 -0
- package/runtime/lib/index.js +46 -0
- package/runtime/lib/index.js.map +1 -0
- package/runtime/lib/internal.d.ts +26 -0
- package/runtime/lib/internal.js +41 -0
- package/runtime/lib/internal.js.map +1 -0
- package/runtime/lib/legacy-react-runtime/index.d.ts +7 -0
- package/runtime/lib/legacy-react-runtime/index.js +34 -0
- package/runtime/lib/legacy-react-runtime/index.js.map +1 -0
- package/runtime/lib/lifecycle/delayUnmount.d.ts +8 -0
- package/runtime/lib/lifecycle/delayUnmount.js +68 -0
- package/runtime/lib/lifecycle/delayUnmount.js.map +1 -0
- package/runtime/lib/lifecycle/destroy.d.ts +2 -0
- package/runtime/lib/lifecycle/destroy.js +21 -0
- package/runtime/lib/lifecycle/destroy.js.map +1 -0
- package/runtime/lib/lifecycle/pass.d.ts +3 -0
- package/runtime/lib/lifecycle/pass.js +12 -0
- package/runtime/lib/lifecycle/pass.js.map +1 -0
- package/runtime/lib/lifecycle/patchUpdate.d.ts +23 -0
- package/runtime/lib/lifecycle/patchUpdate.js +179 -0
- package/runtime/lib/lifecycle/patchUpdate.js.map +1 -0
- package/runtime/lib/lifecycle/reload.d.ts +3 -0
- package/runtime/lib/lifecycle/reload.js +63 -0
- package/runtime/lib/lifecycle/reload.js.map +1 -0
- package/runtime/lib/lifecycle/render.d.ts +2 -0
- package/runtime/lib/lifecycle/render.js +44 -0
- package/runtime/lib/lifecycle/render.js.map +1 -0
- package/runtime/lib/lifecycleConstant.d.ts +12 -0
- package/runtime/lib/lifecycleConstant.js +17 -0
- package/runtime/lib/lifecycleConstant.js.map +1 -0
- package/runtime/lib/list.d.ts +40 -0
- package/runtime/lib/list.js +305 -0
- package/runtime/lib/list.js.map +1 -0
- package/runtime/lib/lynx/calledByNative.d.ts +2 -0
- package/runtime/lib/lynx/calledByNative.js +113 -0
- package/runtime/lib/lynx/calledByNative.js.map +1 -0
- package/runtime/lib/lynx/component.d.ts +1 -0
- package/runtime/lib/lynx/component.js +69 -0
- package/runtime/lib/lynx/component.js.map +1 -0
- package/runtime/lib/lynx/dynamic-js.d.ts +2 -0
- package/runtime/lib/lynx/dynamic-js.js +31 -0
- package/runtime/lib/lynx/dynamic-js.js.map +1 -0
- package/runtime/lib/lynx/env.d.ts +1 -0
- package/runtime/lib/lynx/env.js +92 -0
- package/runtime/lib/lynx/env.js.map +1 -0
- package/runtime/lib/lynx/injectLepusMethods.d.ts +2 -0
- package/runtime/lib/lynx/injectLepusMethods.js +50 -0
- package/runtime/lib/lynx/injectLepusMethods.js.map +1 -0
- package/runtime/lib/lynx/lazy-bundle.d.ts +9 -0
- package/runtime/lib/lynx/lazy-bundle.js +119 -0
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/lynx/performance.d.ts +29 -0
- package/runtime/lib/lynx/performance.js +100 -0
- package/runtime/lib/lynx/performance.js.map +1 -0
- package/runtime/lib/lynx/tt.d.ts +4 -0
- package/runtime/lib/lynx/tt.js +193 -0
- package/runtime/lib/lynx/tt.js.map +1 -0
- package/runtime/lib/lynx-api.d.ts +311 -0
- package/runtime/lib/lynx-api.js +116 -0
- package/runtime/lib/lynx-api.js.map +1 -0
- package/runtime/lib/lynx.d.ts +2 -0
- package/runtime/lib/lynx.js +91 -0
- package/runtime/lib/lynx.js.map +1 -0
- package/runtime/lib/opcodes.d.ts +2 -0
- package/runtime/lib/opcodes.js +59 -0
- package/runtime/lib/opcodes.js.map +1 -0
- package/runtime/lib/renderToOpcodes/constants.d.ts +17 -0
- package/runtime/lib/renderToOpcodes/constants.js +23 -0
- package/runtime/lib/renderToOpcodes/constants.js.map +1 -0
- package/runtime/lib/renderToOpcodes/index.d.ts +13 -0
- package/runtime/lib/renderToOpcodes/index.js +227 -0
- package/runtime/lib/renderToOpcodes/index.js.map +1 -0
- package/runtime/lib/root.d.ts +7 -0
- package/runtime/lib/root.js +17 -0
- package/runtime/lib/root.js.map +1 -0
- package/runtime/lib/snapshot/event.d.ts +3 -0
- package/runtime/lib/snapshot/event.js +24 -0
- package/runtime/lib/snapshot/event.js.map +1 -0
- package/runtime/lib/snapshot/gesture.d.ts +2 -0
- package/runtime/lib/snapshot/gesture.js +18 -0
- package/runtime/lib/snapshot/gesture.js.map +1 -0
- package/runtime/lib/snapshot/platformInfo.d.ts +4 -0
- package/runtime/lib/snapshot/platformInfo.js +35 -0
- package/runtime/lib/snapshot/platformInfo.js.map +1 -0
- package/runtime/lib/snapshot/ref.d.ts +10 -0
- package/runtime/lib/snapshot/ref.js +119 -0
- package/runtime/lib/snapshot/ref.js.map +1 -0
- package/runtime/lib/snapshot/spread.d.ts +5 -0
- package/runtime/lib/snapshot/spread.js +289 -0
- package/runtime/lib/snapshot/spread.js.map +1 -0
- package/runtime/lib/snapshot/workletEvent.d.ts +3 -0
- package/runtime/lib/snapshot/workletEvent.js +22 -0
- package/runtime/lib/snapshot/workletEvent.js.map +1 -0
- package/runtime/lib/snapshot/workletRef.d.ts +5 -0
- package/runtime/lib/snapshot/workletRef.js +52 -0
- package/runtime/lib/snapshot/workletRef.js.map +1 -0
- package/runtime/lib/snapshot.d.ts +81 -0
- package/runtime/lib/snapshot.js +477 -0
- package/runtime/lib/snapshot.js.map +1 -0
- package/runtime/lib/snapshotPatch.d.ts +14 -0
- package/runtime/lib/snapshotPatch.js +31 -0
- package/runtime/lib/snapshotPatch.js.map +1 -0
- package/runtime/lib/snapshotPatchApply.d.ts +2 -0
- package/runtime/lib/snapshotPatchApply.js +110 -0
- package/runtime/lib/snapshotPatchApply.js.map +1 -0
- package/runtime/lib/utils.d.ts +4 -0
- package/runtime/lib/utils.js +32 -0
- package/runtime/lib/utils.js.map +1 -0
- package/runtime/lib/worklet/ctx.d.ts +1 -0
- package/runtime/lib/worklet/ctx.js +17 -0
- package/runtime/lib/worklet/ctx.js.map +1 -0
- package/runtime/lib/worklet/execMap.d.ts +1 -0
- package/runtime/lib/worklet/execMap.js +42 -0
- package/runtime/lib/worklet/execMap.js.map +1 -0
- package/runtime/lib/worklet/functionality.d.ts +1 -0
- package/runtime/lib/worklet/functionality.js +11 -0
- package/runtime/lib/worklet/functionality.js.map +1 -0
- package/runtime/lib/worklet/hmr.d.ts +1 -0
- package/runtime/lib/worklet/hmr.js +21 -0
- package/runtime/lib/worklet/hmr.js.map +1 -0
- package/runtime/lib/worklet/indexMap.d.ts +8 -0
- package/runtime/lib/worklet/indexMap.js +17 -0
- package/runtime/lib/worklet/indexMap.js.map +1 -0
- package/runtime/lib/worklet/jsImpl.d.ts +11 -0
- package/runtime/lib/worklet/jsImpl.js +68 -0
- package/runtime/lib/worklet/jsImpl.js.map +1 -0
- package/runtime/lib/worklet/runWorklet.d.ts +14 -0
- package/runtime/lib/worklet/runWorklet.js +82 -0
- package/runtime/lib/worklet/runWorklet.js.map +1 -0
- package/runtime/lib/worklet/workletRef.d.ts +131 -0
- package/runtime/lib/worklet/workletRef.js +96 -0
- package/runtime/lib/worklet/workletRef.js.map +1 -0
- package/runtime/lib/worklet/workletRefPool.d.ts +2 -0
- package/runtime/lib/worklet/workletRefPool.js +22 -0
- package/runtime/lib/worklet/workletRefPool.js.map +1 -0
- package/runtime/src/backgroundSnapshot.ts +452 -0
- package/runtime/src/compat/componentIs.ts +30 -0
- package/runtime/src/compat/initData.ts +140 -0
- package/runtime/src/compat/lynxComponent.ts +80 -0
- package/runtime/src/debug/debug.ts +9 -0
- package/runtime/src/debug/printSnapshot.ts +28 -0
- package/runtime/src/debug/profile.ts +54 -0
- package/runtime/src/document.ts +53 -0
- package/runtime/src/gesture/processGesture.ts +77 -0
- package/runtime/src/gesture/processGestureBagkround.ts +15 -0
- package/runtime/src/gesture/types.ts +39 -0
- package/runtime/src/hooks/react.ts +62 -0
- package/runtime/src/hooks/useLynxGlobalEventListener.ts +59 -0
- package/runtime/src/hydrate.ts +364 -0
- package/runtime/src/index.ts +89 -0
- package/runtime/src/internal.ts +60 -0
- package/runtime/src/legacy-react-runtime/index.ts +40 -0
- package/runtime/src/lifecycle/delayUnmount.ts +77 -0
- package/runtime/src/lifecycle/destroy.ts +26 -0
- package/runtime/src/lifecycle/pass.ts +14 -0
- package/runtime/src/lifecycle/patchUpdate.ts +240 -0
- package/runtime/src/lifecycle/reload.ts +79 -0
- package/runtime/src/lifecycle/render.ts +46 -0
- package/runtime/src/lifecycleConstant.ts +16 -0
- package/runtime/src/list.ts +375 -0
- package/runtime/src/lynx/calledByNative.ts +132 -0
- package/runtime/src/lynx/component.ts +116 -0
- package/runtime/src/lynx/dynamic-js.ts +33 -0
- package/runtime/src/lynx/env.ts +110 -0
- package/runtime/src/lynx/injectLepusMethods.ts +53 -0
- package/runtime/src/lynx/lazy-bundle.ts +126 -0
- package/runtime/src/lynx/performance.ts +117 -0
- package/runtime/src/lynx/tt.ts +212 -0
- package/runtime/src/lynx-api.ts +374 -0
- package/runtime/src/lynx.ts +105 -0
- package/runtime/src/opcodes.ts +64 -0
- package/runtime/src/renderToOpcodes/constants.ts +24 -0
- package/runtime/src/renderToOpcodes/index.ts +301 -0
- package/runtime/src/root.ts +19 -0
- package/runtime/src/snapshot/event.ts +33 -0
- package/runtime/src/snapshot/gesture.ts +25 -0
- package/runtime/src/snapshot/platformInfo.ts +48 -0
- package/runtime/src/snapshot/ref.ts +151 -0
- package/runtime/src/snapshot/spread.ts +287 -0
- package/runtime/src/snapshot/workletEvent.ts +33 -0
- package/runtime/src/snapshot/workletRef.ts +63 -0
- package/runtime/src/snapshot.ts +576 -0
- package/runtime/src/snapshotPatch.ts +56 -0
- package/runtime/src/snapshotPatchApply.ts +117 -0
- package/runtime/src/utils.ts +35 -0
- package/runtime/src/worklet/ctx.ts +22 -0
- package/runtime/src/worklet/execMap.ts +50 -0
- package/runtime/src/worklet/functionality.ts +12 -0
- package/runtime/src/worklet/hmr.ts +26 -0
- package/runtime/src/worklet/indexMap.ts +20 -0
- package/runtime/src/worklet/jsImpl.ts +86 -0
- package/runtime/src/worklet/runWorklet.ts +88 -0
- package/runtime/src/worklet/workletRef.ts +229 -0
- package/runtime/src/worklet/workletRefPool.ts +25 -0
- package/transform/cjs/main.cjs +6 -0
- package/transform/cjs/main.d.cts +3 -0
- package/transform/cjs/package.json +3 -0
- package/transform/dist/wasm.cjs +8478 -0
- package/transform/index.d.ts +187 -0
- package/transform/main.js +15 -0
- package/types/react.d.ts +147 -0
- package/types/react.docs.d.ts +74 -0
- package/worklet-runtime/dist/dev.js +414 -0
- package/worklet-runtime/dist/dev.js.map +8 -0
- package/worklet-runtime/dist/main.js +414 -0
- package/worklet-runtime/dist/main.js.map +8 -0
- package/worklet-runtime/lib/api/element.d.ts +14 -0
- package/worklet-runtime/lib/api/element.js +71 -0
- package/worklet-runtime/lib/api/element.js.map +1 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.d.ts +3 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js +23 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js.map +1 -0
- package/worklet-runtime/lib/api/lynxApi.d.ts +2 -0
- package/worklet-runtime/lib/api/lynxApi.js +35 -0
- package/worklet-runtime/lib/api/lynxApi.js.map +1 -0
- package/worklet-runtime/lib/bindings/bindings.d.ts +14 -0
- package/worklet-runtime/lib/bindings/bindings.js +61 -0
- package/worklet-runtime/lib/bindings/bindings.js.map +1 -0
- package/worklet-runtime/lib/bindings/events.d.ts +7 -0
- package/worklet-runtime/lib/bindings/events.js +9 -0
- package/worklet-runtime/lib/bindings/events.js.map +1 -0
- package/worklet-runtime/lib/bindings/index.d.ts +4 -0
- package/worklet-runtime/lib/bindings/index.js +7 -0
- package/worklet-runtime/lib/bindings/index.js.map +1 -0
- package/worklet-runtime/lib/bindings/loadRuntime.d.ts +8 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js +25 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js.map +1 -0
- package/worklet-runtime/lib/bindings/types.d.ts +35 -0
- package/worklet-runtime/lib/bindings/types.js +2 -0
- package/worklet-runtime/lib/bindings/types.js.map +1 -0
- package/worklet-runtime/lib/delayWorkletEvent.d.ts +11 -0
- package/worklet-runtime/lib/delayWorkletEvent.js +49 -0
- package/worklet-runtime/lib/delayWorkletEvent.js.map +1 -0
- package/worklet-runtime/lib/global.d.ts +15 -0
- package/worklet-runtime/lib/global.js +2 -0
- package/worklet-runtime/lib/global.js.map +1 -0
- package/worklet-runtime/lib/index.d.ts +1 -0
- package/worklet-runtime/lib/index.js +12 -0
- package/worklet-runtime/lib/index.js.map +1 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.d.ts +18 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js +55 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js.map +1 -0
- package/worklet-runtime/lib/listeners.d.ts +2 -0
- package/worklet-runtime/lib/listeners.js +17 -0
- package/worklet-runtime/lib/listeners.js.map +1 -0
- package/worklet-runtime/lib/utils/profile.d.ts +1 -0
- package/worklet-runtime/lib/utils/profile.js +20 -0
- package/worklet-runtime/lib/utils/profile.js.map +1 -0
- package/worklet-runtime/lib/utils/version.d.ts +1 -0
- package/worklet-runtime/lib/utils/version.js +10 -0
- package/worklet-runtime/lib/utils/version.js.map +1 -0
- package/worklet-runtime/lib/workletRef.d.ts +12 -0
- package/worklet-runtime/lib/workletRef.js +50 -0
- package/worklet-runtime/lib/workletRef.js.map +1 -0
- package/worklet-runtime/lib/workletRuntime.d.ts +2 -0
- package/worklet-runtime/lib/workletRuntime.js +128 -0
- package/worklet-runtime/lib/workletRuntime.js.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# @lynx-js/react
|
|
2
|
+
|
|
3
|
+
## 0.105.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1abf8f0: Support `estimated-main-axis-size-px`
|
|
8
|
+
|
|
9
|
+
NOTE: This changes behavior of `transformReactLynx` so certain features (like lazy bundle) will be BROKEN if version mismatch.
|
|
10
|
+
|
|
11
|
+
- 1abf8f0: Support JSXSpread on `<list-item/>` component.
|
|
12
|
+
|
|
13
|
+
NOTE: This changes behavior of `transformReactLynx` so certain features (like lazy bundle) will be BROKEN if version mismatch.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 1abf8f0: Update readme.
|
|
18
|
+
- 1abf8f0: Save some bytes if `<page/>` is not used.
|
|
19
|
+
- 1abf8f0: Should escape newline character in jsx
|
|
20
|
+
|
|
21
|
+
## 0.104.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 9ce9ec0: Fix argument cannot be accessed correctly in default exported MTS functions.
|
|
26
|
+
- 99a4de6: Change TypeScript configuration to improve tree-shaking by setting `verbatimModuleSyntax: false`.
|
|
27
|
+
|
|
28
|
+
This change allows the bundler to properly remove unused imports and type-only imports, resulting in smaller bundle sizes. For example:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// These imports will be removed from the final bundle
|
|
32
|
+
import type { Foo } from 'xyz';
|
|
33
|
+
import { type Bar } from 'xyz';
|
|
34
|
+
import { xyz } from 'xyz'; // When xyz is not used
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
|
|
38
|
+
|
|
39
|
+
## 0.104.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- 575e804: Remove misleading API `createRoot`
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- 797ff68: Workaround the `cannot find module './snapshot/event.js'` error avoid tree-shaking `event.js` in development.
|
|
48
|
+
- 1bf9271: fix(react): default `compat` in transform to `false`
|
|
49
|
+
|
|
50
|
+
## 0.103.5
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 74e0ea3: Supports new `__MAIN_THREAD__` and `__BACKGROUND__` macro as an alternative to `__LEPUS__` and `__JS__`.
|
|
55
|
+
|
|
56
|
+
## 0.103.4
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- 89a9f7a: Improve the speed of MTS.
|
|
61
|
+
|
|
62
|
+
## 0.103.3
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- 4e94846: Fix variables being renamed in MTS.
|
|
67
|
+
- 297c6ea: Fix the issue that when `runOnBackground()`'s parameter is not legal, it will still report an error in the rendering process of the background thread even though it won't actually be called.
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
function App() {
|
|
71
|
+
const f = undefined;
|
|
72
|
+
|
|
73
|
+
function mts() {
|
|
74
|
+
'main thread';
|
|
75
|
+
// throws in background rendering
|
|
76
|
+
f && runOnBackground(f)();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- 763ad4e: Stop reporting ctx id in the `ctx not found` error.
|
|
82
|
+
- 480611d: Avoid error from changing theme.
|
|
83
|
+
- 3bf5830: Avoid overriding `processEvalResult`.
|
|
84
|
+
|
|
85
|
+
## 0.103.2
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- 580ce54: Fix snapshot not found in HMR updates.
|
|
90
|
+
|
|
91
|
+
## 0.103.1
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- 80a4e38: Use hooks `useLynxGlobalEventListener` to make `useInitData` addListener as early as possible. This will fix the issue that `onDataChanged` has been called before the event listener is added.
|
|
96
|
+
- 8aa3979: Fix generating wrong JavaScript when using a variable multiple times in the main thread script.
|
|
97
|
+
- 318245e: Avoid snapshot ID conflict between different templates and bundles.
|
|
98
|
+
- b520862: Remove unnecessary sideEffects to reduce bundle size.
|
|
99
|
+
- 7cd840c: Integrate with `@lynx-js/types`.
|
|
100
|
+
|
|
101
|
+
## 0.103.0
|
|
102
|
+
|
|
103
|
+
### Minor Changes
|
|
104
|
+
|
|
105
|
+
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
|
|
109
|
+
import { defineConfig } from '@lynx-js/rspeedy';
|
|
110
|
+
|
|
111
|
+
export default defineConfig({
|
|
112
|
+
plugins: [
|
|
113
|
+
pluginReactLynx({
|
|
114
|
+
compat: {
|
|
115
|
+
removeComponentAttrRegex: 'YOUR REGEX',
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
NOTE: This feature is deprecated and will be removed in the future. Use codemod instead.
|
|
123
|
+
|
|
124
|
+
- 5f8d492: Deprecate `compat.simplifyCtorLikeReactLynx2`
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- ca3a639: Fix `cssId` collision issue when hash generated `@jsxCSSId` for jsx snapshot hit the range of auto increased cssId of `@file`.
|
|
129
|
+
- 8fbea78: Fix 'main thread' and 'background only' directives not working in export default declarations.
|
|
130
|
+
- ff18049: Bump swc_core v0.109.2.
|
|
131
|
+
|
|
132
|
+
This would add `/*#__PURE__*/` to the output of TypeScript `enum`. See [swc-project/swc#9558](https://github.com/swc-project/swc/pull/9558) for details.
|
|
133
|
+
|
|
134
|
+
## 0.102.0
|
|
135
|
+
|
|
136
|
+
### Minor Changes
|
|
137
|
+
|
|
138
|
+
- e3be842: Fix some attribute updating of nodes in list does not take effect
|
|
139
|
+
- 2e6b549: Add ability to be compat with pre-0.99 version of ReactLynx
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- 75725cb: Fix a memory leak in MTS.
|
|
144
|
+
- 09e0ec0: Reduce the size of `background.js`.
|
|
145
|
+
- 9e40f33: Slightly improve MTS execution speed.
|
|
146
|
+
- f24599e: Fix the infinite mount and unmount loops of lazy bundle when its JS file fails to execute.
|
|
147
|
+
|
|
148
|
+
## 0.101.0
|
|
149
|
+
|
|
150
|
+
### Minor Changes
|
|
151
|
+
|
|
152
|
+
- 6730c58: Change the snapshot transform result by adding `cssId` and `entryName`.
|
|
153
|
+
|
|
154
|
+
<table>
|
|
155
|
+
<thead>
|
|
156
|
+
<tr>
|
|
157
|
+
<th>Remove Scoped CSS(Default)</th>
|
|
158
|
+
<th>Scoped CSS</th>
|
|
159
|
+
</tr>
|
|
160
|
+
</thead>
|
|
161
|
+
<tbody>
|
|
162
|
+
<tr>
|
|
163
|
+
<td>
|
|
164
|
+
<pre><code>
|
|
165
|
+
createSnapshot(
|
|
166
|
+
$uid,
|
|
167
|
+
$create,
|
|
168
|
+
$update,
|
|
169
|
+
$slot,
|
|
170
|
+
/** cssId */ undefined,
|
|
171
|
+
/** entryName */ globDynamicComponentEntry
|
|
172
|
+
);
|
|
173
|
+
</code></pre>
|
|
174
|
+
</td>
|
|
175
|
+
<td>
|
|
176
|
+
<pre><code>
|
|
177
|
+
createSnapshot(
|
|
178
|
+
$uid,
|
|
179
|
+
$create,
|
|
180
|
+
$update,
|
|
181
|
+
$slot,
|
|
182
|
+
/** cssId */ 0x3da39a,
|
|
183
|
+
/** entryName */ globDynamicComponentEntry
|
|
184
|
+
);
|
|
185
|
+
</code></pre>
|
|
186
|
+
</td>
|
|
187
|
+
</tr>
|
|
188
|
+
</tbody>
|
|
189
|
+
</table>
|
|
190
|
+
|
|
191
|
+
This requires `@lynx-js/react-rsbuild-plugin` v0.5.1 to work.
|
|
192
|
+
|
|
193
|
+
- Inject `globDynamicComponentEntry` for background script. ([#311](https://github.com/lynx-wg/lynx-stack/pull/311))
|
|
194
|
+
- Inject `globDynamicComponentEntry` for main thread script. ([#312](https://github.com/lynx-wg/lynx-stack/pull/312))
|
|
195
|
+
|
|
196
|
+
- efbb7d4: Support Gesture.
|
|
197
|
+
|
|
198
|
+
Gesture Handler is a set of gesture handling capabilities built on top of the Main Thread Script. It currently supports drag, inertial scrolling, long press, and tap gestures for `<view>`, `<scroll-view>`, `<list>`, and `<text>`. In the future, it will also support multi-finger zoom, multi-finger rotation, and other gesture capabilities.
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
import { useGesture, PanGesture } from '@lynx-js/gesture-runtime';
|
|
202
|
+
|
|
203
|
+
function App() {
|
|
204
|
+
const pan = useGesture(PanGesture);
|
|
205
|
+
|
|
206
|
+
pan
|
|
207
|
+
.onBegin((event, stateManager) => {
|
|
208
|
+
'main thread';
|
|
209
|
+
// some logic
|
|
210
|
+
})
|
|
211
|
+
.onUpdate((event, stateManager) => {
|
|
212
|
+
'main thread';
|
|
213
|
+
// some logic
|
|
214
|
+
})
|
|
215
|
+
.onEnd((event, stateManager) => {
|
|
216
|
+
'main thread';
|
|
217
|
+
// some logic
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return <view main-thread:gesture={pan}></view>;
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Patch Changes
|
|
225
|
+
|
|
226
|
+
- b2032eb: Better DCE.
|
|
227
|
+
|
|
228
|
+
Now DCE can remove dead branch:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
function f() {
|
|
232
|
+
if (__LEPUS__) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
console.log('not __LEPUS__'); // This can be removed now
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
- 45edafa: Support using `import()` with variables.
|
|
241
|
+
|
|
242
|
+
## 0.100.0
|
|
243
|
+
|
|
244
|
+
### Minor Changes
|
|
245
|
+
|
|
246
|
+
- 587a782: Release `@lynx-js/react` v0.100.0
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- a335490: Fix an issue where events might not fire after calling `ReloadTemplate`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ReactLynx
|
|
2
|
+
|
|
3
|
+
<p>
|
|
4
|
+
<a aria-label="NPM version" href="https://www.npmjs.com/package/@lynx-js/react">
|
|
5
|
+
<img alt="" src="https://img.shields.io/npm/v/@lynx-js/react?logo=npm" />
|
|
6
|
+
</a>
|
|
7
|
+
<a aria-label="License" href="https://www.npmjs.com/package/@lynx-js/react">
|
|
8
|
+
<img src="https://img.shields.io/badge/License-Apache--2.0-blue" alt="license" />
|
|
9
|
+
</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
`@lynx-js/react` is the package that provides the ReactLynx framework. ReactLynx not only delivers the ultra-high performance and cross-platform usability of the Lynx engine, but also has compatibility with React 17+ and the vast ecosystem of the React community.
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
See [Getting Started](https://lynxjs.org/guide/start/quick-start.html).
|
|
17
|
+
|
|
18
|
+
## Documentation
|
|
19
|
+
|
|
20
|
+
For an introduction to ReactLynx, please visit [ReactLynx](https://lynxjs.org/react/index.html).
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
// We use "@lynx-js/react" here
|
|
5
|
+
// because import * as ReactLynx from "@lynx-js/react/internal"; will be added when transform
|
|
6
|
+
// no matter if we use "@lynx-js/react" here
|
|
7
|
+
import { forwardRef, useEffect, useRef } from '@lynx-js/react';
|
|
8
|
+
import { __root, snapshotManager, updateSpread } from '@lynx-js/react/internal';
|
|
9
|
+
let pageMounted = false;
|
|
10
|
+
const Page =
|
|
11
|
+
/* @__PURE__ */ (function () {
|
|
12
|
+
if (__LEPUS__) {
|
|
13
|
+
snapshotManager.values.get('root').update[0] = (snapshot, index, oldValue) => {
|
|
14
|
+
/* v8 ignore start */
|
|
15
|
+
if (__JS__ && !__DEV__) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
/* v8 ignore stop */
|
|
19
|
+
updateSpread(snapshot, index, oldValue, 0);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return forwardRef(function (props, ref) {
|
|
23
|
+
const { children, ...restProps } = props;
|
|
24
|
+
__root.setAttribute('values', [{
|
|
25
|
+
ref,
|
|
26
|
+
...restProps,
|
|
27
|
+
__spread: true,
|
|
28
|
+
}]);
|
|
29
|
+
const isFirstPageElement = useRef(true);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (pageMounted) {
|
|
32
|
+
lynx.reportError(new Error(`Attempt to render more than one \`<page />\`, which is not supported.`));
|
|
33
|
+
isFirstPageElement.current = false;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
pageMounted = true;
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
__root.setAttribute('values', [
|
|
40
|
+
{
|
|
41
|
+
...Object.fromEntries(Object.entries(restProps).map(([key, _val]) => {
|
|
42
|
+
return [key, undefined];
|
|
43
|
+
})),
|
|
44
|
+
__spread: true,
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
/* v8 ignore next */
|
|
48
|
+
if (isFirstPageElement.current)
|
|
49
|
+
pageMounted = false;
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
return children;
|
|
53
|
+
});
|
|
54
|
+
})();
|
|
55
|
+
export { Page };
|
|
56
|
+
//# sourceMappingURL=Page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Page.js","sourceRoot":"","sources":["../src/Page.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D,+BAA+B;AAC/B,6FAA6F;AAC7F,4CAA4C;AAC5C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEhF,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,MAAM,IAAI;AACR,eAAe,CAAC,CAAC;IACf,IAAI,SAAS,EAAE,CAAC;QACd,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,MAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC7E,qBAAqB;YACrB,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;gBACvB,OAAO;YACT,CAAC;YACD,oBAAoB;YACpB,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,UAAU,CACf,UAAS,KAAK,EAAE,GAAG;QACjB,MAAM,EACJ,QAAQ,EACR,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;QAEV,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;gBAC7B,GAAG;gBACH,GAAG,SAAS;gBACZ,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC,CAAC;QACJ,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAExC,SAAS,CAAC,GAAG,EAAE;YACb,IAAI,WAAW,EAAE,CAAC;gBAChB,IAAI,CAAC,WAAW,CACd,IAAI,KAAK,CACP,uEAAuE,CACxE,CACF,CAAC;gBACF,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACrC,CAAC;iBAAM,CAAC;gBACN,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;YAED,OAAO,GAAG,EAAE;gBACV,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;oBAC5B;wBACE,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;4BAC5C,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;wBAC1B,CAAC,CAAC,CACH;wBACD,QAAQ,EAAE,IAAI;qBACf;iBACF,CAAC,CAAC;gBACH,oBAAoB;gBACpB,IAAI,kBAAkB,CAAC,OAAO;oBAAE,WAAW,GAAG,KAAK,CAAC;YACtD,CAAC,CAAC;QACJ,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,QAAQ,CAAC;IAClB,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC;AAEP,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Page } from './Page.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
|
|
5
|
+
import type { ForwardRefExoticComponent, PropsWithChildren, RefAttributes } from 'react';
|
|
6
|
+
|
|
7
|
+
// We use "@lynx-js/react" here
|
|
8
|
+
// because import * as ReactLynx from "@lynx-js/react/internal"; will be added when transform
|
|
9
|
+
// no matter if we use "@lynx-js/react" here
|
|
10
|
+
import { forwardRef, useEffect, useRef } from '@lynx-js/react';
|
|
11
|
+
import { __root, snapshotManager, updateSpread } from '@lynx-js/react/internal';
|
|
12
|
+
|
|
13
|
+
let pageMounted = false;
|
|
14
|
+
|
|
15
|
+
const Page: ForwardRefExoticComponent<Omit<PropsWithChildren, 'ref'> & RefAttributes<unknown>> =
|
|
16
|
+
/* @__PURE__ */ (function() {
|
|
17
|
+
if (__LEPUS__) {
|
|
18
|
+
snapshotManager.values.get('root')!.update![0] = (snapshot, index, oldValue) => {
|
|
19
|
+
/* v8 ignore start */
|
|
20
|
+
if (__JS__ && !__DEV__) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
/* v8 ignore stop */
|
|
24
|
+
updateSpread(snapshot, index, oldValue, 0);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return forwardRef(
|
|
29
|
+
function(props, ref) {
|
|
30
|
+
const {
|
|
31
|
+
children,
|
|
32
|
+
...restProps
|
|
33
|
+
} = props;
|
|
34
|
+
|
|
35
|
+
__root.setAttribute('values', [{
|
|
36
|
+
ref,
|
|
37
|
+
...restProps,
|
|
38
|
+
__spread: true,
|
|
39
|
+
}]);
|
|
40
|
+
const isFirstPageElement = useRef(true);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (pageMounted) {
|
|
44
|
+
lynx.reportError(
|
|
45
|
+
new Error(
|
|
46
|
+
`Attempt to render more than one \`<page />\`, which is not supported.`,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
isFirstPageElement.current = false;
|
|
50
|
+
} else {
|
|
51
|
+
pageMounted = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
__root.setAttribute('values', [
|
|
56
|
+
{
|
|
57
|
+
...Object.fromEntries(
|
|
58
|
+
Object.entries(restProps).map(([key, _val]) => {
|
|
59
|
+
return [key, undefined];
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
__spread: true,
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
/* v8 ignore next */
|
|
66
|
+
if (isFirstPageElement.current) pageMounted = false;
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
return children;
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
})();
|
|
74
|
+
|
|
75
|
+
export { Page };
|