@lynx-js/react 0.109.1 → 0.110.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 +39 -0
- package/package.json +2 -2
- package/refresh/.turbo/turbo-build.log +1 -1
- package/refresh/package.json +1 -1
- package/runtime/lib/backgroundSnapshot.d.ts +2 -1
- package/runtime/lib/backgroundSnapshot.js +65 -42
- package/runtime/lib/backgroundSnapshot.js.map +1 -1
- package/runtime/lib/hooks/react.js +3 -3
- package/runtime/lib/hooks/react.js.map +1 -1
- package/runtime/lib/lifecycle/destroy.js +1 -0
- package/runtime/lib/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/lifecycle/event/delayEvents.js +3 -0
- package/runtime/lib/lifecycle/event/delayEvents.js.map +1 -1
- package/runtime/lib/lifecycle/event/delayLifecycleEvents.d.ts +3 -2
- package/runtime/lib/lifecycle/event/delayLifecycleEvents.js +1 -12
- package/runtime/lib/lifecycle/event/delayLifecycleEvents.js.map +1 -1
- package/runtime/lib/lifecycle/event/jsReady.d.ts +1 -1
- package/runtime/lib/lifecycle/event/jsReady.js +3 -2
- package/runtime/lib/lifecycle/event/jsReady.js.map +1 -1
- package/runtime/lib/lifecycle/patch/commit.d.ts +0 -2
- package/runtime/lib/lifecycle/patch/commit.js +8 -36
- package/runtime/lib/lifecycle/patch/commit.js.map +1 -1
- package/runtime/lib/lifecycle/patch/error.d.ts +8 -0
- package/runtime/lib/lifecycle/patch/error.js +47 -0
- package/runtime/lib/lifecycle/patch/error.js.map +1 -0
- package/runtime/lib/lifecycle/patch/isMainThreadHydrationFinished.js +3 -0
- package/runtime/lib/lifecycle/patch/isMainThreadHydrationFinished.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatch.d.ts +2 -2
- package/runtime/lib/lifecycle/patch/snapshotPatch.js.map +1 -1
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js +18 -11
- package/runtime/lib/lifecycle/patch/snapshotPatchApply.js.map +1 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.d.ts +0 -1
- package/runtime/lib/lifecycle/patch/updateMainThread.js +6 -13
- package/runtime/lib/lifecycle/patch/updateMainThread.js.map +1 -1
- package/runtime/lib/lifecycle/ref/delay.d.ts +31 -0
- package/runtime/lib/lifecycle/ref/delay.js +80 -0
- package/runtime/lib/lifecycle/ref/delay.js.map +1 -0
- package/runtime/lib/lifecycle/reload.d.ts +1 -1
- package/runtime/lib/lifecycle/reload.js +7 -4
- package/runtime/lib/lifecycle/reload.js.map +1 -1
- package/runtime/lib/lifecycle/render.js +3 -2
- package/runtime/lib/lifecycle/render.js.map +1 -1
- package/runtime/lib/lifecycleConstant.d.ts +10 -7
- package/runtime/lib/lifecycleConstant.js +8 -8
- package/runtime/lib/lifecycleConstant.js.map +1 -1
- package/runtime/lib/list.d.ts +1 -1
- package/runtime/lib/list.js +9 -7
- package/runtime/lib/list.js.map +1 -1
- package/runtime/lib/lynx/calledByNative.js +8 -5
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/lynx/component.js +7 -0
- package/runtime/lib/lynx/component.js.map +1 -1
- package/runtime/lib/lynx/dynamic-js.d.ts +5 -1
- package/runtime/lib/lynx/dynamic-js.js +1 -0
- package/runtime/lib/lynx/dynamic-js.js.map +1 -1
- package/runtime/lib/lynx/env.d.ts +1 -1
- package/runtime/lib/lynx/env.js +13 -13
- package/runtime/lib/lynx/env.js.map +1 -1
- package/runtime/lib/lynx/lazy-bundle.js +7 -5
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -1
- package/runtime/lib/lynx/performance.js +1 -1
- package/runtime/lib/lynx/performance.js.map +1 -1
- package/runtime/lib/lynx/runWithForce.js +3 -0
- package/runtime/lib/lynx/runWithForce.js.map +1 -1
- package/runtime/lib/lynx/tt.js +12 -33
- package/runtime/lib/lynx/tt.js.map +1 -1
- package/runtime/lib/lynx-api.d.ts +1 -1
- package/runtime/lib/lynx.js +5 -6
- package/runtime/lib/lynx.js.map +1 -1
- package/runtime/lib/snapshot/ref.d.ts +14 -9
- package/runtime/lib/snapshot/ref.js +64 -73
- package/runtime/lib/snapshot/ref.js.map +1 -1
- package/runtime/lib/snapshot/spread.js +9 -8
- package/runtime/lib/snapshot/spread.js.map +1 -1
- package/runtime/lib/snapshot/workletRef.d.ts +3 -3
- package/runtime/lib/snapshot/workletRef.js +27 -8
- package/runtime/lib/snapshot/workletRef.js.map +1 -1
- package/runtime/lib/snapshot.d.ts +4 -4
- package/runtime/lib/snapshot.js +28 -13
- package/runtime/lib/snapshot.js.map +1 -1
- package/runtime/lib/snapshotInstanceHydrationMap.d.ts +9 -0
- package/runtime/lib/snapshotInstanceHydrationMap.js +16 -0
- package/runtime/lib/snapshotInstanceHydrationMap.js.map +1 -0
- package/runtime/lib/worklet/workletRef.js +1 -2
- package/runtime/lib/worklet/workletRef.js.map +1 -1
- package/runtime/src/backgroundSnapshot.ts +74 -47
- package/runtime/src/hooks/react.ts +3 -3
- package/runtime/src/lifecycle/destroy.ts +1 -0
- package/runtime/src/lifecycle/event/delayEvents.ts +3 -0
- package/runtime/src/lifecycle/event/delayLifecycleEvents.ts +7 -13
- package/runtime/src/lifecycle/event/jsReady.ts +4 -3
- package/runtime/src/lifecycle/patch/commit.ts +10 -41
- package/runtime/src/lifecycle/patch/error.ts +61 -0
- package/runtime/src/lifecycle/patch/isMainThreadHydrationFinished.ts +3 -0
- package/runtime/src/lifecycle/patch/snapshotPatch.ts +2 -2
- package/runtime/src/lifecycle/patch/snapshotPatchApply.ts +35 -28
- package/runtime/src/lifecycle/patch/updateMainThread.ts +7 -16
- package/runtime/src/lifecycle/ref/delay.ts +99 -0
- package/runtime/src/lifecycle/reload.ts +9 -6
- package/runtime/src/lifecycle/render.ts +3 -2
- package/runtime/src/lifecycleConstant.ts +11 -7
- package/runtime/src/list.ts +9 -7
- package/runtime/src/lynx/calledByNative.ts +14 -9
- package/runtime/src/lynx/component.ts +9 -0
- package/runtime/src/lynx/dynamic-js.ts +5 -1
- package/runtime/src/lynx/env.ts +17 -17
- package/runtime/src/lynx/lazy-bundle.ts +22 -14
- package/runtime/src/lynx/performance.ts +1 -1
- package/runtime/src/lynx/runWithForce.ts +9 -5
- package/runtime/src/lynx/tt.ts +19 -37
- package/runtime/src/lynx-api.ts +1 -1
- package/runtime/src/lynx.ts +6 -6
- package/runtime/src/snapshot/ref.ts +77 -87
- package/runtime/src/snapshot/spread.ts +8 -8
- package/runtime/src/snapshot/workletRef.ts +35 -9
- package/runtime/src/snapshot.ts +39 -20
- package/runtime/src/snapshotInstanceHydrationMap.ts +17 -0
- package/runtime/src/worklet/workletRef.ts +1 -2
- package/testing-library/dist/env/vitest.js +10 -8
- package/testing-library/dist/index.js +3 -3
- package/testing-library/dist/pure.js +93 -92
- package/testing-library/dist/vitest-global-setup.js +41 -41
- package/testing-library/dist/vitest.config.js +17 -14
- package/transform/dist/wasm.cjs +1 -1
- package/worklet-runtime/dist/dev.js +1 -4
- package/worklet-runtime/dist/main.js +0 -4
- package/worklet-runtime/lib/bindings/bindings.d.ts +1 -1
- package/worklet-runtime/lib/bindings/bindings.js +1 -26
- package/worklet-runtime/lib/bindings/bindings.js.map +1 -1
- package/worklet-runtime/lib/bindings/index.d.ts +2 -1
- package/worklet-runtime/lib/bindings/index.js +2 -1
- package/worklet-runtime/lib/bindings/index.js.map +1 -1
- package/worklet-runtime/lib/bindings/observers.d.ts +14 -0
- package/worklet-runtime/lib/bindings/observers.js +31 -0
- package/worklet-runtime/lib/bindings/observers.js.map +1 -0
- package/worklet-runtime/lib/hydrate.js +0 -5
- package/worklet-runtime/lib/hydrate.js.map +1 -1
- package/runtime/lib/lifecycle/delayUnmount.d.ts +0 -8
- package/runtime/lib/lifecycle/delayUnmount.js +0 -65
- package/runtime/lib/lifecycle/delayUnmount.js.map +0 -1
- package/runtime/src/lifecycle/delayUnmount.ts +0 -77
- package/worklet-runtime/dist/dev.js.map +0 -8
- package/worklet-runtime/dist/main.js.map +0 -8
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
/*! For license information please see pure.js.LICENSE.txt */
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
2
|
+
import { jsx } from "@lynx-js/react/jsx-runtime";
|
|
3
|
+
import { cloneElement, createRef, h, render } from "preact";
|
|
4
|
+
import { useEffect } from "preact/hooks";
|
|
5
|
+
import { act } from "preact/test-utils";
|
|
6
|
+
import { __root } from "@lynx-js/react/internal";
|
|
7
|
+
import { flushDelayedLifecycleEvents } from "../../runtime/lib/lynx/tt.js";
|
|
8
|
+
import { clearPage } from "../../runtime/lib/snapshot.js";
|
|
9
9
|
var __webpack_modules__ = {
|
|
10
10
|
"../../../node_modules/.pnpm/@testing-library+dom@10.4.0/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js": function(module, __webpack_exports__, __webpack_require__) {
|
|
11
11
|
__webpack_require__.d(__webpack_exports__, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
SU: ()=>findAllByTitle,
|
|
15
|
-
UK: ()=>getAllByTestId,
|
|
16
|
-
iJ: ()=>getAllByDisplayValue,
|
|
17
|
-
xx: ()=>findByPlaceholderText,
|
|
18
|
-
dB: ()=>getAllByTitle,
|
|
19
|
-
nG: ()=>getElementError,
|
|
20
|
-
F3: ()=>getRoles,
|
|
21
|
-
VF: ()=>queryAllByRoleWithSuggestions,
|
|
22
|
-
Z2: ()=>queryAllByTextWithSuggestions,
|
|
23
|
-
sp: ()=>screen,
|
|
24
|
-
Gi: ()=>buildQueries,
|
|
12
|
+
qg: ()=>getNodeText,
|
|
13
|
+
j: ()=>findAllByPlaceholderText,
|
|
25
14
|
Qc: ()=>findByAltText,
|
|
26
|
-
|
|
15
|
+
FE: ()=>getAllByText,
|
|
16
|
+
Jh: ()=>queryAllByDisplayValueWithSuggestions,
|
|
17
|
+
zZ: ()=>queryByText,
|
|
18
|
+
Rr: ()=>findAllByRole,
|
|
27
19
|
Sd: ()=>queryAllByTestIdWithSuggestions,
|
|
28
|
-
si: ()=>getByTestId,
|
|
29
|
-
DP: ()=>queryAllByPlaceholderTextWithSuggestions,
|
|
30
|
-
fl: ()=>findAllByText,
|
|
31
|
-
pP: ()=>findByTitle,
|
|
32
|
-
gF: ()=>getByDisplayValue,
|
|
33
|
-
u7: ()=>getByPlaceholderText,
|
|
34
|
-
kt: ()=>makeGetAllQuery,
|
|
35
|
-
fV: ()=>makeSingleQuery,
|
|
36
20
|
m_: ()=>build,
|
|
37
|
-
j: ()=>findAllByPlaceholderText,
|
|
38
|
-
cp: ()=>queryAllByTitleWithSuggestions,
|
|
39
|
-
MS: ()=>getByText,
|
|
40
|
-
PD: ()=>queryAllByAltTextWithSuggestions,
|
|
41
|
-
jQ: ()=>configure,
|
|
42
|
-
QU: ()=>queryAllByLabelTextWithSuggestions,
|
|
43
|
-
hq: ()=>queryByDisplayValue,
|
|
44
|
-
$S: ()=>getAllByRole,
|
|
45
21
|
Lr: ()=>getAllByAltText,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
KS: ()=>queryByPlaceholderText,
|
|
53
|
-
X_: ()=>waitForWrapper,
|
|
22
|
+
iE: ()=>getConfig,
|
|
23
|
+
Op: ()=>getAllByPlaceholderText,
|
|
24
|
+
dB: ()=>getAllByTitle,
|
|
25
|
+
DR: ()=>findByDisplayValue,
|
|
26
|
+
MY: ()=>findAllByTestId,
|
|
27
|
+
o$: ()=>queries,
|
|
54
28
|
mz: ()=>waitForElementToBeRemoved,
|
|
55
|
-
zZ: ()=>queryByText,
|
|
56
|
-
uh: ()=>getQueriesForElement,
|
|
57
29
|
Do: ()=>findAllByLabelText,
|
|
30
|
+
YA: ()=>getByRole,
|
|
31
|
+
bH: ()=>wrapAllByQueryWithSuggestion,
|
|
58
32
|
BX: ()=>fireEvent,
|
|
33
|
+
pP: ()=>findByTitle,
|
|
34
|
+
DP: ()=>queryAllByPlaceholderTextWithSuggestions,
|
|
35
|
+
SU: ()=>findAllByTitle,
|
|
36
|
+
aT: ()=>findAllByDisplayValue,
|
|
59
37
|
YS: ()=>getByLabelTextWithSuggestions,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
38
|
+
Qz: ()=>getSuggestedQuery,
|
|
39
|
+
iJ: ()=>getAllByDisplayValue,
|
|
40
|
+
X_: ()=>waitForWrapper,
|
|
41
|
+
J$: ()=>logDOM,
|
|
42
|
+
UK: ()=>getAllByTestId,
|
|
43
|
+
$S: ()=>getAllByRole,
|
|
44
|
+
gm: ()=>findByLabelText,
|
|
45
|
+
Cn: ()=>getByTitle,
|
|
46
|
+
si: ()=>getByTestId,
|
|
47
|
+
Gi: ()=>buildQueries,
|
|
48
|
+
c6: ()=>getMultipleElementsFoundError,
|
|
49
|
+
MS: ()=>getByText,
|
|
50
|
+
CZ: ()=>dom_esm_isInaccessible,
|
|
51
|
+
VF: ()=>queryAllByRoleWithSuggestions,
|
|
70
52
|
JU: ()=>queryByAttribute,
|
|
71
|
-
fn: ()=>queryByLabelText,
|
|
72
53
|
zx: ()=>queryHelpers,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
cp: ()=>queryAllByTitleWithSuggestions,
|
|
55
|
+
hq: ()=>queryByDisplayValue,
|
|
56
|
+
fn: ()=>queryByLabelText,
|
|
57
|
+
nG: ()=>getElementError,
|
|
58
|
+
sp: ()=>screen,
|
|
59
|
+
nd: ()=>findByTestId,
|
|
60
|
+
u7: ()=>getByPlaceholderText,
|
|
61
|
+
kG: ()=>wrapSingleQueryWithSuggestion,
|
|
62
|
+
uh: ()=>getQueriesForElement,
|
|
63
|
+
QU: ()=>queryAllByLabelTextWithSuggestions,
|
|
76
64
|
kd: ()=>findAllByAltText,
|
|
77
|
-
|
|
78
|
-
o$: ()=>queries,
|
|
79
|
-
Xv: ()=>queryByTestId,
|
|
80
|
-
MY: ()=>findAllByTestId,
|
|
65
|
+
fl: ()=>findAllByText,
|
|
81
66
|
T6: ()=>getAllByLabelTextWithSuggestions,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
nE: ()=>getByAltText,
|
|
68
|
+
vF: ()=>prettyDOM,
|
|
69
|
+
PD: ()=>queryAllByAltTextWithSuggestions,
|
|
70
|
+
M: ()=>findByText,
|
|
71
|
+
RG: ()=>queryByRole,
|
|
72
|
+
Xv: ()=>queryByTestId,
|
|
73
|
+
Ox: ()=>queryAllByAttribute,
|
|
74
|
+
Uv: ()=>makeFindQuery,
|
|
75
|
+
xG: ()=>getDefaultNormalizer,
|
|
76
|
+
yM: ()=>createEvent,
|
|
77
|
+
xx: ()=>findByPlaceholderText,
|
|
78
|
+
fV: ()=>makeSingleQuery,
|
|
79
|
+
jQ: ()=>configure,
|
|
80
|
+
Z2: ()=>queryAllByTextWithSuggestions,
|
|
81
|
+
hN: ()=>findByRole,
|
|
85
82
|
W2: ()=>getQueriesForElement,
|
|
86
83
|
m2: ()=>logRoles,
|
|
87
|
-
Jh: ()=>queryAllByDisplayValueWithSuggestions,
|
|
88
84
|
rf: ()=>queryByAltText,
|
|
89
|
-
|
|
85
|
+
KS: ()=>queryByPlaceholderText,
|
|
86
|
+
kt: ()=>makeGetAllQuery,
|
|
87
|
+
F3: ()=>getRoles,
|
|
88
|
+
MM: ()=>queryByTitle,
|
|
89
|
+
gF: ()=>getByDisplayValue
|
|
90
90
|
});
|
|
91
91
|
var build = __webpack_require__("../../../node_modules/.pnpm/pretty-format@27.5.1/node_modules/pretty-format/build/index.js");
|
|
92
92
|
var toStr = Object.prototype.toString;
|
|
@@ -14413,9 +14413,10 @@ function __webpack_require__(moduleId) {
|
|
|
14413
14413
|
};
|
|
14414
14414
|
})();
|
|
14415
14415
|
var dom_esm = __webpack_require__("../../../node_modules/.pnpm/@testing-library+dom@10.4.0/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js");
|
|
14416
|
-
|
|
14416
|
+
const NodesRef = lynx.createSelectorQuery().selectUniqueID(-1).constructor;
|
|
14417
14417
|
function getElement(elemOrNodesRef) {
|
|
14418
14418
|
if (elemOrNodesRef instanceof NodesRef) return __GetElementByUniqueId(Number(elemOrNodesRef._nodeSelectToken.identifier));
|
|
14419
|
+
if ('refAttr' in elemOrNodesRef) return document.querySelector(`[react-ref-${elemOrNodesRef.refAttr[0]}-${elemOrNodesRef.refAttr[1]}]`);
|
|
14419
14420
|
if (elemOrNodesRef?.constructor?.name === 'HTMLUnknownElement') return elemOrNodesRef;
|
|
14420
14421
|
throw new Error('Invalid element, got: ' + elemOrNodesRef.constructor?.name);
|
|
14421
14422
|
}
|
|
@@ -14423,7 +14424,7 @@ const fireEvent = (elemOrNodesRef, ...args)=>{
|
|
|
14423
14424
|
const isMainThread = __MAIN_THREAD__;
|
|
14424
14425
|
lynxTestingEnv.switchToBackgroundThread();
|
|
14425
14426
|
const elem = getElement(elemOrNodesRef);
|
|
14426
|
-
|
|
14427
|
+
const ans = (0, dom_esm.BX)(elem, ...args);
|
|
14427
14428
|
if (isMainThread) lynxTestingEnv.switchToMainThread();
|
|
14428
14429
|
return ans;
|
|
14429
14430
|
};
|
|
@@ -14542,7 +14543,7 @@ Object.keys(eventMap).forEach((key)=>{
|
|
|
14542
14543
|
const isMainThread = __MAIN_THREAD__;
|
|
14543
14544
|
lynxTestingEnv.switchToBackgroundThread();
|
|
14544
14545
|
const elem = getElement(elemOrNodesRef);
|
|
14545
|
-
const eventType = init?.
|
|
14546
|
+
const eventType = init?.eventType || 'bindEvent';
|
|
14546
14547
|
init = {
|
|
14547
14548
|
eventType,
|
|
14548
14549
|
eventName: key,
|
|
@@ -14566,33 +14567,33 @@ function waitSchedule() {
|
|
|
14566
14567
|
(0, dom_esm.jQ)({
|
|
14567
14568
|
asyncWrapper: async (cb)=>{
|
|
14568
14569
|
let result;
|
|
14569
|
-
await
|
|
14570
|
+
await act(()=>{
|
|
14570
14571
|
result = cb();
|
|
14571
14572
|
});
|
|
14572
14573
|
return result;
|
|
14573
14574
|
},
|
|
14574
14575
|
eventWrapper: (cb)=>{
|
|
14575
14576
|
let result;
|
|
14576
|
-
|
|
14577
|
+
act(()=>{
|
|
14577
14578
|
result = cb();
|
|
14578
14579
|
});
|
|
14579
14580
|
return result;
|
|
14580
14581
|
}
|
|
14581
14582
|
});
|
|
14582
|
-
function
|
|
14583
|
+
function pure_render(ui, { queries, wrapper: WrapperComponent, enableMainThread = false, enableBackgroundThread = true } = {}) {
|
|
14583
14584
|
if (!enableMainThread && !enableBackgroundThread) throw new Error('You must enable at least one thread for rendering (enableMainThread or enableBackgroundThread)');
|
|
14584
|
-
const wrapUiIfNeeded = (innerElement)=>WrapperComponent ?
|
|
14585
|
+
const wrapUiIfNeeded = (innerElement)=>WrapperComponent ? h(WrapperComponent, null, innerElement) : innerElement;
|
|
14585
14586
|
const comp = wrapUiIfNeeded(ui);
|
|
14586
|
-
const compMainThread =
|
|
14587
|
-
const compBackgroundThread =
|
|
14587
|
+
const compMainThread = cloneElement(comp);
|
|
14588
|
+
const compBackgroundThread = cloneElement(comp);
|
|
14588
14589
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
14589
|
-
|
|
14590
|
+
__root.__jsx = enableMainThread ? compMainThread : null;
|
|
14590
14591
|
renderPage();
|
|
14591
14592
|
if (enableBackgroundThread) {
|
|
14592
14593
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14594
|
+
act(()=>{
|
|
14595
|
+
render(compBackgroundThread, __root);
|
|
14596
|
+
flushDelayedLifecycleEvents();
|
|
14596
14597
|
});
|
|
14597
14598
|
}
|
|
14598
14599
|
return {
|
|
@@ -14600,7 +14601,7 @@ function render(ui, { queries, wrapper: WrapperComponent, enableMainThread = fal
|
|
|
14600
14601
|
unmount: cleanup,
|
|
14601
14602
|
rerender: (rerenderUi)=>{
|
|
14602
14603
|
lynxTestingEnv.reset();
|
|
14603
|
-
return
|
|
14604
|
+
return pure_render(wrapUiIfNeeded(rerenderUi), {
|
|
14604
14605
|
queries,
|
|
14605
14606
|
wrapper: WrapperComponent,
|
|
14606
14607
|
enableMainThread,
|
|
@@ -14613,31 +14614,31 @@ function render(ui, { queries, wrapper: WrapperComponent, enableMainThread = fal
|
|
|
14613
14614
|
function cleanup() {
|
|
14614
14615
|
const isMainThread = __MAIN_THREAD__;
|
|
14615
14616
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
14616
|
-
|
|
14617
|
-
|
|
14617
|
+
act(()=>{
|
|
14618
|
+
render(null, __root);
|
|
14618
14619
|
});
|
|
14619
14620
|
lynxTestingEnv.mainThread.elementTree.root = void 0;
|
|
14620
|
-
|
|
14621
|
+
clearPage();
|
|
14621
14622
|
lynxTestingEnv.jsdom.window.document.body.innerHTML = '';
|
|
14622
14623
|
if (isMainThread) globalThis.lynxTestingEnv.switchToMainThread();
|
|
14623
14624
|
}
|
|
14624
14625
|
function renderHook(renderCallback, options) {
|
|
14625
14626
|
const { initialProps, wrapper } = options || {};
|
|
14626
|
-
const result =
|
|
14627
|
+
const result = createRef();
|
|
14627
14628
|
function TestComponent({ renderCallbackProps }) {
|
|
14628
14629
|
const pendingResult = renderCallback(renderCallbackProps);
|
|
14629
|
-
|
|
14630
|
+
useEffect(()=>{
|
|
14630
14631
|
result.current = pendingResult;
|
|
14631
14632
|
});
|
|
14632
14633
|
return null;
|
|
14633
14634
|
}
|
|
14634
|
-
const { rerender: baseRerender, unmount } =
|
|
14635
|
+
const { rerender: baseRerender, unmount } = pure_render(/*#__PURE__*/ jsx(TestComponent, {
|
|
14635
14636
|
renderCallbackProps: initialProps
|
|
14636
14637
|
}), {
|
|
14637
14638
|
wrapper
|
|
14638
14639
|
});
|
|
14639
14640
|
function rerender(rerenderCallbackProps) {
|
|
14640
|
-
return baseRerender(/*#__PURE__*/
|
|
14641
|
+
return baseRerender(/*#__PURE__*/ jsx(TestComponent, {
|
|
14641
14642
|
renderCallbackProps: rerenderCallbackProps
|
|
14642
14643
|
}));
|
|
14643
14644
|
}
|
|
@@ -14724,4 +14725,4 @@ var __webpack_exports__waitForElementToBeRemoved = dom_esm.mz;
|
|
|
14724
14725
|
var __webpack_exports__within = dom_esm.uh;
|
|
14725
14726
|
var __webpack_exports__wrapAllByQueryWithSuggestion = dom_esm.bH;
|
|
14726
14727
|
var __webpack_exports__wrapSingleQueryWithSuggestion = dom_esm.kG;
|
|
14727
|
-
export { cleanup, fireEvent, render, renderHook, waitSchedule, __webpack_exports__buildQueries as buildQueries, __webpack_exports__configure as configure, __webpack_exports__createEvent as createEvent, __webpack_exports__findAllByAltText as findAllByAltText, __webpack_exports__findAllByDisplayValue as findAllByDisplayValue, __webpack_exports__findAllByLabelText as findAllByLabelText, __webpack_exports__findAllByPlaceholderText as findAllByPlaceholderText, __webpack_exports__findAllByRole as findAllByRole, __webpack_exports__findAllByTestId as findAllByTestId, __webpack_exports__findAllByText as findAllByText, __webpack_exports__findAllByTitle as findAllByTitle, __webpack_exports__findByAltText as findByAltText, __webpack_exports__findByDisplayValue as findByDisplayValue, __webpack_exports__findByLabelText as findByLabelText, __webpack_exports__findByPlaceholderText as findByPlaceholderText, __webpack_exports__findByRole as findByRole, __webpack_exports__findByTestId as findByTestId, __webpack_exports__findByText as findByText, __webpack_exports__findByTitle as findByTitle, __webpack_exports__getAllByAltText as getAllByAltText, __webpack_exports__getAllByDisplayValue as getAllByDisplayValue, __webpack_exports__getAllByLabelText as getAllByLabelText, __webpack_exports__getAllByPlaceholderText as getAllByPlaceholderText, __webpack_exports__getAllByRole as getAllByRole, __webpack_exports__getAllByTestId as getAllByTestId, __webpack_exports__getAllByText as getAllByText, __webpack_exports__getAllByTitle as getAllByTitle, __webpack_exports__getByAltText as getByAltText, __webpack_exports__getByDisplayValue as getByDisplayValue, __webpack_exports__getByLabelText as getByLabelText, __webpack_exports__getByPlaceholderText as getByPlaceholderText, __webpack_exports__getByRole as getByRole, __webpack_exports__getByTestId as getByTestId, __webpack_exports__getByText as getByText, __webpack_exports__getByTitle as getByTitle, __webpack_exports__getConfig as getConfig, __webpack_exports__getDefaultNormalizer as getDefaultNormalizer, __webpack_exports__getElementError as getElementError, __webpack_exports__getMultipleElementsFoundError as getMultipleElementsFoundError, __webpack_exports__getNodeText as getNodeText, __webpack_exports__getQueriesForElement as getQueriesForElement, __webpack_exports__getRoles as getRoles, __webpack_exports__getSuggestedQuery as getSuggestedQuery, __webpack_exports__isInaccessible as isInaccessible, __webpack_exports__logDOM as logDOM, __webpack_exports__logRoles as logRoles, __webpack_exports__makeFindQuery as makeFindQuery, __webpack_exports__makeGetAllQuery as makeGetAllQuery, __webpack_exports__makeSingleQuery as makeSingleQuery, __webpack_exports__prettyDOM as prettyDOM, __webpack_exports__prettyFormat as prettyFormat, __webpack_exports__queries as queries, __webpack_exports__queryAllByAltText as queryAllByAltText, __webpack_exports__queryAllByAttribute as queryAllByAttribute, __webpack_exports__queryAllByDisplayValue as queryAllByDisplayValue, __webpack_exports__queryAllByLabelText as queryAllByLabelText, __webpack_exports__queryAllByPlaceholderText as queryAllByPlaceholderText, __webpack_exports__queryAllByRole as queryAllByRole, __webpack_exports__queryAllByTestId as queryAllByTestId, __webpack_exports__queryAllByText as queryAllByText, __webpack_exports__queryAllByTitle as queryAllByTitle, __webpack_exports__queryByAltText as queryByAltText, __webpack_exports__queryByAttribute as queryByAttribute, __webpack_exports__queryByDisplayValue as queryByDisplayValue, __webpack_exports__queryByLabelText as queryByLabelText, __webpack_exports__queryByPlaceholderText as queryByPlaceholderText, __webpack_exports__queryByRole as queryByRole, __webpack_exports__queryByTestId as queryByTestId, __webpack_exports__queryByText as queryByText, __webpack_exports__queryByTitle as queryByTitle, __webpack_exports__queryHelpers as queryHelpers, __webpack_exports__screen as screen, __webpack_exports__waitFor as waitFor, __webpack_exports__waitForElementToBeRemoved as waitForElementToBeRemoved, __webpack_exports__within as within, __webpack_exports__wrapAllByQueryWithSuggestion as wrapAllByQueryWithSuggestion, __webpack_exports__wrapSingleQueryWithSuggestion as wrapSingleQueryWithSuggestion };
|
|
14728
|
+
export { cleanup, fireEvent, pure_render as render, renderHook, waitSchedule, __webpack_exports__buildQueries as buildQueries, __webpack_exports__configure as configure, __webpack_exports__createEvent as createEvent, __webpack_exports__findAllByAltText as findAllByAltText, __webpack_exports__findAllByDisplayValue as findAllByDisplayValue, __webpack_exports__findAllByLabelText as findAllByLabelText, __webpack_exports__findAllByPlaceholderText as findAllByPlaceholderText, __webpack_exports__findAllByRole as findAllByRole, __webpack_exports__findAllByTestId as findAllByTestId, __webpack_exports__findAllByText as findAllByText, __webpack_exports__findAllByTitle as findAllByTitle, __webpack_exports__findByAltText as findByAltText, __webpack_exports__findByDisplayValue as findByDisplayValue, __webpack_exports__findByLabelText as findByLabelText, __webpack_exports__findByPlaceholderText as findByPlaceholderText, __webpack_exports__findByRole as findByRole, __webpack_exports__findByTestId as findByTestId, __webpack_exports__findByText as findByText, __webpack_exports__findByTitle as findByTitle, __webpack_exports__getAllByAltText as getAllByAltText, __webpack_exports__getAllByDisplayValue as getAllByDisplayValue, __webpack_exports__getAllByLabelText as getAllByLabelText, __webpack_exports__getAllByPlaceholderText as getAllByPlaceholderText, __webpack_exports__getAllByRole as getAllByRole, __webpack_exports__getAllByTestId as getAllByTestId, __webpack_exports__getAllByText as getAllByText, __webpack_exports__getAllByTitle as getAllByTitle, __webpack_exports__getByAltText as getByAltText, __webpack_exports__getByDisplayValue as getByDisplayValue, __webpack_exports__getByLabelText as getByLabelText, __webpack_exports__getByPlaceholderText as getByPlaceholderText, __webpack_exports__getByRole as getByRole, __webpack_exports__getByTestId as getByTestId, __webpack_exports__getByText as getByText, __webpack_exports__getByTitle as getByTitle, __webpack_exports__getConfig as getConfig, __webpack_exports__getDefaultNormalizer as getDefaultNormalizer, __webpack_exports__getElementError as getElementError, __webpack_exports__getMultipleElementsFoundError as getMultipleElementsFoundError, __webpack_exports__getNodeText as getNodeText, __webpack_exports__getQueriesForElement as getQueriesForElement, __webpack_exports__getRoles as getRoles, __webpack_exports__getSuggestedQuery as getSuggestedQuery, __webpack_exports__isInaccessible as isInaccessible, __webpack_exports__logDOM as logDOM, __webpack_exports__logRoles as logRoles, __webpack_exports__makeFindQuery as makeFindQuery, __webpack_exports__makeGetAllQuery as makeGetAllQuery, __webpack_exports__makeSingleQuery as makeSingleQuery, __webpack_exports__prettyDOM as prettyDOM, __webpack_exports__prettyFormat as prettyFormat, __webpack_exports__queries as queries, __webpack_exports__queryAllByAltText as queryAllByAltText, __webpack_exports__queryAllByAttribute as queryAllByAttribute, __webpack_exports__queryAllByDisplayValue as queryAllByDisplayValue, __webpack_exports__queryAllByLabelText as queryAllByLabelText, __webpack_exports__queryAllByPlaceholderText as queryAllByPlaceholderText, __webpack_exports__queryAllByRole as queryAllByRole, __webpack_exports__queryAllByTestId as queryAllByTestId, __webpack_exports__queryAllByText as queryAllByText, __webpack_exports__queryAllByTitle as queryAllByTitle, __webpack_exports__queryByAltText as queryByAltText, __webpack_exports__queryByAttribute as queryByAttribute, __webpack_exports__queryByDisplayValue as queryByDisplayValue, __webpack_exports__queryByLabelText as queryByLabelText, __webpack_exports__queryByPlaceholderText as queryByPlaceholderText, __webpack_exports__queryByRole as queryByRole, __webpack_exports__queryByTestId as queryByTestId, __webpack_exports__queryByText as queryByText, __webpack_exports__queryByTitle as queryByTitle, __webpack_exports__queryHelpers as queryHelpers, __webpack_exports__screen as screen, __webpack_exports__waitFor as waitFor, __webpack_exports__waitForElementToBeRemoved as waitForElementToBeRemoved, __webpack_exports__within as within, __webpack_exports__wrapAllByQueryWithSuggestion as wrapAllByQueryWithSuggestion, __webpack_exports__wrapSingleQueryWithSuggestion as wrapSingleQueryWithSuggestion };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import { options } from "preact";
|
|
2
|
+
import { BackgroundSnapshotInstance } from "../../runtime/lib/backgroundSnapshot.js";
|
|
3
|
+
import { clearCommitTaskId, replaceCommitHook } from "../../runtime/lib/lifecycle/patch/commit.js";
|
|
4
|
+
import { deinitGlobalSnapshotPatch } from "../../runtime/lib/lifecycle/patch/snapshotPatch.js";
|
|
5
|
+
import { injectUpdateMainThread } from "../../runtime/lib/lifecycle/patch/updateMainThread.js";
|
|
6
|
+
import { injectCalledByNative } from "../../runtime/lib/lynx/calledByNative.js";
|
|
7
|
+
import { flushDelayedLifecycleEvents, injectTt } from "../../runtime/lib/lynx/tt.js";
|
|
8
|
+
import { setRoot } from "../../runtime/lib/root.js";
|
|
9
|
+
import { SnapshotInstance, backgroundSnapshotInstanceManager, snapshotInstanceManager } from "../../runtime/lib/snapshot.js";
|
|
10
|
+
import { destroyWorklet } from "../../runtime/lib/worklet/destroy.js";
|
|
11
|
+
import { initApiEnv } from "../../worklet-runtime/lib/api/lynxApi.js";
|
|
12
|
+
import { initEventListeners } from "../../worklet-runtime/lib/listeners.js";
|
|
13
|
+
import { initWorklet } from "../../worklet-runtime/lib/workletRuntime.js";
|
|
14
14
|
const { onInjectMainThreadGlobals, onInjectBackgroundThreadGlobals, onResetLynxTestingEnv, onSwitchedToMainThread, onSwitchedToBackgroundThread, onInitWorkletRuntime } = globalThis;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
injectCalledByNative();
|
|
16
|
+
injectUpdateMainThread();
|
|
17
|
+
replaceCommitHook();
|
|
18
18
|
globalThis.onInitWorkletRuntime = ()=>{
|
|
19
19
|
if (onInitWorkletRuntime) onInitWorkletRuntime();
|
|
20
20
|
if (process.env.DEBUG) console.log('initWorkletRuntime');
|
|
@@ -22,26 +22,26 @@ globalThis.onInitWorkletRuntime = ()=>{
|
|
|
22
22
|
lynx.setInterval = setInterval;
|
|
23
23
|
lynx.clearTimeout = clearTimeout;
|
|
24
24
|
lynx.clearInterval = clearInterval;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
initWorklet();
|
|
26
|
+
initApiEnv();
|
|
27
|
+
initEventListeners();
|
|
28
28
|
return true;
|
|
29
29
|
};
|
|
30
30
|
globalThis.onInjectMainThreadGlobals = (target)=>{
|
|
31
31
|
if (onInjectMainThreadGlobals) onInjectMainThreadGlobals();
|
|
32
32
|
if (process.env.DEBUG) console.log('onInjectMainThreadGlobals');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
target.__root = new
|
|
33
|
+
snapshotInstanceManager.clear();
|
|
34
|
+
snapshotInstanceManager.nextId = 0;
|
|
35
|
+
target.__root = new SnapshotInstance('root');
|
|
36
36
|
function setupDocument(document) {
|
|
37
37
|
document.createElement = function(type) {
|
|
38
|
-
return new
|
|
38
|
+
return new SnapshotInstance(type);
|
|
39
39
|
};
|
|
40
40
|
document.createElementNS = function(_ns, type) {
|
|
41
|
-
return new
|
|
41
|
+
return new SnapshotInstance(type);
|
|
42
42
|
};
|
|
43
43
|
document.createTextNode = function(text) {
|
|
44
|
-
const i = new
|
|
44
|
+
const i = new SnapshotInstance(null);
|
|
45
45
|
i.setAttribute(0, text);
|
|
46
46
|
Object.defineProperty(i, 'data', {
|
|
47
47
|
set (v) {
|
|
@@ -58,18 +58,18 @@ globalThis.onInjectMainThreadGlobals = (target)=>{
|
|
|
58
58
|
globalThis.onInjectBackgroundThreadGlobals = (target)=>{
|
|
59
59
|
if (onInjectBackgroundThreadGlobals) onInjectBackgroundThreadGlobals();
|
|
60
60
|
if (process.env.DEBUG) console.log('onInjectBackgroundThreadGlobals');
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
target.__root = new
|
|
61
|
+
backgroundSnapshotInstanceManager.clear();
|
|
62
|
+
backgroundSnapshotInstanceManager.nextId = 0;
|
|
63
|
+
target.__root = new BackgroundSnapshotInstance('root');
|
|
64
64
|
function setupBackgroundDocument(document) {
|
|
65
65
|
document.createElement = function(type) {
|
|
66
|
-
return new
|
|
66
|
+
return new BackgroundSnapshotInstance(type);
|
|
67
67
|
};
|
|
68
68
|
document.createElementNS = function(_ns, type) {
|
|
69
|
-
return new
|
|
69
|
+
return new BackgroundSnapshotInstance(type);
|
|
70
70
|
};
|
|
71
71
|
document.createTextNode = function(text) {
|
|
72
|
-
const i = new
|
|
72
|
+
const i = new BackgroundSnapshotInstance(null);
|
|
73
73
|
i.setAttribute(0, text);
|
|
74
74
|
Object.defineProperty(i, 'data', {
|
|
75
75
|
set (v) {
|
|
@@ -84,7 +84,7 @@ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
|
|
|
84
84
|
target.globalPipelineOptions = void 0;
|
|
85
85
|
const oldLynxCoreInject = globalThis.lynxCoreInject;
|
|
86
86
|
globalThis.lynxCoreInject = target.lynxCoreInject;
|
|
87
|
-
|
|
87
|
+
injectTt();
|
|
88
88
|
globalThis.lynxCoreInject = oldLynxCoreInject;
|
|
89
89
|
target.lynx.requireModuleAsync = async (url, callback)=>{
|
|
90
90
|
try {
|
|
@@ -93,29 +93,29 @@ globalThis.onInjectBackgroundThreadGlobals = (target)=>{
|
|
|
93
93
|
callback(err, null);
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
deinitGlobalSnapshotPatch();
|
|
97
|
+
clearCommitTaskId();
|
|
98
98
|
};
|
|
99
99
|
globalThis.onResetLynxTestingEnv = ()=>{
|
|
100
100
|
if (onResetLynxTestingEnv) onResetLynxTestingEnv();
|
|
101
101
|
if (process.env.DEBUG) console.log('onResetLynxTestingEnv');
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
flushDelayedLifecycleEvents();
|
|
103
|
+
destroyWorklet();
|
|
104
104
|
lynxTestingEnv.switchToMainThread();
|
|
105
|
-
|
|
105
|
+
initEventListeners();
|
|
106
106
|
lynxTestingEnv.switchToBackgroundThread();
|
|
107
107
|
};
|
|
108
108
|
globalThis.onSwitchedToMainThread = ()=>{
|
|
109
109
|
if (onSwitchedToMainThread) onSwitchedToMainThread();
|
|
110
110
|
if (process.env.DEBUG) console.log('onSwitchedToMainThread');
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
setRoot(globalThis.__root);
|
|
112
|
+
options.document = globalThis._document;
|
|
113
113
|
};
|
|
114
114
|
globalThis.onSwitchedToBackgroundThread = ()=>{
|
|
115
115
|
if (onSwitchedToBackgroundThread) onSwitchedToBackgroundThread();
|
|
116
116
|
if (process.env.DEBUG) console.log('onSwitchedToBackgroundThread');
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
setRoot(globalThis.__root);
|
|
118
|
+
options.document = globalThis._document;
|
|
119
119
|
};
|
|
120
120
|
globalThis.onInjectMainThreadGlobals(globalThis.lynxTestingEnv.mainThread.globalThis);
|
|
121
121
|
globalThis.onInjectBackgroundThreadGlobals(globalThis.lynxTestingEnv.backgroundThread.globalThis);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const vitest_config_filename =
|
|
7
|
-
const vitest_config_dirname =
|
|
8
|
-
const vitest_config_require =
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
import { VitestPackageInstaller } from "vitest/node";
|
|
3
|
+
import external_path_default from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
const vitest_config_filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const vitest_config_dirname = external_path_default.dirname(vitest_config_filename);
|
|
8
|
+
const vitest_config_require = createRequire(import.meta.url);
|
|
9
9
|
async function ensurePackagesInstalled() {
|
|
10
|
-
const installer = new
|
|
10
|
+
const installer = new VitestPackageInstaller();
|
|
11
11
|
const installed = await installer.ensureInstalled('jsdom', process.cwd());
|
|
12
12
|
if (!installed) {
|
|
13
13
|
console.log('ReactLynx Testing Library requires jsdom to be installed.');
|
|
@@ -28,8 +28,8 @@ const createVitestConfig = async (options)=>{
|
|
|
28
28
|
return '';
|
|
29
29
|
}
|
|
30
30
|
const { transformReactLynxSync } = vitest_config_require('@lynx-js/react/transform');
|
|
31
|
-
const relativePath =
|
|
32
|
-
const basename =
|
|
31
|
+
const relativePath = normalizeSlashes(external_path_default.relative(vitest_config_dirname, sourcePath));
|
|
32
|
+
const basename = external_path_default.basename(sourcePath);
|
|
33
33
|
const result = transformReactLynxSync(sourceText, {
|
|
34
34
|
mode: 'test',
|
|
35
35
|
pluginName: '',
|
|
@@ -67,11 +67,11 @@ const createVitestConfig = async (options)=>{
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return defineConfig({
|
|
71
71
|
server: {
|
|
72
72
|
fs: {
|
|
73
73
|
allow: [
|
|
74
|
-
|
|
74
|
+
external_path_default.join(vitest_config_dirname, '..')
|
|
75
75
|
]
|
|
76
76
|
}
|
|
77
77
|
},
|
|
@@ -82,9 +82,12 @@ const createVitestConfig = async (options)=>{
|
|
|
82
82
|
environment: vitest_config_require.resolve('./env/vitest'),
|
|
83
83
|
globals: true,
|
|
84
84
|
setupFiles: [
|
|
85
|
-
|
|
85
|
+
external_path_default.join(vitest_config_dirname, 'vitest-global-setup')
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
|
+
function normalizeSlashes(file) {
|
|
91
|
+
return file.replaceAll(external_path_default.win32.sep, '/');
|
|
92
|
+
}
|
|
90
93
|
export { createVitestConfig };
|