Compare commits

...

3 Commits

Author SHA1 Message Date
trop[bot]
a5f098d2b7 feat: add support for --experimental-transform-types (#49881)
* feat: add support for `--experimental-transform-types`

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* chore: add tests

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

* docs: add `--experimental-transform-types` to docs

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2026-02-25 12:57:48 -05:00
trop[bot]
74856fdd47 build: exit upload with error code if github upload fails (#49943)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <kleinschmidtorama@gmail.com>
2026-02-25 11:39:26 -05:00
trop[bot]
d733f01f3b fix: apply zoomFactor from setWindowOpenHandler to window.open() windows (#49910)
fix: apply zoomFactor from setWindowOpenHandler to window.open() windows

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2026-02-24 18:01:00 -05:00
9 changed files with 93 additions and 0 deletions

View File

@@ -345,6 +345,11 @@ Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https:
Disable exposition of [Navigator API][] on the global scope from Node.js.
### `--experimental-transform-types`
Enables the [transformation](https://nodejs.org/api/typescript.html#type-stripping)
of TypeScript-only syntax into JavaScript code.
## Chromium Flags
There isn't a documented list of all Chromium switches, but there are a few ways to find them.

View File

@@ -367,6 +367,9 @@ def upload_io_to_github(release, filename, filepath, version):
for c in iter(lambda: upload_process.stdout.read(1), b""):
sys.stdout.buffer.write(c)
sys.stdout.flush()
upload_process.wait()
if upload_process.returncode != 0:
sys.exit(upload_process.returncode)
if "GITHUB_OUTPUT" in os.environ:
output_path = os.environ["GITHUB_OUTPUT"]

View File

@@ -4645,6 +4645,19 @@ gin_helper::Handle<WebContents> WebContents::CreateFromWebPreferences(
existing_preferences->SetFromDictionary(web_preferences_dict);
web_contents->SetBackgroundColor(
existing_preferences->GetBackgroundColor());
double zoom_factor;
if (web_preferences.Get(options::kZoomFactor, &zoom_factor)) {
auto* zoom_controller = WebContentsZoomController::FromWebContents(
web_contents->web_contents());
if (zoom_controller) {
zoom_controller->SetDefaultZoomFactor(zoom_factor);
// Also set the current zoom level immediately, since the page
// has already navigated by the time we wrap the webContents.
zoom_controller->SetZoomLevel(
blink::ZoomFactorToZoomLevel(zoom_factor));
}
}
}
} else {
// Create one if not.

View File

@@ -412,6 +412,7 @@ bool IsAllowedOption(const std::string_view option) {
"--inspect-port",
"--inspect-publish-uid",
"--experimental-network-inspection",
"--experimental-transform-types",
});
// This should be aligned with what's possible to set via the process object.

View File

@@ -3983,6 +3983,28 @@ describe('BrowserWindow module', () => {
expect(webPreferences!.contextIsolation).to.equal(false);
});
it('should apply zoomFactor from setWindowOpenHandler overrideBrowserWindowOptions', async () => {
const w = new BrowserWindow({
show: false,
webPreferences: {
sandbox: true
}
});
w.webContents.setWindowOpenHandler(() => ({
action: 'allow',
overrideBrowserWindowOptions: {
webPreferences: {
zoomFactor: 2.0
}
}
}));
w.loadFile(path.join(fixtures, 'api', 'new-window.html'));
const [childWindow] = await once(w.webContents, 'did-create-window') as [BrowserWindow, any];
await once(childWindow.webContents, 'did-finish-load');
expect(childWindow.webContents.getZoomFactor()).to.be.closeTo(2.0, 0.1);
});
it('should set ipc event sender correctly', async () => {
const w = new BrowserWindow({
show: false,

7
spec/fixtures/type-stripping/basic.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
import { app } from 'electron/main';
const logMessage = (message: string): void => console.log(message);
logMessage('running');
app.exit(0);

View File

@@ -0,0 +1,9 @@
enum Test {
A,
B,
C,
}
console.log(Test.A);
process.exit(0);

View File

@@ -0,0 +1,11 @@
import { app } from 'electron/main';
enum Test {
A,
B,
C,
}
console.log(Test.A);
app.exit(0);

View File

@@ -1030,4 +1030,26 @@ describe('node feature', () => {
});
});
});
describe('type stripping', () => {
it('strips TypeScript types automatically in the main process', async () => {
const child = childProcess.spawn(process.execPath, [path.join(fixtures, 'type-stripping', 'basic.ts')]);
const [code] = await once(child, 'exit');
expect(code).to.equal(0);
});
it('will not transform TypeScript types without --experimental-transform-types', async () => {
const child = childProcess.spawn(process.execPath, [path.join(fixtures, 'type-stripping', 'transform-types-node.ts')], {
env: { ELECTRON_RUN_AS_NODE: 'true' }
});
const [code] = await once(child, 'exit');
expect(code).to.not.equal(0);
});
it('transforms TypeScript types with --experimental-transform-types', async () => {
const child = childProcess.spawn(process.execPath, ['--experimental-transform-types', path.join(fixtures, 'type-stripping', 'transform-types.ts')]);
const [code] = await once(child, 'exit');
expect(code).to.equal(0);
});
});
});