@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 +1 @@
1
- (()=>{var e,t,n;let r,l,i;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class a{cancel(){return __ElementAnimate(this.effect.target.element,[3,this.id])}pause(){return __ElementAnimate(this.effect.target.element,[2,this.id])}play(){return __ElementAnimate(this.effect.target.element,[1,this.id])}start(){return __ElementAnimate(this.effect.target.element,[0,this.id,this.effect.keyframes,this.effect.options])}constructor(e){o(this,"effect",void 0),o(this,"id",void 0),this.effect=e,this.id="__lynx-inner-js-animation-"+a.count++,this.start()}}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}o(a,"count",0);class u{constructor(e,t,n){s(this,"target",void 0),s(this,"keyframes",void 0),s(this,"options",void 0),this.target=e,this.keyframes=t,this.options=n}}function c(e,t){var n;let r=(null!=(n=SystemInfo.lynxSdkVersion)?n:"1.0").split(".");return Number(r[0])>e||Number(r[0])==e&&Number(r[1])>t}let d=!1,f=!0;class y{setAttribute(e,t){__SetAttribute(this.element,e,t),this.flushElementTree()}setStyleProperty(e,t){__AddInlineStyle(this.element,e,t),this.flushElementTree()}setStyleProperties(e){for(let t in e)__AddInlineStyle(this.element,t,e[t]);this.flushElementTree()}getAttribute(e){return __GetAttributeByName(this.element,e)}getAttributeNames(){return __GetAttributeNames(this.element)}querySelector(e){let t=__QuerySelector(this.element,e,{});return t?new y(t):null}querySelectorAll(e){return __QuerySelectorAll(this.element,e,{}).map(e=>new y(e))}getComputedStyleProperty(e){if(!c(3,4))throw Error("getComputedStyleProperty requires Lynx sdk version 3.5");if(!e)throw Error("getComputedStyleProperty: key is required");return __GetComputedStyleByKey(this.element,e)}animate(e,t){return new a(new u(this,e,"number"==typeof t?{duration:t}:null!=t?t:{}))}invoke(e,t){return new Promise((n,r)=>{__InvokeUIMethod(this.element,e,null!=t?t:{},e=>{0===e.code?n(e.data):r(Error("UI method invoke: "+JSON.stringify(e)))}),this.flushElementTree()})}flushElementTree(){!d&&f&&(d=!0,Promise.resolve().then(()=>{d=!1,__FlushElementTree()}))}constructor(e){var t,n;n=void 0,(t="element")in this?Object.defineProperty(this,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):this[t]=n,Object.defineProperty(this,"element",{get:()=>e})}}class m{static get(){return null!=m.pageElement||(m.pageElement=__GetPageElement()),m.pageElement}}function h(e,t,n){let r;try{r=runWorklet(e,t)}finally{lynx.getJSContext().dispatchEvent({type:"Lynx.Worklet.FunctionCallRet",data:JSON.stringify({resolveId:n,returnValue:r})})}}t=void 0,(e="pageElement")in m?Object.defineProperty(m,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):m[e]=t;let _=(e,t)=>({current:t,_wvid:e}),p=e=>{let t,n=e._wvid;return n<0?(t=r._firstScreenWorkletRefMap[n])||(t=r._firstScreenWorkletRefMap[n]=_(n,e._initValue)):t=r._workletRefMap[n],t};function k(){l.delayedBackgroundFunctionArray.length=0}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t,n){lynxWorkletImpl._workletMap[t]=n}let I=new WeakMap;function b(e,t){if("object"!=typeof e||null===e)return e;if(t){let t=I.get(e);if(t)return t}let n={main:e};return x(n,0,e),t&&I.set(e,n.main),n.main}let x=(e,t,n)=>{if(++t>=1e3)throw Error("Depth of value exceeds limit of 1000.");if("object"==typeof e&&null!==e)for(let l in e){let i=e[l];if("object"==typeof i&&null!==i){if("elementRefptr"in i){e[l]=new y(i.elementRefptr);continue}if(!(i instanceof y)){if(x(i,t,n),"_wvid"in i){e[l]=p(i);continue}if("_wkltId"in i){let t=i===n,r={...i};e[l]=lynxWorkletImpl._workletMap[i._wkltId].bind(r),t||(e[l].boundCtx=r);continue}if("_jsFnId"in i){var r;i._execId=n._execId,null==(r=lynxWorkletImpl._jsFunctionLifecycleManager)||r.addRef(n._execId,i);continue}}}}};if(void 0===globalThis.lynxWorkletImpl){let e,t;globalThis.lynxWorkletImpl={_workletMap:{},_refImpl:r={_workletRefMap:{},_firstScreenWorkletRefMap:{},updateWorkletRef:function(e,t){p(e).current=t?new y(t):null},updateWorkletRefInitValueChanges:function(e){e.forEach(([e,t])=>{r._workletRefMap[e]||(r._workletRefMap[e]=_(e,t))})},clearFirstScreenWorkletRefMap:function(){r._firstScreenWorkletRefMap={}}},_runOnBackgroundDelayImpl:l={delayedBackgroundFunctionArray:[],clearDelayedBackgroundFunctions:k,delayRunOnBackground:function(e,t){var n;l.delayedBackgroundFunctionArray.push({task:t}),(null!=(n=e._delayIndices)?n:e._delayIndices=[]).push(l.delayedBackgroundFunctionArray.length-1)},runDelayedBackgroundFunctions:function(){for(let e of l.delayedBackgroundFunctionArray)(null==e?void 0:e.jsFnHandle)&&e.task(e.jsFnHandle._jsFnId,e.jsFnHandle._execId);k()}},_hydrateCtx:function(e,t){!function e(t,n,r){if(t&&"object"==typeof t&&n&&"object"==typeof n&&(!t._wkltId||t._wkltId===n._wkltId))for(let o in t)if("_wvid"===o){var l,i;l=t[o],"_initValue"in(i=n)||(lynxWorkletImpl._refImpl._workletRefMap[l]=i)}else if("_jsFn"===o)!function(e,t,n){for(let r in e){let l=e[r],i=t[r];if(!(null==i?void 0:i._delayIndices)){i&&(i._isFirstScreen=!1,i._execId=n,Object.assign(i,l));continue}for(let e of i._delayIndices){let t=lynxWorkletImpl._runOnBackgroundDelayImpl.delayedBackgroundFunctionArray[e];t&&(l._execId=n,t.jsFnHandle=l)}}}(t[o],n[o],r);else{let l="function"==typeof n[o]?n[o].boundCtx:n[o];e(t[o],l,r)}}(e,t,e._execId)},_eventDelayImpl:i={_delayedWorkletParamsMap:new Map,runDelayedWorklet:function(e,t){(()=>{let n=i._delayedWorkletParamsMap.get(e._wkltId);if(void 0===n)return;let r=[];n.forEach(n=>{var l;let i=n[0];(null==i||null==(l=i.currentTarget)?void 0:l.elementRefptr)===t?setTimeout(()=>{runWorklet(e,n)},0):r.push(n)}),i._delayedWorkletParamsMap.set(e._wkltId,r)})()},clearDelayedWorklets:function(){i._delayedWorkletParamsMap.clear()}},_eomImpl:{setShouldFlush:function(e){f=e}},_runRunOnMainThreadTask:h},c(2,15)&&(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager=new class e{addRef(e,t){var n;this.retainedObjects.has(t)||(this.retainedObjects.add(t),this.execIdRefCount.set(e,(null!=(n=this.execIdRefCount.get(e))?n:0)+1),this.registry.register(t,e))}removeRef(e){let t=this.execIdRefCount.get(e);t>1?this.execIdRefCount.set(e,t-1):(this.execIdRefCount.delete(e),this.execIdSetToFire.add(e),this.willFire||(this.willFire=!0,Promise.resolve().then(()=>{this.fire()})))}fire(){lynx.getJSContext().dispatchEvent({type:"Lynx.Worklet.releaseBackgroundWorkletCtx",data:Array.from(this.execIdSetToFire)}),this.execIdSetToFire.clear(),this.willFire=!1}constructor(){g(this,"execIdRefCount",new Map),g(this,"execIdSetToFire",new Set),g(this,"retainedObjects",new WeakSet),g(this,"willFire",!1),g(this,"registry",void 0),this.registry=new FinalizationRegistry(this.removeRef.bind(this))}}),globalThis.registerWorklet=v,globalThis.registerWorkletInternal=v,globalThis.runWorklet=function(e,t,n){var r,l,o;if("object"==typeof(r=e)&&null!==r&&("_wkltId"in r||"_lepusWorkletHash"in r)){let r,a;return"_lepusWorkletHash"in e?void(l=e._lepusWorkletHash,o=t,(a=(r=i._delayedWorkletParamsMap).get(l))?a.push(o):r.set(l,[o])):function(e,t,n){let r=(e._wkltId,b(e,!0)),l=b(t||[],!1),[i,o]=function(e,t){if(!Array.isArray(e)||"object"!=typeof e[0]||null===e[0]||(!t||1!==t.source)&&1)return[!1,{}];let n={},r=e[0];return r.stopPropagation=function(){var e;n._eventReturnResult=(null!=(e=n._eventReturnResult)?e:0)|1},r.stopImmediatePropagation=function(){var e;n._eventReturnResult=(null!=(e=n._eventReturnResult)?e:0)|2},[!0,n]}(l,n),a=r(...l);return i?{returnValue:a,eventReturnResult:o._eventReturnResult}:a}(e,t,n)}},lynx.querySelector=function(e){let t=m.get();if(!t)return null;let n=__QuerySelector(t,e,{});return n?new y(n):null},lynx.querySelectorAll=function(e){let t=m.get();return t?__QuerySelectorAll(t,e,{}).map(e=>new y(e)):[]},globalThis.setTimeout=lynx.setTimeout,globalThis.setInterval=lynx.setInterval,globalThis.clearTimeout=lynx.clearTimeout,globalThis.clearInterval=null!=(n=lynx.clearInterval)?n:lynx.clearTimeInterval,e=lynx.requestAnimationFrame,lynx.requestAnimationFrame=globalThis.requestAnimationFrame=t=>{if(!c(2,15))throw Error("requestAnimationFrame in main thread script requires Lynx sdk version 2.16");return e(t)},globalThis.cancelAnimationFrame=lynx.cancelAnimationFrame,(t=lynx.getJSContext()).addEventListener("Lynx.Worklet.runWorkletCtx",e=>{let t=JSON.parse(e.data);h(t.worklet,t.params,t.resolveId)}),t.addEventListener("Lynx.Worklet.releaseWorkletRef",e=>{var t;t=e.data.id,delete r._workletRefMap[t]})}})();
1
+ (()=>{var e,t,r;let n,l,i;function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class a{cancel(){return __ElementAnimate(this.effect.target.element,[3,this.id])}pause(){return __ElementAnimate(this.effect.target.element,[2,this.id])}play(){return __ElementAnimate(this.effect.target.element,[1,this.id])}start(){return __ElementAnimate(this.effect.target.element,[0,this.id,this.effect.keyframes,this.effect.options])}constructor(e){o(this,"effect",void 0),o(this,"id",void 0),this.effect=e,this.id="__lynx-inner-js-animation-"+a.count++,this.start()}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}o(a,"count",0);class s{constructor(e,t,r){u(this,"target",void 0),u(this,"keyframes",void 0),u(this,"options",void 0),this.target=e,this.keyframes=t,this.options=r}}function c(e,t){var r;let n=(null!=(r=SystemInfo.lynxSdkVersion)?r:"1.0").split(".");return Number(n[0])>e||Number(n[0])==e&&Number(n[1])>t}let d=!1,f=!0;class y{setAttribute(e,t){__SetAttribute(this.element,e,t),this.flushElementTree()}setStyleProperty(e,t){__AddInlineStyle(this.element,e,t),this.flushElementTree()}setStyleProperties(e){for(let t in e)__AddInlineStyle(this.element,t,e[t]);this.flushElementTree()}getAttribute(e){return __GetAttributeByName(this.element,e)}getAttributeNames(){return __GetAttributeNames(this.element)}querySelector(e){let t=__QuerySelector(this.element,e,{});return t?new y(t):null}querySelectorAll(e){return __QuerySelectorAll(this.element,e,{}).map(e=>new y(e))}getComputedStyleProperty(e){if(!c(3,4))throw Error("getComputedStyleProperty requires Lynx sdk version 3.5");if(!e)throw Error("getComputedStyleProperty: key is required");return __GetComputedStyleByKey(this.element,e)}animate(e,t){return new a(new s(this,e,"number"==typeof t?{duration:t}:null!=t?t:{}))}invoke(e,t){return new Promise((r,n)=>{__InvokeUIMethod(this.element,e,null!=t?t:{},e=>{0===e.code?r(e.data):n(Error("UI method invoke: "+JSON.stringify(e)))}),this.flushElementTree()})}flushElementTree(){!d&&f&&(d=!0,Promise.resolve().then(()=>{d=!1,__FlushElementTree()}))}constructor(e){var t,r;r=void 0,(t="element")in this?Object.defineProperty(this,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):this[t]=r,Object.defineProperty(this,"element",{get:()=>e})}}class h{static get(){return null!=h.pageElement||(h.pageElement=__GetPageElement()),h.pageElement}}function p(e,t,r){let n;try{n=runWorklet(e,t)}finally{lynx.getJSContext().dispatchEvent({type:"Lynx.Worklet.FunctionCallRet",data:JSON.stringify({resolveId:r,returnValue:n})})}}t=void 0,(e="pageElement")in h?Object.defineProperty(h,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):h[e]=t;let m=new Map,_=new WeakMap;function g(e){return"function"==typeof e?Function.prototype.toString.call(e):`worklet:${e._wkltId}`}function b(e){var t;return e._type&&"main-thread"!==e._type?function(e){var t;let r=e._type,n=m.get(r);if(!n)throw Error(`MainThreadObject type is not registered: "${r}". Define the type in a module evaluated on the main thread before initializing its handle.`);let l=(null!=(t=n.resolvedCreate)?t:n.resolvedCreate=function(e){if("function"==typeof e)return e;if(!("_wkltId"in e)||"_lepusWorkletHash"in e)throw Error("Cannot resolve an invalid Main Thread Function.");return lynxWorkletImpl._workletMap[e._wkltId]}(n.create))(e._initValue);if("object"!=typeof l||null===l)throw Error(`MainThreadObject type "${r}" created a non-object value.`);return _.set(l,r),l}(e):(t=e._wvid,{current:e._initValue,_wvid:t})}function k(e){return"object"==typeof e&&null!==e&&"number"==typeof e._wvid&&Object.prototype.hasOwnProperty.call(e,"current")}function w(e,t,r){let n;if(_.has(t)?n="typed-object":k(t)&&(n="mutable-cell"),!n)throw Error(`Cannot apply MainThreadObject ${r} for handle ${e._wvid}: the existing target has no worklet-value metadata.`);let l=e._type,i=l&&"main-thread"!==l?"typed-object":"mutable-cell";if(n!==i)throw Error(`Worklet value kind mismatch during ${r} for handle ${e._wvid}: background handle expects ${i}, but the main-thread target is ${n}.`);"typed-object"===n&&function(e,t,r){let n=_.get(t),l=e._type;if(n!==l)throw Error(`MainThreadObject type mismatch during ${r} for handle ${e._wvid}: background handle expects type "${l}", but the main-thread target is type "${n}".`)}(e,t,r)}let v=e=>{let t,r=e._wvid;if(r<0){var l,i;t=null!=(i=(l=n._firstScreenWorkletRefMap)[r])?i:l[r]=b(e)}else t=n._workletRefMap[r];return t};function I(){l.delayedBackgroundFunctionArray.length=0}function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e,t,r){lynxWorkletImpl._workletMap[t]=r}let R=new WeakMap;function W(e,t){if("object"!=typeof e||null===e)return e;if(t){let t=R.get(e);if(t)return t}let r=T({main:e},0,e);return t&&R.set(e,r.main),r.main}let T=(e,t,r)=>{if(++t>=1e3)throw Error("Depth of value exceeds limit of 1000.");if("object"!=typeof e||null===e)return e;let n=e;for(let o in n){var l,i;let a=n[o];if("object"!=typeof a||null===a||_.has(a))continue;if("number"==typeof(i=a)._wvid&&"string"==typeof i._type&&"main-thread"!==i._type){n=M(n,e,o,v(a));continue}if("elementRefptr"in a){n[o]=new y(a.elementRefptr);continue}if(a instanceof y)continue;let u=T(a,t,r);if("_wvid"in a){n[o]=v(a);continue}if("_wkltId"in a){let t=a===r,l={...u},i=lynxWorkletImpl._workletMap[a._wkltId].bind(l);u!==a&&n===e&&n!==r&&(n=F(n)),n=M(n,e,o,i),t||(i.boundCtx=l);continue}if(u!==a&&(n===e&&n!==r&&(n=F(n)),n=M(n,e,o,u)),"_jsFnId"in a){a._execId=r._execId,null==(l=lynxWorkletImpl._jsFunctionLifecycleManager)||l.addRef(r._execId,a);continue}}return n};function M(e,t,r,n){let l=Object.getOwnPropertyDescriptor(e,r);if(null==l?void 0:l.get){let i={value:n,writable:!0,enumerable:l.enumerable,configurable:l.configurable};if(e===t||!l.configurable){let t=Object.getOwnPropertyDescriptors(e);return t[r]=i,F(e,t)}Object.defineProperty(e,r,i)}else e[r]=n;return e}function F(e,t=Object.getOwnPropertyDescriptors(e)){return Object.defineProperties(Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e)),t)}if(void 0===globalThis.lynxWorkletImpl){let e,t;globalThis.lynxWorkletImpl={_workletMap:{},_refImpl:(m.clear(),_=new WeakMap,n={_workletRefMap:{},_firstScreenWorkletRefMap:{},updateWorkletRef:function(e,t){v(e).current=t?new y(t):null},updateWorkletRefInitValueChanges:function(e){let t,r=!1;if(e.forEach(([e,l,i])=>{try{let t={_wvid:e,_initValue:l,_type:i},r=n._workletRefMap[e];r?w(t,r,"initialization patch"):n._workletRefMap[e]=b(t)}catch(e){r||(t=e,r=!0)}}),r)throw t},registerMainThreadObjectType:function(e,t){if("main-thread"===e)throw Error('MainThreadObject type "main-thread" is reserved for MainThreadRef.');let r=m.get(e);if(r){if(g(r.create)!==g(t))throw Error(`Conflicting MainThreadObject registration for type "${e}". A type key must always use the same create function.`);return}m.set(e,{create:t})},clearFirstScreenWorkletRefMap:function(){n._firstScreenWorkletRefMap={}}}),_runOnBackgroundDelayImpl:l={delayedBackgroundFunctionArray:[],clearDelayedBackgroundFunctions:I,delayRunOnBackground:function(e,t){var r;l.delayedBackgroundFunctionArray.push({task:t}),(null!=(r=e._delayIndices)?r:e._delayIndices=[]).push(l.delayedBackgroundFunctionArray.length-1)},runDelayedBackgroundFunctions:function(){for(let e of l.delayedBackgroundFunctionArray)(null==e?void 0:e.jsFnHandle)&&e.task(e.jsFnHandle._jsFnId,e.jsFnHandle._execId);I()}},_hydrateCtx:function(e,t){!function e(t,r,l){if(t&&"object"==typeof t&&r&&"object"==typeof r&&(!t._wkltId||t._wkltId===r._wkltId)){var i,o,a;if("number"==typeof(i=t)._wvid&&"string"==typeof i._type)return void function(e,t){"object"==typeof t&&null!==t&&(_.has(t)||k(t))&&(w(e,t,"hydration"),n._workletRefMap[e._wvid]=t)}(t,r);for(let n in t)if("_wvid"===n){o=t[n],"_initValue"in(a=r)||(lynxWorkletImpl._refImpl._workletRefMap[o]=a)}else if("_jsFn"===n)!function(e,t,r){for(let n in e){let l=e[n],i=t[n];if(!(null==i?void 0:i._delayIndices)){i&&(i._isFirstScreen=!1,i._execId=r,Object.assign(i,l));continue}for(let e of i._delayIndices){let t=lynxWorkletImpl._runOnBackgroundDelayImpl.delayedBackgroundFunctionArray[e];t&&(l._execId=r,t.jsFnHandle=l)}}}(t[n],r[n],l);else{let i="function"==typeof r[n]?r[n].boundCtx:r[n];e(t[n],i,l)}}}(e,t,e._execId)},_eventDelayImpl:i={_delayedWorkletParamsMap:new Map,runDelayedWorklet:function(e,t){(()=>{let r=i._delayedWorkletParamsMap.get(e._wkltId);if(void 0===r)return;let n=[];r.forEach(r=>{var l;let i=r[0];(null==i||null==(l=i.currentTarget)?void 0:l.elementRefptr)===t?setTimeout(()=>{runWorklet(e,r)},0):n.push(r)}),i._delayedWorkletParamsMap.set(e._wkltId,n)})()},clearDelayedWorklets:function(){i._delayedWorkletParamsMap.clear()}},_eomImpl:{setShouldFlush:function(e){f=e}},_runRunOnMainThreadTask:p},c(2,15)&&(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager=new class e{addRef(e,t){var r;this.retainedObjects.has(t)||(this.retainedObjects.add(t),this.execIdRefCount.set(e,(null!=(r=this.execIdRefCount.get(e))?r:0)+1),this.registry.register(t,e))}removeRef(e){let t=this.execIdRefCount.get(e);t>1?this.execIdRefCount.set(e,t-1):(this.execIdRefCount.delete(e),this.execIdSetToFire.add(e),this.willFire||(this.willFire=!0,Promise.resolve().then(()=>{this.fire()})))}fire(){lynx.getJSContext().dispatchEvent({type:"Lynx.Worklet.releaseBackgroundWorkletCtx",data:Array.from(this.execIdSetToFire)}),this.execIdSetToFire.clear(),this.willFire=!1}constructor(){x(this,"execIdRefCount",new Map),x(this,"execIdSetToFire",new Set),x(this,"retainedObjects",new WeakSet),x(this,"willFire",!1),x(this,"registry",void 0),this.registry=new FinalizationRegistry(this.removeRef.bind(this))}}),globalThis.registerWorklet=j,globalThis.registerWorkletInternal=j,globalThis.runWorklet=function(e,t,r){var n,l,o;if("object"==typeof(n=e)&&null!==n&&("_wkltId"in n||"_lepusWorkletHash"in n)){let n,a;return"_lepusWorkletHash"in e?void(l=e._lepusWorkletHash,o=t,(a=(n=i._delayedWorkletParamsMap).get(l))?a.push(o):n.set(l,[o])):function(e,t,r){let n=(e._wkltId,W(e,!0)),l=W(t||[],!1),[i,o]=function(e,t){if(!Array.isArray(e)||"object"!=typeof e[0]||null===e[0]||(!t||1!==t.source)&&1)return[!1,{}];let r={},n=e[0];return n.stopPropagation=function(){var e;r._eventReturnResult=(null!=(e=r._eventReturnResult)?e:0)|1},n.stopImmediatePropagation=function(){var e;r._eventReturnResult=(null!=(e=r._eventReturnResult)?e:0)|2},[!0,r]}(l,r),a=n(...l);return i?{returnValue:a,eventReturnResult:o._eventReturnResult}:a}(e,t,r)}},lynx.querySelector=function(e){let t=h.get();if(!t)return null;let r=__QuerySelector(t,e,{});return r?new y(r):null},lynx.querySelectorAll=function(e){let t=h.get();return t?__QuerySelectorAll(t,e,{}).map(e=>new y(e)):[]},globalThis.setTimeout=lynx.setTimeout,globalThis.setInterval=lynx.setInterval,globalThis.clearTimeout=lynx.clearTimeout,globalThis.clearInterval=null!=(r=lynx.clearInterval)?r:lynx.clearTimeInterval,e=lynx.requestAnimationFrame,lynx.requestAnimationFrame=globalThis.requestAnimationFrame=t=>{if(!c(2,15))throw Error("requestAnimationFrame in main thread script requires Lynx sdk version 2.16");return e(t)},globalThis.cancelAnimationFrame=lynx.cancelAnimationFrame,(t=lynx.getJSContext()).addEventListener("Lynx.Worklet.runWorkletCtx",e=>{let t=JSON.parse(e.data);p(t.worklet,t.params,t.resolveId)}),t.addEventListener("Lynx.Worklet.releaseWorkletRef",e=>{var t;t=e.data.id,delete n._workletRefMap[t]})}})();
@@ -4,12 +4,12 @@ Rslib v1.0.2
4
4
  info build started...
5
5
  start generating declaration files... (esm0)
6
6
  start generating declaration files... (esm2)
7
- ready built in 0.58s (esm2)
8
- ready built in 0.62s (esm1)
9
- ready built in 0.73s (esm0)
10
- info declaration files prepared with tsgo in 1.18 s (esm2)
11
- ready declaration files bundled successfully: dist/index.d.ts in 2.64 s (esm2)
12
- ready declaration files generated in 5.66 s (esm0)
7
+ ready built in 0.86s (esm2)
8
+ ready built in 0.97s (esm1)
9
+ ready built in 1.52s (esm0)
10
+ info declaration files prepared with tsgo in 1.58 s (esm2)
11
+ ready declaration files bundled successfully: dist/index.d.ts in 3.82 s (esm2)
12
+ ready declaration files generated in 7.63 s (esm0)
13
13
 
14
14
  File (esm0) Size
15
15
  dist/rslib-runtime-0.js 1.6 kB
@@ -1,7 +1,5 @@
1
1
  import { act } from 'preact/test-utils';
2
2
  import { ARIARole } from 'aria-query';
3
- import { OptionsReceived } from 'pretty-format';
4
- import * as prettyFormat from 'pretty-format';
5
3
 
6
4
  export { act }
7
5
 
@@ -284,6 +282,37 @@ export declare interface ByRoleOptions {
284
282
  */
285
283
  export declare function cleanup(): void;
286
284
 
285
+ /**
286
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
287
+ *
288
+ * This source code is licensed under the MIT license found in the
289
+ * LICENSE file in the root directory of this source tree.
290
+ */
291
+ declare type Colors = {
292
+ comment: {
293
+ close: string;
294
+ open: string;
295
+ };
296
+ content: {
297
+ close: string;
298
+ open: string;
299
+ };
300
+ prop: {
301
+ close: string;
302
+ open: string;
303
+ };
304
+ tag: {
305
+ close: string;
306
+ open: string;
307
+ };
308
+ value: {
309
+ close: string;
310
+ open: string;
311
+ };
312
+ };
313
+
314
+ declare type CompareKeys = ((a: string, b: string) => number) | undefined;
315
+
287
316
  export declare function computeHeadingLevel(element: Element): number | undefined
288
317
 
289
318
  export declare interface Config {
@@ -307,6 +336,22 @@ export declare interface Config {
307
336
  getElementError: (message: string | null, container: Element) => Error
308
337
  }
309
338
 
339
+ declare type Config_2 = {
340
+ callToJSON: boolean;
341
+ compareKeys: CompareKeys;
342
+ colors: Colors;
343
+ escapeRegex: boolean;
344
+ escapeString: boolean;
345
+ indent: string;
346
+ maxDepth: number;
347
+ min: boolean;
348
+ plugins: Plugins;
349
+ printBasicPrototype: boolean;
350
+ printFunctionName: boolean;
351
+ spacingInner: string;
352
+ spacingOuter: string;
353
+ };
354
+
310
355
  export declare interface ConfigFn {
311
356
  (existingConfig: Config): Partial<Config>
312
357
  }
@@ -329,6 +374,8 @@ export declare type CreateObject = {
329
374
  ) => Event
330
375
  }
331
376
 
377
+ declare const DEFAULT_OPTIONS: Options;
378
+
332
379
  export declare interface DefaultNormalizerOptions {
333
380
  trim?: boolean
334
381
  collapseWhitespace?: boolean
@@ -618,6 +665,13 @@ declare type FireObject_2 = {
618
665
  ) => boolean
619
666
  }
620
667
 
668
+ /**
669
+ * Returns a presentation string of your `val` object
670
+ * @param val any potential JavaScript object
671
+ * @param options Custom settings
672
+ */
673
+ declare function format(val: unknown, options?: OptionsReceived): string;
674
+
621
675
  export declare type GetAllBy<Arguments extends any[]> = QueryMethod<
622
676
  Arguments,
623
677
  HTMLElement[]
@@ -741,6 +795,8 @@ variant?: Variant,
741
795
  method?: Method,
742
796
  ): Suggestion | undefined
743
797
 
798
+ declare type Indent = (arg0: string) => string;
799
+
744
800
  /**
745
801
  * @public
746
802
  */
@@ -1021,17 +1077,64 @@ export declare type Method =
1021
1077
  | 'Title'
1022
1078
  | 'title'
1023
1079
 
1080
+ declare type NewPlugin = {
1081
+ serialize: (val: any, config: Config_2, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
1082
+ test: Test;
1083
+ };
1084
+
1024
1085
  export declare type NormalizerFn = (text: string) => string
1025
1086
 
1026
1087
  export declare interface NormalizerOptions extends DefaultNormalizerOptions {
1027
1088
  normalizer?: NormalizerFn
1028
1089
  }
1029
1090
 
1091
+ declare type OldPlugin = {
1092
+ print: (val: unknown, print: Print, indent: Indent, options: PluginOptions, colors: Colors) => string;
1093
+ test: Test;
1094
+ };
1095
+
1096
+ declare type Options = {
1097
+ callToJSON: boolean;
1098
+ compareKeys: CompareKeys;
1099
+ escapeRegex: boolean;
1100
+ escapeString: boolean;
1101
+ highlight: boolean;
1102
+ indent: number;
1103
+ maxDepth: number;
1104
+ min: boolean;
1105
+ plugins: Plugins;
1106
+ printBasicPrototype: boolean;
1107
+ printFunctionName: boolean;
1108
+ theme: Theme;
1109
+ };
1110
+
1111
+ declare type OptionsReceived = PrettyFormatOptions;
1112
+
1030
1113
  /**
1031
1114
  * @public
1032
1115
  */
1033
1116
  declare type PickUnderscoreKeys<T> = Pick<T, FilterUnderscoreKeys<T>>;
1034
1117
 
1118
+ declare type Plugin_2 = NewPlugin | OldPlugin;
1119
+
1120
+ declare type PluginOptions = {
1121
+ edgeSpacing: string;
1122
+ min: boolean;
1123
+ spacing: string;
1124
+ };
1125
+
1126
+ declare type Plugins = Array<Plugin_2>;
1127
+
1128
+ declare const plugins: {
1129
+ AsymmetricMatcher: NewPlugin;
1130
+ ConvertAnsi: NewPlugin;
1131
+ DOMCollection: NewPlugin;
1132
+ DOMElement: NewPlugin;
1133
+ Immutable: NewPlugin;
1134
+ ReactElement: NewPlugin;
1135
+ ReactTestComponent: NewPlugin;
1136
+ };
1137
+
1035
1138
  export declare function prettyDOM(
1036
1139
  dom?: Element | HTMLDocument,
1037
1140
  maxLength?: number,
@@ -1046,8 +1149,48 @@ export declare interface PrettyDOMOptions extends prettyFormat.OptionsReceived {
1046
1149
  filterNode?: (node: Node) => boolean
1047
1150
  }
1048
1151
 
1152
+ declare namespace prettyFormat {
1153
+ export {
1154
+ format,
1155
+ Colors,
1156
+ CompareKeys,
1157
+ Config_2 as Config,
1158
+ Options,
1159
+ OptionsReceived,
1160
+ OldPlugin,
1161
+ NewPlugin,
1162
+ Plugin_2 as Plugin,
1163
+ Plugins,
1164
+ PrettyFormatOptions,
1165
+ Printer,
1166
+ Refs,
1167
+ Theme,
1168
+ DEFAULT_OPTIONS,
1169
+ plugins,
1170
+ format as default
1171
+ }
1172
+ }
1049
1173
  export { prettyFormat }
1050
1174
 
1175
+ declare interface PrettyFormatOptions {
1176
+ callToJSON?: boolean;
1177
+ compareKeys?: CompareKeys;
1178
+ escapeRegex?: boolean;
1179
+ escapeString?: boolean;
1180
+ highlight?: boolean;
1181
+ indent?: number;
1182
+ maxDepth?: number;
1183
+ min?: boolean;
1184
+ plugins?: Plugins;
1185
+ printBasicPrototype?: boolean;
1186
+ printFunctionName?: boolean;
1187
+ theme?: ThemeReceived;
1188
+ }
1189
+
1190
+ declare type Print = (arg0: unknown) => string;
1191
+
1192
+ declare type Printer = (val: unknown, config: Config_2, indentation: string, depth: number, refs: Refs, hasCalledToJSON?: boolean) => string;
1193
+
1051
1194
  export declare interface Queries {
1052
1195
  [T: string]: Query
1053
1196
  }
@@ -1267,6 +1410,8 @@ export declare interface QueryOptions {
1267
1410
  [key: string]: RegExp | boolean
1268
1411
  }
1269
1412
 
1413
+ declare type Refs = Array<unknown>;
1414
+
1270
1415
  /**
1271
1416
  * Render into the page. It should be used with cleanup.
1272
1417
  *
@@ -1531,6 +1676,24 @@ export declare interface Suggestion {
1531
1676
  toString(): string
1532
1677
  }
1533
1678
 
1679
+ declare type Test = (arg0: any) => boolean;
1680
+
1681
+ declare type Theme = {
1682
+ comment: string;
1683
+ content: string;
1684
+ prop: string;
1685
+ tag: string;
1686
+ value: string;
1687
+ };
1688
+
1689
+ declare type ThemeReceived = {
1690
+ comment?: string;
1691
+ content?: string;
1692
+ prop?: string;
1693
+ tag?: string;
1694
+ value?: string;
1695
+ };
1696
+
1534
1697
  export declare type Variant =
1535
1698
  | 'find'
1536
1699
  | 'findAll'
@@ -23,6 +23,7 @@
23
23
  "@rstest/core": "catalog:rstest",
24
24
  "@testing-library/dom": "^10.4.1",
25
25
  "@testing-library/jest-dom": "^7.0.0",
26
- "preact": "catalog:lynxjs"
26
+ "preact": "catalog:lynxjs",
27
+ "pretty-format": "^30.4.1"
27
28
  }
28
29
  }
@@ -53,7 +53,7 @@ describe('lynx global API', () => {
53
53
  const reportErrorCalls = lynxTestingEnv.backgroundThread.lynx.reportError.mock.calls;
54
54
 
55
55
  expect(() => render(<view />)).toThrowErrorMatchingInlineSnapshot(
56
- `[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null'. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.]`,
56
+ `[Error: snapshotPatchApply failed: ctx not found, snapshot type: 'null', parent: { id: 10000000000, snapshot type: 'null', missing: true }, child: { id: 10000000000, snapshot type: 'null', missing: true }, operation: 'InsertBefore', commitId: 2, isHydration: true. You can set environment variable \`REACT_ALOG=true\` and restart your dev server for troubleshooting.]`,
57
57
  );
58
58
 
59
59
  const snapshotPatch = JSON.parse(callLepusMethodCalls[0][1]['data']).patchList[0].snapshotPatch;
@@ -1,6 +1,21 @@
1
1
  import { describe, expect, vi } from 'vitest';
2
2
  import { fireEvent, render, waitSchedule } from '..';
3
- import { runOnBackground, useMainThreadRef, runOnMainThread } from '@lynx-js/react';
3
+ import {
4
+ Component,
5
+ defineMainThreadObjectType,
6
+ runOnBackground,
7
+ runOnMainThread,
8
+ useMainThreadObject,
9
+ useMainThreadRef,
10
+ } from '@lynx-js/react';
11
+
12
+ const guardedClassCaptureType = defineMainThreadObjectType({
13
+ type: '@test/guarded-class-capture',
14
+ create: initialValue => ({
15
+ get: () => initialValue,
16
+ }),
17
+ });
18
+
4
19
  describe('worklet', () => {
5
20
  it('main-thread script should work', async () => {
6
21
  const cb = vi.fn();
@@ -615,4 +630,34 @@ describe('worklet', () => {
615
630
  expect(globalThis.secondCb).toBeCalledWith('second-key');
616
631
  vi.resetAllMocks();
617
632
  });
633
+
634
+ it('preserves a guarded main-thread object captured from a class field', () => {
635
+ globalThis.classCaptureCb = vi.fn();
636
+
637
+ class ClassCapture extends Component {
638
+ value = this.props.value;
639
+
640
+ onTap() {
641
+ 'main thread';
642
+ globalThis.classCaptureCb(this.value.get());
643
+ }
644
+
645
+ render() {
646
+ return <view main-thread:bindtap={this.onTap} />;
647
+ }
648
+ }
649
+
650
+ const Comp = () => {
651
+ const value = useMainThreadObject(guardedClassCaptureType, 42);
652
+ return <ClassCapture value={value} />;
653
+ };
654
+
655
+ const { container } = render(<Comp />, {
656
+ enableMainThread: true,
657
+ enableBackgroundThread: true,
658
+ });
659
+ fireEvent.tap(container.firstChild);
660
+
661
+ expect(globalThis.classCaptureCb).toHaveBeenCalledWith(42);
662
+ });
618
663
  });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "composite": false,
6
+ "rootDir": "."
7
+ },
8
+ "include": ["types"]
9
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "name": "@lynx-js/react/testing-library",
4
+ "entryPoints": [
5
+ "types/index.d.ts"
6
+ ],
7
+ "tsconfig": "tsconfig.docs.json",
8
+ "intentionallyNotExported": [
9
+ "ElementTreeGlobals",
10
+ "EventType_2",
11
+ "FireObject_2",
12
+ "Indent",
13
+ "LynxElement",
14
+ "LynxEnv",
15
+ "LynxGlobalThis",
16
+ "PluginOptions",
17
+ "Print",
18
+ "Test",
19
+ "ThemeReceived",
20
+ "initElementTree"
21
+ ]
22
+ }