@lynx-js/web-mainthread-apis-canary 0.19.0 → 0.19.1-canary-20251210-47cc2bc6
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,5 +1,14 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
+
## 0.19.1-canary-20251210073827-47cc2bc694d0da12b41d55e459c4e78338e8b77a
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: fix reload lynx-view when `enableCSSSelector` false may cause css style lost ([#1982](https://github.com/lynx-family/lynx-stack/pull/1982))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @lynx-js/web-constants@0.19.1-canary-20251210073827-47cc2bc694d0da12b41d55e459c4e78338e8b77a
|
|
11
|
+
|
|
3
12
|
## 0.19.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -314,25 +323,25 @@
|
|
|
314
323
|
lynxView.initI18nResources = [
|
|
315
324
|
{
|
|
316
325
|
options: {
|
|
317
|
-
locale:
|
|
318
|
-
channel:
|
|
319
|
-
fallback_url:
|
|
326
|
+
locale: "en",
|
|
327
|
+
channel: "1",
|
|
328
|
+
fallback_url: "",
|
|
320
329
|
},
|
|
321
330
|
resource: {
|
|
322
|
-
hello:
|
|
323
|
-
lynx:
|
|
331
|
+
hello: "hello",
|
|
332
|
+
lynx: "lynx web platform1",
|
|
324
333
|
},
|
|
325
334
|
},
|
|
326
335
|
];
|
|
327
|
-
lynxView.addEventListener(
|
|
336
|
+
lynxView.addEventListener("i18nResourceMissed", (e) => {
|
|
328
337
|
console.log(e);
|
|
329
338
|
});
|
|
330
339
|
|
|
331
340
|
// mts
|
|
332
341
|
_I18nResourceTranslation({
|
|
333
|
-
locale:
|
|
334
|
-
channel:
|
|
335
|
-
fallback_url:
|
|
342
|
+
locale: "en",
|
|
343
|
+
channel: "1",
|
|
344
|
+
fallback_url: "",
|
|
336
345
|
});
|
|
337
346
|
```
|
|
338
347
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Rpc, type StartMainThreadContextConfig, type RpcCallType, type reportErrorEndpoint, type I18nResourceTranslationOptions, type InitI18nResources, type I18nResources, type Cloneable, type SSRHydrateInfo, type SSRDehydrateHooks, type JSRealm, type TemplateLoader, type UpdateDataOptions } from '@lynx-js/web-constants';
|
|
2
|
-
export declare function prepareMainThreadAPIs(backgroundThreadRpc: Rpc, rootDom: Document | ShadowRoot, document: Document, mtsRealmPromise: JSRealm | Promise<JSRealm>, commitDocument: (exposureChangedElements: HTMLElement[]) => Promise<void> | void, markTimingInternal: (timingKey: string, pipelineId?: string) => void, flushMarkTimingInternal: () => void, reportError: RpcCallType<typeof reportErrorEndpoint>, triggerI18nResourceFallback: (options: I18nResourceTranslationOptions) => void, initialI18nResources: (data: InitI18nResources) => I18nResources, loadTemplate: TemplateLoader, ssrHooks?: SSRDehydrateHooks): {
|
|
2
|
+
export declare function prepareMainThreadAPIs(backgroundThreadRpc: Rpc, rootDom: Document | ShadowRoot, document: Document, mtsRealmPromise: JSRealm | Promise<JSRealm>, commitDocument: (exposureChangedElements: HTMLElement[]) => Promise<void> | void, markTimingInternal: (timingKey: string, pipelineId?: string) => void, flushMarkTimingInternal: () => void, reportError: RpcCallType<typeof reportErrorEndpoint>, triggerI18nResourceFallback: (options: I18nResourceTranslationOptions) => void, initialI18nResources: (data: InitI18nResources) => I18nResources, loadTemplate: TemplateLoader, ssrHooks?: SSRDehydrateHooks, allOnUI?: boolean): {
|
|
3
3
|
startMainThread: (config: StartMainThreadContextConfig, ssrHydrateInfo?: SSRHydrateInfo) => Promise<void>;
|
|
4
4
|
handleUpdatedData: (newData: Cloneable, options: UpdateDataOptions | undefined) => Promise<void>;
|
|
5
5
|
};
|
|
@@ -8,7 +8,7 @@ import { createMainThreadGlobalThis } from './createMainThreadGlobalThis.js';
|
|
|
8
8
|
import { createExposureService } from './utils/createExposureService.js';
|
|
9
9
|
import { appendStyleElement } from './utils/processStyleInfo.js';
|
|
10
10
|
import { createQueryComponent } from './crossThreadHandlers/createQueryComponent.js';
|
|
11
|
-
export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealmPromise, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks) {
|
|
11
|
+
export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealmPromise, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks, allOnUI) {
|
|
12
12
|
const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
|
|
13
13
|
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
14
14
|
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
@@ -29,7 +29,7 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mt
|
|
|
29
29
|
sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint,
|
|
30
30
|
});
|
|
31
31
|
const i18nResources = initialI18nResources(initI18nResources);
|
|
32
|
-
const { updateCssOGStyle, updateLazyComponentStyle } = appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo);
|
|
32
|
+
const { updateCssOGStyle, updateLazyComponentStyle } = appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo, allOnUI);
|
|
33
33
|
const mtsGlobalThisRef = {
|
|
34
34
|
mtsGlobalThis: undefined,
|
|
35
35
|
};
|
|
@@ -5,7 +5,7 @@ import { type StyleInfo, type CssOGInfo, type PageConfig, type SSRHydrateInfo, t
|
|
|
5
5
|
* 2. for each css, find all the importing css files (directly and indirectly)
|
|
6
6
|
* 3. return the flattened style info, do not modify the content and rules
|
|
7
7
|
*/
|
|
8
|
-
export declare function flattenStyleInfo(styleInfo: StyleInfo): FlattenedStyleInfo;
|
|
8
|
+
export declare function flattenStyleInfo(styleInfo: StyleInfo, cloneDeep?: boolean): FlattenedStyleInfo;
|
|
9
9
|
/**
|
|
10
10
|
* apply the lynx css -> web css transformation
|
|
11
11
|
*/
|
|
@@ -18,7 +18,7 @@ export declare function genCssContent(styleInfo: FlattenedStyleInfo, pageConfig:
|
|
|
18
18
|
* generate the css-in-js data
|
|
19
19
|
*/
|
|
20
20
|
export declare function genCssOGInfo(styleInfo: FlattenedStyleInfo): CssOGInfo;
|
|
21
|
-
export declare function appendStyleElement(styleInfo: StyleInfo, pageConfig: PageConfig, rootDom: Node, document: Document, ssrHydrateInfo?: SSRHydrateInfo): {
|
|
21
|
+
export declare function appendStyleElement(styleInfo: StyleInfo, pageConfig: PageConfig, rootDom: Node, document: Document, ssrHydrateInfo?: SSRHydrateInfo, allOnUI?: boolean): {
|
|
22
22
|
updateCssOGStyle: (uniqueId: number, newClassName: string, cssID: string | null, entryName: string | null) => void;
|
|
23
23
|
updateLazyComponentStyle: (styleInfo: StyleInfo, entryName: string) => void;
|
|
24
24
|
};
|
|
@@ -64,7 +64,7 @@ function generateImportByMap(styleInfo, sortedCssIds) {
|
|
|
64
64
|
* 2. for each css, find all the importing css files (directly and indirectly)
|
|
65
65
|
* 3. return the flattened style info, do not modify the content and rules
|
|
66
66
|
*/
|
|
67
|
-
export function flattenStyleInfo(styleInfo) {
|
|
67
|
+
export function flattenStyleInfo(styleInfo, cloneDeep) {
|
|
68
68
|
// Step 1. Topological sorting
|
|
69
69
|
const sortedCssIds = topologicalSort(styleInfo);
|
|
70
70
|
// Step 2. generate deps;
|
|
@@ -75,8 +75,17 @@ export function flattenStyleInfo(styleInfo) {
|
|
|
75
75
|
const oneInfo = styleInfo[cssId];
|
|
76
76
|
const flattenedInfo = oneInfo
|
|
77
77
|
? {
|
|
78
|
-
content:
|
|
79
|
-
|
|
78
|
+
content: cloneDeep
|
|
79
|
+
? (oneInfo.content ? [...oneInfo.content] : [])
|
|
80
|
+
: (oneInfo.content ?? []),
|
|
81
|
+
rules: cloneDeep
|
|
82
|
+
? (oneInfo.rules
|
|
83
|
+
? oneInfo.rules.map(rule => ({
|
|
84
|
+
sel: rule.sel.map(selectors => selectors.map(arr => arr.slice())),
|
|
85
|
+
decl: rule.decl.map(([k, v]) => [k, v]),
|
|
86
|
+
}))
|
|
87
|
+
: [])
|
|
88
|
+
: (oneInfo.rules ?? []),
|
|
80
89
|
importBy: Array.from(cssIdToImportBy.get(cssId) ?? [cssId]),
|
|
81
90
|
}
|
|
82
91
|
: {
|
|
@@ -182,7 +191,7 @@ export function genCssOGInfo(styleInfo) {
|
|
|
182
191
|
}
|
|
183
192
|
return cssOGInfo;
|
|
184
193
|
}
|
|
185
|
-
export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo) {
|
|
194
|
+
export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo, allOnUI) {
|
|
186
195
|
const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
|
|
187
196
|
/**
|
|
188
197
|
* now create the style content
|
|
@@ -192,7 +201,7 @@ export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssr
|
|
|
192
201
|
* 4. create the style element
|
|
193
202
|
* 5. append the style element to the root dom
|
|
194
203
|
*/
|
|
195
|
-
const flattenedStyleInfo = flattenStyleInfo(styleInfo);
|
|
204
|
+
const flattenedStyleInfo = flattenStyleInfo(styleInfo, !!allOnUI);
|
|
196
205
|
transformToWebCss(flattenedStyleInfo);
|
|
197
206
|
const cssOGInfo = pageConfig.enableCSSSelector
|
|
198
207
|
? {}
|
|
@@ -224,7 +233,7 @@ export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssr
|
|
|
224
233
|
}
|
|
225
234
|
};
|
|
226
235
|
const updateLazyComponentStyle = (styleInfo, entryName) => {
|
|
227
|
-
const flattenedStyleInfo = flattenStyleInfo(styleInfo);
|
|
236
|
+
const flattenedStyleInfo = flattenStyleInfo(styleInfo, !!allOnUI);
|
|
228
237
|
transformToWebCss(flattenedStyleInfo);
|
|
229
238
|
if (!pageConfig.enableCSSSelector) {
|
|
230
239
|
lazyCSSOGInfo[entryName] = genCssOGInfo(flattenedStyleInfo);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis-canary",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1-canary-20251210-47cc2bc6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"**/*.css"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.
|
|
29
|
+
"@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.19.1-canary-20251210-47cc2bc6",
|
|
30
30
|
"hyphenate-style-name": "^1.1.0",
|
|
31
31
|
"wasm-feature-detect": "^1.8.0"
|
|
32
32
|
},
|