@lynx-js/web-core-wasm-canary 0.0.0 → 0.0.1-canary-20260116-ff5a5b09
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/e7da3f5d.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,52 @@
|
|
|
1
|
+
import { ElementTemplateSection, RawElementTemplate,
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
} from '../../binary/encode/encode.js';
|
|
4
|
+
export function encodeElementTemplates(elementTemplates) {
|
|
5
|
+
const elementTemplateSection = new ElementTemplateSection();
|
|
6
|
+
for (const [key, templateData] of Object.entries(elementTemplates)) {
|
|
7
|
+
let uniqueId = 1;
|
|
8
|
+
const elementTemplate = new RawElementTemplate();
|
|
9
|
+
function createEncodeOneElementTemplateData(data) {
|
|
10
|
+
const currentId = uniqueId;
|
|
11
|
+
elementTemplate.create_element(data.type, uniqueId);
|
|
12
|
+
uniqueId += 1;
|
|
13
|
+
if (data.attributes) {
|
|
14
|
+
for (const [attrKey, attrValue] of Object.entries(data.attributes)) {
|
|
15
|
+
elementTemplate.set_attribute(currentId, attrKey, attrValue);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (data.builtinAttributes) {
|
|
19
|
+
for (const [attrKey, attrValue] of Object.entries(data.builtinAttributes)) {
|
|
20
|
+
elementTemplate.set_attribute(currentId, attrKey, attrValue);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (data.class) {
|
|
24
|
+
elementTemplate.set_attribute(currentId, 'class', data.class.join(' '));
|
|
25
|
+
}
|
|
26
|
+
if (data.dataset) {
|
|
27
|
+
for (const [dataKey, dataValue] of Object.entries(data.dataset)) {
|
|
28
|
+
elementTemplate.set_dataset(currentId, dataKey, dataValue);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (data.events) {
|
|
32
|
+
for (const event of data.events) {
|
|
33
|
+
elementTemplate.set_cross_thread_event(currentId, event.type, event.name, event.value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (data.idSelector) {
|
|
37
|
+
elementTemplate.set_attribute(currentId, 'id', data.idSelector);
|
|
38
|
+
}
|
|
39
|
+
if (data.children) {
|
|
40
|
+
for (const child of data.children) {
|
|
41
|
+
const childId = createEncodeOneElementTemplateData(child);
|
|
42
|
+
elementTemplate.append_child(currentId, childId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return currentId;
|
|
46
|
+
}
|
|
47
|
+
elementTemplate.append_to_root(createEncodeOneElementTemplateData(templateData));
|
|
48
|
+
elementTemplateSection.add_element_template(key, elementTemplate);
|
|
49
|
+
}
|
|
50
|
+
return elementTemplateSection.encode();
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=encodeElementTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { encode, type TasmJSONInfo } from './webEncoder.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 The Lynx Authors. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
export { encode } from './webEncoder.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 The Lynx Authors. All rights reserved.
|
|
3
|
+
* Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
import type * as CSS from '@lynx-js/css-serializer';
|
|
7
|
+
import type { ElementTemplateData } from '../types/index.js';
|
|
8
|
+
export type TasmJSONInfo = {
|
|
9
|
+
styleInfo: Record<string, CSS.LynxStyleNode[]>;
|
|
10
|
+
manifest: Record<string, string>;
|
|
11
|
+
cardType: string;
|
|
12
|
+
appType: string;
|
|
13
|
+
pageConfig: Record<string, unknown>;
|
|
14
|
+
lepusCode: Record<string, string>;
|
|
15
|
+
customSections: Record<string, {
|
|
16
|
+
type?: 'lazy';
|
|
17
|
+
content: string | Record<string, unknown>;
|
|
18
|
+
}>;
|
|
19
|
+
elementTemplates: Record<string, ElementTemplateData>;
|
|
20
|
+
};
|
|
21
|
+
export declare function encode(tasmJSON: TasmJSONInfo): Uint8Array;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { encodeCSS } from './encodeCSS.js';
|
|
2
|
+
import { encodeElementTemplates } from './encodeElementTemplate.js';
|
|
3
|
+
import { MagicHeader, TemplateSectionLabel } from '../constants.js';
|
|
4
|
+
function encodeAsJSON(map) {
|
|
5
|
+
const jsonString = JSON.stringify(map);
|
|
6
|
+
const utf16Array = new Uint16Array(jsonString.length);
|
|
7
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
8
|
+
utf16Array[i] = jsonString.charCodeAt(i);
|
|
9
|
+
}
|
|
10
|
+
return new Uint8Array(utf16Array.buffer);
|
|
11
|
+
}
|
|
12
|
+
function encodeStringMap(map) {
|
|
13
|
+
const entries = Object.entries(map);
|
|
14
|
+
const count = entries.length;
|
|
15
|
+
// Calculate size
|
|
16
|
+
let size = 4; // count
|
|
17
|
+
const encoder = new TextEncoder();
|
|
18
|
+
const encodedEntries = [];
|
|
19
|
+
for (const [key, val] of entries) {
|
|
20
|
+
const keyBytes = encoder.encode(key);
|
|
21
|
+
const valBytes = encoder.encode(val);
|
|
22
|
+
encodedEntries.push({ keyBytes, valBytes });
|
|
23
|
+
size += 4 + keyBytes.length + 4 + valBytes.length;
|
|
24
|
+
}
|
|
25
|
+
const buffer = new Uint8Array(size);
|
|
26
|
+
const view = new DataView(buffer.buffer);
|
|
27
|
+
let offset = 0;
|
|
28
|
+
view.setUint32(offset, count, true);
|
|
29
|
+
offset += 4;
|
|
30
|
+
for (const { keyBytes, valBytes } of encodedEntries) {
|
|
31
|
+
view.setUint32(offset, keyBytes.length, true);
|
|
32
|
+
offset += 4;
|
|
33
|
+
buffer.set(keyBytes, offset);
|
|
34
|
+
offset += keyBytes.length;
|
|
35
|
+
view.setUint32(offset, valBytes.length, true);
|
|
36
|
+
offset += 4;
|
|
37
|
+
buffer.set(valBytes, offset);
|
|
38
|
+
offset += valBytes.length;
|
|
39
|
+
}
|
|
40
|
+
return buffer;
|
|
41
|
+
}
|
|
42
|
+
export function encode(tasmJSON) {
|
|
43
|
+
const { styleInfo, manifest, cardType, appType, pageConfig, lepusCode, customSections, elementTemplates, } = tasmJSON;
|
|
44
|
+
const encodedStyleInfo = encodeCSS(styleInfo);
|
|
45
|
+
const hasElementTemplates = Object.keys(elementTemplates).length > 0;
|
|
46
|
+
const encodedElementTemplates = hasElementTemplates
|
|
47
|
+
? encodeElementTemplates(elementTemplates)
|
|
48
|
+
: new Uint8Array(0);
|
|
49
|
+
const encodedManifest = encodeStringMap(manifest);
|
|
50
|
+
const encodedLepusCode = encodeStringMap(lepusCode);
|
|
51
|
+
const encodedCustomSections = encodeAsJSON(customSections);
|
|
52
|
+
const configMap = {};
|
|
53
|
+
configMap['cardType'] = cardType;
|
|
54
|
+
configMap['isLazy'] = appType !== 'card' ? 'true' : 'false';
|
|
55
|
+
for (const [key, value] of Object.entries(pageConfig)) {
|
|
56
|
+
configMap[key] = String(value);
|
|
57
|
+
}
|
|
58
|
+
const encodedConfigurations = encodeAsJSON(configMap);
|
|
59
|
+
const bufferLength = 8 // Magic Header
|
|
60
|
+
+ 4 // Version
|
|
61
|
+
/*section label*/
|
|
62
|
+
/*section length*/
|
|
63
|
+
+ 4 + 4 + encodedConfigurations.length // Configurations
|
|
64
|
+
+ 4 + 4 + encodedStyleInfo.length // Style Info
|
|
65
|
+
+ (hasElementTemplates ? 4 + 4 + encodedElementTemplates.length : 0) // Element Templates
|
|
66
|
+
+ 4 + 4 + encodedLepusCode.length // Lepus Code
|
|
67
|
+
+ 4 + 4 + encodedCustomSections.length // Custom Sections
|
|
68
|
+
+ 4 + 4 + encodedManifest.length // Manifest
|
|
69
|
+
;
|
|
70
|
+
// generate final buffer in order
|
|
71
|
+
const buffer = new Uint8Array(bufferLength);
|
|
72
|
+
let offset = 0;
|
|
73
|
+
const dataView = new DataView(buffer.buffer);
|
|
74
|
+
dataView.setBigUint64(offset, BigInt(MagicHeader), true);
|
|
75
|
+
offset += 8;
|
|
76
|
+
// Version
|
|
77
|
+
dataView.setUint32(offset, 1, true);
|
|
78
|
+
offset += 4;
|
|
79
|
+
// Configurations
|
|
80
|
+
dataView.setUint32(offset, TemplateSectionLabel.Configurations, true); // section label
|
|
81
|
+
offset += 4;
|
|
82
|
+
dataView.setUint32(offset, encodedConfigurations.length, true); // section length
|
|
83
|
+
offset += 4;
|
|
84
|
+
buffer.set(encodedConfigurations, offset);
|
|
85
|
+
offset += encodedConfigurations.length;
|
|
86
|
+
// Element Templates
|
|
87
|
+
if (hasElementTemplates) {
|
|
88
|
+
dataView.setUint32(offset, TemplateSectionLabel.ElementTemplates, true); // section label
|
|
89
|
+
offset += 4;
|
|
90
|
+
dataView.setUint32(offset, encodedElementTemplates.length, true); // section length
|
|
91
|
+
offset += 4;
|
|
92
|
+
buffer.set(encodedElementTemplates, offset);
|
|
93
|
+
offset += encodedElementTemplates.length;
|
|
94
|
+
}
|
|
95
|
+
// Lepus Code
|
|
96
|
+
dataView.setUint32(offset, TemplateSectionLabel.LepusCode, true); // section label
|
|
97
|
+
offset += 4;
|
|
98
|
+
dataView.setUint32(offset, encodedLepusCode.length, true); // section length
|
|
99
|
+
offset += 4;
|
|
100
|
+
buffer.set(encodedLepusCode, offset);
|
|
101
|
+
offset += encodedLepusCode.length;
|
|
102
|
+
// Custom Sections
|
|
103
|
+
dataView.setUint32(offset, TemplateSectionLabel.CustomSections, true); // section label
|
|
104
|
+
offset += 4;
|
|
105
|
+
dataView.setUint32(offset, encodedCustomSections.length, true); // section length
|
|
106
|
+
offset += 4;
|
|
107
|
+
buffer.set(encodedCustomSections, offset);
|
|
108
|
+
offset += encodedCustomSections.length;
|
|
109
|
+
// Style Info
|
|
110
|
+
dataView.setUint32(offset, TemplateSectionLabel.StyleInfo, true); // section label
|
|
111
|
+
offset += 4;
|
|
112
|
+
dataView.setUint32(offset, encodedStyleInfo.length, true); // section length
|
|
113
|
+
offset += 4;
|
|
114
|
+
buffer.set(encodedStyleInfo, offset);
|
|
115
|
+
offset += encodedStyleInfo.length;
|
|
116
|
+
// Manifest
|
|
117
|
+
dataView.setUint32(offset, TemplateSectionLabel.Manifest, true); // section label
|
|
118
|
+
offset += 4;
|
|
119
|
+
dataView.setUint32(offset, encodedManifest.length, true); // section length
|
|
120
|
+
offset += 4;
|
|
121
|
+
buffer.set(encodedManifest, offset);
|
|
122
|
+
offset += encodedManifest.length;
|
|
123
|
+
return buffer;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=webEncoder.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type BTSChunkEntry = (postMessage: undefined, module: {
|
|
2
|
+
exports: unknown;
|
|
3
|
+
}, exports: unknown, lynxCoreInject: unknown, Card: unknown, setTimeout: unknown, setInterval: unknown, clearInterval: unknown, clearTimeout: unknown, NativeModules: unknown, Component: unknown, ReactLynx: unknown, nativeAppId: unknown, Behavior: unknown, LynxJSBI: unknown, lynx: unknown, window: unknown, document: unknown, frames: unknown, location: unknown, navigator: unknown, localStorage: unknown, history: unknown, Caches: unknown, screen: unknown, alert: unknown, confirm: unknown, prompt: unknown, fetch: unknown, XMLHttpRequest: unknown, webkit: unknown, Reporter: unknown, print: unknown, global: unknown, requestAnimationFrame: unknown, cancelAnimationFrame: unknown) => unknown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DecodedStyle } from '../client/wasm.js';
|
|
2
|
+
import type { PageConfig } from './PageConfig.js';
|
|
3
|
+
export interface DecodedTemplate {
|
|
4
|
+
config?: PageConfig;
|
|
5
|
+
styleInfo?: DecodedStyle;
|
|
6
|
+
lepusCode?: Record<string, string>;
|
|
7
|
+
elementTemplates?: any;
|
|
8
|
+
customSections?: Record<string, any>;
|
|
9
|
+
backgroundCode?: Record<string, string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LynxEventType } from './EventType.js';
|
|
2
|
+
import { uniqueIdSymbol, type AnimationOperation } from '../constants.js';
|
|
3
|
+
export type DecoratedHTMLElement = HTMLElement & {
|
|
4
|
+
[uniqueIdSymbol]: number;
|
|
5
|
+
componentAtIndex?: ComponentAtIndexCallback;
|
|
6
|
+
enqueueComponent?: EnqueueComponentCallback;
|
|
7
|
+
};
|
|
8
|
+
export interface LynxRuntimeInfo {
|
|
9
|
+
eventHandlerMap: Record<string, {
|
|
10
|
+
capture: {
|
|
11
|
+
type: LynxEventType;
|
|
12
|
+
handler: string | {
|
|
13
|
+
type: 'worklet';
|
|
14
|
+
value: unknown;
|
|
15
|
+
};
|
|
16
|
+
} | undefined;
|
|
17
|
+
bind: {
|
|
18
|
+
type: LynxEventType;
|
|
19
|
+
handler: string | {
|
|
20
|
+
type: 'worklet';
|
|
21
|
+
value: unknown;
|
|
22
|
+
};
|
|
23
|
+
} | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
componentAtIndex?: ComponentAtIndexCallback;
|
|
26
|
+
enqueueComponent?: EnqueueComponentCallback;
|
|
27
|
+
}
|
|
28
|
+
export type ComponentAtIndexCallback = (list: HTMLElement, listID: number, cellIndex: number, operationID: number, enableReuseNotification: boolean) => void;
|
|
29
|
+
export type EnqueueComponentCallback = (list: HTMLElement, listID: number, sign: number) => void;
|
|
30
|
+
export interface ElementAnimationOptions {
|
|
31
|
+
operation: AnimationOperation;
|
|
32
|
+
id: string;
|
|
33
|
+
keyframes?: any;
|
|
34
|
+
timingOptions?: Record<string, any>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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 { uniqueIdSymbol } from '../constants.js';
|
|
5
|
+
//# sourceMappingURL=Element.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LynxEventType } from './EventType.js';
|
|
2
|
+
export type ElementTemplateData = {
|
|
3
|
+
type: string;
|
|
4
|
+
idSelector?: string;
|
|
5
|
+
class?: string[];
|
|
6
|
+
attributes?: Record<string, string>;
|
|
7
|
+
builtinAttributes?: Record<string, string>;
|
|
8
|
+
children?: ElementTemplateData[];
|
|
9
|
+
events?: {
|
|
10
|
+
type: LynxEventType;
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
dataset?: Record<string, string>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Cloneable } from './Cloneable.js';
|
|
2
|
+
export type LynxEventType = 'bindEvent' | 'catchEvent' | 'capture-bind' | 'capture-catch';
|
|
3
|
+
export interface LynxCrossThreadEventTarget {
|
|
4
|
+
dataset: {
|
|
5
|
+
[key: string]: Cloneable;
|
|
6
|
+
};
|
|
7
|
+
id: string | null;
|
|
8
|
+
uniqueId: number;
|
|
9
|
+
}
|
|
10
|
+
export interface LynxCrossThreadEvent<T = {
|
|
11
|
+
[key: string]: string | number | undefined | null;
|
|
12
|
+
}> {
|
|
13
|
+
type: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
target: LynxCrossThreadEventTarget;
|
|
16
|
+
currentTarget: LynxCrossThreadEventTarget | null;
|
|
17
|
+
detail: T;
|
|
18
|
+
[key: string]: string | number | undefined | null | {};
|
|
19
|
+
}
|
|
20
|
+
export interface MainThreadScriptEvent<T = {
|
|
21
|
+
[key: string]: string | number | undefined | null;
|
|
22
|
+
}> extends LynxCrossThreadEvent<T> {
|
|
23
|
+
target: LynxCrossThreadEventTarget & {
|
|
24
|
+
elementRefptr: unknown;
|
|
25
|
+
};
|
|
26
|
+
currentTarget: (LynxCrossThreadEventTarget & {
|
|
27
|
+
elementRefptr: unknown;
|
|
28
|
+
}) | null;
|
|
29
|
+
}
|
|
30
|
+
export type ExposureEventDetail = {
|
|
31
|
+
'exposure-id': string;
|
|
32
|
+
'exposure-scene': string;
|
|
33
|
+
exposureID: string;
|
|
34
|
+
exposureScene: string;
|
|
35
|
+
'unique-id': number;
|
|
36
|
+
};
|
|
37
|
+
export type ExposureEvent = {
|
|
38
|
+
detail: ExposureEventDetail;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* event passed by the GlobalEventEmitter(`sendGlobalEvent()`)
|
|
42
|
+
*/
|
|
43
|
+
export type GlobalExposureEvent = LynxCrossThreadEvent<ExposureEventDetail> & ExposureEventDetail;
|
|
44
|
+
export type MinimalRawEventObject = {
|
|
45
|
+
type: string;
|
|
46
|
+
target: EventTarget | null;
|
|
47
|
+
currentTarget: EventTarget | null;
|
|
48
|
+
detail?: Cloneable;
|
|
49
|
+
isTrusted: boolean;
|
|
50
|
+
timeStamp: number;
|
|
51
|
+
propertyName?: string;
|
|
52
|
+
animationName?: string;
|
|
53
|
+
touches?: unknown[];
|
|
54
|
+
targetTouches?: unknown[];
|
|
55
|
+
changedTouches?: unknown[];
|
|
56
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Cloneable } from './Cloneable.js';
|
|
2
|
+
export interface I18nResourceTranslationOptions {
|
|
3
|
+
locale: string;
|
|
4
|
+
channel: string;
|
|
5
|
+
fallback_url?: string;
|
|
6
|
+
[key: string]: Cloneable;
|
|
7
|
+
}
|
|
8
|
+
export interface CacheI18nResources {
|
|
9
|
+
/** the i18nResource key currently being used by the page */
|
|
10
|
+
curCacheKey: string;
|
|
11
|
+
/** the complete set of all requested i18nResources */
|
|
12
|
+
i18nResources: Map<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export type InitI18nResources = Array<{
|
|
15
|
+
options: I18nResourceTranslationOptions;
|
|
16
|
+
resource: Record<string, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export interface II18nResource {
|
|
19
|
+
data?: Cloneable;
|
|
20
|
+
setData(data: Cloneable): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Cloneable } from './Cloneable.js';
|
|
2
|
+
import type { ComponentAtIndexCallback, EnqueueComponentCallback } from './Element.js';
|
|
3
|
+
import type { LynxEventType } from './EventType.js';
|
|
4
|
+
import type { I18nResourceTranslationOptions, PerformancePipelineOptions } from './index.js';
|
|
5
|
+
import type { MainThreadLynx } from './MainThreadLynx.js';
|
|
6
|
+
import type { ProcessDataCallback } from './ProcessDataCallback.js';
|
|
7
|
+
import type { UpdateDataOptions } from './UpdateDataOptions.js';
|
|
8
|
+
export interface FlushElementTreeOptions {
|
|
9
|
+
pipelineOptions?: PerformancePipelineOptions;
|
|
10
|
+
}
|
|
11
|
+
type ElementPAPIEventHandler = string | {
|
|
12
|
+
type: 'worklet';
|
|
13
|
+
value: unknown;
|
|
14
|
+
} | undefined;
|
|
15
|
+
export type AddEventPAPI = (element: HTMLElement, eventType: LynxEventType, eventName: string, newEventHandler: ElementPAPIEventHandler) => void;
|
|
16
|
+
export type GetEventPAPI = (element: HTMLElement, eventName: string, eventType: LynxEventType) => ElementPAPIEventHandler;
|
|
17
|
+
export type GetEventsPAPI = (element: HTMLElement) => {
|
|
18
|
+
type: LynxEventType;
|
|
19
|
+
name: string;
|
|
20
|
+
function: ElementPAPIEventHandler;
|
|
21
|
+
}[];
|
|
22
|
+
export type SetEventsPAPI = (element: HTMLElement, listeners: {
|
|
23
|
+
type: LynxEventType;
|
|
24
|
+
name: string;
|
|
25
|
+
function: ElementPAPIEventHandler;
|
|
26
|
+
}[]) => void;
|
|
27
|
+
export type AppendElementPAPI = (parent: HTMLElement, child: HTMLElement) => void;
|
|
28
|
+
export type ElementIsEqualPAPI = (left: HTMLElement | null, right: HTMLElement | null) => boolean;
|
|
29
|
+
export type FirstElementPAPI = (element: HTMLElement) => HTMLElement | null;
|
|
30
|
+
export type GetChildrenPAPI = (element: HTMLElement) => HTMLElement[];
|
|
31
|
+
export type GetParentPAPI = (element: HTMLElement) => HTMLElement | null;
|
|
32
|
+
export type InsertElementBeforePAPI = (parent: HTMLElement, child: HTMLElement, ref?: HTMLElement | null) => HTMLElement;
|
|
33
|
+
export type LastElementPAPI = (element: HTMLElement) => HTMLElement | null;
|
|
34
|
+
export type NextElementPAPI = (element: HTMLElement) => HTMLElement | null;
|
|
35
|
+
export type RemoveElementPAPI = (parent: HTMLElement, child: HTMLElement) => HTMLElement;
|
|
36
|
+
export type ReplaceElementPAPI = (newElement: HTMLElement, oldElement: HTMLElement) => void;
|
|
37
|
+
export type ReplaceElementsPAPI = (parent: HTMLElement, newChildren: HTMLElement[] | HTMLElement, oldChildren?: HTMLElement[] | HTMLElement | null | undefined) => void;
|
|
38
|
+
export type AddConfigPAPI = (element: HTMLElement, type: string, value: Cloneable) => void;
|
|
39
|
+
export type AddDatasetPAPI = (element: HTMLElement, key: string, value: Cloneable) => void;
|
|
40
|
+
export type GetDatasetPAPI = (element: HTMLElement) => Record<string, Cloneable>;
|
|
41
|
+
export type GetDataByKeyPAPI = (element: HTMLElement, key: string) => Cloneable | undefined;
|
|
42
|
+
export type GetAttributesPAPI = (element: HTMLElement) => Record<string, string>;
|
|
43
|
+
export type GetComponentIdPAPI = (element: HTMLElement) => string | null | undefined;
|
|
44
|
+
export type GetElementConfigPAPI = (element: HTMLElement) => Record<string, Cloneable>;
|
|
45
|
+
export type GetElementUniqueIDPAPI = (element: HTMLElement) => number;
|
|
46
|
+
export type GetIDPAPI = (element: HTMLElement) => string | null;
|
|
47
|
+
export type GetTagPAPI = (element: HTMLElement) => string;
|
|
48
|
+
export type SetConfigPAPI = (element: HTMLElement, config: Record<string, Cloneable>) => void;
|
|
49
|
+
export type SetDatasetPAPI = (element: HTMLElement, dataset: Record<string, Cloneable>) => void;
|
|
50
|
+
export type SetIDPAPI = (element: HTMLElement, id: string | null) => void;
|
|
51
|
+
export type UpdateComponentIDPAPI = (element: HTMLElement, componentID: string) => void;
|
|
52
|
+
export type UpdateComponentInfoPAPI = (element: HTMLElement, params: {
|
|
53
|
+
componentID?: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
path?: string;
|
|
56
|
+
entry?: string;
|
|
57
|
+
cssID?: number;
|
|
58
|
+
}) => void;
|
|
59
|
+
export type GetClassesPAPI = (element: HTMLElement) => string[];
|
|
60
|
+
export type CreateViewPAPI = (parentComponentUniqueID: number) => HTMLElement;
|
|
61
|
+
export type SwapElementPAPI = (childA: HTMLElement, childB: HTMLElement) => void;
|
|
62
|
+
export type UpdateListInfoAttributeValue = {
|
|
63
|
+
insertAction: {
|
|
64
|
+
position: number;
|
|
65
|
+
}[];
|
|
66
|
+
removeAction: {
|
|
67
|
+
position: number;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
export type SetAttributePAPI = (element: HTMLElement, key: Exclude<string, 'update-list-info'>, value: string | null | undefined | boolean) => void;
|
|
71
|
+
export type SetAttributePAPIUpdateListInfo = (element: HTMLElement, key: 'update-list-info', value: UpdateListInfoAttributeValue | null) => void;
|
|
72
|
+
export type UpdateListCallbacksPAPI = (element: HTMLElement, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => void;
|
|
73
|
+
export type CreateTextPAPI = CreateViewPAPI;
|
|
74
|
+
export type CreateRawTextPAPI = (text: string) => HTMLElement;
|
|
75
|
+
export type CreateImagePAPI = CreateViewPAPI;
|
|
76
|
+
export type CreateScrollViewPAPI = CreateViewPAPI;
|
|
77
|
+
export type CreateWrapperElementPAPI = CreateViewPAPI;
|
|
78
|
+
export type CreateComponentPAPI = (componentParentUniqueID: number, componentID: string, cssID: number, entryName: string, name: string, path: string, config: Record<string, Cloneable> | null | undefined, info: Record<string, Cloneable> | null | undefined) => HTMLElement;
|
|
79
|
+
export type CreateElementPAPI = (tagName: string, parentComponentUniqueId: number, info?: Record<string, Cloneable> | null | undefined) => HTMLElement;
|
|
80
|
+
export type CreatePagePAPI = (componentID: string, cssID: number, info?: Record<string, Cloneable> | null | undefined) => HTMLElement;
|
|
81
|
+
export type CreateListPAPI = (parentComponentUniqueId: number, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => HTMLElement;
|
|
82
|
+
export type AddClassPAPI = (element: HTMLElement, className: string) => void;
|
|
83
|
+
export type SetClassesPAPI = (element: HTMLElement, classNames: string | null) => void;
|
|
84
|
+
export type AddInlineStylePAPI = (element: HTMLElement, key: number | string, value: string | number | null | undefined) => void;
|
|
85
|
+
export type SetInlineStylesPAPI = (element: HTMLElement, value: string | Record<string, string> | undefined) => void;
|
|
86
|
+
export type SetCSSIdPAPI = (elements: HTMLElement[], cssId: number | null, entryName: string | undefined) => void;
|
|
87
|
+
export type GetPageElementPAPI = () => HTMLElement | undefined;
|
|
88
|
+
export type MarkTemplateElementPAPI = (element: HTMLElement) => void;
|
|
89
|
+
export type MarkPartElementPAPI = (element: HTMLElement, partId: string) => void;
|
|
90
|
+
export type GetTemplatePartsPAPI = (templateElement: HTMLElement) => Record<string, HTMLElement>;
|
|
91
|
+
interface JSErrorInfo {
|
|
92
|
+
release: string;
|
|
93
|
+
}
|
|
94
|
+
export type ElementFromBinaryPAPI = (templateId: string, parentComponentUniId: number) => HTMLElement;
|
|
95
|
+
export type GetAttributeByNamePAPI = (element: HTMLElement, name: string) => string | null;
|
|
96
|
+
export type QueryComponentPAPI = (source: string, resultCallback?: (result: {
|
|
97
|
+
code: number;
|
|
98
|
+
data?: {
|
|
99
|
+
url: string;
|
|
100
|
+
evalResult: unknown;
|
|
101
|
+
};
|
|
102
|
+
}) => void) => null;
|
|
103
|
+
export interface ElementPAPIs {
|
|
104
|
+
__ElementFromBinary: ElementFromBinaryPAPI;
|
|
105
|
+
__GetTemplateParts: GetTemplatePartsPAPI;
|
|
106
|
+
__MarkPartElement: MarkPartElementPAPI;
|
|
107
|
+
__MarkTemplateElement: MarkTemplateElementPAPI;
|
|
108
|
+
__AddEvent: AddEventPAPI;
|
|
109
|
+
__GetEvent: GetEventPAPI;
|
|
110
|
+
__GetEvents: GetEventsPAPI;
|
|
111
|
+
__SetEvents: SetEventsPAPI;
|
|
112
|
+
__AppendElement: AppendElementPAPI;
|
|
113
|
+
__ElementIsEqual: ElementIsEqualPAPI;
|
|
114
|
+
__FirstElement: FirstElementPAPI;
|
|
115
|
+
__GetChildren: GetChildrenPAPI;
|
|
116
|
+
__GetParent: GetParentPAPI;
|
|
117
|
+
__InsertElementBefore: InsertElementBeforePAPI;
|
|
118
|
+
__LastElement: LastElementPAPI;
|
|
119
|
+
__NextElement: NextElementPAPI;
|
|
120
|
+
__RemoveElement: RemoveElementPAPI;
|
|
121
|
+
__ReplaceElement: ReplaceElementPAPI;
|
|
122
|
+
__ReplaceElements: ReplaceElementsPAPI;
|
|
123
|
+
__AddConfig: AddConfigPAPI;
|
|
124
|
+
__AddDataset: AddDatasetPAPI;
|
|
125
|
+
__GetDataset: GetDatasetPAPI;
|
|
126
|
+
__GetDataByKey: GetDataByKeyPAPI;
|
|
127
|
+
__GetAttributes: GetAttributesPAPI;
|
|
128
|
+
__GetComponentID: GetComponentIdPAPI;
|
|
129
|
+
__GetElementConfig: GetElementConfigPAPI;
|
|
130
|
+
__GetElementUniqueID: GetElementUniqueIDPAPI;
|
|
131
|
+
__GetID: GetIDPAPI;
|
|
132
|
+
__GetTag: GetTagPAPI;
|
|
133
|
+
__SetConfig: SetConfigPAPI;
|
|
134
|
+
__GetConfig: GetElementConfigPAPI;
|
|
135
|
+
__SetDataset: SetDatasetPAPI;
|
|
136
|
+
__SetID: SetIDPAPI;
|
|
137
|
+
__UpdateComponentID: UpdateComponentIDPAPI;
|
|
138
|
+
__UpdateComponentInfo: UpdateComponentInfoPAPI;
|
|
139
|
+
__GetClasses: GetClassesPAPI;
|
|
140
|
+
__CreateView: CreateViewPAPI;
|
|
141
|
+
__SwapElement: SwapElementPAPI;
|
|
142
|
+
__CreateText: CreateTextPAPI;
|
|
143
|
+
__CreateRawText: CreateRawTextPAPI;
|
|
144
|
+
__CreateImage: CreateImagePAPI;
|
|
145
|
+
__CreateScrollView: CreateScrollViewPAPI;
|
|
146
|
+
__CreateWrapperElement: CreateWrapperElementPAPI;
|
|
147
|
+
__CreateComponent: CreateComponentPAPI;
|
|
148
|
+
__CreateElement: CreateElementPAPI;
|
|
149
|
+
__CreatePage: CreatePagePAPI;
|
|
150
|
+
__CreateList: CreateListPAPI;
|
|
151
|
+
__SetAttribute: SetAttributePAPI & SetAttributePAPIUpdateListInfo;
|
|
152
|
+
__UpdateListCallbacks: UpdateListCallbacksPAPI;
|
|
153
|
+
__AddClass: AddClassPAPI;
|
|
154
|
+
__SetClasses: SetClassesPAPI;
|
|
155
|
+
__AddInlineStyle: AddInlineStylePAPI;
|
|
156
|
+
__SetInlineStyles: SetInlineStylesPAPI;
|
|
157
|
+
__SetCSSId: SetCSSIdPAPI;
|
|
158
|
+
__GetPageElement: GetPageElementPAPI;
|
|
159
|
+
__GetAttributeByName: GetAttributeByNamePAPI;
|
|
160
|
+
__FlushElementTree: (_subTree?: unknown, options?: FlushElementTreeOptions) => void;
|
|
161
|
+
}
|
|
162
|
+
export interface MainThreadGlobalAPIs {
|
|
163
|
+
__globalProps: unknown;
|
|
164
|
+
SystemInfo: Cloneable;
|
|
165
|
+
lynx: MainThreadLynx;
|
|
166
|
+
_ReportError: (error: Error, _: unknown) => void;
|
|
167
|
+
_SetSourceMapRelease: (errInfo: JSErrorInfo) => void;
|
|
168
|
+
__OnLifecycleEvent: (lifeCycleEvent: Cloneable) => void;
|
|
169
|
+
__LoadLepusChunk: (path: string) => boolean;
|
|
170
|
+
_I18nResourceTranslation: (options: I18nResourceTranslationOptions) => unknown | undefined;
|
|
171
|
+
_AddEventListener: (...args: unknown[]) => void;
|
|
172
|
+
__QueryComponent: QueryComponentPAPI;
|
|
173
|
+
}
|
|
174
|
+
export type JSFrameworkInjectedHandlers = {
|
|
175
|
+
renderPage: ((data: unknown) => void) | undefined;
|
|
176
|
+
updatePage?: (data: Cloneable, options?: UpdateDataOptions) => void;
|
|
177
|
+
runWorklet?: (obj: unknown, event: unknown) => void;
|
|
178
|
+
processData?: ProcessDataCallback;
|
|
179
|
+
ssrEncode?: () => string;
|
|
180
|
+
ssrHydrate?: (encodeData?: string | null) => void;
|
|
181
|
+
processEvalResult?: (exports: unknown, schema: string) => unknown;
|
|
182
|
+
};
|
|
183
|
+
export type MainThreadGlobalThis = MainThreadGlobalAPIs & ElementPAPIs & JSFrameworkInjectedHandlers;
|
|
184
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CloneableObject } from './Cloneable.js';
|
|
2
|
+
import type { LynxCrossThreadEvent } from './EventType.js';
|
|
3
|
+
/**
|
|
4
|
+
* The JS binding for the WASM main thread context instance.
|
|
5
|
+
*/
|
|
6
|
+
export interface RustMainthreadContextBinding {
|
|
7
|
+
runWorklet(handler: unknown, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: CloneableObject, currentTargetUniqueId: number, currentTargetDataset: CloneableObject): void;
|
|
8
|
+
publishEvent(handlerName: string, parentComponentId: string | undefined, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: CloneableObject, currentTargetUniqueId: number, currentTargetDataset: CloneableObject): void;
|
|
9
|
+
addEventListener(event_name: string): void;
|
|
10
|
+
markExposureRelatedElementByUniqueId(uniqueId: number, toEnable: boolean): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Cloneable } from './Cloneable.js';
|
|
2
|
+
export type ContextCrossThreadEvent = {
|
|
3
|
+
type: string;
|
|
4
|
+
data: Cloneable;
|
|
5
|
+
};
|
|
6
|
+
export interface LynxContextEventTarget {
|
|
7
|
+
onTriggerEvent?: (event: ContextCrossThreadEvent) => void;
|
|
8
|
+
postMessage(message: any): void;
|
|
9
|
+
dispatchEvent(event: ContextCrossThreadEvent): number;
|
|
10
|
+
addEventListener(type: string, listener: (event: Event) => void): void;
|
|
11
|
+
removeEventListener(type: string, listener: (event: Event) => void): void;
|
|
12
|
+
}
|