@lynx-js/web-core-server-canary 0.16.1 → 0.17.0-canary-20250918-b17b7cb2
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 +11 -9
- package/dist/index.js +102 -51
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @lynx-js/web-core-server
|
|
2
2
|
|
|
3
|
+
## 0.17.0-canary-20250918080343-b17b7cb2bb92d1539e76276f136806eefa788258
|
|
4
|
+
|
|
3
5
|
## 0.16.1
|
|
4
6
|
|
|
5
7
|
### Patch Changes
|
|
@@ -103,25 +105,25 @@
|
|
|
103
105
|
lynxView.initI18nResources = [
|
|
104
106
|
{
|
|
105
107
|
options: {
|
|
106
|
-
locale:
|
|
107
|
-
channel:
|
|
108
|
-
fallback_url:
|
|
108
|
+
locale: "en",
|
|
109
|
+
channel: "1",
|
|
110
|
+
fallback_url: "",
|
|
109
111
|
},
|
|
110
112
|
resource: {
|
|
111
|
-
hello:
|
|
112
|
-
lynx:
|
|
113
|
+
hello: "hello",
|
|
114
|
+
lynx: "lynx web platform1",
|
|
113
115
|
},
|
|
114
116
|
},
|
|
115
117
|
];
|
|
116
|
-
lynxView.addEventListener(
|
|
118
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
117
119
|
console.log(e);
|
|
118
120
|
});
|
|
119
121
|
|
|
120
122
|
// mts
|
|
121
123
|
_I18nResourceTranslation({
|
|
122
|
-
locale:
|
|
123
|
-
channel:
|
|
124
|
-
fallback_url:
|
|
124
|
+
locale: "en",
|
|
125
|
+
channel: "1",
|
|
126
|
+
fallback_url: "",
|
|
125
127
|
});
|
|
126
128
|
```
|
|
127
129
|
|
package/dist/index.js
CHANGED
|
@@ -1782,30 +1782,74 @@ function decodeCssOG(classes, styleInfo, cssId) {
|
|
|
1782
1782
|
else console.warn(`[lynx-web] cannot find styleinfo for cssid ${cssId}`);
|
|
1783
1783
|
return declarations.map(([property, value])=>`${property}:${value};`).join('');
|
|
1784
1784
|
}
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1785
|
+
function topologicalSort(styleInfo) {
|
|
1786
|
+
const queue = [];
|
|
1787
|
+
const inDegreeMap = new Map();
|
|
1788
|
+
for (const [cssId, oneStyleInfo] of Object.entries(styleInfo)){
|
|
1789
|
+
inDegreeMap.has(cssId) || inDegreeMap.set(cssId, 0);
|
|
1790
|
+
for (const importCssId of oneStyleInfo.imports ?? []){
|
|
1791
|
+
const currentInDegree = inDegreeMap.get(importCssId) ?? 0;
|
|
1792
|
+
inDegreeMap.set(importCssId, currentInDegree + 1);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
for (const [cssId, inDegree] of inDegreeMap.entries())if (0 === inDegree) queue.push(cssId);
|
|
1796
|
+
const sortedCssIds = [];
|
|
1797
|
+
while(queue.length > 0){
|
|
1798
|
+
const currentCssId = queue.shift();
|
|
1799
|
+
sortedCssIds.push(currentCssId);
|
|
1800
|
+
const currentAdjunction = styleInfo[currentCssId]?.imports;
|
|
1801
|
+
if (currentAdjunction) for (const importCssId of currentAdjunction){
|
|
1802
|
+
const importInDegree = inDegreeMap.get(importCssId) - 1;
|
|
1803
|
+
inDegreeMap.set(importCssId, importInDegree);
|
|
1804
|
+
if (0 === importInDegree) queue.push(importCssId);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
return sortedCssIds;
|
|
1808
|
+
}
|
|
1809
|
+
function generateImportByMap(styleInfo, sortedCssIds) {
|
|
1810
|
+
const cssIdToImportBy = new Map();
|
|
1811
|
+
for (const cssId of sortedCssIds){
|
|
1812
|
+
const currentAdjunction = styleInfo[cssId]?.imports;
|
|
1813
|
+
if (currentAdjunction) {
|
|
1814
|
+
const currentImportBy = cssIdToImportBy.get(cssId) ?? new Set([
|
|
1815
|
+
cssId
|
|
1816
|
+
]);
|
|
1817
|
+
for (const importCssId of currentAdjunction){
|
|
1818
|
+
const importDeps = cssIdToImportBy.get(importCssId) ?? new Set([
|
|
1819
|
+
importCssId
|
|
1820
|
+
]);
|
|
1821
|
+
importDeps.add(cssId);
|
|
1822
|
+
cssIdToImportBy.set(importCssId, currentImportBy.union(importDeps));
|
|
1798
1823
|
}
|
|
1799
|
-
|
|
1824
|
+
cssIdToImportBy.set(cssId, currentImportBy);
|
|
1800
1825
|
}
|
|
1801
|
-
return oneInfo;
|
|
1802
1826
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1827
|
+
return cssIdToImportBy;
|
|
1828
|
+
}
|
|
1829
|
+
function flattenStyleInfo(styleInfo) {
|
|
1830
|
+
const sortedCssIds = topologicalSort(styleInfo);
|
|
1831
|
+
const cssIdToImportBy = generateImportByMap(styleInfo, sortedCssIds);
|
|
1832
|
+
sortedCssIds.reverse();
|
|
1833
|
+
return sortedCssIds.map((cssId)=>{
|
|
1834
|
+
const oneInfo = styleInfo[cssId];
|
|
1835
|
+
const flattenedInfo = oneInfo ? {
|
|
1836
|
+
content: oneInfo.content,
|
|
1837
|
+
rules: oneInfo.rules,
|
|
1838
|
+
importBy: Array.from(cssIdToImportBy.get(cssId) ?? [
|
|
1839
|
+
cssId
|
|
1840
|
+
])
|
|
1841
|
+
} : {
|
|
1842
|
+
content: [],
|
|
1843
|
+
rules: [],
|
|
1844
|
+
importBy: [
|
|
1845
|
+
cssId
|
|
1846
|
+
]
|
|
1847
|
+
};
|
|
1848
|
+
return flattenedInfo;
|
|
1805
1849
|
});
|
|
1806
1850
|
}
|
|
1807
1851
|
function transformToWebCss(styleInfo) {
|
|
1808
|
-
for (const cssInfos of
|
|
1852
|
+
for (const cssInfos of styleInfo)for (const rule of cssInfos.rules){
|
|
1809
1853
|
const { sel: selectors, decl: declarations } = rule;
|
|
1810
1854
|
const { transformedStyle, childStyle } = transformParsedStyles(declarations);
|
|
1811
1855
|
rule.decl = transformedStyle;
|
|
@@ -1822,18 +1866,20 @@ function transformToWebCss(styleInfo) {
|
|
|
1822
1866
|
function genCssContent(styleInfo, pageConfig, entryName) {
|
|
1823
1867
|
function getExtraSelectors(cssId) {
|
|
1824
1868
|
let suffix;
|
|
1825
|
-
suffix = pageConfig.enableRemoveCSSScope ? `[${lynxTagAttribute}]` :
|
|
1869
|
+
suffix = pageConfig.enableRemoveCSSScope ? `[${lynxTagAttribute}]` : `[${cssIdAttribute}="${cssId}"]`;
|
|
1826
1870
|
suffix = entryName ? `${suffix}[${lynxEntryNameAttribute}=${JSON.stringify(entryName)}]` : `${suffix}:not([${lynxEntryNameAttribute}])`;
|
|
1827
1871
|
return suffix;
|
|
1828
1872
|
}
|
|
1829
1873
|
const finalCssContent = [];
|
|
1830
|
-
for (const
|
|
1831
|
-
const suffix = getExtraSelectors(cssId);
|
|
1874
|
+
for (const cssInfos of styleInfo){
|
|
1832
1875
|
const declarationContent = cssInfos.rules.map((rule)=>{
|
|
1833
1876
|
const { sel: selectorList, decl: declarations } = rule;
|
|
1834
|
-
const selectorString =
|
|
1835
|
-
|
|
1836
|
-
|
|
1877
|
+
const selectorString = cssInfos.importBy.map((cssId)=>{
|
|
1878
|
+
const suffix = getExtraSelectors(cssId);
|
|
1879
|
+
return selectorList.map((selectors)=>selectors.toSpliced(-4, 0, [
|
|
1880
|
+
suffix
|
|
1881
|
+
]).flat().join('')).join(',');
|
|
1882
|
+
}).join(',');
|
|
1837
1883
|
const declarationString = declarations.map(([k, v])=>`${k}:${v};`).join('');
|
|
1838
1884
|
return `${selectorString}{${declarationString}}`;
|
|
1839
1885
|
}).join('');
|
|
@@ -1842,38 +1888,36 @@ function genCssContent(styleInfo, pageConfig, entryName) {
|
|
|
1842
1888
|
return finalCssContent.join('\n');
|
|
1843
1889
|
}
|
|
1844
1890
|
function genCssOGInfo(styleInfo) {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1891
|
+
const cssOGInfo = {};
|
|
1892
|
+
for (const oneInfo of styleInfo)oneInfo.rules = oneInfo.rules.filter((oneRule)=>{
|
|
1893
|
+
oneRule.sel = oneRule.sel.filter((selectorList)=>{
|
|
1894
|
+
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors, combinator] = selectorList;
|
|
1895
|
+
if (1 === classSelectors.length && '.' === classSelectors[0][0] && 0 === pseudoClassSelectors.length && 0 === pseudoElementSelectors.length && 0 === combinator.length) {
|
|
1896
|
+
const selectorName = classSelectors[0].substring(1);
|
|
1897
|
+
for (const cssId of oneInfo.importBy){
|
|
1898
|
+
if (!cssOGInfo[cssId]) cssOGInfo[cssId] = {};
|
|
1899
|
+
const currentDeclarations = cssOGInfo[cssId][selectorName];
|
|
1900
|
+
if (currentDeclarations) currentDeclarations.push(...oneRule.decl);
|
|
1901
|
+
else cssOGInfo[cssId][selectorName] = oneRule.decl;
|
|
1856
1902
|
}
|
|
1857
|
-
return
|
|
1858
|
-
}
|
|
1859
|
-
return
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
return true;
|
|
1860
1906
|
});
|
|
1861
|
-
return
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
];
|
|
1865
|
-
}));
|
|
1907
|
+
return oneRule.sel.length > 0;
|
|
1908
|
+
});
|
|
1909
|
+
return cssOGInfo;
|
|
1866
1910
|
}
|
|
1867
1911
|
function appendStyleElement(styleInfo, pageConfig, rootDom, document, entryName, ssrHydrateInfo) {
|
|
1868
1912
|
const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
|
|
1869
|
-
flattenStyleInfo(styleInfo
|
|
1870
|
-
transformToWebCss(
|
|
1871
|
-
const cssOGInfo = pageConfig.enableCSSSelector ? {} : genCssOGInfo(
|
|
1913
|
+
const flattenedStyleInfo = flattenStyleInfo(styleInfo);
|
|
1914
|
+
transformToWebCss(flattenedStyleInfo);
|
|
1915
|
+
const cssOGInfo = pageConfig.enableCSSSelector ? {} : genCssOGInfo(flattenedStyleInfo);
|
|
1872
1916
|
let cardStyleElement;
|
|
1873
1917
|
if (ssrHydrateInfo?.cardStyleElement) cardStyleElement = ssrHydrateInfo.cardStyleElement;
|
|
1874
1918
|
else {
|
|
1875
1919
|
cardStyleElement = document.createElement('style');
|
|
1876
|
-
cardStyleElement.textContent = genCssContent(
|
|
1920
|
+
cardStyleElement.textContent = genCssContent(flattenedStyleInfo, pageConfig, entryName);
|
|
1877
1921
|
rootDom.appendChild(cardStyleElement);
|
|
1878
1922
|
}
|
|
1879
1923
|
const cardStyleElementSheet = cardStyleElement.sheet;
|
|
@@ -1888,9 +1932,9 @@ function appendStyleElement(styleInfo, pageConfig, rootDom, document, entryName,
|
|
|
1888
1932
|
}
|
|
1889
1933
|
};
|
|
1890
1934
|
const updateLazyComponentStyle = (styleInfo, entryName)=>{
|
|
1891
|
-
flattenStyleInfo(styleInfo
|
|
1892
|
-
transformToWebCss(
|
|
1893
|
-
const newStyleSheet = genCssContent(
|
|
1935
|
+
const flattenedStyleInfo = flattenStyleInfo(styleInfo);
|
|
1936
|
+
transformToWebCss(flattenedStyleInfo);
|
|
1937
|
+
const newStyleSheet = genCssContent(flattenedStyleInfo, pageConfig, entryName);
|
|
1894
1938
|
cardStyleElement.textContent += newStyleSheet;
|
|
1895
1939
|
};
|
|
1896
1940
|
return {
|
|
@@ -1900,8 +1944,10 @@ function appendStyleElement(styleInfo, pageConfig, rootDom, document, entryName,
|
|
|
1900
1944
|
}
|
|
1901
1945
|
function createQueryComponent(loadTemplate, updateLazyComponentStyle, backgroundThreadRpc, mtsGlobalThisRef, jsContext, mtsRealm) {
|
|
1902
1946
|
const updateBTSTemplateCache = backgroundThreadRpc.createCall(updateBTSTemplateCacheEndpoint);
|
|
1947
|
+
const lazyCache = new Map();
|
|
1903
1948
|
const __QueryComponentImpl = (url, callback)=>{
|
|
1904
|
-
|
|
1949
|
+
const cacheLazy = lazyCache.get(url);
|
|
1950
|
+
const loadPromise = cacheLazy ?? loadTemplate(url).then(async (template)=>{
|
|
1905
1951
|
const updateBTSCachePromise = updateBTSTemplateCache(url, template);
|
|
1906
1952
|
let lepusRootChunkExport = await mtsRealm.loadScript(template.lepusCode.root);
|
|
1907
1953
|
if (mtsGlobalThisRef.mtsGlobalThis.processEvalResult) lepusRootChunkExport = mtsGlobalThisRef.mtsGlobalThis.processEvalResult(lepusRootChunkExport, url);
|
|
@@ -1911,6 +1957,10 @@ function createQueryComponent(loadTemplate, updateLazyComponentStyle, background
|
|
|
1911
1957
|
type: '__OnDynamicJSSourcePrepared',
|
|
1912
1958
|
data: url
|
|
1913
1959
|
});
|
|
1960
|
+
return lepusRootChunkExport;
|
|
1961
|
+
});
|
|
1962
|
+
cacheLazy || lazyCache.set(url, loadPromise);
|
|
1963
|
+
loadPromise.then((lepusRootChunkExport)=>{
|
|
1914
1964
|
callback?.({
|
|
1915
1965
|
code: 0,
|
|
1916
1966
|
data: {
|
|
@@ -1920,6 +1970,7 @@ function createQueryComponent(loadTemplate, updateLazyComponentStyle, background
|
|
|
1920
1970
|
});
|
|
1921
1971
|
}).catch((error)=>{
|
|
1922
1972
|
console.error("lynx web: lazy bundle load failed:", error);
|
|
1973
|
+
lazyCache.delete(url);
|
|
1923
1974
|
callback?.({
|
|
1924
1975
|
code: -1,
|
|
1925
1976
|
data: void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core-server-canary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0-canary-20250918-b17b7cb2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"rsbuild-plugin-arethetypeswrong": "0.1.1",
|
|
27
27
|
"rsbuild-plugin-publint": "0.3.3",
|
|
28
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.
|
|
28
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.17.0-canary-20250918-b17b7cb2",
|
|
29
29
|
"@lynx-js/web-elements-template": "npm:@lynx-js/web-elements-template-canary@0.8.6",
|
|
30
|
-
"@lynx-js/web-
|
|
30
|
+
"@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.0-canary-20250918-b17b7cb2",
|
|
31
31
|
"@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4",
|
|
32
|
-
"@lynx-js/web-
|
|
32
|
+
"@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.0-canary-20250918-b17b7cb2"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "rslib build",
|