@lynx-js/react 0.126.2 → 0.127.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 (190) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/docs/directives.md +90 -0
  4. package/docs/global-events.md +50 -0
  5. package/docs/import-attributes.md +43 -0
  6. package/docs/macros.md +285 -0
  7. package/package.json +3 -2
  8. package/refresh/.turbo/turbo-build.log +1 -1
  9. package/refresh/dist/index.js +26 -6
  10. package/refresh/package.json +1 -1
  11. package/runtime/__test__/core/main-thread-object.test.js +149 -0
  12. package/runtime/__test__/element-template/fixtures/background/main-thread-function/run-on-main-thread/index.tsx +26 -3
  13. package/runtime/__test__/element-template/imports/main-thread-object-api.test.ts +10 -0
  14. package/runtime/__test__/element-template/internal/legacy-internal-guardrail.test.ts +3 -0
  15. package/runtime/__test__/element-template/runtime/background/main-thread-function/compiled-fixtures.test.tsx +4 -0
  16. package/runtime/__test__/snapshot/ctxNotFound.test.ts +271 -0
  17. package/runtime/__test__/snapshot/event.test.jsx +7 -7
  18. package/runtime/__test__/snapshot/lazy.test.js +73 -1
  19. package/runtime/__test__/snapshot/lynx/portals.test.jsx +75 -37
  20. package/runtime/__test__/snapshot/snapshotPatch.test.jsx +59 -47
  21. package/runtime/__test__/snapshot/spread.test.jsx +10 -10
  22. package/runtime/__test__/snapshot/worklet/main-thread-object.test.jsx +306 -0
  23. package/runtime/__test__/snapshot/worklet/workletRef.test.jsx +1 -0
  24. package/runtime/__test__/worklet-runtime/mainThreadObject.test.js +182 -0
  25. package/runtime/__test__/worklet-runtime/object-methods.test.js +60 -0
  26. package/runtime/__test__/worklet-runtime/workletRef.test.js +362 -2
  27. package/runtime/__test__/worklet-runtime/workletRuntime.test.js +246 -1
  28. package/runtime/lazy/compat.js +2 -0
  29. package/runtime/lazy/element-template-internal.js +1 -0
  30. package/runtime/lazy/element-template.js +2 -0
  31. package/runtime/lazy/internal.js +2 -0
  32. package/runtime/lazy/react.js +2 -0
  33. package/runtime/lib/core/background-function/run-on-background.d.ts +16 -0
  34. package/runtime/lib/core/background-function/run-on-background.js +16 -0
  35. package/runtime/lib/core/background-function/run-on-background.js.map +1 -1
  36. package/runtime/lib/core/capture-main-thread-object.d.ts +1 -0
  37. package/runtime/lib/core/capture-main-thread-object.js +16 -0
  38. package/runtime/lib/core/capture-main-thread-object.js.map +1 -0
  39. package/runtime/lib/core/globalProps.d.ts +2 -0
  40. package/runtime/lib/core/globalProps.js.map +1 -1
  41. package/runtime/lib/core/hooks/react.d.ts +4 -0
  42. package/runtime/lib/core/hooks/react.js +4 -0
  43. package/runtime/lib/core/hooks/react.js.map +1 -1
  44. package/runtime/lib/core/hooks/useLynxGlobalEventListener.d.ts +2 -0
  45. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js +2 -0
  46. package/runtime/lib/core/hooks/useLynxGlobalEventListener.js.map +1 -1
  47. package/runtime/lib/core/initData.d.ts +2 -0
  48. package/runtime/lib/core/initData.js +2 -0
  49. package/runtime/lib/core/initData.js.map +1 -1
  50. package/runtime/lib/core/main-thread-object-handle-registry.d.ts +3 -0
  51. package/runtime/lib/core/main-thread-object-handle-registry.js +17 -0
  52. package/runtime/lib/core/main-thread-object-handle-registry.js.map +1 -0
  53. package/runtime/lib/core/main-thread-object.d.ts +77 -0
  54. package/runtime/lib/core/main-thread-object.js +261 -0
  55. package/runtime/lib/core/main-thread-object.js.map +1 -0
  56. package/runtime/lib/core/main-thread-ref-id.d.ts +1 -0
  57. package/runtime/lib/core/main-thread-ref-id.js +14 -0
  58. package/runtime/lib/core/main-thread-ref-id.js.map +1 -0
  59. package/runtime/lib/core/main-thread-ref-init-value.d.ts +1 -1
  60. package/runtime/lib/core/main-thread-ref-init-value.js +4 -2
  61. package/runtime/lib/core/main-thread-ref-init-value.js.map +1 -1
  62. package/runtime/lib/core/main-thread-ref.d.ts +4 -0
  63. package/runtime/lib/core/main-thread-ref.js +5 -8
  64. package/runtime/lib/core/main-thread-ref.js.map +1 -1
  65. package/runtime/lib/element-template/background/commit-hook.js.map +1 -1
  66. package/runtime/lib/element-template/index.d.ts +2 -0
  67. package/runtime/lib/element-template/index.js +1 -0
  68. package/runtime/lib/element-template/index.js.map +1 -1
  69. package/runtime/lib/element-template/internal.d.ts +1 -0
  70. package/runtime/lib/element-template/internal.js +1 -0
  71. package/runtime/lib/element-template/internal.js.map +1 -1
  72. package/runtime/lib/element-template/protocol/types.d.ts +1 -1
  73. package/runtime/lib/internal.d.ts +1 -0
  74. package/runtime/lib/internal.js +1 -0
  75. package/runtime/lib/internal.js.map +1 -1
  76. package/runtime/lib/lynx-api.d.ts +34 -0
  77. package/runtime/lib/lynx-api.js +21 -0
  78. package/runtime/lib/lynx-api.js.map +1 -1
  79. package/runtime/lib/lynx.js +4 -1
  80. package/runtime/lib/lynx.js.map +1 -1
  81. package/runtime/lib/snapshot/lifecycle/patch/error.d.ts +11 -1
  82. package/runtime/lib/snapshot/lifecycle/patch/error.js +24 -16
  83. package/runtime/lib/snapshot/lifecycle/patch/error.js.map +1 -1
  84. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.d.ts +1 -1
  85. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +29 -7
  86. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  87. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js +2 -2
  88. package/runtime/lib/snapshot/lifecycle/patch/updateMainThread.js.map +1 -1
  89. package/runtime/lib/snapshot/lynx/children.d.ts +2 -0
  90. package/runtime/lib/snapshot/lynx/children.js.map +1 -1
  91. package/runtime/lib/snapshot/lynx/element.d.ts +8 -0
  92. package/runtime/lib/snapshot/lynx/element.js +4 -0
  93. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  94. package/runtime/lib/snapshot/worklet/call/runOnMainThread.d.ts +2 -0
  95. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js +2 -0
  96. package/runtime/lib/snapshot/worklet/call/runOnMainThread.js.map +1 -1
  97. package/runtime/lib/snapshot/worklet/ref/updateInitValue.js.map +1 -1
  98. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  99. package/runtime/lib/worklet-runtime/bindings/bindings.d.ts +3 -3
  100. package/runtime/lib/worklet-runtime/bindings/bindings.js +9 -1
  101. package/runtime/lib/worklet-runtime/bindings/bindings.js.map +1 -1
  102. package/runtime/lib/worklet-runtime/bindings/types.d.ts +3 -6
  103. package/runtime/lib/worklet-runtime/bindings/types.js.map +1 -1
  104. package/runtime/lib/worklet-runtime/hydrate.js +26 -7
  105. package/runtime/lib/worklet-runtime/hydrate.js.map +1 -1
  106. package/runtime/lib/worklet-runtime/mainThreadObject.d.ts +8 -0
  107. package/runtime/lib/worklet-runtime/mainThreadObject.js +67 -0
  108. package/runtime/lib/worklet-runtime/mainThreadObject.js.map +1 -0
  109. package/runtime/lib/worklet-runtime/workletRef.d.ts +11 -7
  110. package/runtime/lib/worklet-runtime/workletRef.js +72 -9
  111. package/runtime/lib/worklet-runtime/workletRef.js.map +1 -1
  112. package/runtime/lib/worklet-runtime/workletRuntime.js +68 -9
  113. package/runtime/lib/worklet-runtime/workletRuntime.js.map +1 -1
  114. package/runtime/package.json +2 -3
  115. package/runtime/src/core/background-function/run-on-background.ts +16 -0
  116. package/runtime/src/core/capture-main-thread-object.ts +17 -0
  117. package/runtime/src/core/globalProps.ts +2 -0
  118. package/runtime/src/core/hooks/react.ts +4 -0
  119. package/runtime/src/core/hooks/useLynxGlobalEventListener.ts +2 -0
  120. package/runtime/src/core/initData.ts +2 -0
  121. package/runtime/src/core/main-thread-object-handle-registry.ts +25 -0
  122. package/runtime/src/core/main-thread-object.ts +387 -0
  123. package/runtime/src/core/main-thread-ref-id.ts +16 -0
  124. package/runtime/src/core/main-thread-ref-init-value.ts +12 -4
  125. package/runtime/src/core/main-thread-ref.ts +7 -8
  126. package/runtime/src/element-template/background/commit-hook.ts +1 -1
  127. package/runtime/src/element-template/index.ts +6 -0
  128. package/runtime/src/element-template/internal.ts +2 -0
  129. package/runtime/src/element-template/protocol/types.ts +1 -1
  130. package/runtime/src/internal.ts +1 -0
  131. package/runtime/src/lynx-api.ts +38 -0
  132. package/runtime/src/lynx.ts +5 -1
  133. package/runtime/src/snapshot/lifecycle/patch/error.ts +36 -19
  134. package/runtime/src/snapshot/lifecycle/patch/snapshotPatchApply.ts +29 -7
  135. package/runtime/src/snapshot/lifecycle/patch/updateMainThread.ts +2 -2
  136. package/runtime/src/snapshot/lynx/children.ts +2 -0
  137. package/runtime/src/snapshot/lynx/element.ts +8 -0
  138. package/runtime/src/snapshot/worklet/call/runOnMainThread.ts +2 -0
  139. package/runtime/src/snapshot/worklet/ref/updateInitValue.ts +1 -1
  140. package/runtime/src/worklet-runtime/bindings/bindings.ts +17 -2
  141. package/runtime/src/worklet-runtime/bindings/types.ts +7 -11
  142. package/runtime/src/worklet-runtime/hydrate.ts +43 -10
  143. package/runtime/src/worklet-runtime/mainThreadObject.ts +117 -0
  144. package/runtime/src/worklet-runtime/workletRef.ts +120 -19
  145. package/runtime/src/worklet-runtime/workletRuntime.ts +83 -11
  146. package/runtime/worklet-runtime/dev.js +154 -17
  147. package/runtime/worklet-runtime/main.js +1 -1
  148. package/testing-library/.turbo/turbo-build.log +6 -6
  149. package/testing-library/dist/index.d.ts +165 -2
  150. package/testing-library/package.json +2 -1
  151. package/testing-library/src/__tests__/lynx.test.jsx +1 -1
  152. package/testing-library/src/__tests__/worklet.test.jsx +46 -1
  153. package/testing-library/tsconfig.docs.json +9 -0
  154. package/testing-library/typedoc.json +22 -0
  155. package/transform/.turbo/turbo-build$colon$wasm.log +150 -78
  156. package/transform/__test__/fixture.spec.js +72 -30
  157. package/transform/__test__/object-methods.spec.js +84 -0
  158. package/transform/crates/swc_plugin_worklet/decl_collect.rs +10 -0
  159. package/transform/crates/swc_plugin_worklet/extract_ident.rs +14 -0
  160. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +202 -3
  161. package/transform/crates/swc_plugin_worklet/lib.rs +468 -3
  162. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +8 -1
  163. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +10 -5
  164. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_js.js +27 -0
  165. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_expose_object_method_capture_channels_lepus.js +45 -0
  166. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +16 -14
  167. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +16 -16
  168. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +7 -5
  169. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +7 -7
  170. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_computed_object_method_key_lepus.js +24 -0
  171. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_not_capture_object_method_local_decls_lepus.js +16 -0
  172. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +42 -0
  173. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +58 -0
  174. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +3 -1
  175. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +3 -3
  176. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_js.js +9 -0
  177. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_object_methods_lepus.js +16 -0
  178. package/transform/dist/wasm.cjs +1 -1
  179. package/transform/rspack-napi/tsconfig.tsbuildinfo +1 -1
  180. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +66 -469
  181. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  182. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +364 -30
  183. package/transform/swc-plugin-reactlynx-compat/swc_plugin_reactlynx_compat.wasm +0 -0
  184. package/transform/vitest.config.ts +5 -1
  185. package/types/react.docs.d.ts +130 -11
  186. package/testing-library/node_modules/.bin/rsbuild +0 -68
  187. package/testing-library/node_modules/.bin/rspeedy +0 -68
  188. package/testing-library/node_modules/.bin/rstest +0 -68
  189. package/transform/node_modules/.bin/esbuild +0 -59
  190. package/transform/node_modules/.bin/napi +0 -68
@@ -1,5 +1,5 @@
1
- import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
- var loadWorkletRuntime = __loadWorkletRuntime;
1
+ import { captureMainThreadObject as __captureMainThreadObject, loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject, loadWorkletRuntime = __loadWorkletRuntime;
3
3
  let onTapLepus = {
4
4
  _c: {
5
5
  aaaa,
@@ -10,23 +10,23 @@ let onTapLepus = {
10
10
  _wkltId: "a123:test:1",
11
11
  ...{
12
12
  aaaa: this.aaaa,
13
- bbbb: {
14
- cccc: {
15
- dddd: this.bbbb.cccc.dddd
16
- }
17
- },
13
+ bbbb: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
14
+ cccc: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
15
+ dddd: __mainThreadObjectSource.dddd
16
+ })(__mainThreadObjectSource.cccc)
17
+ })(this.bbbb),
18
18
  eeee: this.eeee,
19
19
  ffff: this.ffff,
20
- hhhh: {
21
- 'iiii': this.hhhh['iiii'],
22
- kkkk: this.hhhh.kkkk
23
- },
20
+ hhhh: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
21
+ 'iiii': __mainThreadObjectSource['iiii'],
22
+ kkkk: __mainThreadObjectSource.kkkk
23
+ })(this.hhhh),
24
24
  llll: this.llll,
25
- mmmm: {
26
- nnnn: {
27
- 'oooo': this.mmmm.nnnn['oooo']
28
- }
29
- }
25
+ mmmm: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
26
+ nnnn: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
27
+ 'oooo': __mainThreadObjectSource['oooo']
28
+ })(__mainThreadObjectSource.nnnn)
29
+ })(this.mmmm)
30
30
  }
31
31
  };
32
32
  const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
@@ -1,21 +1,23 @@
1
+ import { captureMainThreadObject as __captureMainThreadObject } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject;
1
3
  let onTapLepus = {
2
4
  _c: {
3
- aaaa: {
5
+ aaaa: captureMainThreadObject(aaaa) ?? {
4
6
  bbbb: aaaa.bbbb
5
7
  },
6
- cccc: {
8
+ cccc: captureMainThreadObject(cccc) ?? {
7
9
  dddd: cccc.dddd
8
10
  },
9
- hhhh: {
11
+ hhhh: captureMainThreadObject(hhhh) ?? {
10
12
  iiii: hhhh.iiii
11
13
  },
12
14
  llll,
13
- oooo: {
15
+ oooo: captureMainThreadObject(oooo) ?? {
14
16
  pppp: oooo.pppp,
15
17
  qqqq: oooo.qqqq
16
18
  },
17
19
  rrrr,
18
- uuuu: {
20
+ uuuu: captureMainThreadObject(uuuu) ?? {
19
21
  "__??__": uuuu["__??__"]
20
22
  }
21
23
  },
@@ -1,23 +1,23 @@
1
- import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
- var loadWorkletRuntime = __loadWorkletRuntime;
1
+ import { captureMainThreadObject as __captureMainThreadObject, loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject, loadWorkletRuntime = __loadWorkletRuntime;
3
3
  let onTapLepus = {
4
4
  _c: {
5
- aaaa: {
5
+ aaaa: captureMainThreadObject(aaaa) ?? {
6
6
  bbbb: aaaa.bbbb
7
7
  },
8
- cccc: {
8
+ cccc: captureMainThreadObject(cccc) ?? {
9
9
  dddd: cccc.dddd
10
10
  },
11
- hhhh: {
11
+ hhhh: captureMainThreadObject(hhhh) ?? {
12
12
  iiii: hhhh.iiii
13
13
  },
14
14
  llll,
15
- oooo: {
15
+ oooo: captureMainThreadObject(oooo) ?? {
16
16
  pppp: oooo.pppp,
17
17
  qqqq: oooo.qqqq
18
18
  },
19
19
  rrrr,
20
- uuuu: {
20
+ uuuu: captureMainThreadObject(uuuu) ?? {
21
21
  "__??__": uuuu["__??__"]
22
22
  }
23
23
  },
@@ -0,0 +1,24 @@
1
+ import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var loadWorkletRuntime = __loadWorkletRuntime;
3
+ const name = 'create';
4
+ const nestedName = 'read';
5
+ const valueType = defineMainThreadObjectType({
6
+ type: '@test/value',
7
+ [name]: {
8
+ _c: {
9
+ nestedName
10
+ },
11
+ _wkltId: "a77b:test:1"
12
+ }
13
+ });
14
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
15
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a77b:test:1", function(initialValue) {
16
+ let { nestedName } = this["_c"];
17
+ "main thread";
18
+ return {
19
+ value: initialValue,
20
+ [nestedName] (nestedName) {
21
+ return nestedName;
22
+ }
23
+ };
24
+ });
@@ -0,0 +1,16 @@
1
+ import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var loadWorkletRuntime = __loadWorkletRuntime;
3
+ const valueType = defineMainThreadObjectType({
4
+ type: '@test/value',
5
+ create: {
6
+ _wkltId: "a77b:test:1"
7
+ }
8
+ });
9
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
10
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a77b:test:1", function(initialValue) {
11
+ "main thread";
12
+ const state = {
13
+ value: initialValue
14
+ };
15
+ return state;
16
+ });
@@ -0,0 +1,42 @@
1
+ import { captureMainThreadObject as __captureMainThreadObject } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject;
3
+ class App extends Component {
4
+ value: MotionValue<number>;
5
+ ref: MainThreadRef<number>;
6
+ static value: MotionValue<number>;
7
+ get onTap() {
8
+ return {
9
+ _wkltId: "a123:test:1",
10
+ ...{
11
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
12
+ "get": __mainThreadObjectSource["get"],
13
+ set: __mainThreadObjectSource.set
14
+ })(this.value),
15
+ props: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
16
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
17
+ get: __mainThreadObjectSource.get
18
+ })(__mainThreadObjectSource.value)
19
+ })(this.props),
20
+ ref: this.ref
21
+ }
22
+ };
23
+ }
24
+ get onMove() {
25
+ return {
26
+ _wkltId: "a123:test:2",
27
+ ...{
28
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
29
+ get: __mainThreadObjectSource.get
30
+ })(this.value)
31
+ }
32
+ };
33
+ }
34
+ static onStatic = {
35
+ _wkltId: "a123:test:3",
36
+ ...{
37
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
38
+ get: __mainThreadObjectSource.get
39
+ })(this.value)
40
+ }
41
+ };
42
+ }
@@ -0,0 +1,58 @@
1
+ import { captureMainThreadObject as __captureMainThreadObject, loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject, loadWorkletRuntime = __loadWorkletRuntime;
3
+ class App extends Component {
4
+ value: MotionValue<number>;
5
+ ref: MainThreadRef<number>;
6
+ static value: MotionValue<number>;
7
+ onTap = {
8
+ _wkltId: "a123:test:1",
9
+ ...{
10
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
11
+ "get": __mainThreadObjectSource["get"],
12
+ set: __mainThreadObjectSource.set
13
+ })(this.value),
14
+ props: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
15
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
16
+ get: __mainThreadObjectSource.get
17
+ })(__mainThreadObjectSource.value)
18
+ })(this.props),
19
+ ref: this.ref
20
+ }
21
+ };
22
+ onMove = {
23
+ _wkltId: "a123:test:2",
24
+ ...{
25
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
26
+ get: __mainThreadObjectSource.get
27
+ })(this.value)
28
+ }
29
+ };
30
+ static onStatic = {
31
+ _wkltId: "a123:test:3",
32
+ ...{
33
+ value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
34
+ get: __mainThreadObjectSource.get
35
+ })(this.value)
36
+ }
37
+ };
38
+ }
39
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
40
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a123:test:1", function() {
41
+ this["onTap"] = lynxWorkletImpl._workletMap["a123:test:1"].bind(this);
42
+ "main thread";
43
+ this.value.get();
44
+ this.props.value.get();
45
+ this.value.set(1);
46
+ this.value?.get();
47
+ this.value["get"]();
48
+ return this.ref.current;
49
+ });
50
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a123:test:2", function() {
51
+ "main thread";
52
+ return this.value.get();
53
+ });
54
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a123:test:3", function() {
55
+ this["onStatic"] = lynxWorkletImpl._workletMap["a123:test:3"].bind(this);
56
+ "main thread";
57
+ return this.value.get();
58
+ });
@@ -1,3 +1,5 @@
1
+ import { captureMainThreadObject as __captureMainThreadObject } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject;
1
3
  let X = {
2
4
  _c: {
3
5
  y1,
@@ -6,7 +8,7 @@ let X = {
6
8
  y4,
7
9
  y8,
8
10
  y5,
9
- y6: {
11
+ y6: captureMainThreadObject(y6) ?? {
10
12
  m: y6.m
11
13
  },
12
14
  y7
@@ -1,5 +1,5 @@
1
- import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
- var loadWorkletRuntime = __loadWorkletRuntime;
1
+ import { captureMainThreadObject as __captureMainThreadObject, loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var captureMainThreadObject = __captureMainThreadObject, loadWorkletRuntime = __loadWorkletRuntime;
3
3
  let X = {
4
4
  _c: {
5
5
  y1,
@@ -8,7 +8,7 @@ let X = {
8
8
  y4,
9
9
  y8,
10
10
  y5,
11
- y6: {
11
+ y6: captureMainThreadObject(y6) ?? {
12
12
  m: y6.m
13
13
  },
14
14
  y7
@@ -0,0 +1,9 @@
1
+ import { create } from './shared.js' with {
2
+ runtime: "shared"
3
+ };
4
+ const valueType = defineMainThreadObjectType({
5
+ type: '@test/value',
6
+ create: {
7
+ _wkltId: "a77b:test:1"
8
+ }
9
+ });
@@ -0,0 +1,16 @@
1
+ import { loadWorkletRuntime as __loadWorkletRuntime } from "@lynx-js/react";
2
+ var loadWorkletRuntime = __loadWorkletRuntime;
3
+ import { create } from './shared.js' with {
4
+ runtime: "shared"
5
+ };
6
+ const valueType = defineMainThreadObjectType({
7
+ type: '@test/value',
8
+ create: {
9
+ _wkltId: "a77b:test:1"
10
+ }
11
+ });
12
+ const __workletRuntimeLoaded = loadWorkletRuntime(typeof globDynamicComponentEntry === 'undefined' ? undefined : globDynamicComponentEntry);
13
+ __workletRuntimeLoaded && registerWorkletInternal("main-thread", "a77b:test:1", function(initialValue: number) {
14
+ "main thread";
15
+ return create(initialValue);
16
+ });