@lynx-js/web-mainthread-apis-canary 0.17.0-canary-20250918-db58f3c8 → 0.17.0-canary-20250919-1d4ce685

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,6 +1,6 @@
1
1
  # @lynx-js/web-mainthread-apis
2
2
 
3
- ## 0.17.0-canary-20250918141730-db58f3c88a8f863d91c0397384f9826b969b1734
3
+ ## 0.17.0-canary-20250919032145-1d4ce685a87313dfe83f0b4a366ff44090415641
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -10,9 +10,11 @@
10
10
 
11
11
  After this commit, we use DAG methods to handle the styleInfos
12
12
 
13
+ - feat: support lazy bundle with CSSOG(`enableCSSSelector: false`). ([#1770](https://github.com/lynx-family/lynx-stack/pull/1770))
14
+
13
15
  - Updated dependencies [[`93d707b`](https://github.com/lynx-family/lynx-stack/commit/93d707b82a59f7256952e21da6dcad2999f8233d)]:
14
- - @lynx-js/web-constants@0.17.0-canary-20250918141730-db58f3c88a8f863d91c0397384f9826b969b1734
15
- - @lynx-js/web-style-transformer@0.17.0-canary-20250918141730-db58f3c88a8f863d91c0397384f9826b969b1734
16
+ - @lynx-js/web-constants@0.17.0-canary-20250919032145-1d4ce685a87313dfe83f0b4a366ff44090415641
17
+ - @lynx-js/web-style-transformer@0.17.0-canary-20250919032145-1d4ce685a87313dfe83f0b4a366ff44090415641
16
18
 
17
19
  ## 0.16.1
18
20
 
@@ -8,7 +8,7 @@ export interface MainThreadRuntimeCallbacks {
8
8
  publishEvent: RpcCallType<typeof publishEventEndpoint>;
9
9
  publicComponentEvent: RpcCallType<typeof publicComponentEventEndpoint>;
10
10
  _I18nResourceTranslation: (options: I18nResourceTranslationOptions) => unknown | undefined;
11
- updateCssOGStyle: (uniqueId: number, newClassName: string, cssID: string | null) => void;
11
+ updateCssOGStyle: (uniqueId: number, newClassName: string, cssID: string | null, entryName: string | null) => void;
12
12
  __QueryComponent: QueryComponentPAPI;
13
13
  }
14
14
  export interface MainThreadRuntimeConfig {
@@ -1,7 +1,7 @@
1
1
  // Copyright 2023 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
- import { lynxUniqueIdAttribute, systemInfo, parentComponentUniqueIdAttribute, componentIdAttribute, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, lynxTagAttribute, W3cEventNameToLynx, cssIdAttribute, lynxDefaultDisplayLinearAttribute, __lynx_timing_flag, lynxDisposedAttribute, } from '@lynx-js/web-constants';
4
+ import { lynxUniqueIdAttribute, systemInfo, parentComponentUniqueIdAttribute, componentIdAttribute, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, lynxTagAttribute, W3cEventNameToLynx, cssIdAttribute, lynxDefaultDisplayLinearAttribute, __lynx_timing_flag, lynxDisposedAttribute, lynxEntryNameAttribute, } from '@lynx-js/web-constants';
5
5
  import { createMainThreadLynx } from './createMainThreadLynx.js';
6
6
  import { __AddClass, __AddConfig, __AddDataset, __AddInlineStyle, __AppendElement, __ElementIsEqual, __FirstElement, __GetAttributes, __GetChildren, __GetClasses, __GetComponentID, __GetDataByKey, __GetDataset, __GetElementConfig, __GetElementUniqueID, __GetID, __GetParent, __GetTag, __GetTemplateParts, __InsertElementBefore, __LastElement, __MarkPartElement, __MarkTemplateElement, __NextElement, __RemoveElement, __ReplaceElement, __ReplaceElements, __SetClasses, __SetConfig, __SetCSSId, __SetDataset, __SetID, __SetInlineStyles, __UpdateComponentID, __UpdateComponentInfo, __GetAttributeByName, } from './pureElementPAPIs.js';
7
7
  import { createCrossThreadEvent } from './utils/createCrossThreadEvent.js';
@@ -291,9 +291,10 @@ export function createMainThreadGlobalThis(config) {
291
291
  // @ts-expect-error fixme
292
292
  temp.replaceWith(childB);
293
293
  };
294
- const __SetCSSIdForCSSOG = (elements, cssId) => {
294
+ const __SetCSSIdForCSSOG = (elements, cssId, entryName) => {
295
295
  for (const element of elements) {
296
296
  element.setAttribute(cssIdAttribute, cssId + '');
297
+ entryName && element.setAttribute(lynxEntryNameAttribute, entryName);
297
298
  const cls = element.getAttribute('class');
298
299
  cls && __SetClassesForCSSOG(element, cls);
299
300
  }
@@ -304,13 +305,15 @@ export function createMainThreadGlobalThis(config) {
304
305
  element.setAttribute('class', newClassName);
305
306
  const cssId = element.getAttribute(cssIdAttribute);
306
307
  const uniqueId = Number(element.getAttribute(lynxUniqueIdAttribute));
307
- callbacks.updateCssOGStyle(uniqueId, newClassName, cssId);
308
+ const entryName = element.getAttribute(lynxEntryNameAttribute);
309
+ callbacks.updateCssOGStyle(uniqueId, newClassName, cssId, entryName);
308
310
  };
309
311
  const __SetClassesForCSSOG = (element, classNames) => {
310
312
  __SetClasses(element, classNames);
311
313
  const cssId = element.getAttribute(cssIdAttribute);
312
314
  const uniqueId = Number(element.getAttribute(lynxUniqueIdAttribute));
313
- callbacks.updateCssOGStyle(uniqueId, classNames ?? '', cssId);
315
+ const entryName = element.getAttribute(lynxEntryNameAttribute);
316
+ callbacks.updateCssOGStyle(uniqueId, classNames ?? '', cssId, entryName);
314
317
  };
315
318
  const __LoadLepusChunk = (path) => {
316
319
  try {
@@ -30,7 +30,7 @@ export function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mt
30
30
  sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint,
31
31
  });
32
32
  const i18nResources = initialI18nResources(initI18nResources);
33
- const { updateCssOGStyle, updateLazyComponentStyle } = appendStyleElement(styleInfo, pageConfig, rootDom, document, undefined, ssrHydrateInfo);
33
+ const { updateCssOGStyle, updateLazyComponentStyle } = appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo);
34
34
  const mtsGlobalThisRef = {
35
35
  mtsGlobalThis: undefined,
36
36
  };
@@ -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, entryName?: string, ssrHydrateInfo?: SSRHydrateInfo): {
22
- updateCssOGStyle: (uniqueId: number, newClassName: string, cssID: string | null) => void;
21
+ export declare function appendStyleElement(styleInfo: StyleInfo, pageConfig: PageConfig, rootDom: Node, document: Document, ssrHydrateInfo?: SSRHydrateInfo): {
22
+ updateCssOGStyle: (uniqueId: number, newClassName: string, cssID: string | null, entryName: string | null) => void;
23
23
  updateLazyComponentStyle: (styleInfo: StyleInfo, entryName: string) => void;
24
24
  };
@@ -182,7 +182,7 @@ export function genCssOGInfo(styleInfo) {
182
182
  }
183
183
  return cssOGInfo;
184
184
  }
185
- export function appendStyleElement(styleInfo, pageConfig, rootDom, document, entryName, ssrHydrateInfo) {
185
+ export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrateInfo) {
186
186
  const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
187
187
  /**
188
188
  * now create the style content
@@ -197,18 +197,22 @@ export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ent
197
197
  const cssOGInfo = pageConfig.enableCSSSelector
198
198
  ? {}
199
199
  : genCssOGInfo(flattenedStyleInfo);
200
+ const lazyCSSOGInfo = {};
200
201
  let cardStyleElement;
201
202
  if (ssrHydrateInfo?.cardStyleElement) {
202
203
  cardStyleElement = ssrHydrateInfo.cardStyleElement;
203
204
  }
204
205
  else {
205
206
  cardStyleElement = document.createElement('style');
206
- cardStyleElement.textContent = genCssContent(flattenedStyleInfo, pageConfig, entryName);
207
+ cardStyleElement.textContent = genCssContent(flattenedStyleInfo, pageConfig, undefined);
207
208
  rootDom.appendChild(cardStyleElement);
208
209
  }
209
- const cardStyleElementSheet = cardStyleElement.sheet;
210
- const updateCssOGStyle = (uniqueId, newClassName, cssID) => {
211
- const newStyles = decodeCssOG(newClassName, cssOGInfo, cssID);
210
+ const updateCssOGStyle = (uniqueId, newClassName, cssID, entryName) => {
211
+ const cardStyleElementSheet = cardStyleElement.sheet;
212
+ const styleMap = entryName && lazyCSSOGInfo[entryName]
213
+ ? lazyCSSOGInfo[entryName]
214
+ : cssOGInfo;
215
+ const newStyles = decodeCssOG(newClassName, styleMap, cssID);
212
216
  if (lynxUniqueIdToStyleRulesIndex[uniqueId] !== undefined) {
213
217
  const rule = cardStyleElementSheet
214
218
  .cssRules[lynxUniqueIdToStyleRulesIndex[uniqueId]];
@@ -222,6 +226,9 @@ export function appendStyleElement(styleInfo, pageConfig, rootDom, document, ent
222
226
  const updateLazyComponentStyle = (styleInfo, entryName) => {
223
227
  const flattenedStyleInfo = flattenStyleInfo(styleInfo);
224
228
  transformToWebCss(flattenedStyleInfo);
229
+ if (!pageConfig.enableCSSSelector) {
230
+ lazyCSSOGInfo[entryName] = genCssOGInfo(flattenedStyleInfo);
231
+ }
225
232
  const newStyleSheet = genCssContent(flattenedStyleInfo, pageConfig, entryName);
226
233
  cardStyleElement.textContent += newStyleSheet;
227
234
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-mainthread-apis-canary",
3
- "version": "0.17.0-canary-20250918-db58f3c8",
3
+ "version": "0.17.0-canary-20250919-1d4ce685",
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.17.0-canary-20250918-db58f3c8",
28
- "@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.17.0-canary-20250918-db58f3c8",
27
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.17.0-canary-20250919-1d4ce685",
28
+ "@lynx-js/web-style-transformer": "npm:@lynx-js/web-style-transformer-canary@0.17.0-canary-20250919-1d4ce685",
29
29
  "hyphenate-style-name": "^1.1.0"
30
30
  }
31
31
  }