Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-ants-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/offscreen-document": patch
---

feat: support touch events
15 changes: 15 additions & 0 deletions .changeset/empty-worms-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@lynx-js/web-mainthread-apis": patch
"@lynx-js/web-worker-runtime": patch
"@lynx-js/web-constants": patch
"@lynx-js/web-core": patch
---

feat: support touch events for MTS

now we support

- main-thread:bindtouchstart
- main-thread:bindtouchend
- main-thread:bindtouchmove
- main-thread:bindtouchcancel
5 changes: 5 additions & 0 deletions .changeset/loud-mangos-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-core": patch
---

feat: add SystemInfo.screenWidth and SystemInfo.screenHeight
5 changes: 5 additions & 0 deletions .changeset/shaky-months-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-explorer": patch
---

chore: update homepage
3 changes: 3 additions & 0 deletions .cspell/lynx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ bindinput
bindload
bindtap
bindtapuser
bindtouchstart
bindtouchend
bindtouchcancel
bindtouchmove
catchlongpress
catchtap
Expand Down
1 change: 1 addition & 0 deletions .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"website/docs/zh/api/**",
"website/docs/en/changelog/**",
"website/docs/zh/changelog/**",
"packages/web-platform/web-explorer/preinstalled/**",

// The tsconfig.json contains comments that align with indents.
"/tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@vitest/coverage-v8": "^3.1.2",
"@vitest/eslint-plugin": "^1.1.43",
"@vitest/ui": "^3.1.2",
"cspell": "^8.19.2",
"cspell": "^8.19.3",
"dprint": "^0.49.1",
"eslint": "^9.25.1",
"eslint-import-resolver-typescript": "^4.3.4",
Expand All @@ -36,7 +36,7 @@
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-n": "^17.17.0",
"eslint-plugin-regexp": "^2.7.0",
"eslint-plugin-unicorn": "^58.0.0",
"eslint-plugin-unicorn": "^59.0.0",
"globals": "^16.0.0",
"husky": "^9.1.7",
"lint-staged": "^15.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
function emptyHandler() {
// no-op
}

const otherPropertyNames = [
'detail',
'keyCode',
Expand All @@ -19,7 +18,41 @@ const otherPropertyNames = [
'propertyName',
'pseudoElement',
'animationName',
'touches',
'targetTouches',
'changedTouches',
];
const blockList = new Set([
'isTrusted',
'target',
'currentTarget',
'type',
'bubbles',
'window',
'self',
'view',
'srcElement',
'eventPhase',
]);

function transferToCloneable(value: any): any {
if (
typeof value === 'string' || typeof value === 'number'
|| typeof value === 'boolean' || value === null || value === undefined
) {
return value;
} else if (value[Symbol.iterator]) {
return [...value].map(transferToCloneable);
} else if (typeof value === 'object' && !(value instanceof EventTarget)) {
const obj: Record<string, any> = {};
for (const key in value) {
if (!blockList.has(key)) {
obj[key] = transferToCloneable(value[key]);
}
}
return obj;
}
}

export function initOffscreenDocument(options: {
shadowRoot: ShadowRoot;
Expand Down Expand Up @@ -64,7 +97,8 @@ export function initOffscreenDocument(options: {
const otherProperties: Record<string, unknown> = {};
for (const propertyName of otherPropertyNames) {
if (propertyName in ev) {
otherProperties[propertyName] = (ev as any)[propertyName];
// @ts-expect-error
otherProperties[propertyName] = transferToCloneable(ev[propertyName]);
}
}
onEvent(eventType, targetUniqueId, ev.bubbles, otherProperties);
Expand Down
11 changes: 6 additions & 5 deletions packages/web-platform/web-constants/src/types/Cloneable.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
export type Cloneable<T = string | number | null | undefined> =
export type Cloneable<T = string | number | null | boolean | undefined> =
| T
| Record<string, T>
| T[];

export type CloneableObject<T = string | number | null | undefined> = Record<
string,
T
>;
export type CloneableObject<T = string | number | null | boolean | undefined> =
Record<
string,
T | T[]
>;
2 changes: 2 additions & 0 deletions packages/web-platform/web-constants/src/types/PageConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ export interface PageConfig {

export interface BrowserConfig {
pixelRatio: number;
pixelWidth: number;
pixelHeight: number;
}
5 changes: 5 additions & 0 deletions packages/web-platform/web-core/src/apis/createLynxView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
type StartUIThreadCallbacks,
} from '../uiThread/startUIThread.js';
import type { RpcCallType } from '@lynx-js/web-worker-rpc';
const pixelRatio = window.devicePixelRatio;
const screenWidth = window.screen.availWidth * pixelRatio;
const screenHeight = window.screen.availHeight * pixelRatio;

export interface LynxViewConfigs {
templateUrl: string;
Expand Down Expand Up @@ -61,6 +64,8 @@ export function createLynxView(configs: LynxViewConfigs): LynxView {
napiModulesMap,
browserConfig: {
pixelRatio: window.devicePixelRatio,
pixelWidth: screenWidth,
pixelHeight: screenHeight,
},
},
shadowRoot,
Expand Down
Loading