Skip to content

Commit 6061e0f

Browse files
committed
Merge remote-tracking branch 'gh/main' into feat/react-compiler
2 parents 0dff201 + 53eed0a commit 6061e0f

File tree

13 files changed

+321
-259
lines changed

13 files changed

+321
-259
lines changed

.changeset/seven-coats-appear.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@lynx-js/web-core-server": patch
3+
"@lynx-js/web-core": patch
4+
"@lynx-js/web-explorer": patch
5+
---
6+
7+
feat: builtinTagTransformMap add `'input': 'x-input'`

.changeset/thin-webs-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@lynx-js/template-webpack-plugin": patch
3+
---
4+
5+
Remove `compiler.hooks.initialize` as [it's not called in child compilers](https://github.com/web-infra-dev/rspack/blob/aa4ad886b900770787ecddd625d3e24a51b6b99c/packages/rspack/src/rspack.ts#L78).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2025 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
5+
import { root } from '@lynx-js/react';
6+
7+
import { RunBenchmarkUntilHydrate } from '../../src/RunBenchmarkUntil.js';
8+
9+
runAfterLoadScript(() => {
10+
root.render(
11+
<>
12+
{Array.from(
13+
{ length: 100 },
14+
() => (
15+
<text>
16+
Hello, ReactLynx 🎉!
17+
</text>
18+
),
19+
)}
20+
<RunBenchmarkUntilHydrate />
21+
</>,
22+
);
23+
});

benchmark/react/lynx.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export default defineConfig({
4545
'005-load-script': [
4646
'./cases/005-load-script/index.tsx',
4747
],
48+
'006-static-raw-text': [
49+
'./src/patchProfile.ts',
50+
'./cases/006-static-raw-text/index.tsx',
51+
],
4852
},
4953
},
5054
plugins: [

benchmark/react/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"bench:003-hello-list": "benchx_cli run dist/003-hello-list.lynx.bundle --wait-for-id=stop-benchmark-true",
1111
"bench:004-various-update": "benchx_cli run dist/004-various-update.lynx.bundle --wait-for-id=stop-benchmark-true",
1212
"bench:005-load-script": "benchx_cli run dist/005-load-script.lynx.bundle",
13+
"bench:006-static-raw-text": "benchx_cli run dist/006-static-raw-text.lynx.bundle --wait-for-id=stop-benchmark-true",
1314
"build": "rspeedy build",
1415
"dev": "rspeedy dev",
1516
"perfetto": "pnpm run --sequential --stream --aggregate-output '/^perfetto:.*/'",
@@ -18,6 +19,7 @@
1819
"perfetto:003-hello-list": "benchx_cli -o dist/003-hello-list.ptrace run dist/003-hello-list.lynx.bundle --wait-for-id=stop-benchmark-true",
1920
"perfetto:004-various-update": "benchx_cli -o dist/004-various-update.ptrace run dist/004-various-update.lynx.bundle --wait-for-id=stop-benchmark-true",
2021
"perfetto:005-load-script": "benchx_cli -o dist/005-load-script.ptrace run dist/005-load-script.lynx.bundle",
22+
"perfetto:006-static-raw-text": "benchx_cli -o dist/006-static-raw-text.ptrace run dist/006-static-raw-text.lynx.bundle --wait-for-id=stop-benchmark-true",
2123
"test": "echo 'No tests specified'"
2224
},
2325
"dependencies": {

packages/web-platform/web-core-server/src/createLynxView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const builtinTagTransformMap = {
8181
'image': 'x-image',
8282
'list': 'x-list',
8383
'svg': 'x-svg',
84+
'input': 'x-input',
8485
};
8586

8687
// @ts-expect-error

packages/web-platform/web-core/src/apis/LynxView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ export class LynxView extends HTMLElement {
420420
'image': 'x-image',
421421
'list': 'x-list',
422422
'svg': 'x-svg',
423+
'input': 'x-input',
423424
...this.overrideLynxTagToHTMLTagMap,
424425
};
425426
if (!this.shadowRoot) {

packages/web-platform/web-tests/tests/react.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,16 @@ test.describe('reactlynx3 tests', () => {
30033003
const result = await page.locator('.result').first().innerText();
30043004
expect(result).toBe('foobar-6-6');
30053005
});
3006+
// input/bindinput test-case start for <input>
3007+
test('basic-element-input-bindinput', async ({ page }, { title }) => {
3008+
await goto(page, title);
3009+
await page.locator('input').press('Enter');
3010+
await wait(200);
3011+
await page.locator('input').fill('foobar');
3012+
await wait(200);
3013+
const result = await page.locator('.result').first().innerText();
3014+
expect(result).toBe('foobar-6-6');
3015+
});
30063016
// input/bindinput test-case end
30073017
test(
30083018
'basic-element-x-input-getValue',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2023 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
import { root, useState } from '@lynx-js/react';
5+
6+
function App() {
7+
const value = 'bindinput';
8+
const [result, setResult] = useState();
9+
10+
const onInput = ({ detail }) => {
11+
if (typeof detail !== 'object') {
12+
throw new Error(
13+
`detail type not match. expect object, got ${typeof detail}`,
14+
);
15+
}
16+
17+
const { value, cursor, textLength, selectionStart, selectionEnd } = detail;
18+
19+
if (value.length !== textLength) {
20+
throw new Error(
21+
`input length not match. expect ${textLength}, got ${value.length}`,
22+
);
23+
}
24+
25+
setResult(`${value}-${selectionStart}-${selectionStart}`);
26+
};
27+
28+
return (
29+
<view>
30+
<input
31+
bindinput={onInput}
32+
value={value}
33+
style='border: 1px solid;width: 300px;height:40px'
34+
/>
35+
<view class='result'>
36+
<text>{result}</text>
37+
</view>
38+
</view>
39+
);
40+
}
41+
42+
root.render(<App></App>);

packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -469,57 +469,55 @@ class LynxTemplatePluginImpl {
469469

470470
this.hash = createHash(compiler.options.output.hashFunction ?? 'xxhash64');
471471

472-
compiler.hooks.initialize.tap(this.name, () => {
473-
// entryName to fileName conversion function
474-
const userOptionFilename = this.#options.filename;
475-
476-
const filenameFunction = typeof userOptionFilename === 'function'
477-
? userOptionFilename
478-
// Replace '[name]' with entry name
479-
: (entryName: string) =>
480-
userOptionFilename.replace(/\[name\]/g, entryName);
481-
482-
/** output filenames for the given entry names */
483-
const entryNames = Object.keys(compiler.options.entry);
484-
const outputFileNames = new Set(
485-
(entryNames.length > 0 ? entryNames : ['main']).map((name) =>
486-
filenameFunction(name)
487-
),
488-
);
472+
// entryName to fileName conversion function
473+
const userOptionFilename = this.#options.filename;
474+
475+
const filenameFunction = typeof userOptionFilename === 'function'
476+
? userOptionFilename
477+
// Replace '[name]' with entry name
478+
: (entryName: string) =>
479+
userOptionFilename.replace(/\[name\]/g, entryName);
480+
481+
/** output filenames for the given entry names */
482+
const entryNames = Object.keys(compiler.options.entry);
483+
const outputFileNames = new Set(
484+
(entryNames.length > 0 ? entryNames : ['main']).map((name) =>
485+
filenameFunction(name)
486+
),
487+
);
489488

490-
outputFileNames.forEach((outputFileName) => {
491-
// convert absolute filename into relative so that webpack can
492-
// generate it at correct location
493-
let filename = outputFileName;
494-
if (path.resolve(filename) === path.normalize(filename)) {
495-
filename = path.relative(
496-
/** Once initialized the path is always a string */
497-
compiler.options.output.path!,
498-
filename,
499-
);
500-
}
489+
outputFileNames.forEach((outputFileName) => {
490+
// convert absolute filename into relative so that webpack can
491+
// generate it at correct location
492+
let filename = outputFileName;
493+
if (path.resolve(filename) === path.normalize(filename)) {
494+
filename = path.relative(
495+
/** Once initialized the path is always a string */
496+
compiler.options.output.path!,
497+
filename,
498+
);
499+
}
501500

502-
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
503-
compilation.hooks.processAssets.tapPromise(
504-
{
505-
name: this.name,
506-
stage:
507-
/**
508-
* Generate the html after minification and dev tooling is done
509-
* and source-map is generated
510-
*/
511-
compiler.webpack.Compilation
512-
.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,
513-
},
514-
() => {
515-
return this.#generateTemplate(
516-
compiler,
517-
compilation,
518-
filename,
519-
);
520-
},
521-
);
522-
});
501+
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
502+
compilation.hooks.processAssets.tapPromise(
503+
{
504+
name: this.name,
505+
stage:
506+
/**
507+
* Generate the html after minification and dev tooling is done
508+
* and source-map is generated
509+
*/
510+
compiler.webpack.Compilation
511+
.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,
512+
},
513+
() => {
514+
return this.#generateTemplate(
515+
compiler,
516+
compilation,
517+
filename,
518+
);
519+
},
520+
);
523521
});
524522
});
525523

0 commit comments

Comments
 (0)