@lynx-js/web-mainthread-apis 0.9.0 → 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 +38 -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,24 +1,30 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"lynx-css-id": string | null;
|
|
1
|
+
import { type ComponentAtIndexCallback, type EnqueueComponentCallback } from '../ElementThreadElement.js';
|
|
2
|
+
import { type MainThreadRuntime } from '../../MainThreadRuntime.js';
|
|
3
|
+
type UpdateListInfoAttributeValue = {
|
|
4
|
+
insertAction: {
|
|
5
|
+
position: number;
|
|
6
|
+
}[];
|
|
7
|
+
removeAction: {
|
|
8
|
+
position: number;
|
|
9
|
+
}[];
|
|
11
10
|
};
|
|
12
|
-
export declare function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
export declare function createAttributeAndPropertyFunctions(runtime: MainThreadRuntime): {
|
|
12
|
+
__AddConfig: (element: HTMLElement, type: string, value: any) => void;
|
|
13
|
+
__AddDataset: (element: HTMLElement, key: string, value: string | number | Record<string, any>) => void;
|
|
14
|
+
__GetAttributes: (element: HTMLElement) => Record<string, string | null>;
|
|
15
|
+
__GetComponentID: (element: HTMLElement) => string | null;
|
|
16
|
+
__GetDataByKey: (element: HTMLElement, key: string) => import("@lynx-js/web-constants").Cloneable;
|
|
17
|
+
__GetDataset: (element: HTMLElement) => Record<string, any>;
|
|
18
|
+
__GetElementConfig: (element: HTMLElement) => Record<string, import("@lynx-js/web-constants").Cloneable>;
|
|
19
|
+
__GetElementUniqueID: (element: HTMLElement) => number;
|
|
20
|
+
__GetID: (element: HTMLElement) => string;
|
|
21
|
+
__GetTag: (element: HTMLElement) => string;
|
|
22
|
+
__SetConfig: (element: HTMLElement, config: Record<string, any>) => void;
|
|
23
|
+
__SetDataset: (element: HTMLElement, dataset: Record<string, any>) => void;
|
|
24
|
+
__SetID: (element: HTMLElement, id: string) => void;
|
|
25
|
+
__UpdateComponentID: (element: HTMLElement, componentID: string) => void;
|
|
26
|
+
__UpdateListCallbacks: (element: HTMLElement, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => void;
|
|
27
|
+
__GetConfig: (element: HTMLElement) => Record<string, import("@lynx-js/web-constants").Cloneable>;
|
|
28
|
+
__SetAttribute: (element: HTMLElement, key: string, value: string | null | undefined | UpdateListInfoAttributeValue) => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -1,59 +1,122 @@
|
|
|
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 { componentIdAttribute, lynxTagAttribute } from '@lynx-js/web-constants';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
export function __GetComponentID(element) {
|
|
16
|
-
return element.attributes[componentIdAttribute];
|
|
17
|
-
}
|
|
18
|
-
export function __GetDataByKey(element, key) {
|
|
19
|
-
return element.property.dataset[key];
|
|
20
|
-
}
|
|
21
|
-
export function __GetDataset(element) {
|
|
22
|
-
return element.property.dataset;
|
|
23
|
-
}
|
|
24
|
-
export function __GetElementConfig(element) {
|
|
25
|
-
return element.property.componentConfig;
|
|
26
|
-
}
|
|
27
|
-
export function __GetElementUniqueID(element) {
|
|
28
|
-
if (element && typeof element === 'object'
|
|
29
|
-
&& element.type === RefCountType.Element) {
|
|
30
|
-
return element.uniqueId;
|
|
4
|
+
import { __lynx_timing_flag, componentIdAttribute, lynxTagAttribute, } from '@lynx-js/web-constants';
|
|
5
|
+
import {} from '../ElementThreadElement.js';
|
|
6
|
+
import { elementToRuntimeInfoMap, } from '../../MainThreadRuntime.js';
|
|
7
|
+
function setDatasetAttribute(element, key, value) {
|
|
8
|
+
if (value !== null && value !== undefined) {
|
|
9
|
+
if (typeof value === 'object') {
|
|
10
|
+
element.setAttribute('data-' + key, JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
element.setAttribute('data-' + key, value.toString());
|
|
14
|
+
}
|
|
31
15
|
}
|
|
32
|
-
return -1;
|
|
33
|
-
}
|
|
34
|
-
export function __GetID(element) {
|
|
35
|
-
return element.attributes.id ?? '';
|
|
36
16
|
}
|
|
37
|
-
export function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
17
|
+
export function createAttributeAndPropertyFunctions(runtime) {
|
|
18
|
+
function __AddConfig(element, type, value) {
|
|
19
|
+
runtime[elementToRuntimeInfoMap].get(element).componentConfig[type] =
|
|
20
|
+
value;
|
|
21
|
+
}
|
|
22
|
+
function __AddDataset(element, key, value) {
|
|
23
|
+
runtime[elementToRuntimeInfoMap].get(element).lynxDataset[key] = value;
|
|
24
|
+
setDatasetAttribute(element, key, value);
|
|
25
|
+
}
|
|
26
|
+
function __GetAttributes(element) {
|
|
27
|
+
return Object.fromEntries(element.getAttributeNames().map((attributeName) => [attributeName, element.getAttribute(attributeName)]));
|
|
28
|
+
}
|
|
29
|
+
function __GetComponentID(element) {
|
|
30
|
+
return element.getAttribute(componentIdAttribute);
|
|
31
|
+
}
|
|
32
|
+
function __GetDataByKey(element, key) {
|
|
33
|
+
return runtime[elementToRuntimeInfoMap].get(element).lynxDataset[key];
|
|
34
|
+
}
|
|
35
|
+
function __GetDataset(element) {
|
|
36
|
+
return runtime[elementToRuntimeInfoMap].get(element).lynxDataset;
|
|
37
|
+
}
|
|
38
|
+
function __GetElementConfig(element) {
|
|
39
|
+
return runtime[elementToRuntimeInfoMap].get(element).componentConfig;
|
|
40
|
+
}
|
|
41
|
+
function __GetElementUniqueID(element) {
|
|
42
|
+
return runtime[elementToRuntimeInfoMap].get(element)?.uniqueId ?? -1;
|
|
43
|
+
}
|
|
44
|
+
function __GetID(element) {
|
|
45
|
+
return element.id;
|
|
46
|
+
}
|
|
47
|
+
function __GetTag(element) {
|
|
48
|
+
return element.getAttribute(lynxTagAttribute);
|
|
49
|
+
}
|
|
50
|
+
function __SetConfig(element, config) {
|
|
51
|
+
runtime[elementToRuntimeInfoMap].get(element).componentConfig = config;
|
|
52
|
+
}
|
|
53
|
+
function __SetDataset(element, dataset) {
|
|
54
|
+
runtime[elementToRuntimeInfoMap].get(element).lynxDataset = dataset;
|
|
55
|
+
for (const [key, value] of Object.entries(dataset)) {
|
|
56
|
+
setDatasetAttribute(element, key, value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function __SetID(element, id) {
|
|
60
|
+
element.id = id;
|
|
61
|
+
}
|
|
62
|
+
function __UpdateComponentID(element, componentID) {
|
|
63
|
+
element.setAttribute(componentIdAttribute, componentID);
|
|
64
|
+
}
|
|
65
|
+
function __GetConfig(element) {
|
|
66
|
+
return runtime[elementToRuntimeInfoMap].get(element).componentConfig;
|
|
67
|
+
}
|
|
68
|
+
function __UpdateListCallbacks(element, componentAtIndex, enqueueComponent) {
|
|
69
|
+
runtime[elementToRuntimeInfoMap].get(element).componentAtIndex =
|
|
70
|
+
componentAtIndex;
|
|
71
|
+
runtime[elementToRuntimeInfoMap].get(element).enqueueComponent =
|
|
72
|
+
enqueueComponent;
|
|
73
|
+
}
|
|
74
|
+
function __SetAttribute(element, key, value) {
|
|
75
|
+
if (value === null || value === undefined) {
|
|
76
|
+
element.removeAttribute(key);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (__GetTag(element) === 'list' && key === 'update-list-info') {
|
|
80
|
+
const listInfo = value;
|
|
81
|
+
const { insertAction, removeAction } = listInfo;
|
|
82
|
+
queueMicrotask(() => {
|
|
83
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(element);
|
|
84
|
+
const componentAtIndex = runtimeInfo.componentAtIndex;
|
|
85
|
+
const enqueueComponent = runtimeInfo.enqueueComponent;
|
|
86
|
+
for (const action of insertAction) {
|
|
87
|
+
componentAtIndex?.(element, runtimeInfo.uniqueId, action.position, 0, false);
|
|
88
|
+
}
|
|
89
|
+
for (const action of removeAction) {
|
|
90
|
+
enqueueComponent?.(element, runtimeInfo.uniqueId, action.position);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
element.setAttribute(key, value.toString());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (key === __lynx_timing_flag && value) {
|
|
99
|
+
runtime._timingFlags.push(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
__AddConfig,
|
|
104
|
+
__AddDataset,
|
|
105
|
+
__GetAttributes,
|
|
106
|
+
__GetComponentID,
|
|
107
|
+
__GetDataByKey,
|
|
108
|
+
__GetDataset,
|
|
109
|
+
__GetElementConfig,
|
|
110
|
+
__GetElementUniqueID,
|
|
111
|
+
__GetID,
|
|
112
|
+
__GetTag,
|
|
113
|
+
__SetConfig,
|
|
114
|
+
__SetDataset,
|
|
115
|
+
__SetID,
|
|
116
|
+
__UpdateComponentID,
|
|
117
|
+
__UpdateListCallbacks,
|
|
118
|
+
__GetConfig,
|
|
119
|
+
__SetAttribute,
|
|
120
|
+
};
|
|
58
121
|
}
|
|
59
122
|
//# sourceMappingURL=attributeAndPropertyFunctions.js.map
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function __ReplaceElements(parent: ElementThreadElement, newChildren: ElementThreadElement[] | ElementThreadElement, oldChildren: ElementThreadElement[] | ElementThreadElement | null | undefined): void;
|
|
13
|
-
export declare function __SwapElement(childA: ElementThreadElement, childB: ElementThreadElement): void;
|
|
1
|
+
export declare function __AppendElement(parent: HTMLElement, child: HTMLElement): void;
|
|
2
|
+
export declare function __ElementIsEqual(left: HTMLElement, right: HTMLElement): boolean;
|
|
3
|
+
export declare function __FirstElement(element: HTMLElement): HTMLElement | undefined;
|
|
4
|
+
export declare function __GetChildren(element: HTMLElement): HTMLElement[];
|
|
5
|
+
export declare function __GetParent(element: HTMLElement): HTMLElement | undefined;
|
|
6
|
+
export declare function __InsertElementBefore(parent: HTMLElement, child: HTMLElement, ref: HTMLElement | null): HTMLElement;
|
|
7
|
+
export declare function __LastElement(element: HTMLElement): HTMLElement | undefined;
|
|
8
|
+
export declare function __NextElement(element: HTMLElement): HTMLElement | undefined;
|
|
9
|
+
export declare function __RemoveElement(parent: HTMLElement, child: HTMLElement): HTMLElement;
|
|
10
|
+
export declare function __ReplaceElement(newElement: HTMLElement, oldElement: HTMLElement): void;
|
|
11
|
+
export declare function __ReplaceElements(parent: HTMLElement, newChildren: HTMLElement[] | HTMLElement, oldChildren: HTMLElement[] | HTMLElement | null | undefined): void;
|
|
@@ -2,40 +2,40 @@
|
|
|
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 function __AppendElement(parent, child) {
|
|
5
|
-
parent.
|
|
5
|
+
parent.append(child);
|
|
6
6
|
}
|
|
7
7
|
export function __ElementIsEqual(left, right) {
|
|
8
8
|
return left === right;
|
|
9
9
|
}
|
|
10
10
|
export function __FirstElement(element) {
|
|
11
|
-
return element.firstElementChild;
|
|
11
|
+
return element.firstElementChild || undefined;
|
|
12
12
|
}
|
|
13
13
|
export function __GetChildren(element) {
|
|
14
14
|
return element.children;
|
|
15
15
|
}
|
|
16
16
|
export function __GetParent(element) {
|
|
17
|
-
return element.
|
|
17
|
+
return element.parentElement || undefined;
|
|
18
18
|
}
|
|
19
19
|
export function __InsertElementBefore(parent, child, ref) {
|
|
20
20
|
return parent.insertBefore(child, ref);
|
|
21
21
|
}
|
|
22
22
|
export function __LastElement(element) {
|
|
23
|
-
return element.lastElementChild;
|
|
23
|
+
return element.lastElementChild || undefined;
|
|
24
24
|
}
|
|
25
25
|
export function __NextElement(element) {
|
|
26
|
-
return element.nextElementSibling;
|
|
26
|
+
return element.nextElementSibling || undefined;
|
|
27
27
|
}
|
|
28
28
|
export function __RemoveElement(parent, child) {
|
|
29
29
|
parent.removeChild(child);
|
|
30
30
|
return child;
|
|
31
31
|
}
|
|
32
32
|
export function __ReplaceElement(newElement, oldElement) {
|
|
33
|
-
oldElement.
|
|
33
|
+
oldElement.replaceWith(newElement);
|
|
34
34
|
}
|
|
35
35
|
export function __ReplaceElements(parent, newChildren, oldChildren) {
|
|
36
36
|
newChildren = Array.isArray(newChildren) ? newChildren : [newChildren];
|
|
37
37
|
if (!oldChildren || (Array.isArray(oldChildren) && oldChildren?.length === 0)) {
|
|
38
|
-
parent.
|
|
38
|
+
parent.append(...newChildren);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
oldChildren = Array.isArray(oldChildren) ? oldChildren : [oldChildren];
|
|
@@ -43,10 +43,7 @@ export function __ReplaceElements(parent, newChildren, oldChildren) {
|
|
|
43
43
|
__RemoveElement(parent, oldChildren[ii]);
|
|
44
44
|
}
|
|
45
45
|
const firstOldChildren = oldChildren[0];
|
|
46
|
-
firstOldChildren.
|
|
46
|
+
firstOldChildren.replaceWith(...newChildren);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
export function __SwapElement(childA, childB) {
|
|
50
|
-
childA.swapWith(childB);
|
|
51
|
-
}
|
|
52
49
|
//# sourceMappingURL=domTreeFunctions.js.map
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__CreatePage: (componentID: string, cssID: number, info: Record<string, any> | null | undefined) => ElementThreadElement;
|
|
16
|
-
__CreateRawText: (text: string) => ElementThreadElement;
|
|
17
|
-
__CreateImage: (parentComponentUniqueId: number) => ElementThreadElement;
|
|
18
|
-
__CreateScrollView: (parentComponentUniqueId: number) => ElementThreadElement;
|
|
19
|
-
__CreateElement: (tagName: string, parentComponentUniqueId: number, info?: object) => ElementThreadElement;
|
|
20
|
-
__CreateWrapperElement: (parentComponentUniqueId: number) => ElementThreadElement;
|
|
21
|
-
__CreateList: (parentComponentUniqueId: number, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback, info?: any) => ListElement;
|
|
1
|
+
import { type ComponentAtIndexCallback, type EnqueueComponentCallback } from '../ElementThreadElement.js';
|
|
2
|
+
import { type MainThreadRuntime } from '../../MainThreadRuntime.js';
|
|
3
|
+
export declare function initializeElementCreatingFunction(runtime: MainThreadRuntime): {
|
|
4
|
+
__CreateView: (parentComponentUniqueId: number) => HTMLElement;
|
|
5
|
+
__CreateText: (parentComponentUniqueId: number) => HTMLElement;
|
|
6
|
+
__CreateComponent: (componentParentUniqueID: number, componentID: string, cssID: number, entryName: string, name: string, path: string, config: Record<string, any> | null | undefined, info: Record<string, any> | null | undefined) => HTMLElement;
|
|
7
|
+
__CreatePage: (componentID: string, cssID: number, info: Record<string, any> | null | undefined) => HTMLElement;
|
|
8
|
+
__CreateRawText: (text: string) => HTMLElement;
|
|
9
|
+
__CreateImage: (parentComponentUniqueId: number) => HTMLElement;
|
|
10
|
+
__CreateScrollView: (parentComponentUniqueId: number) => HTMLElement;
|
|
11
|
+
__CreateElement: (tagName: string, parentComponentUniqueId: number, info?: object) => HTMLElement;
|
|
12
|
+
__CreateWrapperElement: (parentComponentUniqueId: number) => HTMLElement;
|
|
13
|
+
__CreateList: (parentComponentUniqueId: number, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback, info?: any) => HTMLElement;
|
|
14
|
+
__SwapElement: (childA: HTMLElement, childB: HTMLElement) => void;
|
|
22
15
|
};
|
|
@@ -1,37 +1,42 @@
|
|
|
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 { cssIdAttribute,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function initializeElementCreatingFunction(config) {
|
|
10
|
-
const { operationsRef, pageConfig, styleInfo, tagMap } = config;
|
|
11
|
-
const document = createOffscreenDocument({
|
|
12
|
-
pageConfig,
|
|
13
|
-
operationsRef,
|
|
14
|
-
styleInfo,
|
|
15
|
-
});
|
|
4
|
+
import { cssIdAttribute, lynxUniqueIdAttribute, lynxTagAttribute, lynxDefaultDisplayLinearAttribute, } from '@lynx-js/web-constants';
|
|
5
|
+
import {} from '../ElementThreadElement.js';
|
|
6
|
+
import { elementToRuntimeInfoMap, getElementByUniqueId, lynxUniqueIdToElement, } from '../../MainThreadRuntime.js';
|
|
7
|
+
export function initializeElementCreatingFunction(runtime) {
|
|
8
|
+
let uniqueIdInc = 1;
|
|
16
9
|
function createLynxElement(tag, parentComponentUniqueId, cssId, componentId,
|
|
17
10
|
// @ts-expect-error
|
|
18
11
|
info) {
|
|
19
|
-
|
|
20
|
-
const
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
const __SetCSSId = runtime.__SetCSSId;
|
|
14
|
+
const htmlTag = runtime.config.tagMap[tag] ?? tag;
|
|
15
|
+
const element = runtime.config.docu.createElement(htmlTag);
|
|
21
16
|
element.setAttribute(lynxTagAttribute, tag);
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const uniqueId = uniqueIdInc++;
|
|
18
|
+
const runtimeInfo = {
|
|
19
|
+
uniqueId,
|
|
20
|
+
componentConfig: {},
|
|
21
|
+
lynxDataset: {},
|
|
22
|
+
eventHandlerMap: {},
|
|
23
|
+
parentComponentUniqueId,
|
|
24
|
+
};
|
|
25
|
+
runtime[elementToRuntimeInfoMap].set(element, runtimeInfo);
|
|
26
|
+
runtime[lynxUniqueIdToElement][uniqueId] = new WeakRef(element);
|
|
27
|
+
element.setAttribute(lynxUniqueIdAttribute, uniqueId.toString());
|
|
24
28
|
if (cssId !== undefined)
|
|
25
29
|
__SetCSSId([element], cssId);
|
|
26
30
|
else if (parentComponentUniqueId >= 0) { // don't infer for uniqueid === -1
|
|
27
|
-
const parentComponent =
|
|
31
|
+
const parentComponent = runtime[getElementByUniqueId](parentComponentUniqueId);
|
|
28
32
|
const parentCssId = parentComponent?.getAttribute(cssIdAttribute);
|
|
29
33
|
if (parentCssId && parentCssId !== '0') {
|
|
30
34
|
__SetCSSId([element], parentCssId);
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
if (componentId !== undefined) {
|
|
34
|
-
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
runtime.__UpdateComponentID(element, componentId);
|
|
35
40
|
}
|
|
36
41
|
return element;
|
|
37
42
|
}
|
|
@@ -52,7 +57,15 @@ export function initializeElementCreatingFunction(config) {
|
|
|
52
57
|
function __CreatePage(componentID, cssID, info) {
|
|
53
58
|
const page = createLynxElement('page', 0, cssID, componentID, info);
|
|
54
59
|
page.setAttribute('part', 'page');
|
|
55
|
-
|
|
60
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(page);
|
|
61
|
+
runtimeInfo.parentComponentUniqueId = runtimeInfo.uniqueId;
|
|
62
|
+
if (runtime.config.pageConfig.defaultDisplayLinear === false) {
|
|
63
|
+
page.setAttribute(lynxDefaultDisplayLinearAttribute, 'false');
|
|
64
|
+
}
|
|
65
|
+
if (runtime.config.pageConfig.defaultOverflowVisible === true) {
|
|
66
|
+
page.setAttribute('lynx-default-overflow-visible', 'true');
|
|
67
|
+
}
|
|
68
|
+
runtime._page = page;
|
|
56
69
|
return page;
|
|
57
70
|
}
|
|
58
71
|
function __CreateView(parentComponentUniqueId) {
|
|
@@ -82,10 +95,17 @@ export function initializeElementCreatingFunction(config) {
|
|
|
82
95
|
}
|
|
83
96
|
function __CreateList(parentComponentUniqueId, componentAtIndex, enqueueComponent, info) {
|
|
84
97
|
const element = createLynxElement('list', parentComponentUniqueId, undefined, undefined, info);
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
const runtimeInfo = runtime[elementToRuntimeInfoMap].get(element);
|
|
99
|
+
runtimeInfo.componentAtIndex = componentAtIndex;
|
|
100
|
+
runtimeInfo.enqueueComponent = enqueueComponent;
|
|
87
101
|
return element;
|
|
88
102
|
}
|
|
103
|
+
function __SwapElement(childA, childB) {
|
|
104
|
+
const temp = runtime.config.docu.createElement('div');
|
|
105
|
+
childA.replaceWith(temp);
|
|
106
|
+
childB.replaceWith(childA);
|
|
107
|
+
temp.replaceWith(childB);
|
|
108
|
+
}
|
|
89
109
|
return {
|
|
90
110
|
__CreateView,
|
|
91
111
|
__CreateText,
|
|
@@ -97,6 +117,7 @@ export function initializeElementCreatingFunction(config) {
|
|
|
97
117
|
__CreateElement,
|
|
98
118
|
__CreateWrapperElement,
|
|
99
119
|
__CreateList,
|
|
120
|
+
__SwapElement,
|
|
100
121
|
};
|
|
101
122
|
}
|
|
102
123
|
//# sourceMappingURL=elementCreatingFunctions.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { type LynxCrossThreadEvent, type LynxEventType } from '@lynx-js/web-constants';
|
|
2
|
+
import { type MainThreadRuntime } from '../../MainThreadRuntime.js';
|
|
3
|
+
export declare function createEventFunctions(runtime: MainThreadRuntime): {
|
|
4
|
+
__AddEvent: (element: HTMLElement, eventType: LynxEventType, eventName: string, newEventHandler: string | undefined) => void;
|
|
5
|
+
__GetEvent: (element: HTMLElement, eventName: string, eventType: LynxEventType) => string | ((ev: LynxCrossThreadEvent) => void) | undefined;
|
|
6
|
+
__GetEvents: (element: HTMLElement) => {
|
|
7
|
+
type: LynxEventType;
|
|
8
|
+
name: string;
|
|
9
|
+
function: string | ((ev: Event) => void) | undefined;
|
|
10
|
+
}[];
|
|
11
|
+
__SetEvents: (element: HTMLElement, listeners: {
|
|
12
|
+
type: LynxEventType;
|
|
13
|
+
name: string;
|
|
14
|
+
function: string | undefined;
|
|
15
|
+
}[]) => void;
|
|
16
|
+
};
|