@lynx-js/react-canary 0.115.3 → 0.115.4-canary-20260106-4c60674c
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 +40 -35
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +2 -7
- package/refresh/dist/index.js +3 -3
- package/runtime/lib/lynx/calledByNative.js +8 -2
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/testing-library/dist/env/vitest.js +13 -24
- package/testing-library/dist/pure.js +3584 -3796
- package/testing-library/dist/rslib-runtime.js +58 -0
- package/worklet-runtime/dist/dev.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.115.4-canary-20260106061017-4c60674c8ef9917bcbf1e26ecb9a50c07f335ef1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: unable to access `MainThreadRef` in some scenarios ([#1996](https://github.com/lynx-family/lynx-stack/pull/1996))
|
|
8
|
+
|
|
3
9
|
## 0.115.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -11,7 +17,7 @@
|
|
|
11
17
|
```ts
|
|
12
18
|
const LazyComponent = lazy(async () => {
|
|
13
19
|
try {
|
|
14
|
-
const mod = await import(
|
|
20
|
+
const mod = await import("./lazy-bundle");
|
|
15
21
|
return mod.default;
|
|
16
22
|
} catch (error) {
|
|
17
23
|
console.error(`Lazy Bundle load failed message: ${error.message}`);
|
|
@@ -123,11 +129,11 @@
|
|
|
123
129
|
- Support testing React Compiler in testing library. Enable React Compiler by setting the `experimental_enableReactCompiler` option of `createVitestConfig` to `true`. ([#1269](https://github.com/lynx-family/lynx-stack/pull/1269))
|
|
124
130
|
|
|
125
131
|
```js
|
|
126
|
-
import { defineConfig, mergeConfig } from
|
|
127
|
-
import { createVitestConfig } from
|
|
132
|
+
import { defineConfig, mergeConfig } from "vitest/config";
|
|
133
|
+
import { createVitestConfig } from "@lynx-js/react/testing-library/vitest-config";
|
|
128
134
|
|
|
129
135
|
const defaultConfig = await createVitestConfig({
|
|
130
|
-
runtimePkgName:
|
|
136
|
+
runtimePkgName: "@lynx-js/react",
|
|
131
137
|
experimental_enableReactCompiler: true,
|
|
132
138
|
});
|
|
133
139
|
|
|
@@ -157,7 +163,7 @@
|
|
|
157
163
|
```tsx
|
|
158
164
|
function App() {
|
|
159
165
|
function handleInnerTap(event: MainThread.TouchEvent) {
|
|
160
|
-
|
|
166
|
+
"main thread";
|
|
161
167
|
event.stopPropagation();
|
|
162
168
|
// Or stop immediate propagation with
|
|
163
169
|
// event.stopImmediatePropagation();
|
|
@@ -255,10 +261,10 @@
|
|
|
255
261
|
- Add `animate` API in Main Thread Script(MTS), so you can now control a CSS animation imperatively ([#1534](https://github.com/lynx-family/lynx-stack/pull/1534))
|
|
256
262
|
|
|
257
263
|
```ts
|
|
258
|
-
import type { MainThread } from
|
|
264
|
+
import type { MainThread } from "@lynx-js/types";
|
|
259
265
|
|
|
260
266
|
function startAnimation(ele: MainThread.Element) {
|
|
261
|
-
|
|
267
|
+
"main thread";
|
|
262
268
|
const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
263
269
|
duration: 3000,
|
|
264
270
|
});
|
|
@@ -287,7 +293,7 @@
|
|
|
287
293
|
- Supports `recyclable` attribute in `<list-item>` to control whether the list item is recyclable. The `recyclable` attribute depends on Lynx Engine 3.4 or later. ([#1388](https://github.com/lynx-family/lynx-stack/pull/1388))
|
|
288
294
|
|
|
289
295
|
```jsx
|
|
290
|
-
<list-item recyclable={false}
|
|
296
|
+
<list-item recyclable={false} />
|
|
291
297
|
```
|
|
292
298
|
|
|
293
299
|
- feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
|
|
@@ -308,7 +314,7 @@
|
|
|
308
314
|
|
|
309
315
|
```ts
|
|
310
316
|
function handleTap() {
|
|
311
|
-
|
|
317
|
+
"main thread";
|
|
312
318
|
// The following check always returned false before this fix
|
|
313
319
|
if (myHandleTap) {
|
|
314
320
|
runOnBackground(myHandleTap)();
|
|
@@ -369,10 +375,10 @@
|
|
|
369
375
|
Add the import to `@lynx-js/react/debug` at the first line of the entry:
|
|
370
376
|
|
|
371
377
|
```js
|
|
372
|
-
import
|
|
373
|
-
import { root } from
|
|
378
|
+
import "@lynx-js/react/debug";
|
|
379
|
+
import { root } from "@lynx-js/react";
|
|
374
380
|
|
|
375
|
-
import { App } from
|
|
381
|
+
import { App } from "./App.jsx";
|
|
376
382
|
|
|
377
383
|
root.render(<App />);
|
|
378
384
|
```
|
|
@@ -382,9 +388,9 @@
|
|
|
382
388
|
For example, you can use it like this:
|
|
383
389
|
|
|
384
390
|
```jsx
|
|
385
|
-
<list-item defer={{ unmountRecycled: true }} item-key=
|
|
391
|
+
<list-item defer={{ unmountRecycled: true }} item-key="1">
|
|
386
392
|
<WillBeUnmountIfRecycled />
|
|
387
|
-
</list-item
|
|
393
|
+
</list-item>
|
|
388
394
|
```
|
|
389
395
|
|
|
390
396
|
Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
|
|
@@ -392,7 +398,7 @@
|
|
|
392
398
|
- Avoid some unexpected `__SetAttribute` in hydrate when `undefined` is passed as an attribute value to intrinsic elements, for example: ([#1318](https://github.com/lynx-family/lynx-stack/pull/1318))
|
|
393
399
|
|
|
394
400
|
```jsx
|
|
395
|
-
<image async-mode={undefined}
|
|
401
|
+
<image async-mode={undefined} />
|
|
396
402
|
```
|
|
397
403
|
|
|
398
404
|
## 0.111.1
|
|
@@ -438,7 +444,7 @@
|
|
|
438
444
|
- Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
|
|
439
445
|
|
|
440
446
|
```js
|
|
441
|
-
import { act } from
|
|
447
|
+
import { act } from "@lynx-js/react/testing-library";
|
|
442
448
|
|
|
443
449
|
act(() => {
|
|
444
450
|
// ...
|
|
@@ -544,8 +550,7 @@
|
|
|
544
550
|
* 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
|
|
545
551
|
*/
|
|
546
552
|
experimental-batch-render-strategy={3}
|
|
547
|
-
>
|
|
548
|
-
</list>;
|
|
553
|
+
></list>
|
|
549
554
|
```
|
|
550
555
|
|
|
551
556
|
- rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
|
|
@@ -663,7 +668,7 @@
|
|
|
663
668
|
You can now use `useErrorBoundary` it in TypeScript like this:
|
|
664
669
|
|
|
665
670
|
```tsx
|
|
666
|
-
import { useErrorBoundary } from
|
|
671
|
+
import { useErrorBoundary } from "@lynx-js/react";
|
|
667
672
|
```
|
|
668
673
|
|
|
669
674
|
- Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
|
|
@@ -715,13 +720,13 @@
|
|
|
715
720
|
Now you can get the return value from `runOnBackground()` and `runOnMainThread()`, which enables more flexible data flow between the main thread and the background thread.
|
|
716
721
|
|
|
717
722
|
```js
|
|
718
|
-
import { runOnBackground } from
|
|
723
|
+
import { runOnBackground } from "@lynx-js/react";
|
|
719
724
|
|
|
720
725
|
const onTap = async () => {
|
|
721
|
-
|
|
726
|
+
"main thread";
|
|
722
727
|
const text = await runOnBackground(() => {
|
|
723
|
-
|
|
724
|
-
return
|
|
728
|
+
"background only";
|
|
729
|
+
return "Hello, world!";
|
|
725
730
|
})();
|
|
726
731
|
console.log(text);
|
|
727
732
|
};
|
|
@@ -756,9 +761,9 @@
|
|
|
756
761
|
|
|
757
762
|
```ts
|
|
758
763
|
// These imports will be removed from the final bundle
|
|
759
|
-
import type { Foo } from
|
|
760
|
-
import { type Bar } from
|
|
761
|
-
import { xyz } from
|
|
764
|
+
import type { Foo } from "xyz";
|
|
765
|
+
import { type Bar } from "xyz";
|
|
766
|
+
import { xyz } from "xyz"; // When xyz is not used
|
|
762
767
|
```
|
|
763
768
|
|
|
764
769
|
See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
|
|
@@ -798,7 +803,7 @@
|
|
|
798
803
|
const f = undefined;
|
|
799
804
|
|
|
800
805
|
function mts() {
|
|
801
|
-
|
|
806
|
+
"main thread";
|
|
802
807
|
// throws in background rendering
|
|
803
808
|
f && runOnBackground(f)();
|
|
804
809
|
}
|
|
@@ -832,14 +837,14 @@
|
|
|
832
837
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
833
838
|
|
|
834
839
|
```js
|
|
835
|
-
import { pluginReactLynx } from
|
|
836
|
-
import { defineConfig } from
|
|
840
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
841
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
837
842
|
|
|
838
843
|
export default defineConfig({
|
|
839
844
|
plugins: [
|
|
840
845
|
pluginReactLynx({
|
|
841
846
|
compat: {
|
|
842
|
-
removeComponentAttrRegex:
|
|
847
|
+
removeComponentAttrRegex: "YOUR REGEX",
|
|
843
848
|
},
|
|
844
849
|
}),
|
|
845
850
|
],
|
|
@@ -925,22 +930,22 @@
|
|
|
925
930
|
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.
|
|
926
931
|
|
|
927
932
|
```tsx
|
|
928
|
-
import { useGesture, PanGesture } from
|
|
933
|
+
import { useGesture, PanGesture } from "@lynx-js/gesture-runtime";
|
|
929
934
|
|
|
930
935
|
function App() {
|
|
931
936
|
const pan = useGesture(PanGesture);
|
|
932
937
|
|
|
933
938
|
pan
|
|
934
939
|
.onBegin((event, stateManager) => {
|
|
935
|
-
|
|
940
|
+
"main thread";
|
|
936
941
|
// some logic
|
|
937
942
|
})
|
|
938
943
|
.onUpdate((event, stateManager) => {
|
|
939
|
-
|
|
944
|
+
"main thread";
|
|
940
945
|
// some logic
|
|
941
946
|
})
|
|
942
947
|
.onEnd((event, stateManager) => {
|
|
943
|
-
|
|
948
|
+
"main thread";
|
|
944
949
|
// some logic
|
|
945
950
|
});
|
|
946
951
|
|
|
@@ -960,7 +965,7 @@
|
|
|
960
965
|
return;
|
|
961
966
|
}
|
|
962
967
|
|
|
963
|
-
console.log(
|
|
968
|
+
console.log("not __LEPUS__"); // This can be removed now
|
|
964
969
|
}
|
|
965
970
|
```
|
|
966
971
|
|
package/package.json
CHANGED
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
> @lynx-js/react-refresh@0.1.0 build /home/runner/work/lynx-stack/lynx-stack/packages/react/refresh
|
|
3
3
|
> rslib build
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Rslib v0.19.1
|
|
6
6
|
|
|
7
|
-
[Rspack Deprecation] `experiments.lazyBarrel` config is deprecated and will be removed in Rspack v2.0. Lazy barrel is already stable and enabled by default. Remove this option from your Rspack configuration.
|
|
8
|
-
[Rspack Deprecation] `experiments.inlineConst` config is deprecated and will be removed in Rspack v2.0. Inline Const is already stable and enabled by default. Remove this option from your Rspack configuration.
|
|
9
|
-
[Rspack Deprecation] `experiments.inlineEnum` config is deprecated and will be removed in Rspack v2.0. Inline Enum is already stable. Remove this option from your Rspack configuration.
|
|
10
|
-
[Rspack Deprecation] `experiments.typeReexportsPresence` config is deprecated and will be removed in Rspack v2.0. typeReexportsPresence is already stable. Remove this option from your Rspack configuration.
|
|
11
7
|
info build started...
|
|
12
|
-
|
|
13
|
-
ready built in [1m0.12[22m s
|
|
8
|
+
ready built in [1m0.18[22m s
|
|
14
9
|
|
|
15
10
|
[34mFile (esm) Size [39m
|
|
16
11
|
[2mdist/[22m[36mindex.js[39m 10.1 kB
|
package/refresh/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, options } from "@lynx-js/react/internal";
|
|
2
|
-
const NAMESPACE = '__PREFRESH__';
|
|
3
2
|
const COMPONENT_DIRTY_BIT = 8;
|
|
4
3
|
const isDirty = (vnode)=>{
|
|
5
4
|
if (vnode["__c"] && vnode["__c"]["__d"]) return true;
|
|
@@ -89,6 +88,7 @@ options.unmount = (vnode)=>{
|
|
|
89
88
|
}
|
|
90
89
|
if (oldUnmount) oldUnmount(vnode);
|
|
91
90
|
};
|
|
91
|
+
const NAMESPACE = '__PREFRESH__';
|
|
92
92
|
const signaturesForType = new WeakMap();
|
|
93
93
|
const computeKey = (signature)=>{
|
|
94
94
|
let fullKey = signature.key;
|
|
@@ -222,8 +222,8 @@ globalThis[NAMESPACE] = {
|
|
|
222
222
|
flush: ()=>{
|
|
223
223
|
pendingUpdates = [];
|
|
224
224
|
},
|
|
225
|
-
replaceComponent,
|
|
226
|
-
sign,
|
|
225
|
+
replaceComponent: replaceComponent,
|
|
226
|
+
sign: sign,
|
|
227
227
|
computeKey: computeKey
|
|
228
228
|
};
|
|
229
229
|
const compareSignatures = (prev, next)=>{
|
|
@@ -9,10 +9,10 @@ import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
|
9
9
|
import { ssrHydrateByOpcodes } from '../opcodes.js';
|
|
10
10
|
import { __pendingListUpdates } from '../pendingListUpdates.js';
|
|
11
11
|
import { __root, setRoot } from '../root.js';
|
|
12
|
+
import { markTiming, setPipeline } from './performance.js';
|
|
12
13
|
import { applyRefQueue } from '../snapshot/workletRef.js';
|
|
13
14
|
import { SnapshotInstance, __page, setupPage } from '../snapshot.js';
|
|
14
15
|
import { isEmptyObject } from '../utils.js';
|
|
15
|
-
import { markTiming, setPipeline } from './performance.js';
|
|
16
16
|
function ssrEncode() {
|
|
17
17
|
const { __opcodes } = __root;
|
|
18
18
|
delete __root.__opcodes;
|
|
@@ -26,7 +26,13 @@ function ssrEncode() {
|
|
|
26
26
|
];
|
|
27
27
|
};
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
const replacer = (_key, value) => {
|
|
30
|
+
if (value && typeof value === 'object' && '_wkltId' in value) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
return JSON.stringify({ __opcodes, __root_values: __root.__values }, replacer);
|
|
30
36
|
}
|
|
31
37
|
finally {
|
|
32
38
|
SnapshotInstance.prototype.toJSON = oldToJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calledByNative.js","sourceRoot":"","sources":["../../src/lynx/calledByNative.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"calledByNative.js","sourceRoot":"","sources":["../../src/lynx/calledByNative.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,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AM,OAAO,GAAG,MAAM,CAAC;QACvB,OAAO,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE7B,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACtC,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAClC,CAAC;YACC,oBAAoB,CAAC,kBAAkB,EAAE,CAAC;YAC1C,gBAAgB,EAAE,CAAC;YACnB,yFAAyF;YACzF,+DAA+D;YAC/D,OAAO,CACL,OAA2B,EAC3B,MAA0B,EAC1B,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAC9C,CAAC;YAEF,+CAA+C;YAC/C,oBAAoB,CAAC,KAAK,EAAE,CAAC;YAC7B,aAAa,EAAE,CAAC;QAClB,CAAC;QACD,YAAY,CAAC,kBAAkB,GAAG,IAAI,CAAC;QACvC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IAED,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAU,EAAE,OAA0B;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,kBAAkB,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -111,8 +111,7 @@ const initElementTree = ()=>{
|
|
|
111
111
|
e.setAttribute(key, JSON.stringify(value));
|
|
112
112
|
}
|
|
113
113
|
__AddEvent(e, eventType, eventName, eventHandler) {
|
|
114
|
-
|
|
115
|
-
if (null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`]) {
|
|
114
|
+
if (e.eventMap?.[`${eventType}:${eventName}`]) {
|
|
116
115
|
e.removeEventListener(`${eventType}:${eventName}`, e.eventMap[`${eventType}:${eventName}`]);
|
|
117
116
|
delete e.eventMap[`${eventType}:${eventName}`];
|
|
118
117
|
}
|
|
@@ -138,8 +137,7 @@ const initElementTree = ()=>{
|
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
__GetEvent(e, eventType, eventName) {
|
|
141
|
-
|
|
142
|
-
const jsFunction = null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`];
|
|
140
|
+
const jsFunction = e.eventMap?.[`${eventType}:${eventName}`];
|
|
143
141
|
if (void 0 !== jsFunction) return {
|
|
144
142
|
type: eventType,
|
|
145
143
|
name: eventName,
|
|
@@ -325,12 +323,11 @@ function __injectElementApi(target) {
|
|
|
325
323
|
function createPolyfills() {
|
|
326
324
|
const app = {
|
|
327
325
|
callLepusMethod: (...rLynxChange)=>{
|
|
328
|
-
var _rLynxChange_;
|
|
329
326
|
const isBackground = !__MAIN_THREAD__;
|
|
330
327
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
331
328
|
globalThis[rLynxChange[0]](rLynxChange[1]);
|
|
332
329
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
333
|
-
|
|
330
|
+
rLynxChange[2]?.();
|
|
334
331
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
335
332
|
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
336
333
|
},
|
|
@@ -389,10 +386,8 @@ function createPolyfills() {
|
|
|
389
386
|
const isBackground = !__MAIN_THREAD__;
|
|
390
387
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
391
388
|
let ans;
|
|
392
|
-
if ('worklet-runtime' === chunkName)
|
|
393
|
-
|
|
394
|
-
ans = null == (_globalThis_onInitWorkletRuntime = (_globalThis = globalThis).onInitWorkletRuntime) ? void 0 : _globalThis_onInitWorkletRuntime.call(_globalThis);
|
|
395
|
-
} else throw new Error(`__LoadLepusChunk: Unknown chunk name: ${chunkName}`);
|
|
389
|
+
if ('worklet-runtime' === chunkName) ans = globalThis.onInitWorkletRuntime?.();
|
|
390
|
+
else throw new Error(`__LoadLepusChunk: Unknown chunk name: ${chunkName}`);
|
|
396
391
|
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
397
392
|
return ans;
|
|
398
393
|
}
|
|
@@ -412,7 +407,6 @@ function createPreconfiguredConsole() {
|
|
|
412
407
|
return console1;
|
|
413
408
|
}
|
|
414
409
|
function injectMainThreadGlobals(target, polyfills) {
|
|
415
|
-
var _globalThis_onInjectMainThreadGlobals, _globalThis;
|
|
416
410
|
__injectElementApi(target);
|
|
417
411
|
const { performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
|
|
418
412
|
if (void 0 === target) target = globalThis;
|
|
@@ -440,7 +434,7 @@ function injectMainThreadGlobals(target, polyfills) {
|
|
|
440
434
|
target.cancelAnimationFrame = clearTimeout;
|
|
441
435
|
target.console = createPreconfiguredConsole();
|
|
442
436
|
target.__LoadLepusChunk = __LoadLepusChunk;
|
|
443
|
-
|
|
437
|
+
globalThis.onInjectMainThreadGlobals?.(target);
|
|
444
438
|
}
|
|
445
439
|
const IGNORE_LIST_GLOBALS = [
|
|
446
440
|
'globalThis',
|
|
@@ -473,7 +467,6 @@ class NodesRef {
|
|
|
473
467
|
}
|
|
474
468
|
}
|
|
475
469
|
function injectBackgroundThreadGlobals(target, polyfills) {
|
|
476
|
-
var _globalThis_onInjectBackgroundThreadGlobals, _globalThis;
|
|
477
470
|
const { app, performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
|
|
478
471
|
if (void 0 === target) target = globalThis;
|
|
479
472
|
target.__DEV__ = true;
|
|
@@ -536,7 +529,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
|
|
|
536
529
|
lynxSdkVersion: '3.0'
|
|
537
530
|
};
|
|
538
531
|
target.__LoadLepusChunk = __LoadLepusChunk;
|
|
539
|
-
|
|
532
|
+
globalThis.onInjectBackgroundThreadGlobals?.(target);
|
|
540
533
|
}
|
|
541
534
|
class LynxTestingEnv {
|
|
542
535
|
injectGlobals() {
|
|
@@ -545,38 +538,34 @@ class LynxTestingEnv {
|
|
|
545
538
|
injectMainThreadGlobals(this.mainThread.globalThis, polyfills);
|
|
546
539
|
}
|
|
547
540
|
switchToBackgroundThread() {
|
|
548
|
-
var _globalThis_onSwitchedToBackgroundThread, _globalThis;
|
|
549
541
|
this.originals = new Map();
|
|
550
542
|
Object.getOwnPropertyNames(this.backgroundThread.globalThis).forEach((key)=>{
|
|
551
543
|
if (IGNORE_LIST_GLOBALS.includes(key)) return;
|
|
552
544
|
this.originals.set(key, global[key]);
|
|
553
545
|
global[key] = this.backgroundThread.globalThis[key];
|
|
554
546
|
});
|
|
555
|
-
|
|
547
|
+
globalThis?.onSwitchedToBackgroundThread?.();
|
|
556
548
|
}
|
|
557
549
|
switchToMainThread() {
|
|
558
|
-
var _globalThis_onSwitchedToMainThread, _globalThis;
|
|
559
550
|
this.originals = new Map();
|
|
560
551
|
Object.getOwnPropertyNames(this.mainThread.globalThis).forEach((key)=>{
|
|
561
552
|
if (IGNORE_LIST_GLOBALS.includes(key)) return;
|
|
562
553
|
this.originals.set(key, global[key]);
|
|
563
554
|
global[key] = this.mainThread.globalThis[key];
|
|
564
555
|
});
|
|
565
|
-
|
|
556
|
+
globalThis?.onSwitchedToMainThread?.();
|
|
566
557
|
}
|
|
567
558
|
clearGlobal() {
|
|
568
|
-
|
|
569
|
-
null == (_this_originals = this.originals) || _this_originals.forEach((v, k)=>{
|
|
559
|
+
this.originals?.forEach((v, k)=>{
|
|
570
560
|
global[k] = v;
|
|
571
561
|
});
|
|
572
|
-
|
|
562
|
+
this.originals?.clear();
|
|
573
563
|
}
|
|
574
564
|
reset() {
|
|
575
|
-
var _globalThis_onResetLynxTestingEnv, _globalThis;
|
|
576
565
|
this.injectGlobals();
|
|
577
566
|
this.switchToMainThread();
|
|
578
567
|
this.switchToBackgroundThread();
|
|
579
|
-
|
|
568
|
+
globalThis.onResetLynxTestingEnv?.();
|
|
580
569
|
}
|
|
581
570
|
constructor(jsdom){
|
|
582
571
|
dist_define_property(this, "originals", new Map());
|
|
@@ -619,4 +608,4 @@ const env = {
|
|
|
619
608
|
};
|
|
620
609
|
const vitest = env;
|
|
621
610
|
const env_vitest = vitest;
|
|
622
|
-
export
|
|
611
|
+
export default env_vitest;
|