@lynx-js/web-core-wasm-canary 0.0.2-canary-20260129-b0205255 → 0.0.2-canary-20260129-d02a6062
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 +3 -3
- package/binary/client/client.d.ts +99 -99
- package/binary/client/client.js +381 -391
- package/binary/client/client_bg.wasm +0 -0
- package/binary/client/client_bg.wasm.d.ts +41 -40
- package/binary/client/client_debug.d.ts +102 -102
- package/binary/client/client_debug.js +381 -391
- package/binary/client/client_debug_bg.wasm +0 -0
- package/binary/client/client_debug_bg.wasm.d.ts +44 -43
- package/binary/encode/encode.d.ts +10 -59
- package/binary/encode/encode.js +151 -330
- package/binary/encode/encode_bg.wasm +0 -0
- package/binary/encode/encode_bg.wasm.d.ts +4 -24
- package/binary/encode/encode_debug.d.ts +10 -59
- package/binary/encode/encode_debug.js +82 -333
- package/binary/encode/encode_debug_bg.wasm +0 -0
- package/binary/encode/encode_debug_bg.wasm.d.ts +5 -25
- package/dist/client/decodeWorker/cssLoader.d.ts +1 -1
- package/dist/client/decodeWorker/cssLoader.js +2 -3
- package/dist/client/decodeWorker/decode.worker.js +4 -3
- package/dist/client/mainthread/LynxViewInstance.d.ts +1 -5
- package/dist/client/mainthread/LynxViewInstance.js +8 -16
- package/dist/client/mainthread/TemplateManager.d.ts +0 -1
- package/dist/client/mainthread/TemplateManager.js +5 -29
- package/dist/client/mainthread/elementAPIs/WASMJSBinding.d.ts +4 -10
- package/dist/client/mainthread/elementAPIs/WASMJSBinding.js +14 -19
- package/dist/client/mainthread/elementAPIs/createElementAPI.d.ts +1 -1
- package/dist/client/mainthread/elementAPIs/createElementAPI.js +60 -84
- package/dist/client/wasm.d.ts +1 -9
- package/dist/client/wasm.js +3 -17
- package/dist/client/webElementsDynamicLoader.d.ts +0 -7
- package/dist/client/webElementsDynamicLoader.js +3 -72
- package/dist/client_prod/static/js/async/web-core-main-chunk.js +1 -303
- package/dist/client_prod/static/js/async/web-core-template-loader-thread.js +4 -4
- package/dist/client_prod/static/js/async/web-elements.js +309 -0
- package/dist/client_prod/static/js/client.js +2 -2
- package/dist/client_prod/static/wasm/a156b496.module.wasm +0 -0
- package/dist/encode/webEncoder.js +1 -16
- package/dist/types/DecodedTemplate.d.ts +0 -3
- package/dist/types/IElementPAPI.d.ts +0 -2
- package/dist/types/IMtsBinding.d.ts +4 -1
- package/package.json +3 -4
- package/dist/client/mainthread/StyleManager.d.ts +0 -15
- package/dist/client/mainthread/StyleManager.js +0 -72
- package/dist/client_prod/static/js/async/web-elements-audio.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-foldview.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-input.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-list.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-overlay.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-refrshview.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-swiper.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-textarea.js +0 -1
- package/dist/client_prod/static/js/async/web-elements-viewpager.js +0 -1
- package/dist/client_prod/static/wasm/aa6eb16a.module.wasm +0 -0
- package/dist/encode/encodeElementTemplate.d.ts +0 -2
- package/dist/encode/encodeElementTemplate.js +0 -52
- /package/dist/client_prod/static/css/async/{web-core-main-chunk.css → web-elements.css} +0 -0
|
@@ -29,10 +29,7 @@ export class TemplateManager {
|
|
|
29
29
|
const lynxViewInstance = await lynxViewInstancePromise;
|
|
30
30
|
lynxViewInstance.backgroundThread.markTiming('decode_start');
|
|
31
31
|
lynxViewInstance.onPageConfigReady(config);
|
|
32
|
-
|
|
33
|
-
if (styleInfo) {
|
|
34
|
-
lynxViewInstance.onStyleInfoReady(styleInfo, url);
|
|
35
|
-
}
|
|
32
|
+
lynxViewInstance.onStyleInfoReady(url);
|
|
36
33
|
lynxViewInstance.onMTSScriptsLoaded(url, config.isLazy === 'true');
|
|
37
34
|
lynxViewInstance.onBTSScriptsLoaded(url);
|
|
38
35
|
})();
|
|
@@ -141,12 +138,9 @@ export class TemplateManager {
|
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
140
|
async #handleSection(msg, instancePromise) {
|
|
144
|
-
const [instance,
|
|
141
|
+
const [instance, templateManagerWasm,] = await Promise.all([
|
|
145
142
|
instancePromise,
|
|
146
|
-
wasm.then((
|
|
147
|
-
DecodedStyle,
|
|
148
|
-
ElementTemplateSection: wasmInstance.ElementTemplateSection,
|
|
149
|
-
})),
|
|
143
|
+
wasm.then((wasm) => (wasm.templateManagerWasm)),
|
|
150
144
|
]);
|
|
151
145
|
const { label, data, url, config } = msg;
|
|
152
146
|
switch (label) {
|
|
@@ -157,9 +151,8 @@ export class TemplateManager {
|
|
|
157
151
|
break;
|
|
158
152
|
}
|
|
159
153
|
case TemplateSectionLabel.StyleInfo: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
instance.onStyleInfoReady(decodedStyle, url);
|
|
154
|
+
templateManagerWasm.add_style_info(url, new Uint8Array(data), document);
|
|
155
|
+
instance.onStyleInfoReady(url);
|
|
163
156
|
break;
|
|
164
157
|
}
|
|
165
158
|
case TemplateSectionLabel.LepusCode: {
|
|
@@ -168,11 +161,6 @@ export class TemplateManager {
|
|
|
168
161
|
instance.onMTSScriptsLoaded(url, config['isLazy'] === 'true');
|
|
169
162
|
break;
|
|
170
163
|
}
|
|
171
|
-
case TemplateSectionLabel.ElementTemplates:
|
|
172
|
-
// data is Uint8Array
|
|
173
|
-
const section = ElementTemplateSection.from_encoded(new Uint8Array(data));
|
|
174
|
-
this.setElementTemplateSection(url, section);
|
|
175
|
-
break;
|
|
176
164
|
case TemplateSectionLabel.CustomSections: {
|
|
177
165
|
this.#setCustomSection(url, data);
|
|
178
166
|
break;
|
|
@@ -219,24 +207,12 @@ export class TemplateManager {
|
|
|
219
207
|
template.config = config;
|
|
220
208
|
}
|
|
221
209
|
}
|
|
222
|
-
#setStyleInfo(url, styleInfo) {
|
|
223
|
-
const template = this.#templates.get(url);
|
|
224
|
-
if (template) {
|
|
225
|
-
template.styleInfo = styleInfo;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
210
|
#setLepusCode(url, lepusCode) {
|
|
229
211
|
const template = this.#templates.get(url);
|
|
230
212
|
if (template) {
|
|
231
213
|
template.lepusCode = lepusCode;
|
|
232
214
|
}
|
|
233
215
|
}
|
|
234
|
-
setElementTemplateSection(url, section) {
|
|
235
|
-
const template = this.#templates.get(url);
|
|
236
|
-
if (template) {
|
|
237
|
-
template.elementTemplates = section;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
216
|
#setCustomSection(url, customSections) {
|
|
241
217
|
const template = this.#templates.get(url);
|
|
242
218
|
if (template) {
|
|
@@ -2,28 +2,22 @@ import type { LynxCrossThreadEvent, LynxCrossThreadEventTarget, DecoratedHTMLEle
|
|
|
2
2
|
import type { MainThreadWasmContext } from '../../wasm.js';
|
|
3
3
|
import type { BackgroundThread } from '../Background.js';
|
|
4
4
|
import type { ExposureServices } from '../ExposureServices.js';
|
|
5
|
-
import type { StyleManager } from '../StyleManager.js';
|
|
6
5
|
export type WASMJSBindingInjectedHandler = {
|
|
7
6
|
rootDom: ShadowRoot;
|
|
8
7
|
backgroundThread: BackgroundThread;
|
|
9
8
|
exposureServices: ExposureServices;
|
|
10
|
-
loadWebElement: (elementId: number) => void;
|
|
11
|
-
loadUnknownElement: (tagName: string) => void;
|
|
12
9
|
mainThreadGlobalThis: MainThreadGlobalThis;
|
|
13
|
-
styleManager?: StyleManager;
|
|
14
10
|
};
|
|
15
11
|
export declare class WASMJSBinding implements RustMainthreadContextBinding {
|
|
16
12
|
#private;
|
|
17
13
|
readonly lynxViewInstance: WASMJSBindingInjectedHandler;
|
|
18
14
|
wasmContext: InstanceType<MainThreadWasmContext> | undefined;
|
|
19
|
-
uniqueIdToElement: (HTMLElement | undefined)[];
|
|
20
15
|
toBeEnabledElement: Set<HTMLElement>;
|
|
21
16
|
toBeDisabledElement: Set<HTMLElement>;
|
|
22
17
|
constructor(lynxViewInstance: WASMJSBindingInjectedHandler);
|
|
23
|
-
markExposureRelatedElementByUniqueId(
|
|
24
|
-
loadInternalWebElement: (elementId: number) => void;
|
|
25
|
-
loadUnknownElement: (tagName: string) => void;
|
|
18
|
+
markExposureRelatedElementByUniqueId(element: HTMLElement, toEnable: boolean): void;
|
|
26
19
|
generateTargetObject(element: DecoratedHTMLElement, dataset: CloneableObject): LynxCrossThreadEventTarget;
|
|
20
|
+
getClassList(element: HTMLElement): string[];
|
|
27
21
|
getElementByUniqueId(uniqueId: number): HTMLElement | undefined;
|
|
28
22
|
getElementByComponentId(componentId: string): HTMLElement | undefined;
|
|
29
23
|
runWorklet(handler: {
|
|
@@ -33,6 +27,6 @@ export declare class WASMJSBinding implements RustMainthreadContextBinding {
|
|
|
33
27
|
addEventListener(eventName: string): void;
|
|
34
28
|
postTimingFlags(flags: string[], pipelineId?: string): void;
|
|
35
29
|
updateExposureStatus(enabledExposureElements: HTMLElement[], disabledExposureElements: HTMLElement[]): void;
|
|
36
|
-
enableElementEvent(
|
|
37
|
-
disableElementEvent(
|
|
30
|
+
enableElementEvent(element: HTMLElement, eventName: string): void;
|
|
31
|
+
disableElementEvent(element: HTMLElement, eventName: string): void;
|
|
38
32
|
}
|
|
@@ -4,29 +4,23 @@ import { __GetElementUniqueID } from './pureElementPAPIs.js';
|
|
|
4
4
|
export class WASMJSBinding {
|
|
5
5
|
lynxViewInstance;
|
|
6
6
|
wasmContext;
|
|
7
|
-
uniqueIdToElement = [undefined];
|
|
8
7
|
toBeEnabledElement = new Set();
|
|
9
8
|
toBeDisabledElement = new Set();
|
|
10
9
|
constructor(lynxViewInstance) {
|
|
11
10
|
this.lynxViewInstance = lynxViewInstance;
|
|
12
|
-
this.loadInternalWebElement = this.lynxViewInstance.loadWebElement.bind(this.lynxViewInstance);
|
|
13
|
-
this.loadUnknownElement = this.lynxViewInstance.loadUnknownElement.bind(this.lynxViewInstance);
|
|
14
11
|
}
|
|
15
|
-
markExposureRelatedElementByUniqueId(
|
|
16
|
-
|
|
17
|
-
if (dom) {
|
|
12
|
+
markExposureRelatedElementByUniqueId(element, toEnable) {
|
|
13
|
+
if (element) {
|
|
18
14
|
if (toEnable) {
|
|
19
|
-
this.toBeDisabledElement.delete(
|
|
20
|
-
this.toBeEnabledElement.add(
|
|
15
|
+
this.toBeDisabledElement.delete(element);
|
|
16
|
+
this.toBeEnabledElement.add(element);
|
|
21
17
|
}
|
|
22
18
|
else {
|
|
23
|
-
this.toBeEnabledElement.delete(
|
|
24
|
-
this.toBeDisabledElement.add(
|
|
19
|
+
this.toBeEnabledElement.delete(element);
|
|
20
|
+
this.toBeDisabledElement.add(element);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
loadInternalWebElement;
|
|
29
|
-
loadUnknownElement;
|
|
30
24
|
generateTargetObject(element, dataset) {
|
|
31
25
|
const uniqueId = element[uniqueIdSymbol];
|
|
32
26
|
return {
|
|
@@ -35,11 +29,14 @@ export class WASMJSBinding {
|
|
|
35
29
|
uniqueId,
|
|
36
30
|
};
|
|
37
31
|
}
|
|
32
|
+
getClassList(element) {
|
|
33
|
+
return [...element.classList];
|
|
34
|
+
}
|
|
38
35
|
getElementByUniqueId(uniqueId) {
|
|
39
|
-
return this.
|
|
36
|
+
return this.wasmContext?.get_dom_by_unique_id(uniqueId);
|
|
40
37
|
}
|
|
41
38
|
getElementByComponentId(componentId) {
|
|
42
|
-
const uniqueId = this.wasmContext?.
|
|
39
|
+
const uniqueId = this.wasmContext?.get_unique_id_by_component_id(componentId);
|
|
43
40
|
if (uniqueId != undefined) {
|
|
44
41
|
return this.getElementByUniqueId(uniqueId);
|
|
45
42
|
}
|
|
@@ -90,7 +87,7 @@ export class WASMJSBinding {
|
|
|
90
87
|
currentTarget = currentTarget.parentElement;
|
|
91
88
|
}
|
|
92
89
|
const eventObject = createCrossThreadEvent(event);
|
|
93
|
-
this.wasmContext?.
|
|
90
|
+
this.wasmContext?.common_event_handler(eventObject, bubblePath.slice(0, bubblePathLength), eventObject.type);
|
|
94
91
|
};
|
|
95
92
|
addEventListener(eventName) {
|
|
96
93
|
this.lynxViewInstance.rootDom.addEventListener(LynxEventNameToW3cCommon[eventName] ?? eventName, this.#commonEventHandler, {
|
|
@@ -104,15 +101,13 @@ export class WASMJSBinding {
|
|
|
104
101
|
updateExposureStatus(enabledExposureElements, disabledExposureElements) {
|
|
105
102
|
this.lynxViewInstance.exposureServices.updateExposureStatus(enabledExposureElements, disabledExposureElements);
|
|
106
103
|
}
|
|
107
|
-
enableElementEvent(
|
|
108
|
-
const element = this.getElementByUniqueId(uniqueId);
|
|
104
|
+
enableElementEvent(element, eventName) {
|
|
109
105
|
if (element) {
|
|
110
106
|
// @ts-expect-error
|
|
111
107
|
element.enableEvent?.(LynxEventNameToW3cCommon[eventName] ?? eventName);
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
|
-
disableElementEvent(
|
|
115
|
-
const element = this.getElementByUniqueId(uniqueId);
|
|
110
|
+
disableElementEvent(element, eventName) {
|
|
116
111
|
if (element) {
|
|
117
112
|
// @ts-expect-error
|
|
118
113
|
element.disableEvent?.(LynxEventNameToW3cCommon[eventName] ?? eventName);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ElementPAPIs } from '../../../types/index.js';
|
|
2
2
|
import type { WASMJSBinding } from './WASMJSBinding.js';
|
|
3
|
-
export declare function createElementAPI(
|
|
3
|
+
export declare function createElementAPI(rootDom: ShadowRoot, mtsBinding: WASMJSBinding, config_enable_css_selector: boolean, config_default_display_linear: boolean, config_default_overflow_visible: boolean): ElementPAPIs;
|
|
@@ -1,125 +1,105 @@
|
|
|
1
1
|
import { wasmInstance } from '../../wasm.js';
|
|
2
|
-
import {
|
|
3
|
-
import { LYNX_TIMING_FLAG_ATTRIBUTE, lynxDisposedAttribute, lynxDefaultDisplayLinearAttribute, lynxEntryNameAttribute, uniqueIdSymbol, LYNX_TAG_TO_HTML_TAG_MAP, cssIdAttribute, lynxDefaultOverflowVisibleAttribute, } from '../../../constants.js';
|
|
2
|
+
import { LYNX_TAG_TO_HTML_TAG_MAP, LYNX_TIMING_FLAG_ATTRIBUTE, lynxDefaultDisplayLinearAttribute, lynxDefaultOverflowVisibleAttribute, lynxDisposedAttribute, lynxEntryNameAttribute, uniqueIdSymbol, } from '../../../constants.js';
|
|
4
3
|
import { __SwapElement, __AppendElement, __ElementIsEqual, __FirstElement, __GetChildren, __GetParent, __InsertElementBefore, __LastElement, __NextElement, __RemoveElement, __ReplaceElement, __ReplaceElements, __GetAttributes, __GetAttributeByName, __GetID, __SetID, __GetTag, __GetClasses, __SetClasses, __AddClass, __MarkTemplateElement, __MarkPartElement, __GetElementUniqueID, __GetTemplateParts, __UpdateListCallbacks, } from './pureElementPAPIs.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// @ts-expect-error
|
|
5
|
+
import IN_SHADOW_CSS_MODERN from '../../../../css/in_shadow.css?inline';
|
|
6
|
+
const IN_SHADOW_CSS = URL.createObjectURL(new Blob([IN_SHADOW_CSS_MODERN], { type: 'text/css' }));
|
|
7
|
+
const linkElement = document.createElement('link');
|
|
8
|
+
linkElement.rel = 'stylesheet';
|
|
9
|
+
linkElement.href = IN_SHADOW_CSS;
|
|
10
|
+
linkElement.type = 'text/css';
|
|
11
|
+
const { MainThreadWasmContext, add_inline_style_raw_string_key, set_inline_styles_number_key, set_inline_styles_in_str, get_inline_styles_in_key_value_vec, } = wasmInstance;
|
|
12
|
+
export function createElementAPI(rootDom, mtsBinding, config_enable_css_selector, config_default_display_linear, config_default_overflow_visible) {
|
|
13
|
+
rootDom.append(linkElement.cloneNode(false));
|
|
14
|
+
const wasmContext = new MainThreadWasmContext(rootDom, mtsBinding, config_enable_css_selector);
|
|
8
15
|
mtsBinding.wasmContext = wasmContext;
|
|
9
16
|
let page = undefined;
|
|
10
17
|
const timingFlags = [];
|
|
11
|
-
const uniqueIdToElement = mtsBinding.uniqueIdToElement;
|
|
12
18
|
const __SetCSSId = (elements, cssId, entryName) => {
|
|
13
19
|
const uniqueIds = elements.map((element) => {
|
|
14
|
-
if (entryName) {
|
|
15
|
-
element.setAttribute(lynxEntryNameAttribute, entryName);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
element.removeAttribute(lynxEntryNameAttribute);
|
|
19
|
-
}
|
|
20
|
-
if (cssId) {
|
|
21
|
-
element.setAttribute(cssIdAttribute, cssId.toString());
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
element.removeAttribute(cssIdAttribute);
|
|
25
|
-
}
|
|
26
20
|
return element[uniqueIdSymbol];
|
|
27
21
|
});
|
|
28
|
-
|
|
29
|
-
wasmContext.__wasm_set_css_id(new Uint32Array(uniqueIds), cssId);
|
|
30
|
-
for (const element of elements) {
|
|
31
|
-
const uniqueId = element[uniqueIdSymbol];
|
|
32
|
-
if (!config_enable_css_selector) {
|
|
33
|
-
mtsBinding.lynxViewInstance.styleManager.updateCssOgStyle(uniqueId, cssId, element.classList, entryName);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
22
|
+
return wasmContext.set_css_id(new Uint32Array(uniqueIds), cssId ?? 0, entryName);
|
|
37
23
|
};
|
|
38
24
|
const __AddEvent = (element, eventType, eventName, frameworkCrossThreadIdentifier) => {
|
|
39
25
|
const uniqueId = element[uniqueIdSymbol];
|
|
40
26
|
if (typeof frameworkCrossThreadIdentifier === 'string') {
|
|
41
|
-
wasmContext.
|
|
27
|
+
wasmContext.add_cross_thread_event(uniqueId, eventType, eventName, frameworkCrossThreadIdentifier);
|
|
42
28
|
}
|
|
43
29
|
else if (frameworkCrossThreadIdentifier == null) {
|
|
44
|
-
wasmContext.
|
|
45
|
-
wasmContext.
|
|
30
|
+
wasmContext.add_cross_thread_event(uniqueId, eventType, eventName, undefined);
|
|
31
|
+
wasmContext.add_run_worklet_event(uniqueId, eventType, eventName, undefined);
|
|
46
32
|
}
|
|
47
33
|
else if (typeof frameworkCrossThreadIdentifier === 'object') {
|
|
48
|
-
wasmContext.
|
|
34
|
+
wasmContext.add_run_worklet_event(uniqueId, eventType, eventName, frameworkCrossThreadIdentifier);
|
|
49
35
|
}
|
|
50
36
|
if (eventName === 'uiappear' || eventName === 'uidisappear') {
|
|
51
|
-
|
|
37
|
+
const element = wasmContext.get_dom_by_unique_id(uniqueId);
|
|
38
|
+
if (element) {
|
|
39
|
+
mtsBinding.markExposureRelatedElementByUniqueId(element, frameworkCrossThreadIdentifier != null);
|
|
40
|
+
}
|
|
52
41
|
}
|
|
53
42
|
};
|
|
54
43
|
return {
|
|
55
44
|
__CreateView(parentComponentUniqueId) {
|
|
56
45
|
const dom = document.createElement('x-view');
|
|
57
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
58
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
46
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
59
47
|
return dom;
|
|
60
48
|
},
|
|
61
49
|
__CreateText(parentComponentUniqueId) {
|
|
62
50
|
const dom = document.createElement('x-text');
|
|
63
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
64
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
51
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
65
52
|
return dom;
|
|
66
53
|
},
|
|
67
54
|
__CreateImage(parentComponentUniqueId) {
|
|
68
55
|
const dom = document.createElement('x-image');
|
|
69
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
70
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
56
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
71
57
|
return dom;
|
|
72
58
|
},
|
|
73
59
|
__CreateRawText(text) {
|
|
74
60
|
const dom = document.createElement('raw-text');
|
|
75
61
|
dom.setAttribute('text', text);
|
|
76
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
77
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
62
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(-1, dom);
|
|
78
63
|
return dom;
|
|
79
64
|
},
|
|
80
65
|
__CreateScrollView(parentComponentUniqueId) {
|
|
81
66
|
const dom = document.createElement('scroll-view');
|
|
82
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
83
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
67
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
84
68
|
return dom;
|
|
85
69
|
},
|
|
86
70
|
__CreateElement(tagName, parentComponentUniqueId) {
|
|
87
71
|
const dom = document.createElement(LYNX_TAG_TO_HTML_TAG_MAP[tagName] ?? tagName);
|
|
88
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
89
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
72
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
90
73
|
return dom;
|
|
91
74
|
},
|
|
92
75
|
__CreateComponent(parentComponentUniqueId, componentID, cssID, entryName, name) {
|
|
93
76
|
const dom = document.createElement('x-view');
|
|
94
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
77
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom, cssID, componentID);
|
|
95
78
|
if (entryName) {
|
|
96
79
|
dom.setAttribute(lynxEntryNameAttribute, entryName);
|
|
97
80
|
}
|
|
98
81
|
if (name) {
|
|
99
82
|
dom.setAttribute('name', name);
|
|
100
83
|
}
|
|
101
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
102
84
|
return dom;
|
|
103
85
|
},
|
|
104
86
|
__CreateWrapperElement(parentComponentUniqueId) {
|
|
105
87
|
const dom = document.createElement('lynx-wrapper');
|
|
106
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
107
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
88
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
108
89
|
return dom;
|
|
109
90
|
},
|
|
110
91
|
__CreateList(parentComponentUniqueId, componentAtIndex, enqueueComponent) {
|
|
111
92
|
const dom = document.createElement('x-list');
|
|
112
93
|
dom.componentAtIndex = componentAtIndex;
|
|
113
94
|
dom.enqueueComponent = enqueueComponent;
|
|
114
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
115
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
95
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(parentComponentUniqueId, dom);
|
|
116
96
|
return dom;
|
|
117
97
|
},
|
|
118
98
|
__CreatePage(componentID, cssID) {
|
|
119
99
|
if (page)
|
|
120
100
|
return page;
|
|
121
101
|
const dom = document.createElement('div');
|
|
122
|
-
dom[uniqueIdSymbol] = wasmContext.
|
|
102
|
+
dom[uniqueIdSymbol] = wasmContext.create_element_common(0, dom, cssID, componentID);
|
|
123
103
|
if (config_default_overflow_visible) {
|
|
124
104
|
dom.setAttribute(lynxDefaultOverflowVisibleAttribute, 'true');
|
|
125
105
|
}
|
|
@@ -128,21 +108,14 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
128
108
|
}
|
|
129
109
|
dom.setAttribute('part', 'page');
|
|
130
110
|
page = dom;
|
|
131
|
-
uniqueIdToElement[dom[uniqueIdSymbol]] = dom;
|
|
132
111
|
return dom;
|
|
133
112
|
},
|
|
134
|
-
__ElementFromBinary(templateId, parentComponentUniqueId) {
|
|
135
|
-
let template_root = wasmContext._wasm_elementFromBinary(parentComponentUniqueId, entryTemplateUrl, templateId, templateManager.getTemplate(entryTemplateUrl).elementTemplates);
|
|
136
|
-
__MarkTemplateElement(template_root);
|
|
137
|
-
return template_root;
|
|
138
|
-
},
|
|
139
113
|
__SetClasses: config_enable_css_selector
|
|
140
114
|
? __SetClasses
|
|
141
115
|
: ((element, classname) => {
|
|
142
116
|
__SetClasses(element, classname);
|
|
143
|
-
// Also sync to wasm side
|
|
144
117
|
const uniqueId = element[uniqueIdSymbol];
|
|
145
|
-
|
|
118
|
+
wasmContext.update_css_og_style(uniqueId, element.getAttribute(lynxEntryNameAttribute));
|
|
146
119
|
}),
|
|
147
120
|
__SetCSSId,
|
|
148
121
|
__AddInlineStyle: (element, key, value) => {
|
|
@@ -150,10 +123,10 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
150
123
|
value = value.toString();
|
|
151
124
|
}
|
|
152
125
|
if (typeof key === 'number') {
|
|
153
|
-
return
|
|
126
|
+
return set_inline_styles_number_key(element, key, value);
|
|
154
127
|
}
|
|
155
128
|
else {
|
|
156
|
-
return
|
|
129
|
+
return add_inline_style_raw_string_key(element, key.toString(), value);
|
|
157
130
|
}
|
|
158
131
|
},
|
|
159
132
|
__SetInlineStyles: (element, value) => {
|
|
@@ -161,17 +134,22 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
161
134
|
element.removeAttribute('style');
|
|
162
135
|
}
|
|
163
136
|
else {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
137
|
+
if (typeof value === 'string') {
|
|
138
|
+
if (!set_inline_styles_in_str(element, value)) {
|
|
139
|
+
element.setAttribute('style', value);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (!value) {
|
|
143
|
+
element.removeAttribute('style');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
get_inline_styles_in_key_value_vec(element, Object.entries(value).flat().map((item) => item.toString()));
|
|
169
147
|
}
|
|
170
148
|
}
|
|
171
149
|
},
|
|
172
150
|
__AddConfig: (element, type, value) => {
|
|
173
151
|
const uniqueId = element[uniqueIdSymbol];
|
|
174
|
-
const config = wasmContext.
|
|
152
|
+
const config = wasmContext.get_config(uniqueId);
|
|
175
153
|
// @ts-ignore
|
|
176
154
|
config[type] = value;
|
|
177
155
|
},
|
|
@@ -184,34 +162,34 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
184
162
|
else {
|
|
185
163
|
element.removeAttribute('name');
|
|
186
164
|
}
|
|
187
|
-
wasmContext.
|
|
165
|
+
wasmContext.update_component_id(uniqueId, componentID);
|
|
188
166
|
if (cssID !== undefined) {
|
|
189
167
|
__SetCSSId([element], cssID, entry);
|
|
190
168
|
}
|
|
191
169
|
},
|
|
192
170
|
__UpdateComponentID: (element, componentID) => {
|
|
193
171
|
const uniqueId = element[uniqueIdSymbol];
|
|
194
|
-
wasmContext.
|
|
172
|
+
wasmContext.update_component_id(uniqueId, componentID);
|
|
195
173
|
},
|
|
196
174
|
__GetConfig: (element) => {
|
|
197
175
|
const uniqueId = element[uniqueIdSymbol];
|
|
198
|
-
return wasmContext.
|
|
176
|
+
return wasmContext.get_config(uniqueId);
|
|
199
177
|
},
|
|
200
178
|
__SetConfig: (element, config) => {
|
|
201
179
|
const uniqueId = element[uniqueIdSymbol];
|
|
202
|
-
wasmContext.
|
|
180
|
+
wasmContext.set_config(uniqueId, config);
|
|
203
181
|
},
|
|
204
182
|
__GetElementConfig: (element) => {
|
|
205
183
|
const uniqueId = element[uniqueIdSymbol];
|
|
206
|
-
return wasmContext.
|
|
184
|
+
return wasmContext.get_element_config(uniqueId);
|
|
207
185
|
},
|
|
208
186
|
__GetComponentID: (element) => {
|
|
209
187
|
const uniqueId = element[uniqueIdSymbol];
|
|
210
|
-
return wasmContext.
|
|
188
|
+
return wasmContext.get_component_id(uniqueId);
|
|
211
189
|
},
|
|
212
190
|
__SetDataset: (element, dataset) => {
|
|
213
191
|
const uniqueId = element[uniqueIdSymbol];
|
|
214
|
-
wasmContext.
|
|
192
|
+
wasmContext.set_dataset(uniqueId, element, dataset);
|
|
215
193
|
},
|
|
216
194
|
__AddDataset: (element, key, value) => {
|
|
217
195
|
const uniqueId = element[uniqueIdSymbol];
|
|
@@ -221,15 +199,15 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
221
199
|
else {
|
|
222
200
|
element.removeAttribute(`data-${key}`);
|
|
223
201
|
}
|
|
224
|
-
wasmContext.
|
|
202
|
+
wasmContext.add_dataset(uniqueId, key, value);
|
|
225
203
|
},
|
|
226
204
|
__GetDataset: (element) => {
|
|
227
205
|
const uniqueId = element[uniqueIdSymbol];
|
|
228
|
-
return Object.assign(Object.create(null), wasmContext.
|
|
206
|
+
return Object.assign(Object.create(null), wasmContext.get_dataset(uniqueId));
|
|
229
207
|
},
|
|
230
208
|
__GetDataByKey: (element, key) => {
|
|
231
209
|
const uniqueId = element[uniqueIdSymbol];
|
|
232
|
-
return wasmContext.
|
|
210
|
+
return wasmContext.get_data_by_key(uniqueId, key);
|
|
233
211
|
},
|
|
234
212
|
__SetAttribute(element, name, value) {
|
|
235
213
|
if (name === 'update-list-info') {
|
|
@@ -255,12 +233,10 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
255
233
|
}
|
|
256
234
|
if (name === 'exposure-id') {
|
|
257
235
|
if (value != null) {
|
|
258
|
-
|
|
259
|
-
mtsBinding.markExposureRelatedElementByUniqueId(uniqueId, true);
|
|
236
|
+
mtsBinding.markExposureRelatedElementByUniqueId(element, true);
|
|
260
237
|
}
|
|
261
238
|
else {
|
|
262
|
-
|
|
263
|
-
mtsBinding.markExposureRelatedElementByUniqueId(uniqueId, false);
|
|
239
|
+
mtsBinding.markExposureRelatedElementByUniqueId(element, false);
|
|
264
240
|
}
|
|
265
241
|
}
|
|
266
242
|
else if (name === LYNX_TIMING_FLAG_ATTRIBUTE) {
|
|
@@ -271,11 +247,11 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
271
247
|
__AddEvent,
|
|
272
248
|
__GetEvent: (element, eventType, eventName) => {
|
|
273
249
|
const uniqueId = element[uniqueIdSymbol];
|
|
274
|
-
return wasmContext.
|
|
250
|
+
return wasmContext.get_event(uniqueId, eventType, eventName);
|
|
275
251
|
},
|
|
276
252
|
__GetEvents: (element) => {
|
|
277
253
|
const uniqueId = element[uniqueIdSymbol];
|
|
278
|
-
return wasmContext.
|
|
254
|
+
return wasmContext.get_events(uniqueId);
|
|
279
255
|
},
|
|
280
256
|
__SetEvents: (element, events) => {
|
|
281
257
|
for (const event of events) {
|
|
@@ -326,7 +302,7 @@ export function createElementAPI(entryTemplateUrl, rootDom, mtsBinding, config_e
|
|
|
326
302
|
backgroundThread.markTiming('dispatch_end', pipelineId);
|
|
327
303
|
backgroundThread.flushTimingInfo();
|
|
328
304
|
}
|
|
329
|
-
let timingFlagsAll = timingFlags.concat(wasmContext.
|
|
305
|
+
let timingFlagsAll = timingFlags.concat(wasmContext.take_timing_flags());
|
|
330
306
|
requestAnimationFrame(() => {
|
|
331
307
|
mtsBinding.postTimingFlags(timingFlagsAll, pipelineId);
|
|
332
308
|
});
|
package/dist/client/wasm.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
export declare const wasmInstance: typeof import("../../binary/client/client.js"), wasmModule: WebAssembly.Module | undefined;
|
|
2
|
-
export declare
|
|
3
|
-
#private;
|
|
4
|
-
static webWorkerDecode(data: Uint8Array, configEnableCssSelector: boolean, entryName?: string): Uint8Array<ArrayBufferLike>;
|
|
5
|
-
readonly style_content: string;
|
|
6
|
-
readonly font_face_content: string;
|
|
7
|
-
constructor(data: Uint8Array);
|
|
8
|
-
query_css_og_declarations_by_css_id: InstanceType<typeof wasmInstance.DecodedStyleData>['query_css_og_declarations_by_css_id'];
|
|
9
|
-
}
|
|
2
|
+
export declare const templateManagerWasm: import("../../binary/client/client.js").TemplateManager | undefined;
|
|
10
3
|
export type MainThreadWasmContext = typeof import('../../binary/client/client.js').MainThreadWasmContext;
|
|
11
|
-
export type ElementTemplateSection = typeof import('../../binary/client/client.js').ElementTemplateSection;
|
package/dist/client/wasm.js
CHANGED
|
@@ -32,21 +32,7 @@ export const [wasmInstance, wasmModule] = await wasmLoaded;
|
|
|
32
32
|
if (!isWorker) {
|
|
33
33
|
wasmInstance.initSync({ module: wasmModule });
|
|
34
34
|
}
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
#styleData;
|
|
40
|
-
style_content;
|
|
41
|
-
font_face_content;
|
|
42
|
-
constructor(data) {
|
|
43
|
-
this.#styleData = new wasmInstance.DecodedStyleData(data);
|
|
44
|
-
// cache the string result to avoid multiple utf8 -> utf16 string transformation
|
|
45
|
-
this.style_content = this.#styleData.style_content;
|
|
46
|
-
this.font_face_content = this.#styleData.font_face_content;
|
|
47
|
-
this.query_css_og_declarations_by_css_id = this.#styleData
|
|
48
|
-
.query_css_og_declarations_by_css_id.bind(this.#styleData);
|
|
49
|
-
}
|
|
50
|
-
query_css_og_declarations_by_css_id;
|
|
51
|
-
}
|
|
35
|
+
export const templateManagerWasm = isWorker
|
|
36
|
+
? undefined
|
|
37
|
+
: new wasmInstance.TemplateManager();
|
|
52
38
|
//# sourceMappingURL=wasm.js.map
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import '@lynx-js/web-elements/XView';
|
|
2
|
-
import '@lynx-js/web-elements/XText';
|
|
3
|
-
import '@lynx-js/web-elements/XImage';
|
|
4
|
-
import '@lynx-js/web-elements/XSvg';
|
|
5
|
-
import '@lynx-js/web-elements/LynxWrapper';
|
|
6
|
-
import '@lynx-js/web-elements/ScrollView';
|
|
7
|
-
export declare function loadWebElement(id: number): Promise<void> | undefined;
|
|
8
1
|
export declare function loadAllWebElements(): Promise<void>;
|
|
@@ -3,78 +3,9 @@
|
|
|
3
3
|
* Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
5
5
|
*/
|
|
6
|
-
import '@lynx-js/web-elements/XView';
|
|
7
|
-
import '@lynx-js/web-elements/XText';
|
|
8
|
-
import '@lynx-js/web-elements/XImage';
|
|
9
|
-
import '@lynx-js/web-elements/XSvg';
|
|
10
|
-
import '@lynx-js/web-elements/LynxWrapper';
|
|
11
|
-
import '@lynx-js/web-elements/ScrollView';
|
|
12
|
-
const loadedWebElementsCSSIds = new Set();
|
|
13
|
-
export function loadWebElement(id) {
|
|
14
|
-
if (loadedWebElementsCSSIds.has(id)) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
let promise = undefined;
|
|
18
|
-
switch (id) {
|
|
19
|
-
case 0:
|
|
20
|
-
promise = import(
|
|
21
|
-
/* webpackChunkName: "web-elements-list" */
|
|
22
|
-
'@lynx-js/web-elements/XList');
|
|
23
|
-
break;
|
|
24
|
-
case 1:
|
|
25
|
-
promise = import(
|
|
26
|
-
/* webpackChunkName: "web-elements-swiper" */
|
|
27
|
-
'@lynx-js/web-elements/XSwiper');
|
|
28
|
-
break;
|
|
29
|
-
case 2:
|
|
30
|
-
promise = import(
|
|
31
|
-
/* webpackChunkName: "web-elements-input" */
|
|
32
|
-
'@lynx-js/web-elements/XInput');
|
|
33
|
-
break;
|
|
34
|
-
case 3:
|
|
35
|
-
promise = import(
|
|
36
|
-
/* webpackChunkName: "web-elements-textarea" */
|
|
37
|
-
'@lynx-js/web-elements/XTextarea');
|
|
38
|
-
break;
|
|
39
|
-
case 4:
|
|
40
|
-
promise = import(
|
|
41
|
-
/* webpackChunkName: "web-elements-audio" */
|
|
42
|
-
'@lynx-js/web-elements/XAudioTT');
|
|
43
|
-
break;
|
|
44
|
-
case 5:
|
|
45
|
-
promise = import(
|
|
46
|
-
/* webpackChunkName: "web-elements-foldview" */
|
|
47
|
-
'@lynx-js/web-elements/XFoldViewNg');
|
|
48
|
-
break;
|
|
49
|
-
case 6:
|
|
50
|
-
promise = import(
|
|
51
|
-
/* webpackChunkName: "web-elements-refrshview" */
|
|
52
|
-
'@lynx-js/web-elements/XRefreshView');
|
|
53
|
-
break;
|
|
54
|
-
case 7:
|
|
55
|
-
promise = import(
|
|
56
|
-
/* webpackChunkName: "web-elements-overlay" */
|
|
57
|
-
'@lynx-js/web-elements/XOverlayNg');
|
|
58
|
-
break;
|
|
59
|
-
case 8:
|
|
60
|
-
promise = import(
|
|
61
|
-
/* webpackChunkName: "web-elements-viewpager" */
|
|
62
|
-
'@lynx-js/web-elements/XViewpagerNg');
|
|
63
|
-
break;
|
|
64
|
-
default:
|
|
65
|
-
}
|
|
66
|
-
return promise?.then(() => {
|
|
67
|
-
loadedWebElementsCSSIds.add(id);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
6
|
export function loadAllWebElements() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (p) {
|
|
75
|
-
promises.push(p);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return Promise.all(promises);
|
|
7
|
+
return import(
|
|
8
|
+
/* webpackChunkName: "web-elements" */
|
|
9
|
+
'@lynx-js/web-elements/all').then(() => { });
|
|
79
10
|
}
|
|
80
11
|
//# sourceMappingURL=webElementsDynamicLoader.js.map
|