@lynx-js/web-mainthread-apis 0.7.1 → 0.8.0
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 +36 -0
- package/dist/MainThreadRuntime.d.ts +0 -1
- package/dist/MainThreadRuntime.js +1 -2
- package/dist/elementAPI/elementCreating/elementCreatingFunctions.d.ts +0 -1
- package/dist/elementAPI/elementCreating/elementCreatingFunctions.js +0 -5
- package/dist/utils/processStyleInfo.d.ts +2 -2
- package/dist/utils/processStyleInfo.js +4 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @lynx-js/web-mainthread-apis
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- refactor: remove web-elements/lazy and loadNewTag ([#123](https://github.com/lynx-family/lynx-stack/pull/123))
|
|
8
|
+
|
|
9
|
+
- remove @lynx-js/web-elements/lazy
|
|
10
|
+
- remove loadElement
|
|
11
|
+
- remove loadNewTag callback
|
|
12
|
+
|
|
13
|
+
**This is a breaking change**
|
|
14
|
+
|
|
15
|
+
Now we removed the default lazy loading preinstalled in web-core
|
|
16
|
+
|
|
17
|
+
Please add the following statement in your web project
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
import "@lynx-js/web-elements/all";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- feat: use shadowroot to isolate one lynx-view ([#198](https://github.com/lynx-family/lynx-stack/pull/198))
|
|
24
|
+
|
|
25
|
+
Before this commit, we have been detecting if current browser supports the `@scope` rule.
|
|
26
|
+
This allows us to scope one lynx-view's styles.
|
|
27
|
+
|
|
28
|
+
After this commit we always create a shadowroot to scope then.
|
|
29
|
+
|
|
30
|
+
Also for the new shadowroot pattern, we add a new **attribute** `inject-head-links`.
|
|
31
|
+
By default, we will iterate all `<link rel="stylesheet">` in the `<head>`, and use `@import url()` to import them inside the shadowroot.
|
|
32
|
+
Developers could add a `inject-head-links="false"` to disable this behavior.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`e9e8370`](https://github.com/lynx-family/lynx-stack/commit/e9e8370e070a50cbf65a4ebc46c2e37ea1e0be40), [`ec4e1ce`](https://github.com/lynx-family/lynx-stack/commit/ec4e1ce0d7612d6c0701792a46c78cd52130bad4), [`f0a717c`](https://github.com/lynx-family/lynx-stack/commit/f0a717c630700e16ab0af7f1fe370fd60ac75b30)]:
|
|
37
|
+
- @lynx-js/web-constants@0.8.0
|
|
38
|
+
|
|
3
39
|
## 0.7.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -2,7 +2,6 @@ import { type ElementOperation, type LynxLifecycleEvent, type LynxTemplate, type
|
|
|
2
2
|
import { type MainThreadLynx } from './MainThreadLynx.js';
|
|
3
3
|
export interface MainThreadRuntimeCallbacks {
|
|
4
4
|
mainChunkReady: () => void;
|
|
5
|
-
onNewTag: (tag: string) => void;
|
|
6
5
|
flushElementTree: (operations: ElementOperation[], options: FlushElementTreeOptions, styleContent?: string) => void;
|
|
7
6
|
_ReportError: (error: Error, info?: unknown) => void;
|
|
8
7
|
__OnLifecycleEvent: (lynxLifecycleEvents: LynxLifecycleEvent) => void;
|
|
@@ -28,7 +28,6 @@ export class MainThreadRuntime {
|
|
|
28
28
|
Object.assign(this, attributeAndPropertyApis, domTreeApis, eventApis, styleApis, initializeElementCreatingFunction({
|
|
29
29
|
operationsRef: this.operationsRef,
|
|
30
30
|
pageConfig: config.pageConfig,
|
|
31
|
-
onNewTag: config.callbacks.onNewTag,
|
|
32
31
|
styleInfo: cssInJs,
|
|
33
32
|
}));
|
|
34
33
|
this.__LoadLepusChunk = (path) => {
|
|
@@ -82,7 +81,7 @@ export class MainThreadRuntime {
|
|
|
82
81
|
const operations = this.operationsRef.operations;
|
|
83
82
|
this.operationsRef.operations = [];
|
|
84
83
|
this.config.callbacks.flushElementTree(operations, options, this.isFp
|
|
85
|
-
? genCssContent(this.config.styleInfo, this.config.
|
|
84
|
+
? genCssContent(this.config.styleInfo, this.config.pageConfig)
|
|
86
85
|
: undefined);
|
|
87
86
|
this.isFp = false;
|
|
88
87
|
};
|
|
@@ -5,7 +5,6 @@ export interface initializeElementCreatingFunctionConfig {
|
|
|
5
5
|
operations: ElementOperation[];
|
|
6
6
|
};
|
|
7
7
|
pageConfig: PageConfig;
|
|
8
|
-
onNewTag: (tag: string) => void;
|
|
9
8
|
styleInfo: CssInJsInfo;
|
|
10
9
|
}
|
|
11
10
|
export declare function initializeElementCreatingFunction(config: initializeElementCreatingFunctionConfig): {
|
|
@@ -7,7 +7,6 @@ import { ListElement, ElementThreadElement, } from '../ElementThreadElement.js';
|
|
|
7
7
|
import { __SetCSSId } from '../style/styleFunctions.js';
|
|
8
8
|
import { createOffscreenDocument } from '../createOffscreenDocument.js';
|
|
9
9
|
export function initializeElementCreatingFunction(config) {
|
|
10
|
-
const tagSet = new Set();
|
|
11
10
|
const { operationsRef, pageConfig, styleInfo } = config;
|
|
12
11
|
const document = createOffscreenDocument({
|
|
13
12
|
pageConfig,
|
|
@@ -17,10 +16,6 @@ export function initializeElementCreatingFunction(config) {
|
|
|
17
16
|
function createLynxElement(tag, parentComponentUniqueId, cssId, componentId,
|
|
18
17
|
// @ts-expect-error
|
|
19
18
|
info) {
|
|
20
|
-
if (!tagSet.has(tag)) {
|
|
21
|
-
config.onNewTag(tag);
|
|
22
|
-
tagSet.add(tag);
|
|
23
|
-
}
|
|
24
19
|
const element = document.createElement(tag);
|
|
25
20
|
// element.parentComponentUniqueId = parentComponentUniqueId;
|
|
26
21
|
element.setAttribute(parentComponentUniqueIdAttribute, parentComponentUniqueId.toString());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type StyleInfo, type CssInJsInfo, type PageConfig
|
|
1
|
+
import { type StyleInfo, type CssInJsInfo, type PageConfig } from '@lynx-js/web-constants';
|
|
2
2
|
export declare function flattenStyleInfo(styleInfo: StyleInfo): void;
|
|
3
3
|
/**
|
|
4
4
|
* apply the lynx css -> web css transformation
|
|
@@ -7,7 +7,7 @@ export declare function transformToWebCss(styleInfo: StyleInfo): void;
|
|
|
7
7
|
/**
|
|
8
8
|
* generate those styles applied by <style>...</style>
|
|
9
9
|
*/
|
|
10
|
-
export declare function genCssContent(styleInfo: StyleInfo,
|
|
10
|
+
export declare function genCssContent(styleInfo: StyleInfo, pageConfig: PageConfig): string;
|
|
11
11
|
/**
|
|
12
12
|
* generate the css-in-js data
|
|
13
13
|
*/
|
|
@@ -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 { cssIdAttribute, lynxTagAttribute,
|
|
4
|
+
import { cssIdAttribute, lynxTagAttribute, } from '@lynx-js/web-constants';
|
|
5
5
|
import { transformLynxStyles } from '@lynx-js/web-style-transformer';
|
|
6
6
|
export function flattenStyleInfo(styleInfo) {
|
|
7
7
|
function flattenOneStyleInfo(cssId) {
|
|
@@ -48,7 +48,7 @@ export function transformToWebCss(styleInfo) {
|
|
|
48
48
|
/**
|
|
49
49
|
* generate those styles applied by <style>...</style>
|
|
50
50
|
*/
|
|
51
|
-
export function genCssContent(styleInfo,
|
|
51
|
+
export function genCssContent(styleInfo, pageConfig) {
|
|
52
52
|
function getExtraSelectors(cssId) {
|
|
53
53
|
let prepend = '', suffix = '';
|
|
54
54
|
if (!pageConfig.enableRemoveCSSScope) {
|
|
@@ -60,9 +60,8 @@ export function genCssContent(styleInfo, entryId, pageConfig, browserConfig) {
|
|
|
60
60
|
suffix += `[${lynxTagAttribute}]`;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
+ prepend;
|
|
63
|
+
else {
|
|
64
|
+
suffix += `[${lynxTagAttribute}]`;
|
|
66
65
|
}
|
|
67
66
|
return { prepend, suffix };
|
|
68
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-mainthread-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"css-tree": "^3.1.0",
|
|
27
27
|
"hyphenate-style-name": "^1.1.0",
|
|
28
|
-
"@lynx-js/web-constants": "0.
|
|
28
|
+
"@lynx-js/web-constants": "0.8.0",
|
|
29
29
|
"@lynx-js/web-style-transformer": "0.2.2"
|
|
30
30
|
}
|
|
31
31
|
}
|