@lynx-js/web-mainthread-apis 0.12.0 → 0.13.1
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 +71 -0
- package/dist/MainThreadLynx.d.ts +2 -4
- package/dist/MainThreadLynx.js +5 -29
- package/dist/MainThreadRuntime.d.ts +3 -2
- package/dist/MainThreadRuntime.js +14 -8
- package/dist/crossThreadHandlers/registerCallLepusMethodHandler.d.ts +3 -0
- package/dist/crossThreadHandlers/registerCallLepusMethodHandler.js +10 -0
- package/dist/crossThreadHandlers/registerGetCustomSectionHandler.d.ts +2 -0
- package/dist/crossThreadHandlers/registerGetCustomSectionHandler.js +10 -0
- package/dist/elementAPI/style/cssPropertyMap.d.ts +2 -2
- package/dist/elementAPI/style/cssPropertyMap.js +218 -200
- package/dist/elementAPI/style/styleFunctions.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/loadMainThread.d.ts +5 -0
- package/dist/loadMainThread.js +120 -0
- package/dist/utils/createCrossThreadEvent.js +29 -0
- package/dist/utils/processStyleInfo.js +16 -20
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
+
## 0.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: some inline style properties cause crash ([#647](https://github.com/lynx-family/lynx-stack/pull/647))
|
|
8
|
+
|
|
9
|
+
add support for the following css properties
|
|
10
|
+
|
|
11
|
+
- mask
|
|
12
|
+
- mask-repeat
|
|
13
|
+
- mask-position
|
|
14
|
+
- mask-clip
|
|
15
|
+
- mask-origin
|
|
16
|
+
- mask-size
|
|
17
|
+
- gap
|
|
18
|
+
- column-gap
|
|
19
|
+
- row-gap
|
|
20
|
+
- image-rendering
|
|
21
|
+
- hyphens
|
|
22
|
+
- offset-path
|
|
23
|
+
- offset-distance
|
|
24
|
+
|
|
25
|
+
- feat: support touch events for MTS ([#641](https://github.com/lynx-family/lynx-stack/pull/641))
|
|
26
|
+
|
|
27
|
+
now we support
|
|
28
|
+
|
|
29
|
+
- main-thread:bindtouchstart
|
|
30
|
+
- main-thread:bindtouchend
|
|
31
|
+
- main-thread:bindtouchmove
|
|
32
|
+
- main-thread:bindtouchcancel
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91)]:
|
|
35
|
+
- @lynx-js/web-constants@0.13.1
|
|
36
|
+
|
|
37
|
+
## 0.13.0
|
|
38
|
+
|
|
39
|
+
### Minor Changes
|
|
40
|
+
|
|
41
|
+
- fix: mts lynx will no longer provide requireModule, requireModuleAsync methods, which is aligned with Native. ([#537](https://github.com/lynx-family/lynx-stack/pull/537))
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- refactor: isolate SystemInfo ([#628](https://github.com/lynx-family/lynx-stack/pull/628))
|
|
46
|
+
|
|
47
|
+
Never assign `SystemInfo` on worker's self object.
|
|
48
|
+
|
|
49
|
+
- feat: support thread strategy `all-on-ui` ([#625](https://github.com/lynx-family/lynx-stack/pull/625))
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<lynx-view thread-strategy="all-on-ui"></lynx-view>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will make the lynx's main-thread run on the UA's main thread.
|
|
56
|
+
|
|
57
|
+
Note that the `all-on-ui` does not support the HMR & chunk splitting yet.
|
|
58
|
+
|
|
59
|
+
- fix(web): `:root` not work on web platform ([#607](https://github.com/lynx-family/lynx-stack/pull/607))
|
|
60
|
+
|
|
61
|
+
Note: To solve this issue, you need to upgrade your `react-rsbuild-plugin`
|
|
62
|
+
|
|
63
|
+
- refactor: move mainthread impl into mainthread-api packages ([#622](https://github.com/lynx-family/lynx-stack/pull/622))
|
|
64
|
+
|
|
65
|
+
- fix(web): css selector not work for selectors with combinator and pseudo-class on WEB ([#608](https://github.com/lynx-family/lynx-stack/pull/608))
|
|
66
|
+
|
|
67
|
+
like `.parent > :not([hidden]) ~ :not([hidden])`
|
|
68
|
+
|
|
69
|
+
you will need to upgrade your `react-rsbuild-plugin` to fix this issue
|
|
70
|
+
|
|
71
|
+
- Updated dependencies [[`4ee0465`](https://github.com/lynx-family/lynx-stack/commit/4ee0465f6e5846a0d038b49d2a7c95e87c9e5c77), [`5a3d9af`](https://github.com/lynx-family/lynx-stack/commit/5a3d9afe52ba639987db124ca35580261e0718b5), [`5269cab`](https://github.com/lynx-family/lynx-stack/commit/5269cabef7609159bdd0dd14a03c5da667907424)]:
|
|
72
|
+
- @lynx-js/web-constants@0.13.0
|
|
73
|
+
|
|
3
74
|
## 0.12.0
|
|
4
75
|
|
|
5
76
|
### Patch Changes
|
package/dist/MainThreadLynx.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { type MainThreadConfig
|
|
2
|
-
export declare function createMainThreadLynx(config: MainThreadConfig
|
|
1
|
+
import { type MainThreadConfig } from './MainThreadRuntime.js';
|
|
2
|
+
export declare function createMainThreadLynx(config: MainThreadConfig): {
|
|
3
3
|
getJSContext(): import("@lynx-js/web-constants").LynxContextEventTarget;
|
|
4
4
|
requestAnimationFrame(cb: FrameRequestCallback): number;
|
|
5
5
|
cancelAnimationFrame(handler: number): void;
|
|
6
6
|
__globalProps: unknown;
|
|
7
|
-
requireModule(path: string): unknown;
|
|
8
|
-
requireModuleAsync(path: string, callback: (error: Error | null, exports?: unknown) => void): void;
|
|
9
7
|
getCustomSectionSync(key: string): import("@lynx-js/web-constants").Cloneable;
|
|
10
8
|
markPipelineTiming: (pipelineId: string, timingKey: string) => void;
|
|
11
9
|
};
|
package/dist/MainThreadLynx.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Copyright 2023 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 {} from './MainThreadRuntime.js';
|
|
5
|
+
export function createMainThreadLynx(config) {
|
|
3
6
|
return {
|
|
4
7
|
getJSContext() {
|
|
5
8
|
return config.jsContext;
|
|
@@ -11,33 +14,6 @@ export function createMainThreadLynx(config, lepusRuntime) {
|
|
|
11
14
|
return cancelAnimationFrame(handler);
|
|
12
15
|
},
|
|
13
16
|
__globalProps: config.globalProps,
|
|
14
|
-
requireModule(path) {
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
if (self.WorkerGlobalScope) {
|
|
17
|
-
const lepusChunkUrl = config.lepusCode[`${path}`];
|
|
18
|
-
if (lepusChunkUrl)
|
|
19
|
-
path = lepusChunkUrl;
|
|
20
|
-
// @ts-expect-error
|
|
21
|
-
importScripts(path);
|
|
22
|
-
const entry = globalThis.module.exports;
|
|
23
|
-
return entry?.(lepusRuntime);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
throw new Error('importing scripts synchronously is only available for the multi-thread running mode');
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
requireModuleAsync(path, callback) {
|
|
30
|
-
const lepusChunkUrl = config.lepusCode[`${path}`];
|
|
31
|
-
if (lepusChunkUrl)
|
|
32
|
-
path = lepusChunkUrl;
|
|
33
|
-
import(
|
|
34
|
-
/* webpackIgnore: true */
|
|
35
|
-
path).catch(callback).then(() => {
|
|
36
|
-
const entry = globalThis.module.exports;
|
|
37
|
-
const ret = entry?.(lepusRuntime);
|
|
38
|
-
callback(null, ret);
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
17
|
getCustomSectionSync(key) {
|
|
42
18
|
return config.customSections[key]?.content;
|
|
43
19
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LynxTemplate, type PageConfig, type ProcessDataCallback, type StyleInfo, type FlushElementTreeOptions, type Cloneable, type BrowserConfig, type publishEventEndpoint, type publicComponentEventEndpoint, type reportErrorEndpoint, type RpcCallType, type postExposureEndpoint, type LynxContextEventTarget } from '@lynx-js/web-constants';
|
|
1
|
+
import { type LynxTemplate, type PageConfig, type ProcessDataCallback, type StyleInfo, type FlushElementTreeOptions, type Cloneable, type BrowserConfig, type publishEventEndpoint, type publicComponentEventEndpoint, type reportErrorEndpoint, type RpcCallType, type postExposureEndpoint, type LynxContextEventTarget, type LynxJSModule, systemInfo } from '@lynx-js/web-constants';
|
|
2
2
|
import { type MainThreadLynx } from './MainThreadLynx.js';
|
|
3
3
|
import type { LynxRuntimeInfo } from './elementAPI/ElementThreadElement.js';
|
|
4
4
|
export interface MainThreadRuntimeCallbacks {
|
|
@@ -17,7 +17,7 @@ export interface MainThreadConfig {
|
|
|
17
17
|
callbacks: MainThreadRuntimeCallbacks;
|
|
18
18
|
styleInfo: StyleInfo;
|
|
19
19
|
customSections: LynxTemplate['customSections'];
|
|
20
|
-
lepusCode:
|
|
20
|
+
lepusCode: Record<string, LynxJSModule>;
|
|
21
21
|
browserConfig: BrowserConfig;
|
|
22
22
|
tagMap: Record<string, string>;
|
|
23
23
|
docu: Pick<Document, 'append' | 'createElement' | 'addEventListener'>;
|
|
@@ -70,6 +70,7 @@ export declare class MainThreadRuntime {
|
|
|
70
70
|
*/
|
|
71
71
|
__lynxGlobalBindingValues: Record<string, any>;
|
|
72
72
|
get globalThis(): this;
|
|
73
|
+
SystemInfo: typeof systemInfo;
|
|
73
74
|
lynx: MainThreadLynx;
|
|
74
75
|
__globalProps: unknown;
|
|
75
76
|
processData?: ProcessDataCallback;
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
|
|
4
|
+
import { lynxUniqueIdAttribute, systemInfo, } from '@lynx-js/web-constants';
|
|
5
5
|
import { globalMuteableVars } from '@lynx-js/web-constants';
|
|
6
6
|
import { createMainThreadLynx } from './MainThreadLynx.js';
|
|
7
7
|
import { initializeElementCreatingFunction } from './elementAPI/elementCreating/elementCreatingFunctions.js';
|
|
@@ -49,7 +49,7 @@ export class MainThreadRuntime {
|
|
|
49
49
|
constructor(config) {
|
|
50
50
|
this.config = config;
|
|
51
51
|
this.__globalProps = config.globalProps;
|
|
52
|
-
this.lynx = createMainThreadLynx(config
|
|
52
|
+
this.lynx = createMainThreadLynx(config);
|
|
53
53
|
/**
|
|
54
54
|
* now create the style content
|
|
55
55
|
* 1. flatten the styleInfo
|
|
@@ -63,7 +63,6 @@ export class MainThreadRuntime {
|
|
|
63
63
|
const cssInJsInfo = this.config.pageConfig.enableCSSSelector
|
|
64
64
|
? {}
|
|
65
65
|
: genCssInJsInfo(this.config.styleInfo);
|
|
66
|
-
this._rootDom = this.config.docu.createElement('div');
|
|
67
66
|
const cardStyleElement = this.config.docu.createElement('style');
|
|
68
67
|
cardStyleElement.innerHTML = genCssContent(this.config.styleInfo, this.config.pageConfig);
|
|
69
68
|
this._rootDom = this.config.docu;
|
|
@@ -74,6 +73,10 @@ export class MainThreadRuntime {
|
|
|
74
73
|
Object.assign(this, createAttributeAndPropertyFunctions(this), domTreeApis, createEventFunctions(this), createStyleFunctions(this, cssInJsInfo), initializeElementCreatingFunction(this));
|
|
75
74
|
this._ReportError = this.config.callbacks._ReportError;
|
|
76
75
|
this.__OnLifecycleEvent = this.config.callbacks.__OnLifecycleEvent;
|
|
76
|
+
this.SystemInfo = {
|
|
77
|
+
...systemInfo,
|
|
78
|
+
...config.browserConfig,
|
|
79
|
+
};
|
|
77
80
|
/**
|
|
78
81
|
* Start the exposure service
|
|
79
82
|
*/
|
|
@@ -128,6 +131,7 @@ export class MainThreadRuntime {
|
|
|
128
131
|
get globalThis() {
|
|
129
132
|
return this;
|
|
130
133
|
}
|
|
134
|
+
SystemInfo;
|
|
131
135
|
lynx;
|
|
132
136
|
__globalProps;
|
|
133
137
|
processData;
|
|
@@ -135,18 +139,20 @@ export class MainThreadRuntime {
|
|
|
135
139
|
_ReportError;
|
|
136
140
|
__OnLifecycleEvent;
|
|
137
141
|
__LoadLepusChunk = (path) => {
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
const lepusModule = this.config.lepusCode[`${path}`];
|
|
143
|
+
if (lepusModule) {
|
|
144
|
+
const entry = lepusModule.exports;
|
|
145
|
+
entry?.(this);
|
|
140
146
|
return true;
|
|
141
147
|
}
|
|
142
|
-
|
|
148
|
+
else {
|
|
149
|
+
return false;
|
|
143
150
|
}
|
|
144
|
-
return false;
|
|
145
151
|
};
|
|
146
152
|
__FlushElementTree = (_subTree, options) => {
|
|
147
153
|
const timingFlags = this._timingFlags;
|
|
148
154
|
this._timingFlags = [];
|
|
149
|
-
if (this._page && !this._page.
|
|
155
|
+
if (this._page && !this._page.parentNode) {
|
|
150
156
|
this._rootDom.append(this._page);
|
|
151
157
|
}
|
|
152
158
|
this.config.callbacks.flushElementTree(options, timingFlags);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2023 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 { callLepusMethodEndpoint } from '@lynx-js/web-constants';
|
|
5
|
+
export function registerCallLepusMethodHandler(rpc, runtime) {
|
|
6
|
+
rpc.registerHandler(callLepusMethodEndpoint, (methodName, data) => {
|
|
7
|
+
(runtime[methodName])(data);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=registerCallLepusMethodHandler.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2023 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 { getCustomSectionsEndpoint, } from '@lynx-js/web-constants';
|
|
5
|
+
export function registerGetCustomSectionHandler(rpc, customSections) {
|
|
6
|
+
rpc.registerHandler(getCustomSectionsEndpoint, (key) => {
|
|
7
|
+
return customSections[key]?.content;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=registerGetCustomSectionHandler.js.map
|
|
@@ -2,12 +2,12 @@ export declare function camelize(str: string): string;
|
|
|
2
2
|
declare const cssPropertyMap: Record<number, {
|
|
3
3
|
name: string;
|
|
4
4
|
dashName: string;
|
|
5
|
-
|
|
5
|
+
isX: boolean;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function queryCSSProperty(index: number): {
|
|
8
8
|
name: string;
|
|
9
|
-
defaultValue: string;
|
|
10
9
|
dashName: string;
|
|
10
|
+
isX: boolean;
|
|
11
11
|
};
|
|
12
12
|
export declare function queryCSSPropertyNumber(name: string): number;
|
|
13
13
|
export { cssPropertyMap };
|
|
@@ -15,209 +15,227 @@ export function camelize(str) {
|
|
|
15
15
|
let index = 1;
|
|
16
16
|
const cssPropertyMap = {};
|
|
17
17
|
const cssPropertyReverseMap = {};
|
|
18
|
-
const V = (name
|
|
18
|
+
const V = (name) => {
|
|
19
19
|
const k = index++;
|
|
20
|
-
|
|
20
|
+
const isX = name.startsWith('-x-');
|
|
21
|
+
cssPropertyMap[k] = { name: camelize(name), dashName: name, isX };
|
|
21
22
|
cssPropertyReverseMap[name] = k;
|
|
22
23
|
};
|
|
23
|
-
V('top'
|
|
24
|
-
V('left'
|
|
25
|
-
V('right'
|
|
26
|
-
V('bottom'
|
|
27
|
-
V('position'
|
|
28
|
-
V('box-sizing'
|
|
29
|
-
V('background-color'
|
|
30
|
-
V('border-left-color'
|
|
31
|
-
V('border-right-color'
|
|
32
|
-
V('border-top-color'
|
|
33
|
-
V('border-bottom-color'
|
|
34
|
-
V('border-radius'
|
|
35
|
-
V('border-top-left-radius'
|
|
36
|
-
V('border-bottom-left-radius'
|
|
37
|
-
V('border-top-right-radius'
|
|
38
|
-
V('border-bottom-right-radius'
|
|
39
|
-
V('border-width'
|
|
40
|
-
V('border-left-width'
|
|
41
|
-
V('border-right-width'
|
|
42
|
-
V('border-top-width'
|
|
43
|
-
V('border-bottom-width'
|
|
44
|
-
V('color'
|
|
45
|
-
V('opacity'
|
|
46
|
-
V('display'
|
|
47
|
-
V('overflow'
|
|
48
|
-
V('height'
|
|
49
|
-
V('width'
|
|
50
|
-
V('max-width'
|
|
51
|
-
V('min-width'
|
|
52
|
-
V('max-height'
|
|
53
|
-
V('min-height'
|
|
54
|
-
V('padding'
|
|
55
|
-
V('padding-left'
|
|
56
|
-
V('padding-right'
|
|
57
|
-
V('padding-top'
|
|
58
|
-
V('padding-bottom'
|
|
59
|
-
V('margin'
|
|
60
|
-
V('margin-left'
|
|
61
|
-
V('margin-right'
|
|
62
|
-
V('margin-top'
|
|
63
|
-
V('margin-bottom'
|
|
64
|
-
V('white-space'
|
|
65
|
-
V('letter-spacing'
|
|
66
|
-
V('text-align'
|
|
67
|
-
V('line-height'
|
|
68
|
-
V('text-overflow'
|
|
69
|
-
V('font-size'
|
|
70
|
-
V('font-weight'
|
|
71
|
-
V('flex'
|
|
72
|
-
V('flex-grow'
|
|
73
|
-
V('flex-shrink'
|
|
74
|
-
V('flex-basis'
|
|
75
|
-
V('flex-direction'
|
|
76
|
-
V('flex-wrap'
|
|
77
|
-
V('align-items'
|
|
78
|
-
V('align-self'
|
|
79
|
-
V('align-content'
|
|
80
|
-
V('justify-content'
|
|
81
|
-
V('background'
|
|
82
|
-
V('border-color'
|
|
83
|
-
V('font-family'
|
|
84
|
-
V('font-style'
|
|
85
|
-
V('transform'
|
|
86
|
-
V('animation'
|
|
87
|
-
V('animation-name'
|
|
88
|
-
V('animation-duration'
|
|
89
|
-
V('animation-timing-function'
|
|
90
|
-
V('animation-delay'
|
|
91
|
-
V('animation-iteration-count'
|
|
92
|
-
V('animation-direction'
|
|
93
|
-
V('animation-fill-mode'
|
|
94
|
-
V('animation-play-state'
|
|
95
|
-
V('line-spacing'
|
|
96
|
-
V('border-style'
|
|
97
|
-
V('order'
|
|
98
|
-
V('box-shadow'
|
|
99
|
-
V('transform-origin'
|
|
100
|
-
V('linear-orientation'
|
|
101
|
-
V('linear-weight-sum'
|
|
102
|
-
V('linear-weight'
|
|
103
|
-
V('linear-gravity'
|
|
104
|
-
V('linear-layout-gravity'
|
|
105
|
-
V('layout-animation-create-duration'
|
|
106
|
-
V('layout-animation-create-timing-function'
|
|
107
|
-
V('layout-animation-create-delay'
|
|
108
|
-
V('layout-animation-create-property'
|
|
109
|
-
V('layout-animation-delete-duration'
|
|
110
|
-
V('layout-animation-delete-timing-function'
|
|
111
|
-
V('layout-animation-delete-delay'
|
|
112
|
-
V('layout-animation-delete-property'
|
|
113
|
-
V('layout-animation-update-duration'
|
|
114
|
-
V('layout-animation-update-timing-function'
|
|
115
|
-
V('layout-animation-update-delay'
|
|
116
|
-
V('adapt-font-size'
|
|
117
|
-
V('aspect-ratio'
|
|
118
|
-
V('text-decoration'
|
|
119
|
-
V('text-shadow'
|
|
120
|
-
V('background-image'
|
|
121
|
-
V('background-position'
|
|
122
|
-
V('background-origin'
|
|
123
|
-
V('background-repeat'
|
|
124
|
-
V('background-size'
|
|
125
|
-
V('border'
|
|
126
|
-
V('visibility'
|
|
127
|
-
V('border-right'
|
|
128
|
-
V('border-left'
|
|
129
|
-
V('border-top'
|
|
130
|
-
V('border-bottom'
|
|
131
|
-
V('transition'
|
|
132
|
-
V('transition-property'
|
|
133
|
-
V('transition-duration'
|
|
134
|
-
V('transition-delay'
|
|
135
|
-
V('transition-timing-function'
|
|
136
|
-
V('content'
|
|
137
|
-
V('border-left-style'
|
|
138
|
-
V('border-right-style'
|
|
139
|
-
V('border-top-style'
|
|
140
|
-
V('border-bottom-style'
|
|
141
|
-
V('implicit-animation'
|
|
142
|
-
V('overflow-x'
|
|
143
|
-
V('overflow-y'
|
|
144
|
-
V('word-break'
|
|
145
|
-
V('background-clip'
|
|
146
|
-
V('outline'
|
|
147
|
-
V('outline-color'
|
|
148
|
-
V('outline-style'
|
|
149
|
-
V('outline-width'
|
|
150
|
-
V('vertical-align'
|
|
151
|
-
V('caret-color'
|
|
152
|
-
V('direction'
|
|
153
|
-
V('relative-id'
|
|
154
|
-
V('relative-align-top'
|
|
155
|
-
V('relative-align-right'
|
|
156
|
-
V('relative-align-bottom'
|
|
157
|
-
V('relative-align-left'
|
|
158
|
-
V('relative-top-of'
|
|
159
|
-
V('relative-right-of'
|
|
160
|
-
V('relative-bottom-of'
|
|
161
|
-
V('relative-left-of'
|
|
162
|
-
V('relative-layout-once'
|
|
163
|
-
V('relative-center'
|
|
164
|
-
V('enter-transition-name'
|
|
165
|
-
V('exit-transition-name'
|
|
166
|
-
V('pause-transition-name'
|
|
167
|
-
V('resume-transition-name'
|
|
168
|
-
V('flex-flow'
|
|
169
|
-
V('z-index'
|
|
170
|
-
V('text-decoration-color'
|
|
171
|
-
V('linear-cross-gravity'
|
|
172
|
-
V('margin-inline-start'
|
|
173
|
-
V('margin-inline-end'
|
|
174
|
-
V('padding-inline-start'
|
|
175
|
-
V('padding-inline-end'
|
|
176
|
-
V('border-inline-start-color'
|
|
177
|
-
V('border-inline-end-color'
|
|
178
|
-
V('border-inline-start-width'
|
|
179
|
-
V('border-inline-end-width'
|
|
180
|
-
V('border-inline-start-style'
|
|
181
|
-
V('border-inline-end-style'
|
|
182
|
-
V('border-start-start-radius'
|
|
183
|
-
V('border-end-start-radius'
|
|
184
|
-
V('border-start-end-radius'
|
|
185
|
-
V('border-end-end-radius'
|
|
186
|
-
V('relative-align-inline-start'
|
|
187
|
-
V('relative-align-inline-end'
|
|
188
|
-
V('relative-inline-start-of'
|
|
189
|
-
V('relative-inline-end-of'
|
|
190
|
-
V('inset-inline-start'
|
|
191
|
-
V('inset-inline-end'
|
|
192
|
-
V('mask-image'
|
|
193
|
-
V('grid-template-columns'
|
|
194
|
-
V('grid-template-rows'
|
|
195
|
-
V('grid-auto-columns'
|
|
196
|
-
V('grid-auto-rows'
|
|
197
|
-
V('grid-column-span'
|
|
198
|
-
V('grid-row-span'
|
|
199
|
-
V('grid-column-start'
|
|
200
|
-
V('grid-column-end'
|
|
201
|
-
V('grid-row-start'
|
|
202
|
-
V('grid-row-end'
|
|
203
|
-
V('grid-column-gap'
|
|
204
|
-
V('grid-row-gap'
|
|
205
|
-
V('justify-items'
|
|
206
|
-
V('justify-self'
|
|
207
|
-
V('grid-auto-flow'
|
|
208
|
-
V('filter'
|
|
209
|
-
V('list-main-axis-gap'
|
|
210
|
-
V('list-cross-axis-gap'
|
|
211
|
-
V('linear-direction'
|
|
212
|
-
V('perspective'
|
|
213
|
-
V('cursor'
|
|
214
|
-
V('text-indent'
|
|
215
|
-
V('clip-path'
|
|
216
|
-
V('text-stroke'
|
|
217
|
-
V('text-stroke-width'
|
|
218
|
-
V('text-stroke-color'
|
|
219
|
-
V('-x-auto-font-size'
|
|
220
|
-
V('-x-auto-font-size-preset-sizes'
|
|
24
|
+
V('top');
|
|
25
|
+
V('left');
|
|
26
|
+
V('right');
|
|
27
|
+
V('bottom');
|
|
28
|
+
V('position');
|
|
29
|
+
V('box-sizing');
|
|
30
|
+
V('background-color');
|
|
31
|
+
V('border-left-color');
|
|
32
|
+
V('border-right-color');
|
|
33
|
+
V('border-top-color');
|
|
34
|
+
V('border-bottom-color');
|
|
35
|
+
V('border-radius');
|
|
36
|
+
V('border-top-left-radius');
|
|
37
|
+
V('border-bottom-left-radius');
|
|
38
|
+
V('border-top-right-radius');
|
|
39
|
+
V('border-bottom-right-radius');
|
|
40
|
+
V('border-width');
|
|
41
|
+
V('border-left-width');
|
|
42
|
+
V('border-right-width');
|
|
43
|
+
V('border-top-width');
|
|
44
|
+
V('border-bottom-width');
|
|
45
|
+
V('color');
|
|
46
|
+
V('opacity');
|
|
47
|
+
V('display');
|
|
48
|
+
V('overflow');
|
|
49
|
+
V('height');
|
|
50
|
+
V('width');
|
|
51
|
+
V('max-width');
|
|
52
|
+
V('min-width');
|
|
53
|
+
V('max-height');
|
|
54
|
+
V('min-height');
|
|
55
|
+
V('padding');
|
|
56
|
+
V('padding-left');
|
|
57
|
+
V('padding-right');
|
|
58
|
+
V('padding-top');
|
|
59
|
+
V('padding-bottom');
|
|
60
|
+
V('margin');
|
|
61
|
+
V('margin-left');
|
|
62
|
+
V('margin-right');
|
|
63
|
+
V('margin-top');
|
|
64
|
+
V('margin-bottom');
|
|
65
|
+
V('white-space');
|
|
66
|
+
V('letter-spacing');
|
|
67
|
+
V('text-align');
|
|
68
|
+
V('line-height');
|
|
69
|
+
V('text-overflow');
|
|
70
|
+
V('font-size');
|
|
71
|
+
V('font-weight');
|
|
72
|
+
V('flex');
|
|
73
|
+
V('flex-grow');
|
|
74
|
+
V('flex-shrink');
|
|
75
|
+
V('flex-basis');
|
|
76
|
+
V('flex-direction');
|
|
77
|
+
V('flex-wrap');
|
|
78
|
+
V('align-items');
|
|
79
|
+
V('align-self');
|
|
80
|
+
V('align-content');
|
|
81
|
+
V('justify-content');
|
|
82
|
+
V('background');
|
|
83
|
+
V('border-color');
|
|
84
|
+
V('font-family');
|
|
85
|
+
V('font-style');
|
|
86
|
+
V('transform');
|
|
87
|
+
V('animation');
|
|
88
|
+
V('animation-name');
|
|
89
|
+
V('animation-duration');
|
|
90
|
+
V('animation-timing-function');
|
|
91
|
+
V('animation-delay');
|
|
92
|
+
V('animation-iteration-count');
|
|
93
|
+
V('animation-direction');
|
|
94
|
+
V('animation-fill-mode');
|
|
95
|
+
V('animation-play-state');
|
|
96
|
+
V('line-spacing');
|
|
97
|
+
V('border-style');
|
|
98
|
+
V('order');
|
|
99
|
+
V('box-shadow');
|
|
100
|
+
V('transform-origin');
|
|
101
|
+
V('linear-orientation');
|
|
102
|
+
V('linear-weight-sum');
|
|
103
|
+
V('linear-weight');
|
|
104
|
+
V('linear-gravity');
|
|
105
|
+
V('linear-layout-gravity');
|
|
106
|
+
V('layout-animation-create-duration');
|
|
107
|
+
V('layout-animation-create-timing-function');
|
|
108
|
+
V('layout-animation-create-delay');
|
|
109
|
+
V('layout-animation-create-property');
|
|
110
|
+
V('layout-animation-delete-duration');
|
|
111
|
+
V('layout-animation-delete-timing-function');
|
|
112
|
+
V('layout-animation-delete-delay');
|
|
113
|
+
V('layout-animation-delete-property');
|
|
114
|
+
V('layout-animation-update-duration');
|
|
115
|
+
V('layout-animation-update-timing-function');
|
|
116
|
+
V('layout-animation-update-delay');
|
|
117
|
+
V('adapt-font-size');
|
|
118
|
+
V('aspect-ratio');
|
|
119
|
+
V('text-decoration');
|
|
120
|
+
V('text-shadow');
|
|
121
|
+
V('background-image');
|
|
122
|
+
V('background-position');
|
|
123
|
+
V('background-origin');
|
|
124
|
+
V('background-repeat');
|
|
125
|
+
V('background-size');
|
|
126
|
+
V('border');
|
|
127
|
+
V('visibility');
|
|
128
|
+
V('border-right');
|
|
129
|
+
V('border-left');
|
|
130
|
+
V('border-top');
|
|
131
|
+
V('border-bottom');
|
|
132
|
+
V('transition');
|
|
133
|
+
V('transition-property');
|
|
134
|
+
V('transition-duration');
|
|
135
|
+
V('transition-delay');
|
|
136
|
+
V('transition-timing-function');
|
|
137
|
+
V('content');
|
|
138
|
+
V('border-left-style');
|
|
139
|
+
V('border-right-style');
|
|
140
|
+
V('border-top-style');
|
|
141
|
+
V('border-bottom-style');
|
|
142
|
+
V('implicit-animation');
|
|
143
|
+
V('overflow-x');
|
|
144
|
+
V('overflow-y');
|
|
145
|
+
V('word-break');
|
|
146
|
+
V('background-clip');
|
|
147
|
+
V('outline');
|
|
148
|
+
V('outline-color');
|
|
149
|
+
V('outline-style');
|
|
150
|
+
V('outline-width');
|
|
151
|
+
V('vertical-align');
|
|
152
|
+
V('caret-color');
|
|
153
|
+
V('direction');
|
|
154
|
+
V('relative-id');
|
|
155
|
+
V('relative-align-top');
|
|
156
|
+
V('relative-align-right');
|
|
157
|
+
V('relative-align-bottom');
|
|
158
|
+
V('relative-align-left');
|
|
159
|
+
V('relative-top-of');
|
|
160
|
+
V('relative-right-of');
|
|
161
|
+
V('relative-bottom-of');
|
|
162
|
+
V('relative-left-of');
|
|
163
|
+
V('relative-layout-once');
|
|
164
|
+
V('relative-center');
|
|
165
|
+
V('enter-transition-name');
|
|
166
|
+
V('exit-transition-name');
|
|
167
|
+
V('pause-transition-name');
|
|
168
|
+
V('resume-transition-name');
|
|
169
|
+
V('flex-flow');
|
|
170
|
+
V('z-index');
|
|
171
|
+
V('text-decoration-color');
|
|
172
|
+
V('linear-cross-gravity');
|
|
173
|
+
V('margin-inline-start');
|
|
174
|
+
V('margin-inline-end');
|
|
175
|
+
V('padding-inline-start');
|
|
176
|
+
V('padding-inline-end');
|
|
177
|
+
V('border-inline-start-color');
|
|
178
|
+
V('border-inline-end-color');
|
|
179
|
+
V('border-inline-start-width');
|
|
180
|
+
V('border-inline-end-width');
|
|
181
|
+
V('border-inline-start-style');
|
|
182
|
+
V('border-inline-end-style');
|
|
183
|
+
V('border-start-start-radius');
|
|
184
|
+
V('border-end-start-radius');
|
|
185
|
+
V('border-start-end-radius');
|
|
186
|
+
V('border-end-end-radius');
|
|
187
|
+
V('relative-align-inline-start');
|
|
188
|
+
V('relative-align-inline-end');
|
|
189
|
+
V('relative-inline-start-of');
|
|
190
|
+
V('relative-inline-end-of');
|
|
191
|
+
V('inset-inline-start');
|
|
192
|
+
V('inset-inline-end');
|
|
193
|
+
V('mask-image');
|
|
194
|
+
V('grid-template-columns');
|
|
195
|
+
V('grid-template-rows');
|
|
196
|
+
V('grid-auto-columns');
|
|
197
|
+
V('grid-auto-rows');
|
|
198
|
+
V('grid-column-span');
|
|
199
|
+
V('grid-row-span');
|
|
200
|
+
V('grid-column-start');
|
|
201
|
+
V('grid-column-end');
|
|
202
|
+
V('grid-row-start');
|
|
203
|
+
V('grid-row-end');
|
|
204
|
+
V('grid-column-gap');
|
|
205
|
+
V('grid-row-gap');
|
|
206
|
+
V('justify-items');
|
|
207
|
+
V('justify-self');
|
|
208
|
+
V('grid-auto-flow');
|
|
209
|
+
V('filter');
|
|
210
|
+
V('list-main-axis-gap');
|
|
211
|
+
V('list-cross-axis-gap');
|
|
212
|
+
V('linear-direction');
|
|
213
|
+
V('perspective');
|
|
214
|
+
V('cursor');
|
|
215
|
+
V('text-indent');
|
|
216
|
+
V('clip-path');
|
|
217
|
+
V('text-stroke');
|
|
218
|
+
V('text-stroke-width');
|
|
219
|
+
V('text-stroke-color');
|
|
220
|
+
V('-x-auto-font-size');
|
|
221
|
+
V('-x-auto-font-size-preset-sizes');
|
|
222
|
+
V('mask');
|
|
223
|
+
V('mask-repeat');
|
|
224
|
+
V('mask-position');
|
|
225
|
+
V('mask-clip');
|
|
226
|
+
V('mask-origin');
|
|
227
|
+
V('mask-size');
|
|
228
|
+
V('gap');
|
|
229
|
+
V('column-gap');
|
|
230
|
+
V('row-gap');
|
|
231
|
+
V('image-rendering');
|
|
232
|
+
V('hyphens');
|
|
233
|
+
V('-x-app-region');
|
|
234
|
+
V('-x-animation-color-interpolation');
|
|
235
|
+
V('-x-handle-color');
|
|
236
|
+
V('-x-handle-size');
|
|
237
|
+
V('offset-path');
|
|
238
|
+
V('offset-distance');
|
|
221
239
|
export function queryCSSProperty(index) {
|
|
222
240
|
return cssPropertyMap[index];
|
|
223
241
|
}
|
|
@@ -32,7 +32,11 @@ export function createStyleFunctions(runtime, cssInJsInfo) {
|
|
|
32
32
|
function __AddInlineStyle(element, key, value) {
|
|
33
33
|
let dashName;
|
|
34
34
|
if (typeof key === 'number') {
|
|
35
|
-
|
|
35
|
+
const queryResult = queryCSSProperty(key);
|
|
36
|
+
dashName = queryResult.dashName;
|
|
37
|
+
if (queryResult.isX) {
|
|
38
|
+
console.error(`[lynx-web] css property: ${dashName} is not supported.`);
|
|
39
|
+
}
|
|
36
40
|
}
|
|
37
41
|
else {
|
|
38
42
|
dashName = key;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
|
+
export { loadMainThread } from './loadMainThread.js';
|
|
4
5
|
export * from './MainThreadRuntime.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Rpc, type MainThreadStartConfigs, type RpcCallType, type reportErrorEndpoint } from '@lynx-js/web-constants';
|
|
2
|
+
import { MainThreadRuntime } from './MainThreadRuntime.js';
|
|
3
|
+
export declare function loadMainThread(backgroundThreadRpc: Rpc, docu: Pick<Document, 'append' | 'createElement' | 'addEventListener'>, commitDocument: () => Promise<void> | void, markTimingInternal: (timingKey: string, pipelineId?: string) => void, reportError: RpcCallType<typeof reportErrorEndpoint>): {
|
|
4
|
+
startMainThread: (config: MainThreadStartConfigs) => Promise<MainThreadRuntime>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Copyright 2023 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 { BackgroundThreadStartEndpoint, publishEventEndpoint, publicComponentEventEndpoint, postExposureEndpoint, switchExposureServiceEndpoint, postTimingFlagsEndpoint, dispatchCoreContextOnBackgroundEndpoint, dispatchJSContextOnMainThreadEndpoint, LynxCrossThreadContext, } from '@lynx-js/web-constants';
|
|
5
|
+
import { registerCallLepusMethodHandler } from './crossThreadHandlers/registerCallLepusMethodHandler.js';
|
|
6
|
+
import { registerGetCustomSectionHandler } from './crossThreadHandlers/registerGetCustomSectionHandler.js';
|
|
7
|
+
import { MainThreadRuntime, switchExposureService, } from './MainThreadRuntime.js';
|
|
8
|
+
const moduleCache = {};
|
|
9
|
+
export function loadMainThread(backgroundThreadRpc, docu, commitDocument, markTimingInternal, reportError) {
|
|
10
|
+
const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
|
|
11
|
+
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
12
|
+
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
13
|
+
const publicComponentEvent = backgroundThreadRpc.createCall(publicComponentEventEndpoint);
|
|
14
|
+
const postExposure = backgroundThreadRpc.createCall(postExposureEndpoint);
|
|
15
|
+
markTimingInternal('lepus_execute_start');
|
|
16
|
+
async function startMainThread(config) {
|
|
17
|
+
let isFp = true;
|
|
18
|
+
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, } = config;
|
|
19
|
+
const { styleInfo, pageConfig, customSections, cardType, lepusCode } = template;
|
|
20
|
+
markTimingInternal('decode_start');
|
|
21
|
+
const lepusCodeEntries = await Promise.all(Object.entries(lepusCode).map(async ([name, url]) => {
|
|
22
|
+
const cachedModule = moduleCache[name];
|
|
23
|
+
if (cachedModule) {
|
|
24
|
+
return [name, cachedModule];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
Object.assign(globalThis, { module: {} });
|
|
28
|
+
await import(/* webpackIgnore: true */ url);
|
|
29
|
+
const module = globalThis.module;
|
|
30
|
+
Object.assign(globalThis, { module: {} });
|
|
31
|
+
moduleCache[name] = module;
|
|
32
|
+
return [name, module];
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
const lepusCodeLoaded = Object.fromEntries(lepusCodeEntries);
|
|
36
|
+
const entry = lepusCodeLoaded['root'].exports;
|
|
37
|
+
const jsContext = new LynxCrossThreadContext({
|
|
38
|
+
rpc: backgroundThreadRpc,
|
|
39
|
+
receiveEventEndpoint: dispatchJSContextOnMainThreadEndpoint,
|
|
40
|
+
sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint,
|
|
41
|
+
});
|
|
42
|
+
const runtime = new MainThreadRuntime({
|
|
43
|
+
jsContext,
|
|
44
|
+
tagMap,
|
|
45
|
+
browserConfig,
|
|
46
|
+
customSections,
|
|
47
|
+
globalProps,
|
|
48
|
+
pageConfig,
|
|
49
|
+
styleInfo,
|
|
50
|
+
lepusCode: lepusCodeLoaded,
|
|
51
|
+
docu,
|
|
52
|
+
callbacks: {
|
|
53
|
+
mainChunkReady: () => {
|
|
54
|
+
markTimingInternal('data_processor_start');
|
|
55
|
+
const initData = runtime.processData
|
|
56
|
+
? runtime.processData(config.initData)
|
|
57
|
+
: config.initData;
|
|
58
|
+
markTimingInternal('data_processor_end');
|
|
59
|
+
registerCallLepusMethodHandler(backgroundThreadRpc, runtime);
|
|
60
|
+
registerGetCustomSectionHandler(backgroundThreadRpc, customSections);
|
|
61
|
+
backgroundThreadRpc.registerHandler(switchExposureServiceEndpoint, runtime[switchExposureService]);
|
|
62
|
+
backgroundStart({
|
|
63
|
+
initData,
|
|
64
|
+
globalProps,
|
|
65
|
+
template,
|
|
66
|
+
cardType: cardType ?? 'react',
|
|
67
|
+
customSections: Object.fromEntries(Object.entries(customSections).filter(([, value]) => value.type !== 'lazy').map(([k, v]) => [k, v.content])),
|
|
68
|
+
nativeModulesMap,
|
|
69
|
+
napiModulesMap,
|
|
70
|
+
browserConfig,
|
|
71
|
+
});
|
|
72
|
+
runtime.renderPage(initData);
|
|
73
|
+
runtime.__FlushElementTree(undefined, {});
|
|
74
|
+
},
|
|
75
|
+
flushElementTree: async (options, timingFlags) => {
|
|
76
|
+
const pipelineId = options?.pipelineOptions?.pipelineID;
|
|
77
|
+
markTimingInternal('dispatch_start', pipelineId);
|
|
78
|
+
if (isFp) {
|
|
79
|
+
isFp = false;
|
|
80
|
+
jsContext.dispatchEvent({
|
|
81
|
+
type: '__OnNativeAppReady',
|
|
82
|
+
data: undefined,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
markTimingInternal('layout_start', pipelineId);
|
|
86
|
+
markTimingInternal('ui_operation_flush_start', pipelineId);
|
|
87
|
+
await commitDocument();
|
|
88
|
+
markTimingInternal('ui_operation_flush_end', pipelineId);
|
|
89
|
+
markTimingInternal('layout_end', pipelineId);
|
|
90
|
+
markTimingInternal('dispatch_end', pipelineId);
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
postTimingFlags(timingFlags, pipelineId);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
_ReportError: reportError,
|
|
96
|
+
__OnLifecycleEvent: (data) => {
|
|
97
|
+
jsContext.dispatchEvent({
|
|
98
|
+
type: '__OnLifecycleEvent',
|
|
99
|
+
data,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Note :
|
|
104
|
+
* The parameter of lynx.performance.markTiming is (pipelineId:string, timingFlag:string)=>void
|
|
105
|
+
* But our markTimingInternal is (timingFlag:string, pipelineId?:string, timeStamp?:number) => void
|
|
106
|
+
*/
|
|
107
|
+
markTiming: (a, b) => markTimingInternal(b, a),
|
|
108
|
+
publishEvent,
|
|
109
|
+
publicComponentEvent,
|
|
110
|
+
postExposure,
|
|
111
|
+
},
|
|
112
|
+
}).globalThis;
|
|
113
|
+
markTimingInternal('decode_end');
|
|
114
|
+
entry(runtime);
|
|
115
|
+
jsContext.__start(); // start the jsContext after the runtime is created
|
|
116
|
+
return runtime;
|
|
117
|
+
}
|
|
118
|
+
return { startMainThread };
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=loadMainThread.js.map
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { elementToRuntimeInfoMap, } from '../MainThreadRuntime.js';
|
|
2
|
+
function toCloneableObject(obj) {
|
|
3
|
+
const cloneableObj = {};
|
|
4
|
+
for (const key in obj) {
|
|
5
|
+
const value = obj[key];
|
|
6
|
+
if (typeof value === 'boolean' || typeof value === 'number'
|
|
7
|
+
|| typeof value === 'string' || value === null) {
|
|
8
|
+
cloneableObj[key] = value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return cloneableObj;
|
|
12
|
+
}
|
|
2
13
|
export function createCrossThreadEvent(runtime, domEvent, eventName) {
|
|
3
14
|
const targetElement = domEvent.target;
|
|
4
15
|
const currentTargetElement = domEvent
|
|
5
16
|
.currentTarget;
|
|
6
17
|
const type = domEvent.type;
|
|
7
18
|
const params = {};
|
|
19
|
+
const isTrusted = domEvent.isTrusted;
|
|
20
|
+
const otherProperties = {};
|
|
8
21
|
if (type.match(/^transition/)) {
|
|
9
22
|
Object.assign(params, {
|
|
10
23
|
'animation_type': 'keyframe-animation',
|
|
@@ -19,6 +32,21 @@ export function createCrossThreadEvent(runtime, domEvent, eventName) {
|
|
|
19
32
|
new_animator: true, // we support the new_animator only
|
|
20
33
|
});
|
|
21
34
|
}
|
|
35
|
+
else if (type.startsWith('touch')) {
|
|
36
|
+
const touchEvent = domEvent;
|
|
37
|
+
const touch = [...touchEvent.touches];
|
|
38
|
+
const targetTouches = [...touchEvent.targetTouches];
|
|
39
|
+
const changedTouches = [...touchEvent.changedTouches];
|
|
40
|
+
Object.assign(otherProperties, {
|
|
41
|
+
touches: isTrusted ? touch.map(toCloneableObject) : touch,
|
|
42
|
+
targetTouches: isTrusted
|
|
43
|
+
? targetTouches.map(toCloneableObject)
|
|
44
|
+
: targetTouches,
|
|
45
|
+
changedTouches: isTrusted
|
|
46
|
+
? changedTouches.map(toCloneableObject)
|
|
47
|
+
: changedTouches,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
22
50
|
const targetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(targetElement);
|
|
23
51
|
const currentTargetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(currentTargetElement);
|
|
24
52
|
return {
|
|
@@ -39,6 +67,7 @@ export function createCrossThreadEvent(runtime, domEvent, eventName) {
|
|
|
39
67
|
// @ts-expect-error
|
|
40
68
|
detail: domEvent.detail ?? {},
|
|
41
69
|
params,
|
|
70
|
+
...otherProperties,
|
|
42
71
|
};
|
|
43
72
|
}
|
|
44
73
|
//# sourceMappingURL=createCrossThreadEvent.js.map
|
|
@@ -34,11 +34,9 @@ export function transformToWebCss(styleInfo) {
|
|
|
34
34
|
rule.decl = transformedStyle;
|
|
35
35
|
if (childStyle.length > 0) {
|
|
36
36
|
cssInfos.rules.push({
|
|
37
|
-
sel: selectors.map(selector =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
selector[2],
|
|
41
|
-
]),
|
|
37
|
+
sel: selectors.map(selector => selector.toSpliced(-2, 1,
|
|
38
|
+
/* replace the last combinator and insert at the end */
|
|
39
|
+
['>'], ['*'], [], [], [])),
|
|
42
40
|
decl: childStyle,
|
|
43
41
|
});
|
|
44
42
|
}
|
|
@@ -50,7 +48,7 @@ export function transformToWebCss(styleInfo) {
|
|
|
50
48
|
*/
|
|
51
49
|
export function genCssContent(styleInfo, pageConfig) {
|
|
52
50
|
function getExtraSelectors(cssId) {
|
|
53
|
-
let
|
|
51
|
+
let suffix = '';
|
|
54
52
|
if (!pageConfig.enableRemoveCSSScope) {
|
|
55
53
|
if (cssId !== undefined) {
|
|
56
54
|
suffix += `[${cssIdAttribute}="${cssId}"]`;
|
|
@@ -63,21 +61,16 @@ export function genCssContent(styleInfo, pageConfig) {
|
|
|
63
61
|
else {
|
|
64
62
|
suffix += `[${lynxTagAttribute}]`;
|
|
65
63
|
}
|
|
66
|
-
return
|
|
64
|
+
return suffix;
|
|
67
65
|
}
|
|
68
66
|
const finalCssContent = [];
|
|
69
67
|
for (const [cssId, cssInfos] of Object.entries(styleInfo)) {
|
|
70
|
-
const
|
|
68
|
+
const suffix = getExtraSelectors(cssId);
|
|
71
69
|
const declarationContent = cssInfos.rules.map((rule) => {
|
|
72
|
-
const { sel:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
plainSelectors.join(''),
|
|
77
|
-
suffix,
|
|
78
|
-
pseudoClassSelectors.join(''),
|
|
79
|
-
pseudoElementSelectors.join(''),
|
|
80
|
-
].join('');
|
|
70
|
+
const { sel: selectorList, decl: declarations } = rule;
|
|
71
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
|
|
72
|
+
const selectorString = selectorList.map((selectors) => {
|
|
73
|
+
return selectors.toSpliced(-4, 0, [suffix]).join('');
|
|
81
74
|
}).join(',');
|
|
82
75
|
const declarationString = declarations.map(([k, v]) => `${k}:${v};`).join('');
|
|
83
76
|
return `${selectorString}{${declarationString}}`;
|
|
@@ -94,10 +87,13 @@ export function genCssInJsInfo(styleInfo) {
|
|
|
94
87
|
const oneCssInJsInfo = {};
|
|
95
88
|
cssInfos.rules = cssInfos.rules.filter(oneCssInfo => {
|
|
96
89
|
oneCssInfo.sel = oneCssInfo.sel.filter(selectorList => {
|
|
97
|
-
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors] = selectorList;
|
|
98
|
-
if (
|
|
90
|
+
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors, combinator,] = selectorList;
|
|
91
|
+
if (
|
|
92
|
+
// only one class selector
|
|
93
|
+
classSelectors.length === 1 && classSelectors[0][0] === '.'
|
|
99
94
|
&& pseudoClassSelectors.length === 0
|
|
100
|
-
&& pseudoElementSelectors.length === 0
|
|
95
|
+
&& pseudoElementSelectors.length === 0
|
|
96
|
+
&& combinator.length === 0) {
|
|
101
97
|
const selectorName = classSelectors[0].substring(1);
|
|
102
98
|
const currentDeclarations = oneCssInJsInfo[selectorName];
|
|
103
99
|
if (currentDeclarations) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"css-tree": "^3.1.0",
|
|
27
27
|
"hyphenate-style-name": "^1.1.0",
|
|
28
|
-
"@lynx-js/web-constants": "0.
|
|
28
|
+
"@lynx-js/web-constants": "0.13.1",
|
|
29
29
|
"@lynx-js/web-style-transformer": "0.3.0"
|
|
30
30
|
}
|
|
31
31
|
}
|