@lynx-js/web-mainthread-apis 0.9.1 → 0.10.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 +31 -0
- package/dist/MainThreadLynx.js +13 -6
- package/dist/MainThreadRuntime.d.ts +42 -9
- package/dist/MainThreadRuntime.js +89 -33
- package/dist/elementAPI/ElementThreadElement.d.ts +18 -68
- package/dist/elementAPI/ElementThreadElement.js +1 -269
- package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.d.ts +29 -23
- package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.js +115 -52
- package/dist/elementAPI/domTree/domTreeFunctions.d.ts +11 -13
- package/dist/elementAPI/domTree/domTreeFunctions.js +8 -11
- package/dist/elementAPI/elementCreating/elementCreatingFunctions.d.ts +14 -21
- package/dist/elementAPI/elementCreating/elementCreatingFunctions.js +42 -21
- package/dist/elementAPI/event/eventFunctions.d.ts +16 -14
- package/dist/elementAPI/event/eventFunctions.js +130 -26
- package/dist/elementAPI/style/styleFunctions.d.ts +10 -7
- package/dist/elementAPI/style/styleFunctions.js +66 -52
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/utils/createCrossThreadEvent.d.ts +3 -0
- package/dist/utils/createCrossThreadEvent.js +44 -0
- package/dist/utils/createExposureService.d.ts +4 -0
- package/dist/utils/createExposureService.js +63 -0
- package/package.json +2 -2
- package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.d.ts +0 -5
- package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.js +0 -13
- package/dist/elementAPI/createOffscreenDocument.d.ts +0 -13
- package/dist/elementAPI/createOffscreenDocument.js +0 -18
|
@@ -1,31 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 { componentIdAttribute, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, lynxTagAttribute, W3cEventNameToLynx, } from '@lynx-js/web-constants';
|
|
5
|
+
import { elementToRuntimeInfoMap, getElementByUniqueId, } from '../../MainThreadRuntime.js';
|
|
6
|
+
import { createCrossThreadEvent } from '../../utils/createCrossThreadEvent.js';
|
|
7
|
+
export function createEventFunctions(runtime) {
|
|
8
|
+
const btsHandler = (event) => {
|
|
9
|
+
if (!event.currentTarget) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const currentTarget = event.currentTarget;
|
|
13
|
+
const isCapture = event.eventPhase === Event.CAPTURING_PHASE;
|
|
14
|
+
const lynxEventName = W3cEventNameToLynx[event.type] ?? event.type;
|
|
15
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(currentTarget);
|
|
16
|
+
const hname = isCapture
|
|
17
|
+
? runtimeInfo.eventHandlerMap[lynxEventName]?.capture
|
|
18
|
+
?.handler
|
|
19
|
+
: runtimeInfo.eventHandlerMap[lynxEventName]?.bind
|
|
20
|
+
?.handler;
|
|
21
|
+
if (hname) {
|
|
22
|
+
const crossThreadEvent = createCrossThreadEvent(runtime, event, lynxEventName);
|
|
23
|
+
const parentComponentUniqueId = runtimeInfo.parentComponentUniqueId;
|
|
24
|
+
const parentComponent = runtime[getElementByUniqueId](Number(parentComponentUniqueId));
|
|
25
|
+
const componentId = parentComponent?.getAttribute(lynxTagAttribute) !== 'page'
|
|
26
|
+
? parentComponent?.getAttribute(componentIdAttribute) ?? undefined
|
|
27
|
+
: undefined;
|
|
28
|
+
if (componentId) {
|
|
29
|
+
runtime.config.callbacks.publicComponentEvent(componentId, hname, crossThreadEvent);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
runtime.config.callbacks.publishEvent(hname, crossThreadEvent);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
const btsCatchHandler = (event) => {
|
|
39
|
+
const handlerTriggered = btsHandler(event);
|
|
40
|
+
if (handlerTriggered)
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
};
|
|
43
|
+
function __AddEvent(element, eventType, eventName, newEventHandler // | ((ev: LynxCrossThreadEvent) => void) | undefined,
|
|
44
|
+
) {
|
|
45
|
+
eventName = eventName.toLowerCase();
|
|
46
|
+
const isCatch = eventType === 'catchEvent' || eventType === 'capture-catch';
|
|
47
|
+
const isCapture = eventType.startsWith('capture');
|
|
48
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(element);
|
|
49
|
+
const currentHandler = isCapture
|
|
50
|
+
? runtimeInfo.eventHandlerMap[eventName]?.capture
|
|
51
|
+
: runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
52
|
+
const currentRegisteredHandler = isCatch ? btsCatchHandler : btsHandler;
|
|
53
|
+
if (currentHandler) {
|
|
54
|
+
if (!newEventHandler) {
|
|
55
|
+
/**
|
|
56
|
+
* remove handler
|
|
57
|
+
*/
|
|
58
|
+
element.removeEventListener(eventName, currentRegisteredHandler, {
|
|
59
|
+
capture: isCapture,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
/**
|
|
65
|
+
* append new handler
|
|
66
|
+
*/
|
|
67
|
+
if (newEventHandler) {
|
|
68
|
+
const htmlEventName = LynxEventNameToW3cByTagName[element.tagName]?.[eventName]
|
|
69
|
+
?? LynxEventNameToW3cCommon[eventName] ?? eventName;
|
|
70
|
+
element.addEventListener(htmlEventName, currentRegisteredHandler, {
|
|
71
|
+
capture: isCapture,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (newEventHandler) {
|
|
76
|
+
const info = {
|
|
77
|
+
type: eventType,
|
|
78
|
+
handler: newEventHandler,
|
|
21
79
|
};
|
|
80
|
+
if (!runtimeInfo.eventHandlerMap[eventName]) {
|
|
81
|
+
runtimeInfo.eventHandlerMap[eventName] = {
|
|
82
|
+
capture: undefined,
|
|
83
|
+
bind: undefined,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (isCapture) {
|
|
87
|
+
runtimeInfo.eventHandlerMap[eventName].capture = info;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
runtimeInfo.eventHandlerMap[eventName].bind = info;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function __GetEvent(element, eventName, eventType) {
|
|
95
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(element);
|
|
96
|
+
eventName = eventName.toLowerCase();
|
|
97
|
+
const isCapture = eventType.startsWith('capture');
|
|
98
|
+
const handler = isCapture
|
|
99
|
+
? runtimeInfo.eventHandlerMap[eventName]?.capture
|
|
100
|
+
: runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
101
|
+
return handler?.handler;
|
|
102
|
+
}
|
|
103
|
+
function __GetEvents(element) {
|
|
104
|
+
const eventHandlerMap = runtime[elementToRuntimeInfoMap].get(element).eventHandlerMap;
|
|
105
|
+
const eventInfos = [];
|
|
106
|
+
for (const [lynxEventName, info] of Object.entries(eventHandlerMap)) {
|
|
107
|
+
for (const atomInfo of [info.bind, info.capture]) {
|
|
108
|
+
if (atomInfo) {
|
|
109
|
+
for (const [type, handler] of Object.values(atomInfo)) {
|
|
110
|
+
if (handler) {
|
|
111
|
+
eventInfos.push({
|
|
112
|
+
type: type,
|
|
113
|
+
name: lynxEventName,
|
|
114
|
+
function: handler,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return eventInfos;
|
|
122
|
+
}
|
|
123
|
+
function __SetEvents(element, listeners) {
|
|
124
|
+
for (const { type: eventType, name: lynxEventName, function: eventHandler } of listeners) {
|
|
125
|
+
__AddEvent(element, eventType, lynxEventName, eventHandler);
|
|
22
126
|
}
|
|
23
|
-
return;
|
|
24
|
-
}).filter(e => e);
|
|
25
|
-
}
|
|
26
|
-
export function __SetEvents(element, listeners) {
|
|
27
|
-
for (const { type: eventType, name: lynxEventName, function: eventHandler } of listeners) {
|
|
28
|
-
__AddEvent(element, eventType, lynxEventName, eventHandler);
|
|
29
127
|
}
|
|
128
|
+
return {
|
|
129
|
+
__AddEvent,
|
|
130
|
+
__GetEvent,
|
|
131
|
+
__GetEvents,
|
|
132
|
+
__SetEvents,
|
|
133
|
+
};
|
|
30
134
|
}
|
|
31
135
|
//# sourceMappingURL=eventFunctions.js.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { type CssInJsInfo } from '@lynx-js/web-constants';
|
|
2
|
+
import { type MainThreadRuntime } from '../../MainThreadRuntime.js';
|
|
3
|
+
export declare function createStyleFunctions(runtime: MainThreadRuntime, cssInJsInfo: CssInJsInfo): {
|
|
4
|
+
__AddClass: (element: HTMLElement, className: string) => void;
|
|
5
|
+
__SetClasses: (element: HTMLElement, classNames: string | null) => void;
|
|
6
|
+
__GetClasses: (element: HTMLElement) => string[];
|
|
7
|
+
__AddInlineStyle: (element: HTMLElement, key: number | string, value: string | number | null | undefined) => void;
|
|
8
|
+
__SetInlineStyles: (element: HTMLElement, value: string | Record<string, string> | undefined) => void;
|
|
9
|
+
__SetCSSId: (elements: (HTMLElement)[], cssId: string | number) => void;
|
|
10
|
+
};
|
|
@@ -1,65 +1,79 @@
|
|
|
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.
|
|
1
4
|
import { cssIdAttribute } from '@lynx-js/web-constants';
|
|
2
5
|
import hyphenateStyleName from 'hyphenate-style-name';
|
|
3
6
|
import { queryCSSProperty } from './cssPropertyMap.js';
|
|
4
7
|
import { decodeCssInJs } from '../../utils/decodeCssInJs.js';
|
|
5
8
|
import { transformInlineStyleString, transfromParsedStyles, } from './transformInlineStyle.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
element
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import { elementToRuntimeInfoMap, updateCSSInJsStyle, } from '../../MainThreadRuntime.js';
|
|
10
|
+
export function createStyleFunctions(runtime, cssInJsInfo) {
|
|
11
|
+
function __AddClass(element, className) {
|
|
12
|
+
const newClassName = ((element.className ?? '') + ' ' + className)
|
|
13
|
+
.trim();
|
|
14
|
+
element.setAttribute('class', newClassName);
|
|
15
|
+
if (!runtime.config.pageConfig.enableCSSSelector) {
|
|
16
|
+
const newStyleStr = decodeCssInJs(newClassName, cssInJsInfo, element.getAttribute(cssIdAttribute));
|
|
17
|
+
runtime[updateCSSInJsStyle](runtime[elementToRuntimeInfoMap].get(element).uniqueId, newStyleStr);
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
function __SetClasses(element, classNames) {
|
|
21
|
+
classNames
|
|
22
|
+
? element.setAttribute('class', classNames)
|
|
23
|
+
: element.removeAttribute('class');
|
|
24
|
+
if (!runtime.config.pageConfig.enableCSSSelector) {
|
|
25
|
+
const newStyleStr = decodeCssInJs(classNames ?? '', cssInJsInfo, element.getAttribute(cssIdAttribute));
|
|
26
|
+
runtime[updateCSSInJsStyle](runtime[elementToRuntimeInfoMap].get(element).uniqueId, newStyleStr ?? '');
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (element.attributes.class ?? '').split(' ').filter(e => e);
|
|
26
|
-
}
|
|
27
|
-
export function __AddInlineStyle(element, key, value) {
|
|
28
|
-
const lynxStyleInfo = queryCSSProperty(Number(key));
|
|
29
|
-
if (!value) {
|
|
30
|
-
element.setStyleProperty(lynxStyleInfo.dashName, null);
|
|
31
|
-
return;
|
|
29
|
+
function __GetClasses(element) {
|
|
30
|
+
return (element.className ?? '').split(' ').filter(e => e);
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
function __AddInlineStyle(element, key, value) {
|
|
33
|
+
const lynxStyleInfo = queryCSSProperty(Number(key));
|
|
34
|
+
const valueStr = typeof value === 'number' ? value.toString() : value;
|
|
35
|
+
if (!valueStr) { // null or undefined
|
|
36
|
+
element.style.removeProperty(lynxStyleInfo.dashName);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const { transformedStyle } = transfromParsedStyles([[
|
|
40
|
+
lynxStyleInfo.dashName,
|
|
41
|
+
valueStr,
|
|
42
|
+
]]);
|
|
43
|
+
for (const [property, value] of transformedStyle) {
|
|
44
|
+
element.style.setProperty(property, value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const cls = element.getAttribute('class');
|
|
61
|
-
cls && __SetClasses(element, cls);
|
|
48
|
+
function __SetInlineStyles(element, value) {
|
|
49
|
+
if (!value)
|
|
50
|
+
return;
|
|
51
|
+
const { transformedStyle } = typeof value === 'string'
|
|
52
|
+
? transformInlineStyleString(value)
|
|
53
|
+
: transfromParsedStyles(Object.entries(value).map(([k, value]) => [
|
|
54
|
+
hyphenateStyleName(k),
|
|
55
|
+
value,
|
|
56
|
+
]));
|
|
57
|
+
const transformedStyleStr = transformedStyle.map(([property, value]) => `${property}:${value};`).join('');
|
|
58
|
+
element.setAttribute('style', transformedStyleStr);
|
|
59
|
+
}
|
|
60
|
+
function __SetCSSId(elements, cssId) {
|
|
61
|
+
cssId = cssId.toString();
|
|
62
|
+
for (const element of elements) {
|
|
63
|
+
element.setAttribute(cssIdAttribute, cssId);
|
|
64
|
+
if (!runtime.config.pageConfig.enableCSSSelector) {
|
|
65
|
+
const cls = element.getAttribute('class');
|
|
66
|
+
cls && __SetClasses(element, cls);
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
}
|
|
70
|
+
return {
|
|
71
|
+
__AddClass,
|
|
72
|
+
__SetClasses,
|
|
73
|
+
__GetClasses,
|
|
74
|
+
__AddInlineStyle,
|
|
75
|
+
__SetInlineStyles,
|
|
76
|
+
__SetCSSId,
|
|
77
|
+
};
|
|
64
78
|
}
|
|
65
79
|
//# sourceMappingURL=styleFunctions.js.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,5 +2,4 @@
|
|
|
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
4
|
export * from './MainThreadRuntime.js';
|
|
5
|
-
export { ElementThreadElement } from './elementAPI/ElementThreadElement.js';
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { elementToRuntimeInfoMap, } from '../MainThreadRuntime.js';
|
|
2
|
+
export function createCrossThreadEvent(runtime, domEvent, eventName) {
|
|
3
|
+
const targetElement = domEvent.target;
|
|
4
|
+
const currentTargetElement = domEvent
|
|
5
|
+
.currentTarget;
|
|
6
|
+
const type = domEvent.type;
|
|
7
|
+
const params = {};
|
|
8
|
+
if (type.match(/^transition/)) {
|
|
9
|
+
Object.assign(params, {
|
|
10
|
+
'animation_type': 'keyframe-animation',
|
|
11
|
+
'animation_name': domEvent.propertyName,
|
|
12
|
+
new_animator: true, // we support the new_animator only
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else if (type.match(/animation/)) {
|
|
16
|
+
Object.assign(params, {
|
|
17
|
+
'animation_type': 'keyframe-animation',
|
|
18
|
+
'animation_name': domEvent.animationName,
|
|
19
|
+
new_animator: true, // we support the new_animator only
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const targetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(targetElement);
|
|
23
|
+
const currentTargetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(currentTargetElement);
|
|
24
|
+
return {
|
|
25
|
+
type: eventName,
|
|
26
|
+
timestamp: domEvent.timeStamp,
|
|
27
|
+
target: {
|
|
28
|
+
id: targetElement.id,
|
|
29
|
+
dataset: targetElementRuntimeInfo.lynxDataset,
|
|
30
|
+
uniqueId: targetElementRuntimeInfo.uniqueId,
|
|
31
|
+
},
|
|
32
|
+
currentTarget: currentTargetElementRuntimeInfo
|
|
33
|
+
? {
|
|
34
|
+
id: currentTargetElement.id,
|
|
35
|
+
dataset: currentTargetElementRuntimeInfo.lynxDataset,
|
|
36
|
+
uniqueId: currentTargetElementRuntimeInfo.uniqueId,
|
|
37
|
+
}
|
|
38
|
+
: null,
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
detail: domEvent.detail ?? {},
|
|
41
|
+
params,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=createCrossThreadEvent.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
|
|
5
|
+
import { createCrossThreadEvent } from './createCrossThreadEvent.js';
|
|
6
|
+
export function createExposureService(runtime) {
|
|
7
|
+
const postExposure = runtime.config.callbacks.postExposure;
|
|
8
|
+
let working = true;
|
|
9
|
+
let exposureCache = [];
|
|
10
|
+
let disexposureCache = [];
|
|
11
|
+
const onScreen = new Map();
|
|
12
|
+
function exposureEventHandler(ev) {
|
|
13
|
+
const exposureEvent = createCrossThreadEvent(runtime, ev, ev.type);
|
|
14
|
+
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute(lynxUniqueIdAttribute));
|
|
15
|
+
const exposureID = exposureEvent.detail.exposureID;
|
|
16
|
+
if (ev.type === 'exposure') {
|
|
17
|
+
exposureCache.push(exposureEvent);
|
|
18
|
+
onScreen.set(exposureID, exposureEvent);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
disexposureCache.push(exposureEvent);
|
|
22
|
+
onScreen.delete(exposureID);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
setInterval(() => {
|
|
26
|
+
if (exposureCache.length > 0 || disexposureCache.length > 0) {
|
|
27
|
+
const currentExposure = exposureCache;
|
|
28
|
+
const currentDisexposure = disexposureCache;
|
|
29
|
+
exposureCache = [];
|
|
30
|
+
disexposureCache = [];
|
|
31
|
+
postExposure({
|
|
32
|
+
exposures: currentExposure,
|
|
33
|
+
disExposures: currentDisexposure,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, 1000 / 20);
|
|
37
|
+
runtime._rootDom.addEventListener('exposure', exposureEventHandler, {
|
|
38
|
+
passive: true,
|
|
39
|
+
});
|
|
40
|
+
runtime._rootDom.addEventListener('disexposure', exposureEventHandler, {
|
|
41
|
+
passive: true,
|
|
42
|
+
});
|
|
43
|
+
function switchExposureService(enable, sendEvent) {
|
|
44
|
+
if (enable && !working) {
|
|
45
|
+
// send all onScreen info
|
|
46
|
+
postExposure({
|
|
47
|
+
exposures: [...onScreen.values()],
|
|
48
|
+
disExposures: [],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (!enable && working) {
|
|
52
|
+
if (sendEvent) {
|
|
53
|
+
postExposure({
|
|
54
|
+
exposures: [],
|
|
55
|
+
disExposures: [...onScreen.values()],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
working = enable;
|
|
60
|
+
}
|
|
61
|
+
return { switchExposureService };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=createExposureService.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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.
|
|
28
|
+
"@lynx-js/web-constants": "0.10.0",
|
|
29
29
|
"@lynx-js/web-style-transformer": "0.2.3"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { MainThreadRuntime } from '../../MainThreadRuntime.js';
|
|
2
|
-
import type { ElementThreadElement } from '../ElementThreadElement.js';
|
|
3
|
-
export declare function createAttributeAndPropertyFunctionsWithContext(runtime: MainThreadRuntime): {
|
|
4
|
-
__SetAttribute: (element: ElementThreadElement, key: string, value: string | null | undefined) => void;
|
|
5
|
-
};
|
package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { __lynx_timing_flag } from '@lynx-js/web-constants';
|
|
2
|
-
export function createAttributeAndPropertyFunctionsWithContext(runtime) {
|
|
3
|
-
function __SetAttribute(element, key, value) {
|
|
4
|
-
element.setAttribute(key, value ?? null);
|
|
5
|
-
if (key === __lynx_timing_flag && value) {
|
|
6
|
-
runtime._timingFlags.push(value);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
__SetAttribute,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=createAttributeAndPropertyFunctionsWithContext.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CssInJsInfo, ElementOperation, PageConfig } from '@lynx-js/web-constants';
|
|
2
|
-
import { ElementThreadElement } from './ElementThreadElement.js';
|
|
3
|
-
interface OffscreenDocument {
|
|
4
|
-
createElement(tagName: string): ElementThreadElement;
|
|
5
|
-
}
|
|
6
|
-
export declare function createOffscreenDocument(options: {
|
|
7
|
-
pageConfig: PageConfig;
|
|
8
|
-
styleInfo: CssInJsInfo;
|
|
9
|
-
operationsRef: {
|
|
10
|
-
operations: ElementOperation[];
|
|
11
|
-
};
|
|
12
|
-
}): OffscreenDocument;
|
|
13
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ListElement, ElementThreadElement } from './ElementThreadElement.js';
|
|
2
|
-
export function createOffscreenDocument(options) {
|
|
3
|
-
const { pageConfig, styleInfo, operationsRef } = options;
|
|
4
|
-
let incrementalUniqueId = 0;
|
|
5
|
-
function createElement(tagName) {
|
|
6
|
-
const uniqueId = incrementalUniqueId++;
|
|
7
|
-
if (tagName === 'x-list') {
|
|
8
|
-
return new ListElement(tagName, uniqueId, pageConfig, operationsRef, styleInfo);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return new ElementThreadElement(tagName, uniqueId, pageConfig, operationsRef, styleInfo);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
createElement,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=createOffscreenDocument.js.map
|