@lynx-js/web-mainthread-apis-canary 0.15.4-canary-20250801-47e08f2e → 0.15.4-canary-20250801-22ca433e
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
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
-
## 0.15.4-canary-
|
|
3
|
+
## 0.15.4-canary-20250801085747-22ca433eb96b39724c6eb47ce0a938d291bbdef2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- feat: support `__ElementFromBinary` ([#1391](https://github.com/lynx-family/lynx-stack/pull/1391))
|
|
8
|
+
|
|
7
9
|
- fix: crash on chrome<96 ([#1361](https://github.com/lynx-family/lynx-stack/pull/1361))
|
|
8
10
|
|
|
9
11
|
https://github.com/wasm-bindgen/wasm-bindgen/issues/4211#issuecomment-2505965903
|
|
@@ -20,9 +22,9 @@
|
|
|
20
22
|
|
|
21
23
|
If user's browser supported it, we load the wasm file with `reference types` on, otherwise we load the wasm file with `reference types` off.
|
|
22
24
|
|
|
23
|
-
- Updated dependencies []:
|
|
24
|
-
- @lynx-js/web-constants@0.15.4-canary-
|
|
25
|
-
- @lynx-js/web-style-transformer@0.15.4-canary-
|
|
25
|
+
- Updated dependencies [[`22ca433`](https://github.com/lynx-family/lynx-stack/commit/22ca433eb96b39724c6eb47ce0a938d291bbdef2)]:
|
|
26
|
+
- @lynx-js/web-constants@0.15.4-canary-20250801085747-22ca433eb96b39724c6eb47ce0a938d291bbdef2
|
|
27
|
+
- @lynx-js/web-style-transformer@0.15.4-canary-20250801085747-22ca433eb96b39724c6eb47ce0a938d291bbdef2
|
|
26
28
|
|
|
27
29
|
## 0.15.3
|
|
28
30
|
|
|
@@ -16,10 +16,11 @@ export interface MainThreadRuntimeConfig {
|
|
|
16
16
|
callbacks: MainThreadRuntimeCallbacks;
|
|
17
17
|
styleInfo: StyleInfo;
|
|
18
18
|
customSections: LynxTemplate['customSections'];
|
|
19
|
+
elementTemplate: LynxTemplate['elementTemplate'];
|
|
19
20
|
lepusCode: Record<string, LynxJSModule>;
|
|
20
21
|
browserConfig: BrowserConfig;
|
|
21
22
|
tagMap: Record<string, string>;
|
|
22
|
-
rootDom: Pick<Element, 'append' | 'addEventListener'> & Partial<Pick<
|
|
23
|
+
rootDom: Pick<Element, 'append' | 'addEventListener'> & Partial<Pick<ShadowRoot, 'querySelectorAll' | 'cloneNode'>>;
|
|
23
24
|
jsContext: LynxContextEventTarget;
|
|
24
25
|
ssrHydrateInfo?: SSRHydrateInfo;
|
|
25
26
|
ssrHooks?: SSRDehydrateHooks;
|
|
@@ -376,9 +376,69 @@ export function createMainThreadGlobalThis(config) {
|
|
|
376
376
|
const __GetPageElement = () => {
|
|
377
377
|
return pageElement;
|
|
378
378
|
};
|
|
379
|
+
const templateIdToTemplate = {};
|
|
380
|
+
const createElementForElementTemplateData = (data, parentComponentUniId) => {
|
|
381
|
+
const element = __CreateElement(data.type, parentComponentUniId);
|
|
382
|
+
__SetID(element, data.id);
|
|
383
|
+
__SetClasses(element, data.class.join(' '));
|
|
384
|
+
for (const [key, value] of Object.entries(data.attributes)) {
|
|
385
|
+
__SetAttribute(element, key, value);
|
|
386
|
+
}
|
|
387
|
+
for (const [key, value] of Object.entries(data.builtinAttributes)) {
|
|
388
|
+
__SetAttribute(element, key, value);
|
|
389
|
+
}
|
|
390
|
+
for (const childData of data.children) {
|
|
391
|
+
__AppendElement(element, createElementForElementTemplateData(childData, parentComponentUniId));
|
|
392
|
+
}
|
|
393
|
+
return element;
|
|
394
|
+
};
|
|
395
|
+
const applyEventsForElementTemplate = (data, element) => {
|
|
396
|
+
const uniqueId = uniqueIdInc++;
|
|
397
|
+
element.setAttribute(lynxUniqueIdAttribute, uniqueId + '');
|
|
398
|
+
for (const event of data.events) {
|
|
399
|
+
const { type, name, value } = event;
|
|
400
|
+
__AddEvent(element, type, name, value);
|
|
401
|
+
}
|
|
402
|
+
for (let ii = 0; ii < data.children.length; ii++) {
|
|
403
|
+
const childData = data.children[ii];
|
|
404
|
+
const childElement = element.children[ii];
|
|
405
|
+
if (childData && childElement) {
|
|
406
|
+
applyEventsForElementTemplate(childData, childElement);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
const __ElementFromBinary = (templateId, parentComponentUniId) => {
|
|
411
|
+
const elementTemplateData = config.elementTemplate[templateId];
|
|
412
|
+
if (elementTemplateData) {
|
|
413
|
+
let clonedElements;
|
|
414
|
+
if (templateIdToTemplate[templateId]) {
|
|
415
|
+
clonedElements = Array.from(templateIdToTemplate[templateId].content.cloneNode(true).children);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
clonedElements = elementTemplateData.map(data => createElementForElementTemplateData(data, parentComponentUniId));
|
|
419
|
+
if (rootDom.cloneNode) {
|
|
420
|
+
const template = callbacks.createElement('template');
|
|
421
|
+
template.content.append(...clonedElements);
|
|
422
|
+
templateIdToTemplate[templateId] = template;
|
|
423
|
+
rootDom.append(template);
|
|
424
|
+
return __ElementFromBinary(templateId, parentComponentUniId);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
for (let ii = 0; ii < clonedElements.length; ii++) {
|
|
428
|
+
const data = elementTemplateData[ii];
|
|
429
|
+
const element = clonedElements[ii];
|
|
430
|
+
if (data && element) {
|
|
431
|
+
applyEventsForElementTemplate(data, element);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return clonedElements;
|
|
435
|
+
}
|
|
436
|
+
return [];
|
|
437
|
+
};
|
|
379
438
|
let release = '';
|
|
380
439
|
const isCSSOG = !pageConfig.enableCSSSelector;
|
|
381
440
|
const mtsGlobalThis = {
|
|
441
|
+
__ElementFromBinary,
|
|
382
442
|
__GetTemplateParts: rootDom.querySelectorAll
|
|
383
443
|
? __GetTemplateParts
|
|
384
444
|
: undefined,
|
|
@@ -20,7 +20,7 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElemen
|
|
|
20
20
|
async function startMainThread(config, ssrHydrateInfo) {
|
|
21
21
|
let isFp = true;
|
|
22
22
|
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, initI18nResources, } = config;
|
|
23
|
-
const { styleInfo, pageConfig, customSections, cardType, lepusCode } = template;
|
|
23
|
+
const { styleInfo, pageConfig, customSections, cardType, lepusCode, elementTemplate, } = template;
|
|
24
24
|
markTimingInternal('decode_start');
|
|
25
25
|
await initWasmPromise;
|
|
26
26
|
const lepusCodeEntries = await Promise.all(Object.entries(lepusCode).map(async ([name, url]) => {
|
|
@@ -50,6 +50,7 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElemen
|
|
|
50
50
|
tagMap,
|
|
51
51
|
browserConfig,
|
|
52
52
|
customSections,
|
|
53
|
+
elementTemplate,
|
|
53
54
|
globalProps,
|
|
54
55
|
pageConfig,
|
|
55
56
|
styleInfo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis-canary",
|
|
3
|
-
"version": "0.15.4-canary-20250801-
|
|
3
|
+
"version": "0.15.4-canary-20250801-22ca433e",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"**/*.css"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.15.4-canary-20250801-
|
|
28
|
-
"@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.15.4-canary-20250801-
|
|
27
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.15.4-canary-20250801-22ca433e",
|
|
28
|
+
"@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.15.4-canary-20250801-22ca433e",
|
|
29
29
|
"hyphenate-style-name": "^1.1.0"
|
|
30
30
|
}
|
|
31
31
|
}
|