@lynx-js/web-core-canary 0.16.1-canary-20250915-74388494 → 0.16.1-canary-20250915-608f375e
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 +9 -7
- package/dist/uiThread/createRenderAllOnUI.d.ts +3 -4
- package/dist/uiThread/createRenderAllOnUI.js +2 -2
- package/dist/uiThread/createRenderMultiThread.d.ts +3 -3
- package/dist/uiThread/createRenderMultiThread.js +3 -2
- package/dist/uiThread/startUIThread.d.ts +2 -2
- package/dist/uiThread/startUIThread.js +5 -6
- package/dist/utils/loadTemplate.d.ts +2 -2
- package/dist/utils/loadTemplate.js +24 -17
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# @lynx-js/web-core
|
|
2
2
|
|
|
3
|
-
## 0.16.1-canary-
|
|
3
|
+
## 0.16.1-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- refactor: improve chunk loading ([#1703](https://github.com/lynx-family/lynx-stack/pull/1703))
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- @lynx-js/web-
|
|
13
|
-
- @lynx-js/web-
|
|
14
|
-
- @lynx-js/web-worker-runtime@0.16.1-canary-
|
|
9
|
+
- feat: supports lazy bundle. (This feature requires `@lynx-js/lynx-core >= 0.1.3`) ([#1235](https://github.com/lynx-family/lynx-stack/pull/1235))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`1d97fce`](https://github.com/lynx-family/lynx-stack/commit/1d97fce68178418f6af8d50e54ab24a5567452b7), [`608f375`](https://github.com/lynx-family/lynx-stack/commit/608f375e20732cc4c9f141bfbf9800ba6896100b)]:
|
|
12
|
+
- @lynx-js/web-elements@0.8.6-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
13
|
+
- @lynx-js/web-mainthread-apis@0.16.1-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
14
|
+
- @lynx-js/web-worker-runtime@0.16.1-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
15
|
+
- @lynx-js/web-constants@0.16.1-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
16
|
+
- @lynx-js/web-worker-rpc@0.16.1-canary-20250915073423-608f375e20732cc4c9f141bfbf9800ba6896100b
|
|
15
17
|
|
|
16
18
|
## 0.16.0
|
|
17
19
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type StartMainThreadContextConfig, type Cloneable, type SSRDumpInfo } from '@lynx-js/web-constants';
|
|
1
|
+
import { type StartMainThreadContextConfig, type Cloneable, type SSRDumpInfo, type TemplateLoader } from '@lynx-js/web-constants';
|
|
2
2
|
import { Rpc } from '@lynx-js/web-worker-rpc';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}, ssrDumpInfo: SSRDumpInfo | undefined): {
|
|
3
|
+
import type { StartUIThreadCallbacks } from './startUIThread.js';
|
|
4
|
+
export declare function createRenderAllOnUI(mainToBackgroundRpc: Rpc, shadowRoot: ShadowRoot, loadTemplate: TemplateLoader, markTimingInternal: (timingKey: string, pipelineId?: string, timeStamp?: number) => void, flushMarkTimingInternal: () => void, callbacks: StartUIThreadCallbacks, ssrDumpInfo: SSRDumpInfo | undefined): {
|
|
6
5
|
start: (configs: StartMainThreadContextConfig) => Promise<void>;
|
|
7
6
|
updateDataMainThread: (args_0: Cloneable, args_1: Record<string, string>) => Promise<void>;
|
|
8
7
|
updateI18nResourcesMainThread: (data: Cloneable) => void;
|
|
@@ -69,7 +69,7 @@ function createIFrameRealm(parent) {
|
|
|
69
69
|
};
|
|
70
70
|
return { globalWindow: iframeWindow, loadScript, loadScriptSync };
|
|
71
71
|
}
|
|
72
|
-
export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, markTimingInternal, flushMarkTimingInternal, callbacks, ssrDumpInfo) {
|
|
72
|
+
export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, loadTemplate, markTimingInternal, flushMarkTimingInternal, callbacks, ssrDumpInfo) {
|
|
73
73
|
if (!globalThis.module) {
|
|
74
74
|
Object.assign(globalThis, { module: {} });
|
|
75
75
|
}
|
|
@@ -85,7 +85,7 @@ export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, markTimingI
|
|
|
85
85
|
}, triggerI18nResourceFallback, (initI18nResources) => {
|
|
86
86
|
i18nResources.setData(initI18nResources);
|
|
87
87
|
return i18nResources;
|
|
88
|
-
});
|
|
88
|
+
}, loadTemplate);
|
|
89
89
|
const pendingUpdateCalls = [];
|
|
90
90
|
const start = async (configs) => {
|
|
91
91
|
if (ssrDumpInfo) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type TemplateLoader } from '@lynx-js/web-constants';
|
|
1
2
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}): {
|
|
3
|
+
import type { StartUIThreadCallbacks } from './startUIThread.js';
|
|
4
|
+
export declare function createRenderMultiThread(mainThreadRpc: Rpc, shadowRoot: ShadowRoot, loadTemplate: TemplateLoader, callbacks: StartUIThreadCallbacks): {
|
|
5
5
|
start: (args_0: import("@lynx-js/web-constants").StartMainThreadContextConfig) => void;
|
|
6
6
|
updateDataMainThread: (args_0: import("@lynx-js/web-constants").Cloneable, args_1: Record<string, string>) => Promise<void>;
|
|
7
7
|
updateI18nResourcesMainThread: (args_0: import("@lynx-js/web-constants").Cloneable) => void;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// Copyright 2023 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 { mainThreadStartEndpoint, updateDataEndpoint, updateI18nResourcesEndpoint, } from '@lynx-js/web-constants';
|
|
4
|
+
import { loadTemplateMultiThread, mainThreadStartEndpoint, updateDataEndpoint, updateI18nResourcesEndpoint, } from '@lynx-js/web-constants';
|
|
5
5
|
import { registerReportErrorHandler } from './crossThreadHandlers/registerReportErrorHandler.js';
|
|
6
6
|
import { registerFlushElementTreeHandler } from './crossThreadHandlers/registerFlushElementTreeHandler.js';
|
|
7
7
|
import { registerDispatchLynxViewEventHandler } from './crossThreadHandlers/registerDispatchLynxViewEventHandler.js';
|
|
8
8
|
import { createExposureMonitorForMultiThread } from './crossThreadHandlers/createExposureMonitor.js';
|
|
9
|
-
export function createRenderMultiThread(mainThreadRpc, shadowRoot, callbacks) {
|
|
9
|
+
export function createRenderMultiThread(mainThreadRpc, shadowRoot, loadTemplate, callbacks) {
|
|
10
10
|
registerReportErrorHandler(mainThreadRpc, 'lepus.js', callbacks.onError);
|
|
11
11
|
registerFlushElementTreeHandler(mainThreadRpc, { shadowRoot });
|
|
12
12
|
registerDispatchLynxViewEventHandler(mainThreadRpc, shadowRoot);
|
|
13
13
|
createExposureMonitorForMultiThread(mainThreadRpc, shadowRoot);
|
|
14
|
+
mainThreadRpc.registerHandler(loadTemplateMultiThread, loadTemplate);
|
|
14
15
|
const start = mainThreadRpc.createCall(mainThreadStartEndpoint);
|
|
15
16
|
const updateDataMainThread = mainThreadRpc.createCall(updateDataEndpoint);
|
|
16
17
|
const updateI18nResourcesMainThread = mainThreadRpc.createCall(updateI18nResourcesEndpoint);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LynxView } from '../apis/createLynxView.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type StartMainThreadContextConfig, type NapiModulesCall, type NativeModulesCall, type SSRDumpInfo, type TemplateLoader } from '@lynx-js/web-constants';
|
|
3
3
|
export type StartUIThreadCallbacks = {
|
|
4
4
|
nativeModulesCall: NativeModulesCall;
|
|
5
5
|
napiModulesCall: NapiModulesCall;
|
|
6
6
|
onError?: (err: Error, release: string, fileName: string) => void;
|
|
7
|
-
customTemplateLoader?:
|
|
7
|
+
customTemplateLoader?: TemplateLoader;
|
|
8
8
|
};
|
|
9
9
|
export declare function startUIThread(templateUrl: string, configs: Omit<StartMainThreadContextConfig, 'template'>, shadowRoot: ShadowRoot, lynxGroupId: number | undefined, threadStrategy: 'all-on-ui' | 'multi-thread', callbacks: StartUIThreadCallbacks, ssr?: SSRDumpInfo): LynxView;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { bootWorkers } from './bootWorkers.js';
|
|
5
5
|
import { createDispose } from './crossThreadHandlers/createDispose.js';
|
|
6
6
|
import { updateGlobalPropsEndpoint, dispatchMarkTiming, flushMarkTiming, } from '@lynx-js/web-constants';
|
|
7
|
-
import {
|
|
7
|
+
import { createTemplateLoader } from '../utils/loadTemplate.js';
|
|
8
8
|
import { createUpdateData } from './crossThreadHandlers/createUpdateData.js';
|
|
9
9
|
import { startBackground } from './startBackground.js';
|
|
10
10
|
import { createRenderMultiThread } from './createRenderMultiThread.js';
|
|
@@ -28,15 +28,14 @@ export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, thr
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
const flushMarkTimingInternal = () => flushMarkTiming(markTiming, cacheMarkTimings);
|
|
31
|
+
const templateLoader = createTemplateLoader(callbacks.customTemplateLoader, markTimingInternal);
|
|
31
32
|
const { start, updateDataMainThread, updateI18nResourcesMainThread } = allOnUI
|
|
32
33
|
? createRenderAllOnUI(
|
|
33
|
-
/* main-to-bg rpc*/ mainThreadRpc, shadowRoot, markTimingInternal, flushMarkTimingInternal, callbacks, ssr)
|
|
34
|
+
/* main-to-bg rpc*/ mainThreadRpc, shadowRoot, templateLoader, markTimingInternal, flushMarkTimingInternal, callbacks, ssr)
|
|
34
35
|
: createRenderMultiThread(
|
|
35
|
-
/* main-to-ui rpc*/ mainThreadRpc, shadowRoot, callbacks);
|
|
36
|
+
/* main-to-ui rpc*/ mainThreadRpc, shadowRoot, templateLoader, callbacks);
|
|
36
37
|
markTimingInternal('create_lynx_start', undefined, createLynxStartTiming);
|
|
37
|
-
|
|
38
|
-
loadTemplate(templateUrl, callbacks.customTemplateLoader).then((template) => {
|
|
39
|
-
markTimingInternal('load_template_end');
|
|
38
|
+
templateLoader(templateUrl).then((template) => {
|
|
40
39
|
flushMarkTimingInternal();
|
|
41
40
|
start({
|
|
42
41
|
...configs,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function
|
|
1
|
+
import { type MarkTimingInternal, type TemplateLoader } from '@lynx-js/web-constants';
|
|
2
|
+
export declare function createTemplateLoader(customTemplateLoader: TemplateLoader | undefined, markTimingInternal: MarkTimingInternal): TemplateLoader;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import { generateTemplate } from '@lynx-js/web-constants';
|
|
1
|
+
import { generateTemplate, } from '@lynx-js/web-constants';
|
|
2
2
|
const templateCache = {};
|
|
3
3
|
function createJsModuleUrl(content) {
|
|
4
4
|
return URL.createObjectURL(new Blob([content], { type: 'text/javascript' }));
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
export function createTemplateLoader(customTemplateLoader, markTimingInternal) {
|
|
7
|
+
const loadTemplate = async (url) => {
|
|
8
|
+
markTimingInternal('load_template_start');
|
|
9
|
+
const cachedTemplate = templateCache[url];
|
|
10
|
+
if (cachedTemplate) {
|
|
11
|
+
markTimingInternal('load_template_end');
|
|
12
|
+
return cachedTemplate;
|
|
13
|
+
}
|
|
14
|
+
const template = customTemplateLoader
|
|
15
|
+
? await customTemplateLoader(url)
|
|
16
|
+
: (await (await fetch(url, {
|
|
17
|
+
method: 'GET',
|
|
18
|
+
})).json());
|
|
19
|
+
const decodedTemplate = await generateTemplate(template, createJsModuleUrl);
|
|
20
|
+
templateCache[url] = decodedTemplate;
|
|
21
|
+
/**
|
|
22
|
+
* This will cause a memory leak, which is expected.
|
|
23
|
+
* We cannot ensure that the `URL.createObjectURL` created url will never be used, therefore here we keep it for the entire lifetime of this page.
|
|
24
|
+
*/
|
|
25
|
+
markTimingInternal('load_template_end');
|
|
26
|
+
return decodedTemplate;
|
|
27
|
+
};
|
|
28
|
+
return loadTemplate;
|
|
22
29
|
}
|
|
23
30
|
//# sourceMappingURL=loadTemplate.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core-canary",
|
|
3
|
-
"version": "0.16.1-canary-20250915-
|
|
3
|
+
"version": "0.16.1-canary-20250915-608f375e",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4",
|
|
28
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.16.1-canary-20250915-
|
|
29
|
-
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.16.1-canary-20250915-
|
|
30
|
-
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.1-canary-20250915-
|
|
31
|
-
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.16.1-canary-20250915-
|
|
28
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.16.1-canary-20250915-608f375e",
|
|
29
|
+
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.16.1-canary-20250915-608f375e",
|
|
30
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.1-canary-20250915-608f375e",
|
|
31
|
+
"@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.16.1-canary-20250915-608f375e"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@lynx-js/lynx-core": "0.1.3",
|
|
35
|
-
"@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.6-canary-20250915-
|
|
35
|
+
"@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.6-canary-20250915-608f375e"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@lynx-js/lynx-core": "0.1.3",
|