diff --git a/.changeset/config.json b/.changeset/config.json index eef9de1cf9..5803054e04 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -15,7 +15,6 @@ "@lynx-js/web-mainthread-apis", "@lynx-js/web-worker-rpc", "@lynx-js/web-worker-runtime", - "@lynx-js/web-style-transformer", "@lynx-js/web-rsbuild-server-middleware" ], [ diff --git a/.changeset/long-baths-prove.md b/.changeset/long-baths-prove.md new file mode 100644 index 0000000000..3c4dd87040 --- /dev/null +++ b/.changeset/long-baths-prove.md @@ -0,0 +1,7 @@ +--- +"@lynx-js/web-core-server": patch +--- + +chore: minor bundle output change + +the timing of loading wasm chunk has been changed diff --git a/Cargo.lock b/Cargo.lock index 202efe401d..81d203e59a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -984,10 +984,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "inline-style-parser" -version = "0.0.0" - [[package]] name = "is-macro" version = "0.3.5" @@ -3784,10 +3780,9 @@ dependencies = [ ] [[package]] -name = "web-style-transformer" +name = "web-mainthread-apis" version = "0.0.0" dependencies = [ - "inline-style-parser", "js-sys", "lazy_static", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 544025c39a..99b92fb945 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,8 +6,7 @@ members = [ "packages/react/transform/crates/*", "packages/react/transform/swc-plugin-reactlynx", "packages/react/transform/swc-plugin-reactlynx-compat", - "packages/web-platform/inline-style-parser", - "packages/web-platform/web-style-transformer", + "packages/web-platform/web-mainthread-apis", ] [workspace.dependencies] diff --git a/packages/web-platform/inline-style-parser/Cargo.toml b/packages/web-platform/inline-style-parser/Cargo.toml deleted file mode 100644 index 989903cf91..0000000000 --- a/packages/web-platform/inline-style-parser/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "inline-style-parser" -version = "0.0.0" -edition = "2021" diff --git a/packages/web-platform/web-core-server/rslib.config.ts b/packages/web-platform/web-core-server/rslib.config.ts index 6375697fd4..4ef770b50d 100644 --- a/packages/web-platform/web-core-server/rslib.config.ts +++ b/packages/web-platform/web-core-server/rslib.config.ts @@ -30,6 +30,9 @@ const config: RslibConfig = defineConfig({ output: { wasmLoading: 'async-node', }, + experiments: { + futureDefaults: true, + }, }, }, }); diff --git a/packages/web-platform/web-core-server/src/createLynxView.ts b/packages/web-platform/web-core-server/src/createLynxView.ts index f027e48d73..c06590f773 100644 --- a/packages/web-platform/web-core-server/src/createLynxView.ts +++ b/packages/web-platform/web-core-server/src/createLynxView.ts @@ -10,7 +10,6 @@ import { type MainThreadGlobalThis, } from '@lynx-js/web-constants'; import { Rpc } from '@lynx-js/web-worker-rpc'; -import { prepareMainThreadAPIs } from '@lynx-js/web-mainthread-apis'; import { loadTemplate } from './utils/loadTemplate.js'; import { _attributes, @@ -164,6 +163,9 @@ export async function createLynxView( }); }); }; + const { prepareMainThreadAPIs } = await import( + '@lynx-js/web-mainthread-apis' + ); const { startMainThread } = prepareMainThreadAPIs( backgroundThreadRpc, offscreenDocument, diff --git a/packages/web-platform/web-style-transformer/Cargo.toml b/packages/web-platform/web-mainthread-apis/Cargo.toml similarity index 68% rename from packages/web-platform/web-style-transformer/Cargo.toml rename to packages/web-platform/web-mainthread-apis/Cargo.toml index 05341e851b..8bfda175fe 100644 --- a/packages/web-platform/web-style-transformer/Cargo.toml +++ b/packages/web-platform/web-mainthread-apis/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "web-style-transformer" +name = "web-mainthread-apis" version = "0.0.0" edition = "2021" @@ -7,7 +7,6 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -inline-style-parser = { path = "../inline-style-parser" } js-sys = { workspace = true } lazy_static = { workspace = true } wasm-bindgen = { workspace = true } diff --git a/packages/web-platform/web-mainthread-apis/package.json b/packages/web-platform/web-mainthread-apis/package.json index 7535148f91..7d11c6524a 100644 --- a/packages/web-platform/web-mainthread-apis/package.json +++ b/packages/web-platform/web-mainthread-apis/package.json @@ -16,16 +16,25 @@ "files": [ "dist", "binary", + "wasm", "!dist/**/*.js.map", + "!binary/**/*.js.map", "LICENSE.txt", "Notice.txt", "CHANGELOG.md", "README.md", "**/*.css" ], + "scripts": { + "build": "node scripts/build.js" + }, "dependencies": { "@lynx-js/web-constants": "workspace:*", - "@lynx-js/web-style-transformer": "workspace:*", - "hyphenate-style-name": "^1.1.0" + "hyphenate-style-name": "^1.1.0", + "wasm-feature-detect": "^1.8.0" + }, + "devDependencies": { + "binaryen": "^125.0.0", + "fb-dotslash": "^0.5.8" } } diff --git a/packages/web-platform/web-mainthread-apis/scripts/build.js b/packages/web-platform/web-mainthread-apis/scripts/build.js new file mode 100644 index 0000000000..fb56885900 --- /dev/null +++ b/packages/web-platform/web-mainthread-apis/scripts/build.js @@ -0,0 +1,86 @@ +// run command and dump output +import { execSync } from 'child_process'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const packageRoot = path.join(__dirname, '..'); +const cargoOutput = path.join( + '..', + '..', + '..', + 'target', + 'wasm32-unknown-unknown', + 'release', + 'web_mainthread_apis.wasm', +); +const cargoOutputDebug = path.join( + '..', + '..', + '..', + 'target', + 'wasm32-unknown-unknown', + 'debug', + 'web_mainthread_apis.wasm', +); +// build the standard wasm package + +function build(release, rustFlags, outName, optimizeArgs, rust_features) { + execSync( + `cargo build ${ + release ? '--release' : '' + } --target wasm32-unknown-unknown ${ + rust_features ? `--features ${rust_features}` : '' + }`, + { + cwd: packageRoot, + stdio: 'inherit', + env: { ...process.env, RUSTFLAGS: rustFlags }, + shell: true, + }, + ); + execSync( + `pnpm exec dotslash ./scripts/wasm-bindgen ${ + release ? '' : '--keep-debug' + } --out-dir binary --target bundler --out-name ${outName} ${ + release ? cargoOutput : cargoOutputDebug + }`, + { cwd: packageRoot, stdio: 'inherit' }, + ); + if (release) { + execSync( + `pnpm wasm-opt --enable-bulk-memory ${optimizeArgs} ./binary/${outName}_bg.wasm -o ./binary/${outName}_bg.wasm`, + { cwd: packageRoot, stdio: 'inherit' }, + ); + } +} +/** + * https://webassembly.org/features/ + * https://doc.rust-lang.org/reference/attributes/codegen.html#wasm32-or-wasm64 + * https://doc.rust-lang.org/rustc/platform-support/wasm32-unknown-unknown.html + * feature | chrome | firefox | safari + * bulk-memory| 75 | 79 | 15 + * sign-ext | 74 | 62 | 14.1 + * simd | 91 | 89 | 16.4 + * ref-types | 96 | 79 | 15 + * multivalue | 85 | 78 | 13.1 + * nontrapping + * float- + * to-int | 75 | 64 | 15 + * mutable- + * globals | 74 | 61 | 13.1 + */ + +build( + true, + '-C target_feature=+bulk-memory,+sign-ext,+simd128,+reference-types,+nontrapping-fptoint,+mutable-globals', + 'standard', + '--enable-bulk-memory-opt --enable-sign-ext --enable-simd --enable-reference-types --enable-nontrapping-float-to-int --enable-mutable-globals', +); +build( + true, + '-C target_feature=+bulk-memory -C strip=symbols', + 'legacy', + '', +); +build(false, '', 'debug', ''); diff --git a/packages/web-platform/web-style-transformer/scripts/dotslash-config.json b/packages/web-platform/web-mainthread-apis/scripts/dotslash-config.json similarity index 100% rename from packages/web-platform/web-style-transformer/scripts/dotslash-config.json rename to packages/web-platform/web-mainthread-apis/scripts/dotslash-config.json diff --git a/packages/web-platform/web-style-transformer/scripts/wasm-bindgen b/packages/web-platform/web-mainthread-apis/scripts/wasm-bindgen similarity index 100% rename from packages/web-platform/web-style-transformer/scripts/wasm-bindgen rename to packages/web-platform/web-mainthread-apis/scripts/wasm-bindgen diff --git a/packages/web-platform/web-mainthread-apis/src/lib.rs b/packages/web-platform/web-mainthread-apis/src/lib.rs new file mode 100644 index 0000000000..d6420bc3c1 --- /dev/null +++ b/packages/web-platform/web-mainthread-apis/src/lib.rs @@ -0,0 +1 @@ +mod style; diff --git a/packages/web-platform/inline-style-parser/src/LICENSE b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/LICENSE similarity index 100% rename from packages/web-platform/inline-style-parser/src/LICENSE rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/LICENSE diff --git a/packages/web-platform/inline-style-parser/src/char_code_definitions.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/char_code_definitions.rs similarity index 100% rename from packages/web-platform/inline-style-parser/src/char_code_definitions.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/char_code_definitions.rs diff --git a/packages/web-platform/inline-style-parser/src/lib.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs similarity index 98% rename from packages/web-platform/inline-style-parser/src/lib.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs index 853e05a99c..06e20615df 100644 --- a/packages/web-platform/inline-style-parser/src/lib.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs @@ -10,7 +10,7 @@ mod tests { use super::*; use parse_inline_style::{parse_inline_style, Transformer}; - #[derive(Debug, PartialEq)] + #[derive(PartialEq)] struct Declaration { name_start: usize, name_end: usize, @@ -502,7 +502,7 @@ mod tests { #[test] fn test_character_classification_macros() { - use crate::char_code_definitions::*; + use super::char_code_definitions::*; // Test digit classification assert!(is_digit(b'0')); @@ -585,7 +585,7 @@ mod tests { #[test] fn test_char_code_category() { - use crate::char_code_definitions::*; + use super::char_code_definitions::*; // Test basic categories assert_eq!(char_code_category(0x0020), WHITE_SPACE_CATEGORY); // SPACE @@ -602,7 +602,7 @@ mod tests { #[test] fn test_utility_functions() { - use crate::utils::*; + use super::utils::*; // Test cmp_str function let test_str: &[u8] = b"hello"; @@ -707,7 +707,7 @@ mod tests { #[test] fn test_tokenizer_specific_cases() { - use crate::tokenize::{self, Parser}; + use super::tokenize::{self, Parser}; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, @@ -800,8 +800,8 @@ mod tests { #[test] fn test_string_tokenizer_edge_cases() { - use crate::tokenize::{tokenize, Parser}; - use crate::types::*; + use super::tokenize::{tokenize, Parser}; + use super::types::*; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, @@ -856,8 +856,8 @@ mod tests { #[test] fn test_url_tokenizer_edge_cases() { - use crate::tokenize::{tokenize, Parser}; - use crate::types::*; + use super::tokenize::{tokenize, Parser}; + use super::types::*; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, @@ -936,8 +936,8 @@ mod tests { #[test] fn test_numeric_tokenizer_edge_cases() { - use crate::tokenize::{tokenize, Parser}; - use crate::types::*; + use super::tokenize::{tokenize, Parser}; + use super::types::*; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, @@ -1048,8 +1048,8 @@ mod tests { #[test] fn test_comment_tokenizer() { - use crate::tokenize::{tokenize, Parser}; - use crate::types::*; + use super::tokenize::{tokenize, Parser}; + use super::types::*; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, @@ -1097,8 +1097,8 @@ mod tests { #[test] fn test_additional_edge_cases() { - use crate::char_code_definitions::*; - use crate::utils::*; + use super::char_code_definitions::*; + use super::utils::*; // Test cmp_char macro let source: &[u8] = "Hello".as_bytes(); @@ -1146,9 +1146,9 @@ mod tests { #[test] fn test_remaining_coverage_gaps() { - use crate::char_code_definitions::*; - use crate::tokenize::{tokenize, Parser}; - use crate::utils::*; + use super::char_code_definitions::*; + use super::tokenize::{tokenize, Parser}; + use super::utils::*; struct TokenCollector { tokens: Vec<(u8, usize, usize)>, diff --git a/packages/web-platform/inline-style-parser/src/parse_inline_style.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs similarity index 99% rename from packages/web-platform/inline-style-parser/src/parse_inline_style.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs index a11d243603..70e83e8d1d 100644 --- a/packages/web-platform/inline-style-parser/src/parse_inline_style.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs @@ -1,4 +1,4 @@ -use crate::{ +use super::{ char_code_definitions::{get_char_code, is_white_space}, tokenize::{self, Parser}, types::*, diff --git a/packages/web-platform/inline-style-parser/src/tokenize.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs similarity index 99% rename from packages/web-platform/inline-style-parser/src/tokenize.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs index 939a86ea58..96f5338317 100644 --- a/packages/web-platform/inline-style-parser/src/tokenize.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs @@ -1,5 +1,8 @@ -use crate::*; -use crate::{char_code_definitions::*, types::*, utils::*}; +use super::{ + char_code_definitions::{self, *}, + types::*, + utils::*, +}; /* * this code forked from css-tree @@ -536,7 +539,7 @@ pub fn tokenize(source: &[u8], parser: &mut T) { #[cfg(test)] mod test { - use crate::tokenize::*; + use super::*; struct TokenStreamRecorder { tokens: Vec<(u8, usize, usize)>, diff --git a/packages/web-platform/inline-style-parser/src/types.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/types.rs similarity index 100% rename from packages/web-platform/inline-style-parser/src/types.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/types.rs diff --git a/packages/web-platform/inline-style-parser/src/utils.rs b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs similarity index 99% rename from packages/web-platform/inline-style-parser/src/utils.rs rename to packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs index ced170210f..1102ee6d83 100644 --- a/packages/web-platform/inline-style-parser/src/utils.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs @@ -1,4 +1,4 @@ -use crate::char_code_definitions::*; +use super::char_code_definitions::*; pub fn cmp_str(test_str: &[u8], start: usize, end: usize, reference_str: &[u8]) -> bool { if (end - start) != reference_str.len() { diff --git a/packages/web-platform/web-style-transformer/src/lib.rs b/packages/web-platform/web-mainthread-apis/src/style/mod.rs similarity index 97% rename from packages/web-platform/web-style-transformer/src/lib.rs rename to packages/web-platform/web-mainthread-apis/src/style/mod.rs index 6e1d4f8db1..6e5d980924 100644 --- a/packages/web-platform/web-style-transformer/src/lib.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/mod.rs @@ -1,6 +1,6 @@ use wasm_bindgen::prelude::*; - -pub mod transformer; +mod inline_style_parser; +mod transformer; #[wasm_bindgen] pub fn transform_raw_u16_inline_style_ptr(str: &str) -> Option { diff --git a/packages/web-platform/web-style-transformer/src/transformer/mod.rs b/packages/web-platform/web-mainthread-apis/src/style/transformer/mod.rs similarity index 100% rename from packages/web-platform/web-style-transformer/src/transformer/mod.rs rename to packages/web-platform/web-mainthread-apis/src/style/transformer/mod.rs diff --git a/packages/web-platform/web-style-transformer/src/transformer/rules.rs b/packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs similarity index 99% rename from packages/web-platform/web-style-transformer/src/transformer/rules.rs rename to packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs index bba31821f2..cb64982488 100644 --- a/packages/web-platform/web-style-transformer/src/transformer/rules.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs @@ -236,7 +236,7 @@ pub fn get_replace_rule_value( #[cfg(test)] mod tests { - use crate::transformer::rules::{get_rename_rule_value, get_replace_rule_value}; + use super::{get_rename_rule_value, get_replace_rule_value}; #[test] fn test_rename_rule_flex_direction() { diff --git a/packages/web-platform/web-style-transformer/src/transformer/transform.rs b/packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs similarity index 97% rename from packages/web-platform/web-style-transformer/src/transformer/transform.rs rename to packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs index a29a0e112d..b84a844131 100644 --- a/packages/web-platform/web-style-transformer/src/transformer/transform.rs +++ b/packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs @@ -1,7 +1,6 @@ -use inline_style_parser::parse_inline_style::Transformer; -use inline_style_parser::{char_code_definitions::is_white_space, parse_inline_style}; +use super::super::inline_style_parser::{char_code_definitions::*, parse_inline_style::*}; +use super::rules::{get_rename_rule_value, get_replace_rule_value}; -use crate::transformer::rules::{get_rename_rule_value, get_replace_rule_value}; pub struct TransformerData<'a> { source: &'a str, transformed_source: String, @@ -251,13 +250,10 @@ pub fn transform_inline_style_string<'a>(source: &'a str) -> (String, String) { extra_children_styles: String::new(), }; let bytes = source.as_bytes(); - parse_inline_style::parse_inline_style(bytes, &mut transformer); - if transformer.offset != 0 { - // append the remaining part of the source - transformer - .transformed_source - .push_str(&source[transformer.offset..]); - } + parse_inline_style(bytes, &mut transformer); + transformer + .transformed_source + .push_str(&source[transformer.offset..]); ( transformer.transformed_source, transformer.extra_children_styles, @@ -268,6 +264,13 @@ pub fn transform_inline_style_string<'a>(source: &'a str) -> (String, String) { mod tests { use super::*; + #[test] + fn basic_one_simple_decl() { + let source = "height:1px;"; + let result = transform_inline_style_string(source).0; + assert_eq!(result, "height:1px;"); + } + #[test] fn transform_basic() { let source = "height:1px;display:linear;flex-direction:row;width:100px;"; diff --git a/packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts b/packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts index 6c2412cdac..1d21933770 100644 --- a/packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts +++ b/packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts @@ -34,10 +34,8 @@ import { registerCallLepusMethodHandler } from './crossThreadHandlers/registerCa import { registerGetCustomSectionHandler } from './crossThreadHandlers/registerGetCustomSectionHandler.js'; import { createMainThreadGlobalThis } from './createMainThreadGlobalThis.js'; import { createExposureService } from './utils/createExposureService.js'; -import { initWasm } from '@lynx-js/web-style-transformer'; import { appendStyleElement } from './utils/processStyleInfo.js'; import { createQueryComponent } from './crossThreadHandlers/createQueryComponent.js'; -const initWasmPromise = initWasm(); export function prepareMainThreadAPIs( backgroundThreadRpc: Rpc, @@ -99,7 +97,6 @@ export function prepareMainThreadAPIs( } = template; const mtsRealm = await mtsRealmPromise; markTimingInternal('decode_start'); - await initWasmPromise; const jsContext = new LynxCrossThreadContext({ rpc: backgroundThreadRpc, receiveEventEndpoint: dispatchJSContextOnMainThreadEndpoint, diff --git a/packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts b/packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts index 47cbfa8f52..24d7878643 100644 --- a/packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts +++ b/packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts @@ -1,4 +1,4 @@ -import { wasm } from '@lynx-js/web-style-transformer'; +import { wasm } from '../../wasm/index.js'; export function transformInlineStyleString(str: string): string { return wasm.transform_raw_u16_inline_style_ptr(str) ?? str; } diff --git a/packages/web-platform/web-mainthread-apis/turbo.json b/packages/web-platform/web-mainthread-apis/turbo.json index 425ece42b1..939d6be9f2 100644 --- a/packages/web-platform/web-mainthread-apis/turbo.json +++ b/packages/web-platform/web-mainthread-apis/turbo.json @@ -13,7 +13,8 @@ "src/**" ], "outputs": [ - "dist/**" + "dist/**", + "binary/**" ] } } diff --git a/packages/web-platform/web-style-transformer/index.d.ts b/packages/web-platform/web-mainthread-apis/wasm/index.d.ts similarity index 100% rename from packages/web-platform/web-style-transformer/index.d.ts rename to packages/web-platform/web-mainthread-apis/wasm/index.d.ts diff --git a/packages/web-platform/web-style-transformer/index.js b/packages/web-platform/web-mainthread-apis/wasm/index.js similarity index 97% rename from packages/web-platform/web-style-transformer/index.js rename to packages/web-platform/web-mainthread-apis/wasm/index.js index 75f0c36f31..ef4274c150 100644 --- a/packages/web-platform/web-style-transformer/index.js +++ b/packages/web-platform/web-mainthread-apis/wasm/index.js @@ -20,3 +20,4 @@ export async function initWasm() { ); } } +await initWasm(); diff --git a/packages/web-platform/web-mainthread-apis/wasm/legacy.js b/packages/web-platform/web-mainthread-apis/wasm/legacy.js new file mode 100644 index 0000000000..b3d20eea31 --- /dev/null +++ b/packages/web-platform/web-mainthread-apis/wasm/legacy.js @@ -0,0 +1 @@ +export * from '../binary/legacy.js'; diff --git a/packages/web-platform/web-style-transformer/standard.d.ts b/packages/web-platform/web-mainthread-apis/wasm/standard.d.ts similarity index 100% rename from packages/web-platform/web-style-transformer/standard.d.ts rename to packages/web-platform/web-mainthread-apis/wasm/standard.d.ts diff --git a/packages/web-platform/web-mainthread-apis/wasm/standard.js b/packages/web-platform/web-mainthread-apis/wasm/standard.js new file mode 100644 index 0000000000..a010daeb8a --- /dev/null +++ b/packages/web-platform/web-mainthread-apis/wasm/standard.js @@ -0,0 +1 @@ +export * from '../binary/standard.js'; diff --git a/packages/web-platform/web-style-transformer/CHANGELOG.md b/packages/web-platform/web-style-transformer/CHANGELOG.md deleted file mode 100644 index 9ee4e43608..0000000000 --- a/packages/web-platform/web-style-transformer/CHANGELOG.md +++ /dev/null @@ -1,140 +0,0 @@ -# @lynx-js/web-style-transformer - -## 0.18.3 - -## 0.18.2 - -## 0.18.1 - -## 0.18.0 - -## 0.17.2 - -## 0.17.1 - -## 0.17.0 - -## 0.16.1 - -## 0.16.0 - -## 0.15.7 - -## 0.15.6 - -### Patch Changes - -- refactor: use utf-8 string ([#1473](https://github.com/lynx-family/lynx-stack/pull/1473)) - -## 0.15.5 - -## 0.15.4 - -## 0.3.3 - -### Patch Changes - -- Fix `index_bg.wasm` not found when publishing. ([#1277](https://github.com/lynx-family/lynx-stack/pull/1277)) - -## 0.3.2 - -### Patch Changes - -- refactor: improve `linear-weight-sum` performance ([#1216](https://github.com/lynx-family/lynx-stack/pull/1216)) - -- perf: use rust implemented style transformer ([#1094](https://github.com/lynx-family/lynx-stack/pull/1094)) - -## 0.3.1 - -### Patch Changes - -- fix: --lynx-color will be removed, and if color contains `gradient` it will be processed as transparent. ([#1069](https://github.com/lynx-family/lynx-stack/pull/1069)) - -## 0.3.0 - -### Minor Changes - -- feat: improve compatibility for chrome 108 & support linear-gradient for nested x-text ([#590](https://github.com/lynx-family/lynx-stack/pull/590)) - - **This is a breaking change** - - - Please upgrade your `@lynx-js/web-elements` to >=0.6.0 - - Please upgrade your `@lynx-js/web-core` to >=0.12.0 - - The compiled lynx template json won't be impacted. - - On chrome 108, the `-webkit-background-clip:text` cannot be computed by a `var(--css-var-value-text)` - - Therefore we move the logic into style transformation logic. - - Now the following status is supported - - ``` - - - - - ``` - -## 0.2.3 - -### Patch Changes - -- feat: 1. list adds support for the `sticky` attribute. Now sticky-offset, sticky-top, and sticky-bottom will only take effect when `sticky` is `true`. ([#257](https://github.com/lynx-family/lynx-stack/pull/257)) - - 2. Added support for `list-main-axis-gap`, `list-cross-axis-gap`. - -## 0.2.2 - -### Patch Changes - -- Support NPM provenance. ([#30](https://github.com/lynx-family/lynx-stack/pull/30)) - -- feat: support `justify-content`, `align-self` in linear container ([#37](https://github.com/lynx-family/lynx-stack/pull/37)) - - Now these two properties could work in a linear container. - - We don't transforms the `justify-content` and `align-self` to css vars any more. - - The previous version of `@lynx-js/web-core` won't work with current `@lynx-js/web-core` after this change. - -## 0.2.1 - -### Patch Changes - -- 2738fdc: feat: support linear-direction - -## 0.2.0 - -### Minor Changes - -- e406d69: refractor: update output json format - - **This is a breaking change** - - Before this change the style info is dump in Javascript code. - - After this change the style info will be pure JSON data. - - Now we're using the css-serializer tool's output only. If you're using plugins for it, now they're enabled. - -## 0.1.0 - -### Minor Changes - -- 39cf3ae: feat: improve performance for supporting linear layout - - Before this commit, we'll use `getComputedStyle()` to find out if a dom is a linear container. - - After this commit, we'll use the css variable cyclic toggle pattern and `@container style()` - - This feature requires **Chrome 111, Safari 18**. - - We'll provide a fallback implementation for firefox and legacy browsers. - - After this commit, your `flex-direction`, `flex-shrink`, `flex`, `flex-grow`, `flex-basis` will be transformed to a css variable expression. - -- 6e003e8: feat(web): support linear layout and add tests - -### Patch Changes - -- f28650f: fix: `flex:1` transforming issue diff --git a/packages/web-platform/web-style-transformer/LICENSE.txt b/packages/web-platform/web-style-transformer/LICENSE.txt deleted file mode 100644 index ce66b4c3a7..0000000000 --- a/packages/web-platform/web-style-transformer/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2023-2024 The Lynx Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/web-platform/web-style-transformer/Notice.txt b/packages/web-platform/web-style-transformer/Notice.txt deleted file mode 100644 index 3ff8881bfd..0000000000 --- a/packages/web-platform/web-style-transformer/Notice.txt +++ /dev/null @@ -1 +0,0 @@ -Copyright 2023-2024 The Lynx Authors. All rights reserved. \ No newline at end of file diff --git a/packages/web-platform/web-style-transformer/README.md b/packages/web-platform/web-style-transformer/README.md deleted file mode 100644 index 94fd027145..0000000000 --- a/packages/web-platform/web-style-transformer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @lynx-js/web-style-transformer - -style transformer for flex、linear layout. diff --git a/packages/web-platform/web-style-transformer/legacy.js b/packages/web-platform/web-style-transformer/legacy.js deleted file mode 100644 index aa4d755f70..0000000000 --- a/packages/web-platform/web-style-transformer/legacy.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from './dist/legacy.js'; -export { memory } from './dist/legacy_bg.wasm'; diff --git a/packages/web-platform/web-style-transformer/package.json b/packages/web-platform/web-style-transformer/package.json deleted file mode 100644 index c7a707d718..0000000000 --- a/packages/web-platform/web-style-transformer/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@lynx-js/web-style-transformer", - "version": "0.18.3", - "private": false, - "repository": { - "type": "git", - "url": "https://github.com/lynx-family/lynx-stack.git", - "directory": "packages/web-platform/web-style-transformer" - }, - "license": "Apache-2.0", - "sideEffects": false, - "type": "module", - "main": "index.js", - "typings": "index.d.ts", - "files": [ - "dist", - "!dist/**/*.js.map", - "*.d.ts", - "*.js", - "LICENSE.txt", - "Notice.txt", - "CHANGELOG.md", - "README.md" - ], - "scripts": { - "build": "node scripts/build.js" - }, - "dependencies": { - "wasm-feature-detect": "^1.8.0" - }, - "devDependencies": { - "binaryen": "^124.0.0", - "fb-dotslash": "^0.5.8" - } -} diff --git a/packages/web-platform/web-style-transformer/scripts/build.js b/packages/web-platform/web-style-transformer/scripts/build.js deleted file mode 100644 index ce000acc66..0000000000 --- a/packages/web-platform/web-style-transformer/scripts/build.js +++ /dev/null @@ -1,47 +0,0 @@ -// run command and dump output -import { execSync } from 'child_process'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const packageRoot = path.join(__dirname, '..'); -const cargoOutput = path.join( - '..', - '..', - '..', - 'target', - 'wasm32-unknown-unknown', - 'release', - 'web_style_transformer.wasm', -); -// build the standard wasm package -execSync( - `cargo build --release --target wasm32-unknown-unknown`, - { cwd: packageRoot, stdio: 'inherit' }, -); -execSync( - `pnpm exec dotslash ./scripts/wasm-bindgen --out-dir dist --target bundler --out-name standard ${cargoOutput}`, - { cwd: packageRoot, stdio: 'inherit' }, -); -execSync( - `pnpm wasm-opt --enable-bulk-memory ./dist/standard_bg.wasm -O3 -o ./dist/standard_bg.wasm`, - { cwd: packageRoot, stdio: 'inherit' }, -); - -// build the legacy wasm package -execSync( - `cargo build --release --target wasm32-unknown-unknown`, - { - env: { ...process.env, RUSTFLAGS: '-Cstrip=symbols' }, - cwd: packageRoot, - stdio: 'inherit', - }, -); -execSync( - `pnpm exec dotslash ./scripts/wasm-bindgen --out-dir dist --target bundler --out-name legacy ${cargoOutput}`, - { cwd: packageRoot, stdio: 'inherit' }, -); -execSync( - `pnpm wasm-opt --enable-bulk-memory ./dist/legacy_bg.wasm -O3 -o ./dist/legacy_bg.wasm`, - { cwd: packageRoot, stdio: 'inherit' }, -); diff --git a/packages/web-platform/web-style-transformer/standard.js b/packages/web-platform/web-style-transformer/standard.js deleted file mode 100644 index 10b19e0cc3..0000000000 --- a/packages/web-platform/web-style-transformer/standard.js +++ /dev/null @@ -1 +0,0 @@ -export * from './dist/standard.js'; diff --git a/packages/web-platform/web-style-transformer/turbo.json b/packages/web-platform/web-style-transformer/turbo.json deleted file mode 100644 index b45c74e8eb..0000000000 --- a/packages/web-platform/web-style-transformer/turbo.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "https://turbo.build/schema.json", - "extends": ["//"], - "tasks": { - "build": { - "dependsOn": [], - "inputs": [ - "scripts/**", - "src/**" - ], - "outputs": [ - "dist" - ] - } - } -} diff --git a/packages/web-platform/web-tests/package.json b/packages/web-platform/web-tests/package.json index b54b3ffaf9..c4b95e5b81 100644 --- a/packages/web-platform/web-tests/package.json +++ b/packages/web-platform/web-tests/package.json @@ -38,7 +38,6 @@ "@lynx-js/web-mainthread-apis": "workspace:*", "@lynx-js/web-platform-rsbuild-plugin": "workspace:*", "@lynx-js/web-rsbuild-server-middleware": "workspace:*", - "@lynx-js/web-style-transformer": "workspace:*", "@lynx-js/web-worker-rpc": "workspace:*", "@lynx-js/webpack-dev-transport": "workspace:*", "@playwright/test": "^1.56.0", diff --git a/packages/web-platform/web-tests/shell-project/mainthread-test.ts b/packages/web-platform/web-tests/shell-project/mainthread-test.ts index bfa00a42ce..69fca9e937 100644 --- a/packages/web-platform/web-tests/shell-project/mainthread-test.ts +++ b/packages/web-platform/web-tests/shell-project/mainthread-test.ts @@ -6,8 +6,6 @@ import * as lynxTemplate from '../resources/web-core.main-thread.json' with { }; import { createMainThreadGlobalThis } from '@lynx-js/web-mainthread-apis'; import { initOffscreenDocument } from '@lynx-js/offscreen-document/main'; -import { initWasm } from '@lynx-js/web-style-transformer'; -await initWasm(); import { _onEvent, OffscreenDocument, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 900165e4dc..e611623141 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -982,12 +982,19 @@ importers: '@lynx-js/web-constants': specifier: workspace:* version: link:../web-constants - '@lynx-js/web-style-transformer': - specifier: workspace:* - version: link:../web-style-transformer hyphenate-style-name: specifier: ^1.1.0 version: 1.1.0 + wasm-feature-detect: + specifier: ^1.8.0 + version: 1.8.0 + devDependencies: + binaryen: + specifier: ^125.0.0 + version: 125.0.0 + fb-dotslash: + specifier: ^0.5.8 + version: 0.5.8 packages/web-platform/web-rsbuild-plugin: dependencies: @@ -1035,19 +1042,6 @@ importers: specifier: 0.3.3 version: 0.3.3(@rsbuild/core@1.5.17) - packages/web-platform/web-style-transformer: - dependencies: - wasm-feature-detect: - specifier: ^1.8.0 - version: 1.8.0 - devDependencies: - binaryen: - specifier: ^124.0.0 - version: 124.0.0 - fb-dotslash: - specifier: ^0.5.8 - version: 0.5.8 - packages/web-platform/web-tests: devDependencies: '@lynx-js/lynx-core': @@ -1092,9 +1086,6 @@ importers: '@lynx-js/web-rsbuild-server-middleware': specifier: workspace:* version: link:../web-rsbuild-server-middleware - '@lynx-js/web-style-transformer': - specifier: workspace:* - version: link:../web-style-transformer '@lynx-js/web-worker-rpc': specifier: workspace:* version: link:../web-worker-rpc @@ -4534,8 +4525,8 @@ packages: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} - binaryen@124.0.0: - resolution: {integrity: sha512-RUv9bWl9C4kwjOmi4yA/yjW/w+YMtoEEpTFtI1nIl1m+1AGWRvxirGgd8AeqUnEB65HcsjZJ+WAIsGuVBwDxwA==} + binaryen@125.0.0: + resolution: {integrity: sha512-X7CUM9ZnwL/Ow++JH5AJKiemc82J7JyeryuPvXQdXBLcL/rqrC5KMUB1mHiORSolietH9sotvaOZlr6HSwPAlw==} hasBin: true bl@4.1.0: @@ -13308,7 +13299,7 @@ snapshots: binary-extensions@2.3.0: {} - binaryen@124.0.0: {} + binaryen@125.0.0: {} bl@4.1.0: dependencies: