@lynx-js/react 0.106.1 → 0.106.2
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 +8 -0
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/lazy/internal.js +1 -1
- package/runtime/lib/lifecycle/event/jsReady.d.ts +6 -0
- package/runtime/lib/lifecycle/event/jsReady.js +29 -0
- package/runtime/lib/lifecycle/event/jsReady.js.map +1 -0
- package/runtime/lib/lifecycle/reload.d.ts +1 -1
- package/runtime/lib/lifecycle/reload.js +18 -14
- package/runtime/lib/lifecycle/reload.js.map +1 -1
- package/runtime/lib/lynx/calledByNative.js +11 -30
- package/runtime/lib/lynx/calledByNative.js.map +1 -1
- package/runtime/lib/lynx/lazy-bundle.d.ts +2 -2
- package/runtime/lib/lynx/lazy-bundle.js +49 -46
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -1
- package/runtime/src/lifecycle/event/jsReady.ts +33 -0
- package/runtime/src/lifecycle/reload.ts +20 -15
- package/runtime/src/lynx/calledByNative.ts +13 -33
- package/runtime/src/lynx/lazy-bundle.ts +52 -46
- package/transform/dist/wasm.cjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.106.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: prevent multiple firstScreen events when reloading before `jsReady` ([#377](https://github.com/lynx-family/lynx-stack/pull/377))
|
|
8
|
+
|
|
9
|
+
- Optimize the bundle size by eliminating unnecessary code when the lazy bundle is not utilized. ([#284](https://github.com/lynx-family/lynx-stack/pull/284))
|
|
10
|
+
|
|
3
11
|
## 0.106.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
package/runtime/lazy/internal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
import { sExportsReactInternal, target } from './target';
|
|
5
|
+
import { sExportsReactInternal, target } from './target.js';
|
|
6
6
|
|
|
7
7
|
export const {
|
|
8
8
|
Component,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LifecycleConstant } from '../../lifecycleConstant.js';
|
|
2
|
+
import { __root } from '../../root.js';
|
|
3
|
+
import { takeGlobalRefPatchMap } from '../../snapshot/ref.js';
|
|
4
|
+
let isJSReady;
|
|
5
|
+
let jsReadyEventIdSwap;
|
|
6
|
+
function jsReady() {
|
|
7
|
+
isJSReady = true;
|
|
8
|
+
__OnLifecycleEvent([
|
|
9
|
+
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
10
|
+
{
|
|
11
|
+
root: JSON.stringify(__root),
|
|
12
|
+
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
13
|
+
jsReadyEventIdSwap,
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
jsReadyEventIdSwap = {};
|
|
17
|
+
}
|
|
18
|
+
function clearJSReadyEventIdSwap() {
|
|
19
|
+
jsReadyEventIdSwap = {};
|
|
20
|
+
}
|
|
21
|
+
function resetJSReady() {
|
|
22
|
+
isJSReady = false;
|
|
23
|
+
jsReadyEventIdSwap = {};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export { jsReady, isJSReady, jsReadyEventIdSwap, clearJSReadyEventIdSwap, resetJSReady };
|
|
29
|
+
//# sourceMappingURL=jsReady.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsReady.js","sourceRoot":"","sources":["../../../src/lifecycle/event/jsReady.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,IAAI,SAAkB,CAAC;AACvB,IAAI,kBAA0C,CAAC;AAE/C,SAAS,OAAO;IACd,SAAS,GAAG,IAAI,CAAC;IACjB,kBAAkB,CAAC;QACjB,iBAAiB,CAAC,WAAW,EAAE,kBAAkB;QACjD;YACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC;YACjD,kBAAkB;SACnB;KACF,CAAC,CAAC;IACH,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,uBAAuB;IAC9B,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY;IACnB,SAAS,GAAG,KAAK,CAAC;IAClB,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { hydrate } from '../hydrate.js';
|
|
5
|
+
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
6
|
+
import { __pendingListUpdates } from '../list.js';
|
|
4
7
|
import { __root, setRoot } from '../root.js';
|
|
8
|
+
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
5
9
|
import { SnapshotInstance, __page, snapshotInstanceManager } from '../snapshot.js';
|
|
6
10
|
import { isEmptyObject } from '../utils.js';
|
|
7
11
|
import { destroyBackground } from './destroy.js';
|
|
12
|
+
import { destroyWorklet } from '../worklet/destroy.js';
|
|
13
|
+
import { clearJSReadyEventIdSwap, isJSReady } from './event/jsReady.js';
|
|
8
14
|
import { increaseReloadVersion } from './pass.js';
|
|
9
|
-
import { renderBackground, renderMainThread } from './render.js';
|
|
10
|
-
import { hydrate } from '../hydrate.js';
|
|
11
|
-
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
12
|
-
import { __pendingListUpdates } from '../list.js';
|
|
13
|
-
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
14
15
|
import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
|
|
15
|
-
import {
|
|
16
|
+
import { renderBackground, renderMainThread } from './render.js';
|
|
16
17
|
function reloadMainThread(data, options) {
|
|
17
18
|
if (__PROFILE__) {
|
|
18
19
|
console.profile('reloadTemplate');
|
|
@@ -24,6 +25,7 @@ function reloadMainThread(data, options) {
|
|
|
24
25
|
destroyWorklet();
|
|
25
26
|
snapshotInstanceManager.clear();
|
|
26
27
|
__pendingListUpdates.clear();
|
|
28
|
+
clearJSReadyEventIdSwap();
|
|
27
29
|
const oldRoot = __root;
|
|
28
30
|
setRoot(new SnapshotInstance('root'));
|
|
29
31
|
__root.__jsx = oldRoot.__jsx;
|
|
@@ -33,14 +35,16 @@ function reloadMainThread(data, options) {
|
|
|
33
35
|
});
|
|
34
36
|
// always call this before `__FlushElementTree`
|
|
35
37
|
__pendingListUpdates.flush();
|
|
38
|
+
if (isJSReady) {
|
|
39
|
+
__OnLifecycleEvent([
|
|
40
|
+
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
41
|
+
{
|
|
42
|
+
root: JSON.stringify(__root),
|
|
43
|
+
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
36
47
|
__FlushElementTree(__page, options);
|
|
37
|
-
__OnLifecycleEvent([
|
|
38
|
-
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
39
|
-
{
|
|
40
|
-
root: JSON.stringify(__root),
|
|
41
|
-
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
42
|
-
},
|
|
43
|
-
]);
|
|
44
48
|
if (__PROFILE__) {
|
|
45
49
|
console.profileEnd();
|
|
46
50
|
}
|
|
@@ -60,5 +64,5 @@ function reloadBackground(updateData) {
|
|
|
60
64
|
console.profileEnd();
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
export {
|
|
67
|
+
export { reloadBackground, reloadMainThread };
|
|
64
68
|
//# sourceMappingURL=reload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/lifecycle/reload.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reload.js","sourceRoot":"","sources":["../../src/lifecycle/reload.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,yBAAyB,E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,EAAE,CAAC;IACvB,CAAC;IACD,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,CAAC,UAA+B;IACvD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,yBAAyB,EAAE,CAAC;IAE5B,iBAAiB,EAAE,CAAC;IAEpB,qBAAqB,EAAE,CAAC;IAExB,2EAA2E;IAC3E,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEjE,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAa,CAAC,CAAC;IAE9C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { render as renderToString } from '../renderToOpcodes/index.js';
|
|
7
|
-
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
8
|
-
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
9
|
-
import { isEmptyObject } from '../utils.js';
|
|
10
|
-
import { __root, setRoot } from '../root.js';
|
|
4
|
+
import { hydrate } from '../hydrate.js';
|
|
5
|
+
import { isJSReady, jsReady, jsReadyEventIdSwap, resetJSReady } from '../lifecycle/event/jsReady.js';
|
|
11
6
|
import { reloadMainThread } from '../lifecycle/reload.js';
|
|
12
7
|
import { renderMainThread } from '../lifecycle/render.js';
|
|
13
|
-
import {
|
|
14
|
-
import { markTiming, PerformanceTimingKeys, setPipeline } from './performance.js';
|
|
8
|
+
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
15
9
|
import { __pendingListUpdates } from '../list.js';
|
|
16
10
|
import { ssrHydrateByOpcodes } from '../opcodes.js';
|
|
11
|
+
import { __root, setRoot } from '../root.js';
|
|
12
|
+
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
13
|
+
import { SnapshotInstance, __page, setupPage } from '../snapshot.js';
|
|
14
|
+
import { isEmptyObject } from '../utils.js';
|
|
15
|
+
import { PerformanceTimingKeys, markTiming, setPipeline } from './performance.js';
|
|
17
16
|
function ssrEncode() {
|
|
18
17
|
const { __opcodes } = __root;
|
|
19
18
|
delete __root.__opcodes;
|
|
@@ -45,10 +44,8 @@ function ssrHydrate(info) {
|
|
|
45
44
|
__root.__element_root = nativePage;
|
|
46
45
|
}
|
|
47
46
|
function injectCalledByNative() {
|
|
48
|
-
if (process.env['NODE_ENV'] !== 'test') {
|
|
49
|
-
|
|
50
|
-
throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');
|
|
51
|
-
}
|
|
47
|
+
if (process.env['NODE_ENV'] !== 'test' && __FIRST_SCREEN_SYNC_TIMING__ !== 'jsReady' && __ENABLE_SSR__) {
|
|
48
|
+
throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');
|
|
52
49
|
}
|
|
53
50
|
const calledByNative = {
|
|
54
51
|
renderPage,
|
|
@@ -67,8 +64,7 @@ function injectCalledByNative() {
|
|
|
67
64
|
}
|
|
68
65
|
function renderPage(data) {
|
|
69
66
|
// reset `jsReady` state
|
|
70
|
-
|
|
71
|
-
jsReadyEventIdSwap = {};
|
|
67
|
+
resetJSReady();
|
|
72
68
|
lynx.__initData = data || {};
|
|
73
69
|
setupPage(__CreatePage('0', 0));
|
|
74
70
|
__root.ensureElements();
|
|
@@ -86,7 +82,6 @@ function updatePage(data, options) {
|
|
|
86
82
|
return;
|
|
87
83
|
}
|
|
88
84
|
if (options?.resetPageData) {
|
|
89
|
-
// @ts-ignore
|
|
90
85
|
lynx.__initData = {};
|
|
91
86
|
}
|
|
92
87
|
if (typeof data == 'object' && !isEmptyObject(data)) {
|
|
@@ -127,20 +122,6 @@ function updateGlobalProps(_data, options) {
|
|
|
127
122
|
__FlushElementTree();
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
|
-
let isJSReady;
|
|
131
|
-
let jsReadyEventIdSwap;
|
|
132
|
-
function jsReady() {
|
|
133
|
-
__OnLifecycleEvent([
|
|
134
|
-
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
135
|
-
{
|
|
136
|
-
root: JSON.stringify(__root),
|
|
137
|
-
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
138
|
-
jsReadyEventIdSwap,
|
|
139
|
-
},
|
|
140
|
-
]);
|
|
141
|
-
isJSReady = true;
|
|
142
|
-
jsReadyEventIdSwap = {};
|
|
143
|
-
}
|
|
144
125
|
/**
|
|
145
126
|
* @internal
|
|
146
127
|
*/
|
|
@@ -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,
|
|
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,oBAAoB,EAAE,MAAM,YAA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;IAED,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,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"}
|
|
@@ -49,56 +49,59 @@ export const makeSyncThen = function (result) {
|
|
|
49
49
|
* @returns
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
result
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
export const loadLazyBundle = /*#__PURE__*/ (() => {
|
|
53
|
+
lynx.loadLazyBundle = loadLazyBundle;
|
|
54
|
+
function loadLazyBundle(source) {
|
|
55
|
+
if (__LEPUS__) {
|
|
56
|
+
const query = __QueryComponent(source);
|
|
57
|
+
let result;
|
|
58
|
+
try {
|
|
59
|
+
result = query.evalResult;
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
// Here we cannot return a rejected promise
|
|
63
|
+
// (which will eventually be an unhandled rejection and cause unnecessary redbox)
|
|
64
|
+
// But we still need a object in shape of Promise
|
|
65
|
+
// So we return a Promise which will never resolve or reject,
|
|
66
|
+
// which fit our principle "lepus run only once at first-screen" better
|
|
67
|
+
return new Promise(() => { });
|
|
68
|
+
}
|
|
69
|
+
const r = Promise.resolve(result);
|
|
70
|
+
// Why we should modify the implementation of `then`?
|
|
71
|
+
// We should make it `sync` so lepus first-screen render can use result above instantly
|
|
72
|
+
// We also should keep promise shape
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
r.then = makeSyncThen(result);
|
|
75
|
+
return r;
|
|
66
76
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const { schema } = detail;
|
|
81
|
-
const exports = lynxCoreInject.tt.getDynamicComponentExports(schema);
|
|
82
|
-
// `code === 0` means that the lazy bundle has been successfully parsed. However,
|
|
83
|
-
// its javascript files may still fail to run, which would prevent the retrieval of the exports object.
|
|
84
|
-
if (exports) {
|
|
85
|
-
resolve(exports);
|
|
86
|
-
return;
|
|
77
|
+
else if (__JS__) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const callback = result => {
|
|
80
|
+
const { code, detail } = result;
|
|
81
|
+
if (code === 0) {
|
|
82
|
+
const { schema } = detail;
|
|
83
|
+
const exports = lynxCoreInject.tt.getDynamicComponentExports(schema);
|
|
84
|
+
// `code === 0` means that the lazy bundle has been successfully parsed. However,
|
|
85
|
+
// its javascript files may still fail to run, which would prevent the retrieval of the exports object.
|
|
86
|
+
if (exports) {
|
|
87
|
+
resolve(exports);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
87
90
|
}
|
|
91
|
+
reject(new Error('Lazy bundle load failed: ' + JSON.stringify(result)));
|
|
92
|
+
};
|
|
93
|
+
if (typeof lynx.QueryComponent === 'function') {
|
|
94
|
+
lynx.QueryComponent(source, callback);
|
|
88
95
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
lynx.getNativeLynx().QueryComponent(source, callback);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
96
|
+
else {
|
|
97
|
+
lynx.getNativeLynx().QueryComponent(source, callback);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
throw new Error('unreachable');
|
|
98
102
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
lynx.loadLazyBundle = loadLazyBundle;
|
|
103
|
+
return loadLazyBundle;
|
|
104
|
+
})();
|
|
102
105
|
/**
|
|
103
106
|
* @internal
|
|
104
107
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-bundle.js","sourceRoot":"","sources":["../../src/lynx/lazy-bundle.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAY,MAAS;IAC/C,OAAO,UAA2B,GAAc;QAC9C,IAAI,GAAG,EAAE,CAAC;YACR,IAAI,GAAG,CAAC;YACR,IAAI,CAAC;gBACH,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;YAED,aAAa;YACb,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,uBAAuB,EAAE,CAAC;gBAClE,aAAa;gBACb,+CAA+C;gBAC/C,IAAI;gBACJ,6DAA6D;gBAC7D,yDAAyD;gBACzD,qCAAqC;gBACrC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBAE7B,8FAA8F;gBAC9F,oBAAoB;gBACpB,eAAe;gBACf,2LAA2L;gBAC3L,OAAO;gBACP,yBAAyB;gBACzB,KAAK;YACP,CAAC;YAED,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,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,CAAC;wBACrE,iFAAiF;wBACjF,uGAAuG;wBACvG,IAAI,OAAO,EAAE,CAAC;4BACZ,OAAO,CAAC,OAAO,CAAC,CAAC;4BACjB,OAAO;wBACT,CAAC;oBACH,CAAC;oBACD,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC,CAAC;gBACF,IAAI,OAAO,IAAI,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;oBAC9C,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACxC,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,aAAa,EAAE,CAAC,cAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC,EAAE,CAAC;AAEL;;GAEG;AACH,MAAM,UAAU,cAAc,CAAI,MAAyC;IACzE,MAAM,IAAI,GAAG,cAAc,CAAI,MAAM,CAAC,CAAC;IAEvC,SAAS,KAAK,CAAC,KAAU;QACvB,IAAI,CAAC;YACH,wEAAwE;YACxE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,sCAAsC;YACtC,OAAO,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO,KAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LifecycleConstant } from '../../lifecycleConstant.js';
|
|
2
|
+
import { __root } from '../../root.js';
|
|
3
|
+
import { takeGlobalRefPatchMap } from '../../snapshot/ref.js';
|
|
4
|
+
|
|
5
|
+
let isJSReady: boolean;
|
|
6
|
+
let jsReadyEventIdSwap: Record<number, number>;
|
|
7
|
+
|
|
8
|
+
function jsReady(): void {
|
|
9
|
+
isJSReady = true;
|
|
10
|
+
__OnLifecycleEvent([
|
|
11
|
+
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
12
|
+
{
|
|
13
|
+
root: JSON.stringify(__root),
|
|
14
|
+
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
15
|
+
jsReadyEventIdSwap,
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
jsReadyEventIdSwap = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function clearJSReadyEventIdSwap(): void {
|
|
22
|
+
jsReadyEventIdSwap = {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resetJSReady(): void {
|
|
26
|
+
isJSReady = false;
|
|
27
|
+
jsReadyEventIdSwap = {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export { jsReady, isJSReady, jsReadyEventIdSwap, clearJSReadyEventIdSwap, resetJSReady };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { hydrate } from '../hydrate.js';
|
|
5
|
+
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
6
|
+
import { __pendingListUpdates } from '../list.js';
|
|
4
7
|
import { __root, setRoot } from '../root.js';
|
|
8
|
+
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
5
9
|
import { SnapshotInstance, __page, snapshotInstanceManager } from '../snapshot.js';
|
|
6
10
|
import { isEmptyObject } from '../utils.js';
|
|
7
11
|
import { destroyBackground } from './destroy.js';
|
|
12
|
+
import { destroyWorklet } from '../worklet/destroy.js';
|
|
13
|
+
import { clearJSReadyEventIdSwap, isJSReady } from './event/jsReady.js';
|
|
8
14
|
import { increaseReloadVersion } from './pass.js';
|
|
9
|
-
import { renderBackground, renderMainThread } from './render.js';
|
|
10
|
-
import { hydrate } from '../hydrate.js';
|
|
11
|
-
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
12
|
-
import { __pendingListUpdates } from '../list.js';
|
|
13
|
-
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
14
15
|
import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
|
|
15
|
-
import {
|
|
16
|
+
import { renderBackground, renderMainThread } from './render.js';
|
|
16
17
|
|
|
17
18
|
function reloadMainThread(data: any, options: UpdatePageOption): void {
|
|
18
19
|
if (__PROFILE__) {
|
|
@@ -28,6 +29,7 @@ function reloadMainThread(data: any, options: UpdatePageOption): void {
|
|
|
28
29
|
destroyWorklet();
|
|
29
30
|
snapshotInstanceManager.clear();
|
|
30
31
|
__pendingListUpdates.clear();
|
|
32
|
+
clearJSReadyEventIdSwap();
|
|
31
33
|
|
|
32
34
|
const oldRoot = __root;
|
|
33
35
|
setRoot(new SnapshotInstance('root'));
|
|
@@ -39,15 +41,18 @@ function reloadMainThread(data: any, options: UpdatePageOption): void {
|
|
|
39
41
|
|
|
40
42
|
// always call this before `__FlushElementTree`
|
|
41
43
|
__pendingListUpdates.flush();
|
|
42
|
-
__FlushElementTree(__page, options);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
if (isJSReady) {
|
|
46
|
+
__OnLifecycleEvent([
|
|
47
|
+
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
48
|
+
{
|
|
49
|
+
root: JSON.stringify(__root),
|
|
50
|
+
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
__FlushElementTree(__page, options);
|
|
51
56
|
|
|
52
57
|
if (__PROFILE__) {
|
|
53
58
|
console.profileEnd();
|
|
@@ -76,4 +81,4 @@ function reloadBackground(updateData: Record<string, any>): void {
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
export {
|
|
84
|
+
export { reloadBackground, reloadMainThread };
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { render as renderToString } from '../renderToOpcodes/index.js';
|
|
7
|
-
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
8
|
-
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
9
|
-
import { isEmptyObject } from '../utils.js';
|
|
10
|
-
import { __root, setRoot } from '../root.js';
|
|
4
|
+
import { hydrate } from '../hydrate.js';
|
|
5
|
+
import { isJSReady, jsReady, jsReadyEventIdSwap, resetJSReady } from '../lifecycle/event/jsReady.js';
|
|
11
6
|
import { reloadMainThread } from '../lifecycle/reload.js';
|
|
12
7
|
import { renderMainThread } from '../lifecycle/render.js';
|
|
13
|
-
import {
|
|
14
|
-
import { markTiming, PerformanceTimingKeys, setPipeline } from './performance.js';
|
|
8
|
+
import { LifecycleConstant } from '../lifecycleConstant.js';
|
|
15
9
|
import { __pendingListUpdates } from '../list.js';
|
|
16
10
|
import { ssrHydrateByOpcodes } from '../opcodes.js';
|
|
11
|
+
import { __root, setRoot } from '../root.js';
|
|
12
|
+
import { takeGlobalRefPatchMap } from '../snapshot/ref.js';
|
|
13
|
+
import { SnapshotInstance, __page, setupPage } from '../snapshot.js';
|
|
14
|
+
import { isEmptyObject } from '../utils.js';
|
|
15
|
+
import { PerformanceTimingKeys, markTiming, setPipeline } from './performance.js';
|
|
17
16
|
|
|
18
17
|
function ssrEncode() {
|
|
19
18
|
const { __opcodes } = __root;
|
|
@@ -52,10 +51,8 @@ function ssrHydrate(info: string) {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
function injectCalledByNative(): void {
|
|
55
|
-
if (process.env['NODE_ENV'] !== 'test') {
|
|
56
|
-
|
|
57
|
-
throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');
|
|
58
|
-
}
|
|
54
|
+
if (process.env['NODE_ENV'] !== 'test' && __FIRST_SCREEN_SYNC_TIMING__ !== 'jsReady' && __ENABLE_SSR__) {
|
|
55
|
+
throw new Error('`firstScreenSyncTiming` must be `jsReady` when SSR is enabled');
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
const calledByNative: LynxCallByNative = {
|
|
@@ -77,8 +74,7 @@ function injectCalledByNative(): void {
|
|
|
77
74
|
|
|
78
75
|
function renderPage(data: any): void {
|
|
79
76
|
// reset `jsReady` state
|
|
80
|
-
|
|
81
|
-
jsReadyEventIdSwap = {};
|
|
77
|
+
resetJSReady();
|
|
82
78
|
|
|
83
79
|
lynx.__initData = data || {};
|
|
84
80
|
|
|
@@ -96,14 +92,13 @@ function renderPage(data: any): void {
|
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
94
|
|
|
99
|
-
function updatePage(data: any, options?: UpdatePageOption
|
|
95
|
+
function updatePage(data: any, options?: UpdatePageOption): void {
|
|
100
96
|
if (options?.reloadTemplate) {
|
|
101
97
|
reloadMainThread(data, options);
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
if (options?.resetPageData) {
|
|
106
|
-
// @ts-ignore
|
|
107
102
|
lynx.__initData = {};
|
|
108
103
|
}
|
|
109
104
|
|
|
@@ -146,7 +141,7 @@ function updatePage(data: any, options?: UpdatePageOption | undefined): void {
|
|
|
146
141
|
}
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
function updateGlobalProps(_data: any, options?: UpdatePageOption
|
|
144
|
+
function updateGlobalProps(_data: any, options?: UpdatePageOption): void {
|
|
150
145
|
if (options) {
|
|
151
146
|
__FlushElementTree(__page, options);
|
|
152
147
|
} else {
|
|
@@ -154,21 +149,6 @@ function updateGlobalProps(_data: any, options?: UpdatePageOption | undefined):
|
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
|
|
157
|
-
let isJSReady: boolean;
|
|
158
|
-
let jsReadyEventIdSwap: Record<number, number>;
|
|
159
|
-
function jsReady() {
|
|
160
|
-
__OnLifecycleEvent([
|
|
161
|
-
LifecycleConstant.firstScreen, /* FIRST_SCREEN */
|
|
162
|
-
{
|
|
163
|
-
root: JSON.stringify(__root),
|
|
164
|
-
refPatch: JSON.stringify(takeGlobalRefPatchMap()),
|
|
165
|
-
jsReadyEventIdSwap,
|
|
166
|
-
},
|
|
167
|
-
]);
|
|
168
|
-
isJSReady = true;
|
|
169
|
-
jsReadyEventIdSwap = {};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
152
|
/**
|
|
173
153
|
* @internal
|
|
174
154
|
*/
|