@lynx-js/web-core-wasm-canary 0.0.0 → 0.0.1-canary-20260116-ce265e8f
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 +8 -0
- package/{LICENSE → LICENSE.txt} +1 -1
- package/Notice.txt +1 -0
- package/README.md +1 -0
- package/binary/client/client.d.ts +263 -0
- package/binary/client/client.js +1339 -0
- package/binary/client/client_bg.wasm +0 -0
- package/binary/client/client_bg.wasm.d.ts +70 -0
- package/binary/client/client_debug.d.ts +263 -0
- package/binary/client/client_debug.js +1339 -0
- package/binary/client/client_debug_bg.wasm +0 -0
- package/binary/client/client_debug_bg.wasm.d.ts +70 -0
- package/binary/encode/encode.d.ts +157 -0
- package/binary/encode/encode.js +17 -0
- package/binary/encode/encode_bg.js +749 -0
- package/binary/encode/encode_bg.wasm +0 -0
- package/binary/encode/encode_bg.wasm.d.ts +50 -0
- package/binary/encode/encode_debug.d.ts +157 -0
- package/binary/encode/encode_debug.js +17 -0
- package/binary/encode/encode_debug_bg.js +822 -0
- package/binary/encode/encode_debug_bg.wasm +0 -0
- package/binary/encode/encode_debug_bg.wasm.d.ts +50 -0
- package/binary/encode/package.json +4 -0
- package/css/in_shadow.css +10 -0
- package/css/index.css +119 -0
- package/dist/client/LynxCrossThreadContext.d.ts +22 -0
- package/dist/client/LynxCrossThreadContext.js +44 -0
- package/dist/client/background/background-apis/createBackgroundLynx.d.ts +24 -0
- package/dist/client/background/background-apis/createBackgroundLynx.js +38 -0
- package/dist/client/background/background-apis/createChunkLoading.d.ts +7 -0
- package/dist/client/background/background-apis/createChunkLoading.js +66 -0
- package/dist/client/background/background-apis/createElement.d.ts +5 -0
- package/dist/client/background/background-apis/createElement.js +18 -0
- package/dist/client/background/background-apis/createNapiLoader.d.ts +5 -0
- package/dist/client/background/background-apis/createNapiLoader.js +23 -0
- package/dist/client/background/background-apis/createNativeApp.d.ts +4 -0
- package/dist/client/background/background-apis/createNativeApp.js +98 -0
- package/dist/client/background/background-apis/createNativeModules.d.ts +3 -0
- package/dist/client/background/background-apis/createNativeModules.js +33 -0
- package/dist/client/background/background-apis/createPerformanceApis.d.ts +3 -0
- package/dist/client/background/background-apis/createPerformanceApis.js +47 -0
- package/dist/client/background/background-apis/createTimingSystem.d.ts +8 -0
- package/dist/client/background/background-apis/createTimingSystem.js +86 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createGetCustomSection.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createGetCustomSection.js +14 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createGetPathInfo.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createGetPathInfo.js +23 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createInvokeUIMethod.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createInvokeUIMethod.js +24 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createJSObjectDestructionObserver.d.ts +2 -0
- package/dist/client/background/background-apis/crossThreadHandlers/createJSObjectDestructionObserver.js +12 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerDisposeHandler.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerDisposeHandler.js +9 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerPublicComponentEventHandler.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerPublicComponentEventHandler.js +8 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerPublishEventHandler.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerPublishEventHandler.js +8 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerSendGlobalEvent.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerSendGlobalEvent.js +10 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateDataHandler.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateDataHandler.js +5 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.js +5 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateI18nResource.d.ts +3 -0
- package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateI18nResource.js +9 -0
- package/dist/client/background/background-apis/startBackgroundThread.d.ts +2 -0
- package/dist/client/background/background-apis/startBackgroundThread.js +42 -0
- package/dist/client/background/index.d.ts +1 -0
- package/dist/client/background/index.js +15 -0
- package/dist/client/decodeWorker/cssLoader.d.ts +12 -0
- package/dist/client/decodeWorker/cssLoader.js +96 -0
- package/dist/client/decodeWorker/decode.worker.d.ts +1 -0
- package/dist/client/decodeWorker/decode.worker.js +338 -0
- package/dist/client/decodeWorker/types.d.ts +32 -0
- package/dist/client/decodeWorker/types.js +2 -0
- package/dist/client/endpoints.d.ts +53 -0
- package/dist/client/endpoints.js +37 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +3 -0
- package/dist/client/mainthread/Background.d.ts +30 -0
- package/dist/client/mainthread/Background.js +207 -0
- package/dist/client/mainthread/ExposureServices.d.ts +11 -0
- package/dist/client/mainthread/ExposureServices.js +211 -0
- package/dist/client/mainthread/I18n.d.ts +9 -0
- package/dist/client/mainthread/I18n.js +44 -0
- package/dist/client/mainthread/LynxView.d.ts +170 -0
- package/dist/client/mainthread/LynxView.js +367 -0
- package/dist/client/mainthread/LynxViewInstance.d.ts +56 -0
- package/dist/client/mainthread/LynxViewInstance.js +196 -0
- package/dist/client/mainthread/StyleManager.d.ts +15 -0
- package/dist/client/mainthread/StyleManager.js +72 -0
- package/dist/client/mainthread/TemplateManager.d.ts +11 -0
- package/dist/client/mainthread/TemplateManager.js +257 -0
- package/dist/client/mainthread/createIFrameRealm.d.ts +6 -0
- package/dist/client/mainthread/createIFrameRealm.js +68 -0
- package/dist/client/mainthread/createMainThreadGlobalAPIs.d.ts +3 -0
- package/dist/client/mainthread/createMainThreadGlobalAPIs.js +82 -0
- package/dist/client/mainthread/crossThreadHandlers/queryNodes.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/queryNodes.js +74 -0
- package/dist/client/mainthread/crossThreadHandlers/registerGetPathInfoHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerGetPathInfoHandler.js +51 -0
- package/dist/client/mainthread/crossThreadHandlers/registerInvokeUIMethodHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerInvokeUIMethodHandler.js +49 -0
- package/dist/client/mainthread/crossThreadHandlers/registerNapiModulesCallHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerNapiModulesCallHandler.js +8 -0
- package/dist/client/mainthread/crossThreadHandlers/registerNativeModulesCallHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerNativeModulesCallHandler.js +7 -0
- package/dist/client/mainthread/crossThreadHandlers/registerSelectComponentHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerSelectComponentHandler.js +20 -0
- package/dist/client/mainthread/crossThreadHandlers/registerSetNativePropsHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerSetNativePropsHandler.js +28 -0
- package/dist/client/mainthread/crossThreadHandlers/registerTriggerComponentEventHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerTriggerComponentEventHandler.js +12 -0
- package/dist/client/mainthread/crossThreadHandlers/registerTriggerElementMethodEndpointHandler.d.ts +3 -0
- package/dist/client/mainthread/crossThreadHandlers/registerTriggerElementMethodEndpointHandler.js +29 -0
- package/dist/client/mainthread/elementAPIs/WASMJSBinding.d.ts +38 -0
- package/dist/client/mainthread/elementAPIs/WASMJSBinding.js +122 -0
- package/dist/client/mainthread/elementAPIs/createCrossThreadEvent.d.ts +2 -0
- package/dist/client/mainthread/elementAPIs/createCrossThreadEvent.js +77 -0
- package/dist/client/mainthread/elementAPIs/createElementAPI.d.ts +3 -0
- package/dist/client/mainthread/elementAPIs/createElementAPI.js +346 -0
- package/dist/client/mainthread/elementAPIs/index.d.ts +2 -0
- package/dist/client/mainthread/elementAPIs/index.js +3 -0
- package/dist/client/mainthread/elementAPIs/pureElementPAPIs.d.ts +26 -0
- package/dist/client/mainthread/elementAPIs/pureElementPAPIs.js +85 -0
- package/dist/client/mainthread/utils/convertLengthToPx.d.ts +1 -0
- package/dist/client/mainthread/utils/convertLengthToPx.js +25 -0
- package/dist/client/wasm.d.ts +11 -0
- package/dist/client/wasm.js +52 -0
- package/dist/client/webElementsDynamicLoader.d.ts +8 -0
- package/dist/client/webElementsDynamicLoader.js +80 -0
- package/dist/client_prod/static/css/async/web-core-main-chunk.css +1 -0
- package/dist/client_prod/static/css/client.css +1 -0
- package/dist/client_prod/static/js/async/lynx-core-chunk.js +3 -0
- package/dist/client_prod/static/js/async/web-core-main-chunk.js +303 -0
- package/dist/client_prod/static/js/async/web-core-template-loader-thread.js +8 -0
- package/dist/client_prod/static/js/async/web-core-worker-chunk.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-audio.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-foldview.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-input.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-list.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-overlay.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-refrshview.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-swiper.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-textarea.js +1 -0
- package/dist/client_prod/static/js/async/web-elements-viewpager.js +1 -0
- package/dist/client_prod/static/js/client.js +2 -0
- package/dist/client_prod/static/wasm/7ff75609.module.wasm +0 -0
- package/dist/constants.d.ts +58 -0
- package/dist/constants.js +114 -0
- package/dist/encode/encodeCSS.d.ts +3 -0
- package/dist/encode/encodeCSS.js +99 -0
- package/dist/encode/encodeElementTemplate.d.ts +2 -0
- package/dist/encode/encodeElementTemplate.js +52 -0
- package/dist/encode/index.d.ts +1 -0
- package/dist/encode/index.js +7 -0
- package/dist/encode/webEncoder.d.ts +21 -0
- package/dist/encode/webEncoder.js +125 -0
- package/dist/types/BTSChunk.d.ts +3 -0
- package/dist/types/BTSChunk.js +5 -0
- package/dist/types/Cloneable.d.ts +2 -0
- package/dist/types/Cloneable.js +2 -0
- package/dist/types/DecodedTemplate.d.ts +10 -0
- package/dist/types/DecodedTemplate.js +7 -0
- package/dist/types/Element.d.ts +35 -0
- package/dist/types/Element.js +5 -0
- package/dist/types/ElementTemplateData.d.ts +15 -0
- package/dist/types/ElementTemplateData.js +7 -0
- package/dist/types/EventType.d.ts +56 -0
- package/dist/types/EventType.js +5 -0
- package/dist/types/I18nTypes.d.ts +21 -0
- package/dist/types/I18nTypes.js +2 -0
- package/dist/types/IElementPAPI.d.ts +184 -0
- package/dist/types/IElementPAPI.js +2 -0
- package/dist/types/IMtsBinding.d.ts +11 -0
- package/dist/types/IMtsBinding.js +7 -0
- package/dist/types/JSRealm.d.ts +5 -0
- package/dist/types/JSRealm.js +7 -0
- package/dist/types/LynxContextEventTarget.d.ts +12 -0
- package/dist/types/LynxContextEventTarget.js +5 -0
- package/dist/types/MainThreadLynx.d.ts +15 -0
- package/dist/types/MainThreadLynx.js +2 -0
- package/dist/types/NapiModules.d.ts +9 -0
- package/dist/types/NapiModules.js +5 -0
- package/dist/types/NativeApp.d.ts +120 -0
- package/dist/types/NativeApp.js +5 -0
- package/dist/types/NativeModules.d.ts +2 -0
- package/dist/types/NativeModules.js +5 -0
- package/dist/types/PageConfig.d.ts +9 -0
- package/dist/types/PageConfig.js +2 -0
- package/dist/types/ProcessDataCallback.d.ts +1 -0
- package/dist/types/ProcessDataCallback.js +2 -0
- package/dist/types/TimingAPIs.d.ts +32 -0
- package/dist/types/TimingAPIs.js +5 -0
- package/dist/types/UpdateDataOptions.d.ts +8 -0
- package/dist/types/UpdateDataOptions.js +6 -0
- package/dist/types/WorkerStartMessage.d.ts +14 -0
- package/dist/types/WorkerStartMessage.js +5 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +7 -0
- package/eslint.config.js +34 -0
- package/package.json +87 -4
- package/index.js +0 -1
- package/selfIdentity.plist +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { queryNodes } from './queryNodes.js';
|
|
2
|
+
import { ErrorCode } from '../../../constants.js';
|
|
3
|
+
import { invokeUIMethodEndpoint } from '../../endpoints.js';
|
|
4
|
+
const methodAlias = {
|
|
5
|
+
'boundingClientRect': (element) => {
|
|
6
|
+
const rect = element.getBoundingClientRect();
|
|
7
|
+
return {
|
|
8
|
+
id: element.id,
|
|
9
|
+
width: rect.width,
|
|
10
|
+
height: rect.height,
|
|
11
|
+
left: rect.left,
|
|
12
|
+
right: rect.right,
|
|
13
|
+
top: rect.top,
|
|
14
|
+
bottom: rect.bottom,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export function registerInvokeUIMethodHandler(rpc, lynxViewInstance) {
|
|
19
|
+
rpc.registerHandler(invokeUIMethodEndpoint, (type, identifier, component_id, method, params, root_unique_id) => {
|
|
20
|
+
let code = ErrorCode.UNKNOWN;
|
|
21
|
+
let data = undefined;
|
|
22
|
+
queryNodes(lynxViewInstance, type, identifier, component_id, true, root_unique_id, (element) => {
|
|
23
|
+
try {
|
|
24
|
+
const aliasMethod = methodAlias[method];
|
|
25
|
+
const hasDomMethod = typeof element[method] === 'function';
|
|
26
|
+
if (!aliasMethod && !hasDomMethod) {
|
|
27
|
+
code = ErrorCode.METHOD_NOT_FOUND;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
if (aliasMethod) {
|
|
31
|
+
data = aliasMethod(element, params);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
data = element[method](params);
|
|
35
|
+
}
|
|
36
|
+
code = ErrorCode.SUCCESS;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
console.error(`[lynx-web] invokeUIMethod: apply method failed with`, e, element);
|
|
41
|
+
code = ErrorCode.PARAM_INVALID;
|
|
42
|
+
}
|
|
43
|
+
}, (error) => {
|
|
44
|
+
code = error;
|
|
45
|
+
});
|
|
46
|
+
return { code, data };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=registerInvokeUIMethodHandler.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { dispatchNapiModuleEndpoint, napiModulesCallEndpoint, } from '../../endpoints.js';
|
|
2
|
+
export function registerNapiModulesCallHandler(rpc, lynxViewInstance) {
|
|
3
|
+
const dispatchNapiModules = rpc.createCall(dispatchNapiModuleEndpoint);
|
|
4
|
+
rpc.registerHandler(napiModulesCallEndpoint, (name, data, moduleName) => {
|
|
5
|
+
return lynxViewInstance.parentDom.onNapiModulesCall?.(name, data, moduleName, dispatchNapiModules);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=registerNapiModulesCallHandler.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { nativeModulesCallEndpoint } from '../../endpoints.js';
|
|
2
|
+
export function registerNativeModulesCallHandler(rpc, lynxViewInstance) {
|
|
3
|
+
rpc.registerHandler(nativeModulesCallEndpoint, (name, data, moduleName) => {
|
|
4
|
+
return lynxViewInstance.parentDom.onNativeModulesCall?.(name, data, moduleName);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=registerNativeModulesCallHandler.js.map
|
|
@@ -0,0 +1,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 { queryNodes } from './queryNodes.js';
|
|
5
|
+
import { selectComponentEndpoint } from '../../endpoints.js';
|
|
6
|
+
import { IdentifierType } from '../../../constants.js';
|
|
7
|
+
export function registerSelectComponentHandler(rpc, lynxViewInstance) {
|
|
8
|
+
rpc.registerHandler(selectComponentEndpoint, (componentId, idSelector, single) => {
|
|
9
|
+
let element = null;
|
|
10
|
+
queryNodes(lynxViewInstance, IdentifierType.ID_SELECTOR, idSelector, componentId === 'card' ? '0' : componentId, single, undefined, (ele) => {
|
|
11
|
+
element = ele;
|
|
12
|
+
});
|
|
13
|
+
if (!element)
|
|
14
|
+
return [];
|
|
15
|
+
return [
|
|
16
|
+
lynxViewInstance.mainThreadGlobalThis.__GetComponentID(element),
|
|
17
|
+
];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=registerSelectComponentHandler.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { queryNodes } from './queryNodes.js';
|
|
2
|
+
import { setNativePropsEndpoint } from '../../endpoints.js';
|
|
3
|
+
function applyNativeProps(element, nativeProps) {
|
|
4
|
+
for (const key in nativeProps) {
|
|
5
|
+
const value = nativeProps[key];
|
|
6
|
+
if (key === 'text' && element?.tagName === 'X-TEXT') {
|
|
7
|
+
if (element.firstElementChild
|
|
8
|
+
&& element.firstElementChild.tagName == 'RAW-TEXT') {
|
|
9
|
+
element = element.firstElementChild;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (CSS.supports(key, value)
|
|
13
|
+
&& element.style) {
|
|
14
|
+
element.style.setProperty(key, value);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
element.setAttribute(key, value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function registerNativePropsHandler(rpc, lynxViewInstance) {
|
|
22
|
+
rpc.registerHandler(setNativePropsEndpoint, (type, identifier, component_id, first_only, native_props, root_unique_id) => {
|
|
23
|
+
queryNodes(lynxViewInstance, type, identifier, component_id, first_only, root_unique_id, (element) => {
|
|
24
|
+
applyNativeProps(element, native_props);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=registerSetNativePropsHandler.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { triggerComponentEventEndpoint } from '../../endpoints.js';
|
|
2
|
+
export function registerTriggerComponentEventHandler(rpc, lynxViewInstance) {
|
|
3
|
+
rpc.registerHandler(triggerComponentEventEndpoint, (id, params) => {
|
|
4
|
+
const componentDom = lynxViewInstance.mtsWasmBinding
|
|
5
|
+
.getElementByComponentId(id);
|
|
6
|
+
componentDom?.dispatchEvent(new CustomEvent(id, {
|
|
7
|
+
...params.eventOption,
|
|
8
|
+
detail: params.eventDetail,
|
|
9
|
+
}));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=registerTriggerComponentEventHandler.js.map
|
package/dist/client/mainthread/crossThreadHandlers/registerTriggerElementMethodEndpointHandler.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { triggerElementMethodEndpoint } from '../../endpoints.js';
|
|
2
|
+
import { AnimationOperation } from '../../../constants.js';
|
|
3
|
+
export function registerTriggerElementMethodEndpointHandler(rpc, lynxViewInstance) {
|
|
4
|
+
const animationMap = new Map();
|
|
5
|
+
rpc.registerHandler(triggerElementMethodEndpoint, (method, id, options) => {
|
|
6
|
+
if (method === 'animate') {
|
|
7
|
+
switch (options.operation) {
|
|
8
|
+
case AnimationOperation.START:
|
|
9
|
+
animationMap.set(options.id, lynxViewInstance.rootDom.querySelector(id)?.animate(options.keyframes, options.timingOptions));
|
|
10
|
+
break;
|
|
11
|
+
case AnimationOperation.PLAY:
|
|
12
|
+
animationMap.get(options.id)?.play();
|
|
13
|
+
break;
|
|
14
|
+
case AnimationOperation.PAUSE:
|
|
15
|
+
animationMap.get(options.id)?.pause();
|
|
16
|
+
break;
|
|
17
|
+
case AnimationOperation.CANCEL:
|
|
18
|
+
animationMap.get(options.id)?.cancel();
|
|
19
|
+
animationMap.delete(options.id);
|
|
20
|
+
break;
|
|
21
|
+
case AnimationOperation.FINISH:
|
|
22
|
+
animationMap.get(options.id)?.finish();
|
|
23
|
+
animationMap.delete(options.id);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=registerTriggerElementMethodEndpointHandler.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { LynxCrossThreadEvent, LynxCrossThreadEventTarget, DecoratedHTMLElement, RustMainthreadContextBinding, CloneableObject, MainThreadGlobalThis } from '../../../types/index.js';
|
|
2
|
+
import type { MainThreadWasmContext } from '../../wasm.js';
|
|
3
|
+
import type { BackgroundThread } from '../Background.js';
|
|
4
|
+
import type { ExposureServices } from '../ExposureServices.js';
|
|
5
|
+
import type { StyleManager } from '../StyleManager.js';
|
|
6
|
+
export type WASMJSBindingInjectedHandler = {
|
|
7
|
+
rootDom: ShadowRoot;
|
|
8
|
+
backgroundThread: BackgroundThread;
|
|
9
|
+
exposureServices: ExposureServices;
|
|
10
|
+
loadWebElement: (elementId: number) => void;
|
|
11
|
+
loadUnknownElement: (tagName: string) => void;
|
|
12
|
+
mainThreadGlobalThis: MainThreadGlobalThis;
|
|
13
|
+
styleManager?: StyleManager;
|
|
14
|
+
};
|
|
15
|
+
export declare class WASMJSBinding implements RustMainthreadContextBinding {
|
|
16
|
+
#private;
|
|
17
|
+
readonly lynxViewInstance: WASMJSBindingInjectedHandler;
|
|
18
|
+
wasmContext: InstanceType<MainThreadWasmContext> | undefined;
|
|
19
|
+
uniqueIdToElement: (HTMLElement | undefined)[];
|
|
20
|
+
toBeEnabledElement: Set<HTMLElement>;
|
|
21
|
+
toBeDisabledElement: Set<HTMLElement>;
|
|
22
|
+
constructor(lynxViewInstance: WASMJSBindingInjectedHandler);
|
|
23
|
+
markExposureRelatedElementByUniqueId(uniqueId: number, toEnable: boolean): void;
|
|
24
|
+
loadInternalWebElement: (elementId: number) => void;
|
|
25
|
+
loadUnknownElement: (tagName: string) => void;
|
|
26
|
+
generateTargetObject(element: DecoratedHTMLElement, dataset: CloneableObject): LynxCrossThreadEventTarget;
|
|
27
|
+
getElementByUniqueId(uniqueId: number): HTMLElement | undefined;
|
|
28
|
+
getElementByComponentId(componentId: string): HTMLElement | undefined;
|
|
29
|
+
runWorklet(handler: {
|
|
30
|
+
value: unknown;
|
|
31
|
+
}, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: Record<string, string>, currentTargetUniqueId: number, currentTargetDataset: Record<string, string>): void;
|
|
32
|
+
publishEvent(handlerName: string, parentComponentId: string | undefined, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: CloneableObject, currentTargetUniqueId: number, currentTargetDataset: CloneableObject): void;
|
|
33
|
+
addEventListener(eventName: string): void;
|
|
34
|
+
postTimingFlags(flags: string[], pipelineId?: string): void;
|
|
35
|
+
updateExposureStatus(enabledExposureElements: HTMLElement[], disabledExposureElements: HTMLElement[]): void;
|
|
36
|
+
enableElementEvent(uniqueId: number, eventName: string): void;
|
|
37
|
+
disableElementEvent(uniqueId: number, eventName: string): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createCrossThreadEvent } from './createCrossThreadEvent.js';
|
|
2
|
+
import { LynxEventNameToW3cCommon, uniqueIdSymbol, } from '../../../constants.js';
|
|
3
|
+
import { __GetElementUniqueID } from './pureElementPAPIs.js';
|
|
4
|
+
export class WASMJSBinding {
|
|
5
|
+
lynxViewInstance;
|
|
6
|
+
wasmContext;
|
|
7
|
+
uniqueIdToElement = [undefined];
|
|
8
|
+
toBeEnabledElement = new Set();
|
|
9
|
+
toBeDisabledElement = new Set();
|
|
10
|
+
constructor(lynxViewInstance) {
|
|
11
|
+
this.lynxViewInstance = lynxViewInstance;
|
|
12
|
+
this.loadInternalWebElement = this.lynxViewInstance.loadWebElement.bind(this.lynxViewInstance);
|
|
13
|
+
this.loadUnknownElement = this.lynxViewInstance.loadUnknownElement.bind(this.lynxViewInstance);
|
|
14
|
+
}
|
|
15
|
+
markExposureRelatedElementByUniqueId(uniqueId, toEnable) {
|
|
16
|
+
const dom = this.uniqueIdToElement[uniqueId];
|
|
17
|
+
if (dom) {
|
|
18
|
+
if (toEnable) {
|
|
19
|
+
this.toBeDisabledElement.delete(dom);
|
|
20
|
+
this.toBeEnabledElement.add(dom);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.toBeEnabledElement.delete(dom);
|
|
24
|
+
this.toBeDisabledElement.add(dom);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
loadInternalWebElement;
|
|
29
|
+
loadUnknownElement;
|
|
30
|
+
generateTargetObject(element, dataset) {
|
|
31
|
+
const uniqueId = element[uniqueIdSymbol];
|
|
32
|
+
return {
|
|
33
|
+
dataset: Object.assign(Object.create(null), dataset),
|
|
34
|
+
id: element.id || null,
|
|
35
|
+
uniqueId,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
getElementByUniqueId(uniqueId) {
|
|
39
|
+
return this.uniqueIdToElement[uniqueId];
|
|
40
|
+
}
|
|
41
|
+
getElementByComponentId(componentId) {
|
|
42
|
+
const uniqueId = this.wasmContext?.__wasm_get_unique_id_by_component_id(componentId);
|
|
43
|
+
if (uniqueId != undefined) {
|
|
44
|
+
return this.getElementByUniqueId(uniqueId);
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
runWorklet(handler, eventObject, targetUniqueId, targetDataset, currentTargetUniqueId, currentTargetDataset) {
|
|
49
|
+
const target = this.getElementByUniqueId(targetUniqueId);
|
|
50
|
+
const currentTarget = this.getElementByUniqueId(currentTargetUniqueId);
|
|
51
|
+
eventObject.target = this.generateTargetObject(target, targetDataset);
|
|
52
|
+
eventObject.currentTarget = this.generateTargetObject(currentTarget, currentTargetDataset);
|
|
53
|
+
// @ts-expect-error
|
|
54
|
+
eventObject.target.elementRefptr = target;
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
eventObject.currentTarget.elementRefptr = currentTarget;
|
|
57
|
+
this.lynxViewInstance.mainThreadGlobalThis.runWorklet?.(handler.value, [
|
|
58
|
+
eventObject,
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
publishEvent(handlerName, parentComponentId, eventObject, targetUniqueId, targetDataset, currentTargetUniqueId, currentTargetDataset) {
|
|
62
|
+
const target = this.getElementByUniqueId(targetUniqueId);
|
|
63
|
+
const currentTarget = this.getElementByUniqueId(currentTargetUniqueId);
|
|
64
|
+
eventObject.target = this.generateTargetObject(target, targetDataset);
|
|
65
|
+
eventObject.currentTarget = this.generateTargetObject(currentTarget, currentTargetDataset);
|
|
66
|
+
if (parentComponentId) {
|
|
67
|
+
this.lynxViewInstance?.backgroundThread.publicComponentEvent(parentComponentId, handlerName, eventObject);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.lynxViewInstance.backgroundThread.publishEvent(handlerName, eventObject);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
#commonEventHandler = (event) => {
|
|
74
|
+
const target = event.target;
|
|
75
|
+
let bubblePath = new Uint32Array(32);
|
|
76
|
+
let bubblePathLength = 0;
|
|
77
|
+
bubblePath;
|
|
78
|
+
let currentTarget = target;
|
|
79
|
+
while (currentTarget) {
|
|
80
|
+
if (currentTarget === this.lynxViewInstance.rootDom) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const uniqueId = __GetElementUniqueID(currentTarget);
|
|
84
|
+
bubblePath[bubblePathLength++] = uniqueId;
|
|
85
|
+
if (bubblePathLength >= bubblePath.length) {
|
|
86
|
+
const newBubblePath = new Uint32Array(bubblePath.length * 2);
|
|
87
|
+
newBubblePath.set(bubblePath);
|
|
88
|
+
bubblePath = newBubblePath;
|
|
89
|
+
}
|
|
90
|
+
currentTarget = currentTarget.parentElement;
|
|
91
|
+
}
|
|
92
|
+
const eventObject = createCrossThreadEvent(event);
|
|
93
|
+
this.wasmContext?.__wasm_commonEventHandler(eventObject, bubblePath.slice(0, bubblePathLength), eventObject.type);
|
|
94
|
+
};
|
|
95
|
+
addEventListener(eventName) {
|
|
96
|
+
this.lynxViewInstance.rootDom.addEventListener(LynxEventNameToW3cCommon[eventName] ?? eventName, this.#commonEventHandler, {
|
|
97
|
+
passive: true,
|
|
98
|
+
capture: true,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
postTimingFlags(flags, pipelineId) {
|
|
102
|
+
this.lynxViewInstance.backgroundThread.postTimingFlags(flags, pipelineId);
|
|
103
|
+
}
|
|
104
|
+
updateExposureStatus(enabledExposureElements, disabledExposureElements) {
|
|
105
|
+
this.lynxViewInstance.exposureServices.updateExposureStatus(enabledExposureElements, disabledExposureElements);
|
|
106
|
+
}
|
|
107
|
+
enableElementEvent(uniqueId, eventName) {
|
|
108
|
+
const element = this.getElementByUniqueId(uniqueId);
|
|
109
|
+
if (element) {
|
|
110
|
+
// @ts-expect-error
|
|
111
|
+
element.enableEvent?.(LynxEventNameToW3cCommon[eventName] ?? eventName);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
disableElementEvent(uniqueId, eventName) {
|
|
115
|
+
const element = this.getElementByUniqueId(uniqueId);
|
|
116
|
+
if (element) {
|
|
117
|
+
// @ts-expect-error
|
|
118
|
+
element.disableEvent?.(LynxEventNameToW3cCommon[eventName] ?? eventName);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=WASMJSBinding.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { W3cEventNameToLynx } from '../../../constants.js';
|
|
2
|
+
function toCloneableObject(obj) {
|
|
3
|
+
const cloneableObj = {};
|
|
4
|
+
for (const key in obj) {
|
|
5
|
+
const value = obj[key];
|
|
6
|
+
if (typeof value === 'boolean' || typeof value === 'number'
|
|
7
|
+
|| typeof value === 'string' || value === null) {
|
|
8
|
+
cloneableObj[key] = value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return cloneableObj;
|
|
12
|
+
}
|
|
13
|
+
export function createCrossThreadEvent(domEvent) {
|
|
14
|
+
const type = domEvent.type;
|
|
15
|
+
const params = {};
|
|
16
|
+
const isTrusted = domEvent.isTrusted;
|
|
17
|
+
const otherProperties = {};
|
|
18
|
+
let detail = domEvent.detail ?? {};
|
|
19
|
+
if (type.match(/^transition/)) {
|
|
20
|
+
Object.assign(params, {
|
|
21
|
+
'animation_type': 'keyframe-animation',
|
|
22
|
+
'animation_name': domEvent.propertyName,
|
|
23
|
+
new_animator: true, // we support the new_animator only
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (type.match(/animation/)) {
|
|
27
|
+
Object.assign(params, {
|
|
28
|
+
'animation_type': 'keyframe-animation',
|
|
29
|
+
'animation_name': domEvent.animationName,
|
|
30
|
+
new_animator: true, // we support the new_animator only
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (type.startsWith('touch')) {
|
|
34
|
+
const touchEvent = domEvent;
|
|
35
|
+
const touch = [...touchEvent.touches];
|
|
36
|
+
const targetTouches = [...touchEvent.targetTouches];
|
|
37
|
+
const changedTouches = [...touchEvent.changedTouches];
|
|
38
|
+
Object.assign(otherProperties, {
|
|
39
|
+
touches: isTrusted ? touch.map(toCloneableObject) : touch,
|
|
40
|
+
targetTouches: isTrusted
|
|
41
|
+
? targetTouches.map(toCloneableObject)
|
|
42
|
+
: targetTouches,
|
|
43
|
+
changedTouches: isTrusted
|
|
44
|
+
? changedTouches.map(toCloneableObject)
|
|
45
|
+
: changedTouches,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else if (type.startsWith('mouse')) {
|
|
49
|
+
const mouseEvent = domEvent;
|
|
50
|
+
Object.assign(otherProperties, {
|
|
51
|
+
button: mouseEvent.button,
|
|
52
|
+
buttons: mouseEvent.buttons,
|
|
53
|
+
x: mouseEvent.x,
|
|
54
|
+
y: mouseEvent.y,
|
|
55
|
+
pageX: mouseEvent.pageX,
|
|
56
|
+
pageY: mouseEvent.pageY,
|
|
57
|
+
clientX: mouseEvent.clientX,
|
|
58
|
+
clientY: mouseEvent.clientY,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (type === 'click') {
|
|
62
|
+
detail = {
|
|
63
|
+
x: domEvent.x,
|
|
64
|
+
y: domEvent.y,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const lynxEventName = W3cEventNameToLynx[type] ?? type;
|
|
68
|
+
return {
|
|
69
|
+
type: lynxEventName,
|
|
70
|
+
timestamp: domEvent.timeStamp,
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
detail,
|
|
73
|
+
params,
|
|
74
|
+
...otherProperties,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=createCrossThreadEvent.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ElementPAPIs } from '../../../types/index.js';
|
|
2
|
+
import type { WASMJSBinding } from './WASMJSBinding.js';
|
|
3
|
+
export declare function createElementAPI(entryTemplateUrl: string, rootDom: ShadowRoot, mtsBinding: WASMJSBinding, config_enable_css_selector: boolean, config_default_display_linear: boolean, config_default_overflow_visible: boolean): ElementPAPIs;
|