Skip to content

BrowserWindow.getAllWindows() won't work #2262

@tokuhirom

Description

@tokuhirom

in kotlin-electron, following code won't work.

import electron.core.BrowserWindow

fun main() {
    BrowserWindow.getAllWindows()
}
./gradlew jsRun
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :kotlinNpmInstall
(node:66351) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
warning workspace-aggregator-3a59d6ae-e958-456f-a59b-4d43e363c8fc > main-test > mocha > [email protected]: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-3a59d6ae-e958-456f-a59b-4d43e363c8fc > main-test > mocha > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning Ignored scripts due to flag.

> Task :jsNodeDevelopmentRun FAILED
Error: Cannot find package 'INTERNAL_ENTITY' imported from /Users/tokuhirom/work/kotlin-electron-getAllWindows-issue/build/js/packages/main/kotlin/main.mjs
    at packageResolve (node:internal/modules/esm/resolve:845:9)
    at moduleResolve (node:internal/modules/esm/resolve:918:18)
    at defaultResolve (node:internal/modules/esm/resolve:1148:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:528:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:497:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:231:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:97:39)
    at link (node:internal/modules/esm/module_job:96:36)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jsNodeDevelopmentRun'.
> Process 'command '/Users/tokuhirom/.gradle/nodejs/node-v22.0.0-darwin-arm64/bin/node'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 16s
14 actionable tasks: 14 executed

with electron.BrowserWindow, i got other compilation error.

import electron.BrowserWindow

fun main() {
    BrowserWindow.getAllWindows()
}
./gradlew jsRun

> Task :compileKotlinJs FAILED
e: file:///Users/tokuhirom/work/kotlin-electron-getAllWindows-issue/src/jsMain/kotlin/Main.kt:4:19 Unresolved reference 'getAllWindows'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlinJs'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 753ms
2 actionable tasks: 1 executed, 1 up-to-date

The API is used in the Electron's official tutorial.
https://www.electronjs.org/docs/latest/tutorial/tutorial-first-app

Is there any solution?

Here's a code I tested:
https://github.com/tokuhirom/kotlin-electron-getAllWindows-issu

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions