@lynx-js/web-mainthread-apis 0.11.0 → 0.12.0
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 +23 -0
- package/dist/MainThreadLynx.d.ts +1 -1
- package/dist/MainThreadLynx.js +1 -2
- package/dist/MainThreadRuntime.d.ts +2 -1
- package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.d.ts +1 -1
- package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.js +6 -1
- package/dist/elementAPI/event/eventFunctions.js +8 -2
- package/dist/elementAPI/style/styleFunctions.js +9 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: fully support MTS ([#569](https://github.com/lynx-family/lynx-stack/pull/569))
|
|
8
|
+
|
|
9
|
+
Now use support the following usage
|
|
10
|
+
|
|
11
|
+
- mainthread event
|
|
12
|
+
- mainthread ref
|
|
13
|
+
- runOnMainThread/runOnBackground
|
|
14
|
+
- ref.current.xx
|
|
15
|
+
|
|
16
|
+
- feat: support mts event with target methods ([#564](https://github.com/lynx-family/lynx-stack/pull/564))
|
|
17
|
+
|
|
18
|
+
After this commit, developers are allowed to invoke `event.target.setStyleProperty` in mts handler
|
|
19
|
+
|
|
20
|
+
- fix: crash on removing a id attribute ([#582](https://github.com/lynx-family/lynx-stack/pull/582))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`f1ca29b`](https://github.com/lynx-family/lynx-stack/commit/f1ca29bd766377dd46583f15e1e75bca447699cd), [`7edf478`](https://github.com/lynx-family/lynx-stack/commit/7edf478410cb57eeedc18aac6f5d3950b16c7fa8)]:
|
|
23
|
+
- @lynx-js/web-constants@0.12.0
|
|
24
|
+
- @lynx-js/web-style-transformer@0.3.0
|
|
25
|
+
|
|
3
26
|
## 0.11.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/MainThreadLynx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MainThreadConfig, MainThreadRuntime } from './MainThreadRuntime.js';
|
|
2
2
|
export declare function createMainThreadLynx(config: MainThreadConfig, lepusRuntime: MainThreadRuntime): {
|
|
3
|
-
getJSContext():
|
|
3
|
+
getJSContext(): import("@lynx-js/web-constants").LynxContextEventTarget;
|
|
4
4
|
requestAnimationFrame(cb: FrameRequestCallback): number;
|
|
5
5
|
cancelAnimationFrame(handler: number): void;
|
|
6
6
|
__globalProps: unknown;
|
package/dist/MainThreadLynx.js
CHANGED
|
@@ -2,8 +2,7 @@ import { MainThreadRuntime, } from './MainThreadRuntime.js';
|
|
|
2
2
|
export function createMainThreadLynx(config, lepusRuntime) {
|
|
3
3
|
return {
|
|
4
4
|
getJSContext() {
|
|
5
|
-
|
|
6
|
-
return new EventTarget();
|
|
5
|
+
return config.jsContext;
|
|
7
6
|
},
|
|
8
7
|
requestAnimationFrame(cb) {
|
|
9
8
|
return requestAnimationFrame(cb);
|
|
@@ -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 } 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 } 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 {
|
|
@@ -21,6 +21,7 @@ export interface MainThreadConfig {
|
|
|
21
21
|
browserConfig: BrowserConfig;
|
|
22
22
|
tagMap: Record<string, string>;
|
|
23
23
|
docu: Pick<Document, 'append' | 'createElement' | 'addEventListener'>;
|
|
24
|
+
jsContext: LynxContextEventTarget;
|
|
24
25
|
}
|
|
25
26
|
export declare const elementToRuntimeInfoMap: unique symbol;
|
|
26
27
|
export declare const getElementByUniqueId: unique symbol;
|
|
@@ -21,7 +21,7 @@ export declare function createAttributeAndPropertyFunctions(runtime: MainThreadR
|
|
|
21
21
|
__GetTag: (element: HTMLElement) => string;
|
|
22
22
|
__SetConfig: (element: HTMLElement, config: Record<string, any>) => void;
|
|
23
23
|
__SetDataset: (element: HTMLElement, dataset: Record<string, any>) => void;
|
|
24
|
-
__SetID: (element: HTMLElement, id: string) => void;
|
|
24
|
+
__SetID: (element: HTMLElement, id: string | null) => void;
|
|
25
25
|
__UpdateComponentID: (element: HTMLElement, componentID: string) => void;
|
|
26
26
|
__UpdateListCallbacks: (element: HTMLElement, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => void;
|
|
27
27
|
__GetConfig: (element: HTMLElement) => Record<string, import("@lynx-js/web-constants").Cloneable>;
|
|
@@ -57,7 +57,12 @@ export function createAttributeAndPropertyFunctions(runtime) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function __SetID(element, id) {
|
|
60
|
-
|
|
60
|
+
if (typeof id === 'string') {
|
|
61
|
+
element.id = id;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
element.removeAttribute('id');
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
function __UpdateComponentID(element, componentID) {
|
|
63
68
|
element.setAttribute(componentIdAttribute, componentID);
|
|
@@ -18,8 +18,8 @@ export function createEventFunctions(runtime) {
|
|
|
18
18
|
?.handler
|
|
19
19
|
: runtimeInfo.eventHandlerMap[lynxEventName]?.bind
|
|
20
20
|
?.handler;
|
|
21
|
+
const crossThreadEvent = createCrossThreadEvent(runtime, event, lynxEventName);
|
|
21
22
|
if (typeof hname === 'string') {
|
|
22
|
-
const crossThreadEvent = createCrossThreadEvent(runtime, event, lynxEventName);
|
|
23
23
|
const parentComponentUniqueId = runtimeInfo.parentComponentUniqueId;
|
|
24
24
|
const parentComponent = runtime[getElementByUniqueId](Number(parentComponentUniqueId));
|
|
25
25
|
const componentId = parentComponent?.getAttribute(lynxTagAttribute) !== 'page'
|
|
@@ -34,7 +34,13 @@ export function createEventFunctions(runtime) {
|
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
else if (hname) {
|
|
37
|
-
|
|
37
|
+
crossThreadEvent.target.elementRefptr =
|
|
38
|
+
event.target;
|
|
39
|
+
if (crossThreadEvent.currentTarget) {
|
|
40
|
+
crossThreadEvent.currentTarget
|
|
41
|
+
.elementRefptr = event.currentTarget;
|
|
42
|
+
}
|
|
43
|
+
runtime.runWorklet?.(hname.value, [crossThreadEvent]);
|
|
38
44
|
}
|
|
39
45
|
return false;
|
|
40
46
|
};
|
|
@@ -30,14 +30,20 @@ export function createStyleFunctions(runtime, cssInJsInfo) {
|
|
|
30
30
|
return (element.className ?? '').split(' ').filter(e => e);
|
|
31
31
|
}
|
|
32
32
|
function __AddInlineStyle(element, key, value) {
|
|
33
|
-
|
|
33
|
+
let dashName;
|
|
34
|
+
if (typeof key === 'number') {
|
|
35
|
+
dashName = queryCSSProperty(key).dashName;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
dashName = key;
|
|
39
|
+
}
|
|
34
40
|
const valueStr = typeof value === 'number' ? value.toString() : value;
|
|
35
41
|
if (!valueStr) { // null or undefined
|
|
36
|
-
element.style.removeProperty(
|
|
42
|
+
element.style.removeProperty(dashName);
|
|
37
43
|
}
|
|
38
44
|
else {
|
|
39
45
|
const { transformedStyle } = transfromParsedStyles([[
|
|
40
|
-
|
|
46
|
+
dashName,
|
|
41
47
|
valueStr,
|
|
42
48
|
]]);
|
|
43
49
|
for (const [property, value] of transformedStyle) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
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.
|
|
29
|
-
"@lynx-js/web-style-transformer": "0.
|
|
28
|
+
"@lynx-js/web-constants": "0.12.0",
|
|
29
|
+
"@lynx-js/web-style-transformer": "0.3.0"
|
|
30
30
|
}
|
|
31
31
|
}
|