@lynx-js/web-core 0.19.5 → 0.19.7

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 CHANGED
@@ -1,5 +1,39 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.19.7
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add browser config of lynx-view, now you can customize the browser config of lynx-view: ([#2140](https://github.com/lynx-family/lynx-stack/pull/2140))
8
+
9
+ ```
10
+ lynxView.browserConfig = {
11
+ pixelRatio: 1,
12
+ pixelWidth: 1234,
13
+ pixelHeight: 5678,
14
+ }
15
+ ```
16
+
17
+ - Updated dependencies []:
18
+ - @lynx-js/web-constants@0.19.7
19
+ - @lynx-js/web-mainthread-apis@0.19.7
20
+ - @lynx-js/web-worker-rpc@0.19.7
21
+ - @lynx-js/web-worker-runtime@0.19.7
22
+
23
+ ## 0.19.6
24
+
25
+ ### Patch Changes
26
+
27
+ - fix: avoid crash on CPUs that do not support SIMD ([#2133](https://github.com/lynx-family/lynx-stack/pull/2133))
28
+
29
+ - feat: support lynx.reload() ([#2127](https://github.com/lynx-family/lynx-stack/pull/2127))
30
+
31
+ - Updated dependencies [[`179f984`](https://github.com/lynx-family/lynx-stack/commit/179f9844adf00ff4b2cd450ffb943649441c87d3), [`f7133c1`](https://github.com/lynx-family/lynx-stack/commit/f7133c137f094063e991dfa0e993ea92177aa173), [`6c2b51a`](https://github.com/lynx-family/lynx-stack/commit/6c2b51a661ae244eb40671f63f29ee971e084ed4), [`556fe9f`](https://github.com/lynx-family/lynx-stack/commit/556fe9fded90945a7926093897288d5302c314d3), [`5b589ab`](https://github.com/lynx-family/lynx-stack/commit/5b589ab53b01a8e2357d3ccbb159edab004086d3)]:
32
+ - @lynx-js/web-constants@0.19.6
33
+ - @lynx-js/web-mainthread-apis@0.19.6
34
+ - @lynx-js/web-worker-rpc@0.19.6
35
+ - @lynx-js/web-worker-runtime@0.19.6
36
+
3
37
  ## 0.19.5
4
38
 
5
39
  ### Patch Changes
@@ -181,6 +181,15 @@ export declare class LynxView extends HTMLElement {
181
181
  * @param url the url of the template
182
182
  */
183
183
  customTemplateLoader?: (url: string) => Promise<LynxTemplate>;
184
+ /**
185
+ * @public
186
+ * allow user to customize the browser config
187
+ */
188
+ browserConfig?: {
189
+ pixelRatio?: number;
190
+ pixelWidth?: number;
191
+ pixelHeight?: number;
192
+ };
184
193
  /**
185
194
  * @private
186
195
  */
@@ -329,6 +329,11 @@ export class LynxView extends HTMLElement {
329
329
  * @param url the url of the template
330
330
  */
331
331
  customTemplateLoader;
332
+ /**
333
+ * @public
334
+ * allow user to customize the browser config
335
+ */
336
+ browserConfig;
332
337
  /**
333
338
  * @private the flag to group all changes into one render operation
334
339
  */
@@ -376,6 +381,7 @@ export class LynxView extends HTMLElement {
376
381
  napiModulesMap: this.#napiModulesMap,
377
382
  lynxGroupId,
378
383
  initI18nResources: this.#initI18nResources,
384
+ browserConfig: this.browserConfig,
379
385
  callbacks: {
380
386
  nativeModulesCall: (...args) => {
381
387
  if (this.onNativeModulesCall) {
@@ -406,6 +412,9 @@ export class LynxView extends HTMLElement {
406
412
  }));
407
413
  },
408
414
  customTemplateLoader: this.customTemplateLoader,
415
+ reload: () => {
416
+ this.reload();
417
+ },
409
418
  },
410
419
  ssr: ssrData
411
420
  ? JSON.parse(decodeURI(ssrData))
@@ -14,6 +14,11 @@ export interface LynxViewConfigs {
14
14
  threadStrategy: 'all-on-ui' | 'multi-thread';
15
15
  initI18nResources: InitI18nResources;
16
16
  ssr?: SSRDumpInfo;
17
+ browserConfig?: {
18
+ pixelRatio?: number;
19
+ pixelWidth?: number;
20
+ pixelHeight?: number;
21
+ };
17
22
  }
18
23
  export interface LynxView {
19
24
  updateData(data: Cloneable, processorName?: string, callback?: () => void): void;
@@ -6,7 +6,7 @@ const pixelRatio = window.devicePixelRatio;
6
6
  const screenWidth = document.documentElement.clientWidth * pixelRatio;
7
7
  const screenHeight = document.documentElement.clientHeight * pixelRatio;
8
8
  export function createLynxView(configs) {
9
- const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, lynxGroupId, threadStrategy = 'multi-thread', initI18nResources, ssr, } = configs;
9
+ const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, lynxGroupId, threadStrategy = 'multi-thread', initI18nResources, ssr, browserConfig, } = configs;
10
10
  return startUIThread(templateUrl, {
11
11
  tagMap,
12
12
  initData,
@@ -14,9 +14,9 @@ export function createLynxView(configs) {
14
14
  nativeModulesMap,
15
15
  napiModulesMap,
16
16
  browserConfig: {
17
- pixelRatio: window.devicePixelRatio,
18
- pixelWidth: screenWidth,
19
- pixelHeight: screenHeight,
17
+ pixelRatio: browserConfig?.pixelRatio ?? window.devicePixelRatio,
18
+ pixelWidth: browserConfig?.pixelWidth ?? screenWidth,
19
+ pixelHeight: browserConfig?.pixelHeight ?? screenHeight,
20
20
  },
21
21
  initI18nResources,
22
22
  }, shadowRoot, lynxGroupId, threadStrategy, callbacks, ssr);
@@ -0,0 +1,2 @@
1
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
2
+ export declare function registerReloadHandler(rpc: Rpc, reloadHandler: () => void): void;
@@ -0,0 +1,8 @@
1
+ // Copyright 2026 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { reloadEndpoint } from '@lynx-js/web-constants';
5
+ export function registerReloadHandler(rpc, reloadHandler) {
6
+ rpc.registerHandler(reloadEndpoint, reloadHandler);
7
+ }
8
+ //# sourceMappingURL=registerReloadHandler.js.map
@@ -9,6 +9,7 @@ import { registerDispatchLynxViewEventHandler } from './crossThreadHandlers/regi
9
9
  import { registerTriggerElementMethodEndpointHandler } from './crossThreadHandlers/registerTriggerElementMethodEndpointHandler.js';
10
10
  import { registerReportErrorHandler } from './crossThreadHandlers/registerReportErrorHandler.js';
11
11
  import { registerGetPathInfoHandler } from './crossThreadHandlers/registerGetPathInfoHandler.js';
12
+ import { registerReloadHandler } from './crossThreadHandlers/registerReloadHandler.js';
12
13
  export function startBackground(backgroundRpc, shadowRoot, callbacks) {
13
14
  registerInvokeUIMethodHandler(backgroundRpc, shadowRoot);
14
15
  registerNativePropsHandler(backgroundRpc, shadowRoot);
@@ -20,6 +21,7 @@ export function startBackground(backgroundRpc, shadowRoot, callbacks) {
20
21
  registerDispatchLynxViewEventHandler(backgroundRpc, shadowRoot);
21
22
  registerTriggerElementMethodEndpointHandler(backgroundRpc, shadowRoot);
22
23
  registerReportErrorHandler(backgroundRpc, 'app-service.js', callbacks.onError);
24
+ registerReloadHandler(backgroundRpc, callbacks.reload);
23
25
  const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
24
26
  const markTiming = backgroundRpc.createCall(markTimingEndpoint);
25
27
  const updateI18nResourceBackground = (data, options) => {
@@ -5,5 +5,6 @@ export type StartUIThreadCallbacks = {
5
5
  napiModulesCall: NapiModulesCall;
6
6
  onError?: (err: Error, release: string, fileName: string) => void;
7
7
  customTemplateLoader?: TemplateLoader;
8
+ reload: () => void;
8
9
  };
9
10
  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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core",
3
- "version": "0.19.5",
3
+ "version": "0.19.7",
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": "0.1.4",
28
- "@lynx-js/web-constants": "0.19.5",
29
- "@lynx-js/web-mainthread-apis": "0.19.5",
30
- "@lynx-js/web-worker-rpc": "0.19.5",
31
- "@lynx-js/web-worker-runtime": "0.19.5"
28
+ "@lynx-js/web-constants": "0.19.7",
29
+ "@lynx-js/web-mainthread-apis": "0.19.7",
30
+ "@lynx-js/web-worker-rpc": "0.19.7",
31
+ "@lynx-js/web-worker-runtime": "0.19.7"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@lynx-js/lynx-core": "0.1.3",
35
- "@lynx-js/web-elements": "0.11.0"
35
+ "@lynx-js/web-elements": "0.11.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lynx-js/lynx-core": "0.1.3",