@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.
Files changed (27) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/MainThreadLynx.js +13 -6
  3. package/dist/MainThreadRuntime.d.ts +42 -9
  4. package/dist/MainThreadRuntime.js +89 -33
  5. package/dist/elementAPI/ElementThreadElement.d.ts +18 -68
  6. package/dist/elementAPI/ElementThreadElement.js +1 -269
  7. package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.d.ts +29 -23
  8. package/dist/elementAPI/attributeAndProperty/attributeAndPropertyFunctions.js +115 -52
  9. package/dist/elementAPI/domTree/domTreeFunctions.d.ts +11 -13
  10. package/dist/elementAPI/domTree/domTreeFunctions.js +8 -11
  11. package/dist/elementAPI/elementCreating/elementCreatingFunctions.d.ts +14 -21
  12. package/dist/elementAPI/elementCreating/elementCreatingFunctions.js +42 -21
  13. package/dist/elementAPI/event/eventFunctions.d.ts +16 -14
  14. package/dist/elementAPI/event/eventFunctions.js +130 -26
  15. package/dist/elementAPI/style/styleFunctions.d.ts +10 -7
  16. package/dist/elementAPI/style/styleFunctions.js +66 -52
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.js +0 -1
  19. package/dist/utils/createCrossThreadEvent.d.ts +3 -0
  20. package/dist/utils/createCrossThreadEvent.js +44 -0
  21. package/dist/utils/createExposureService.d.ts +4 -0
  22. package/dist/utils/createExposureService.js +63 -0
  23. package/package.json +2 -2
  24. package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.d.ts +0 -5
  25. package/dist/elementAPI/attributeAndProperty/createAttributeAndPropertyFunctionsWithContext.js +0 -13
  26. package/dist/elementAPI/createOffscreenDocument.d.ts +0 -13
  27. package/dist/elementAPI/createOffscreenDocument.js +0 -18
@@ -1,24 +1,30 @@
1
- import { type ElementThreadElement, type ComponentAtIndexCallback, type EnqueueComponentCallback, type ListElement } from '../ElementThreadElement.js';
2
- export declare function __AddConfig(element: ElementThreadElement, type: string, value: any): void;
3
- export declare function __AddDataset(element: ElementThreadElement, key: string, value: string | number | Record<string, any>): void;
4
- export declare function __GetAttributes(element: ElementThreadElement): {
5
- [key: string]: string | null | undefined;
6
- id?: string;
7
- style: string | null;
8
- class: string | null;
9
- "lynx-component-id"?: string;
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 __GetComponentID(element: ElementThreadElement): string | undefined;
13
- export declare function __GetDataByKey(element: ElementThreadElement, key: string): unknown;
14
- export declare function __GetDataset(element: ElementThreadElement): Record<string, any>;
15
- export declare function __GetElementConfig(element: ElementThreadElement): Record<string, unknown>;
16
- export declare function __GetElementUniqueID(element: ElementThreadElement | unknown): number;
17
- export declare function __GetID(element: ElementThreadElement): string;
18
- export declare function __GetTag(element: ElementThreadElement): string;
19
- export declare function __SetConfig(element: ElementThreadElement, config: Record<string, any>): void;
20
- export declare function __SetDataset(element: ElementThreadElement, dataset: Record<string, any>): void;
21
- export declare function __SetID(element: ElementThreadElement, id: string): void;
22
- export declare function __UpdateComponentID(element: ElementThreadElement, componentID: string): void;
23
- export declare function __GetConfig(element: ElementThreadElement): Record<string, unknown>;
24
- export declare function __UpdateListCallbacks(list: ListElement, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback): void;
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 { RefCountType, } from '../ElementThreadElement.js';
6
- export function __AddConfig(element, type, value) {
7
- element.property.componentConfig[type] = value;
8
- }
9
- export function __AddDataset(element, key, value) {
10
- element.setDatasetProperty(key, value);
11
- }
12
- export function __GetAttributes(element) {
13
- return element.attributes;
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 __GetTag(element) {
38
- return element.getAttribute(lynxTagAttribute);
39
- }
40
- export function __SetConfig(element, config) {
41
- element.property.componentConfig = config;
42
- }
43
- export function __SetDataset(element, dataset) {
44
- element.setProperty('dataset', dataset);
45
- }
46
- export function __SetID(element, id) {
47
- element.setAttribute('id', id);
48
- }
49
- export function __UpdateComponentID(element, componentID) {
50
- element.setAttribute(componentIdAttribute, componentID);
51
- }
52
- export function __GetConfig(element) {
53
- return element.property.componentConfig;
54
- }
55
- export function __UpdateListCallbacks(list, componentAtIndex, enqueueComponent) {
56
- list.componentAtIndex = componentAtIndex;
57
- list.enqueueComponent = enqueueComponent;
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
- import type { ElementThreadElement } from '../ElementThreadElement.js';
2
- export declare function __AppendElement(parent: ElementThreadElement, child: ElementThreadElement): void;
3
- export declare function __ElementIsEqual(left: ElementThreadElement, right: ElementThreadElement): boolean;
4
- export declare function __FirstElement(element: ElementThreadElement): ElementThreadElement | undefined;
5
- export declare function __GetChildren(element: ElementThreadElement): ElementThreadElement[];
6
- export declare function __GetParent(element: ElementThreadElement): ElementThreadElement | undefined;
7
- export declare function __InsertElementBefore(parent: ElementThreadElement, child: ElementThreadElement, ref: ElementThreadElement | null): ElementThreadElement;
8
- export declare function __LastElement(element: ElementThreadElement): ElementThreadElement | undefined;
9
- export declare function __NextElement(element: ElementThreadElement): ElementThreadElement | undefined;
10
- export declare function __RemoveElement(parent: ElementThreadElement, child: ElementThreadElement): ElementThreadElement;
11
- export declare function __ReplaceElement(newElement: ElementThreadElement, oldElement: ElementThreadElement): void;
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.appendChild([child]);
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.parent;
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.replaceWithElements([newElement]);
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.appendChild(newChildren);
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.replaceWithElements(newChildren);
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 PageConfig, type ElementOperation, type CssInJsInfo } from '@lynx-js/web-constants';
2
- import { type ComponentAtIndexCallback, type EnqueueComponentCallback, ListElement, ElementThreadElement } from '../ElementThreadElement.js';
3
- export interface initializeElementCreatingFunctionConfig {
4
- operationsRef: {
5
- operations: ElementOperation[];
6
- };
7
- pageConfig: PageConfig;
8
- styleInfo: CssInJsInfo;
9
- tagMap: Record<string, string>;
10
- }
11
- export declare function initializeElementCreatingFunction(config: initializeElementCreatingFunctionConfig): {
12
- __CreateView: (parentComponentUniqueId: number) => ElementThreadElement;
13
- __CreateText: (parentComponentUniqueId: number) => ElementThreadElement;
14
- __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) => ElementThreadElement;
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, parentComponentUniqueIdAttribute, lynxTagAttribute, } from '@lynx-js/web-constants';
5
- import { __UpdateComponentID } from '../attributeAndProperty/attributeAndPropertyFunctions.js';
6
- import { ListElement, ElementThreadElement, } from '../ElementThreadElement.js';
7
- import { __SetCSSId } from '../style/styleFunctions.js';
8
- import { createOffscreenDocument } from '../createOffscreenDocument.js';
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
- const htmlTag = tagMap[tag] ?? tag;
20
- const element = document.createElement(htmlTag);
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
- // element.parentComponentUniqueId = parentComponentUniqueId;
23
- element.setAttribute(parentComponentUniqueIdAttribute, parentComponentUniqueId.toString());
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 = ElementThreadElement.getElementByUniqueId(parentComponentUniqueId);
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
- __UpdateComponentID(element, componentId);
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
- page.setAttribute(parentComponentUniqueIdAttribute, page.uniqueId.toString());
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
- element.componentAtIndex = componentAtIndex;
86
- element.enqueueComponent = enqueueComponent;
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 { LynxCrossThreadEvent, LynxEventType } from '@lynx-js/web-constants';
2
- import type { ElementThreadElement } from '../ElementThreadElement.js';
3
- export declare function __AddEvent(element: ElementThreadElement, eventType: LynxEventType, eventName: string, eventHandler: string | ((ev: LynxCrossThreadEvent) => void) | undefined): void;
4
- export declare function __GetEvent(element: ElementThreadElement, eventName: string, eventType: string): string | ((ev: LynxCrossThreadEvent) => void) | undefined;
5
- export declare function __GetEvents(element: ElementThreadElement): {
6
- type: LynxEventType;
7
- name: string;
8
- function: string | ((ev: Event) => void) | undefined;
9
- }[];
10
- export declare function __SetEvents(element: ElementThreadElement, listeners: {
11
- type: LynxEventType;
12
- name: string;
13
- function: string | ((ev: LynxCrossThreadEvent) => void) | undefined;
14
- }[]): void;
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
+ };