Skip to content

Commit eedbbd3

Browse files
committed
Improve and fix window event listener
1 parent dd7f67e commit eedbbd3

File tree

16 files changed

+216
-106
lines changed

16 files changed

+216
-106
lines changed

libs/component/runtime/src/Api/LoadedApplicationExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
namespace Boson\Api;
66

77
use Boson\Application;
8+
use Boson\Component\Saucer\SaucerInterface;
89
use Boson\Contracts\Id\IdentifiableInterface;
910
use Boson\Dispatcher\EventListener;
1011
use Boson\Extension\LoadedExtension;
11-
use Boson\Internal\StructPointerId;
12+
use Boson\Poller\PollerInterface;
13+
use Boson\Shared\StructPointerId;
1214
use FFI\CData;
1315

1416
/**
@@ -32,6 +34,20 @@ abstract class LoadedApplicationExtension extends LoadedExtension
3234
get => $this->id->ptr;
3335
}
3436

37+
/**
38+
* Gets Saucer API reference
39+
*/
40+
protected SaucerInterface $saucer {
41+
get => $this->saucer ??= $this->app->saucer;
42+
}
43+
44+
/**
45+
* Gets application poller API reference
46+
*/
47+
protected PollerInterface $loop {
48+
get => $this->loop ??= $this->app->poller;
49+
}
50+
3551
public function __construct(
3652
protected readonly Application $app,
3753
EventListener $listener,

libs/component/runtime/src/Application.php

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Boson\Exception\WindowDereferenceException;
2020
use Boson\Extension\Exception\ExtensionNotFoundException;
2121
use Boson\Extension\Registry;
22-
use Boson\Internal\Poller\SaucerPoller;
22+
use Boson\Internal\Poller\ApplicationOrderedPoller;
2323
use Boson\Poller\PollerInterface;
2424
use Boson\Shared\Marker\BlockingOperation;
2525
use Boson\Shared\Marker\RequiresDealloc;
@@ -29,7 +29,6 @@
2929
use Boson\Window\Manager\WindowManager;
3030
use Boson\Window\Window;
3131
use FFI\CData;
32-
use Internal\Destroy\Destroyable;
3332
use Psr\Container\ContainerInterface;
3433
use Psr\EventDispatcher\EventDispatcherInterface;
3534

@@ -188,24 +187,6 @@ public function __construct(
188187
*/
189188
public readonly ApplicationCreateInfo $info = new ApplicationCreateInfo(),
190189
?EventDispatcherInterface $dispatcher = null,
191-
/**
192-
* @var array<array-key, mixed>
193-
*
194-
* @deprecated doesn't affect anything anymore and will be removed in future versions
195-
*/
196-
private readonly array $bootHandlers = [],
197-
/**
198-
* @var array<array-key, mixed>
199-
*
200-
* @deprecated doesn't affect anything anymore and will be removed in future versions
201-
*/
202-
private readonly array $quitHandlers = [],
203-
/**
204-
* @var array<array-key, mixed>
205-
*
206-
* @deprecated doesn't affect anything anymore and will be removed in future versions
207-
*/
208-
private readonly array $deferRunners = [],
209190
) {
210191
// Initialization Application's fields and properties
211192
$this->isDebug = $this->createIsDebugParameter($info->debug);
@@ -253,7 +234,7 @@ public function has(string $id): bool
253234
*/
254235
protected function createApplicationPoller(SaucerInterface $saucer): PollerInterface
255236
{
256-
$poller = new SaucerPoller($this->id, $saucer);
237+
$poller = new ApplicationOrderedPoller($this->id, $saucer);
257238

258239
$poller->defer(function (): void {
259240
$this->isRunning = true;

libs/component/runtime/src/ApplicationId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Boson;
66

77
use Boson\Component\Saucer\SaucerInterface;
8-
use Boson\Internal\StructPointerId;
8+
use Boson\Shared\StructPointerId;
99
use FFI\CData;
1010

1111
final readonly class ApplicationId extends StructPointerId

libs/component/runtime/src/Extension/LoadedExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Boson\Dispatcher\Event;
1010
use Boson\Dispatcher\EventListener;
1111
use Boson\Dispatcher\Intention;
12-
use Boson\Internal\StructPointerId;
12+
use Boson\Shared\StructPointerId;
1313

1414
/**
1515
* @template TContext of IdentifiableInterface<StructPointerId>

libs/component/runtime/src/Internal/Poller/SaucerPoller.php renamed to libs/component/runtime/src/Internal/Poller/ApplicationOrderedPoller.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @internal this is an internal library class, please do not use it in your code
1919
* @psalm-internal Boson
2020
*/
21-
final class SaucerPoller implements PollerInterface
21+
final class ApplicationOrderedPoller implements PollerInterface
2222
{
2323
/**
2424
* @var array<array-key, \Closure(array-key):void>
@@ -37,6 +37,9 @@ final class SaucerPoller implements PollerInterface
3737
*/
3838
private readonly IdValueGeneratorInterface $ids;
3939

40+
/**
41+
* Reference to the event loop pointer
42+
*/
4043
private readonly CData $ptr;
4144

4245
public function __construct(

libs/component/runtime/src/Internal/PositiveIntId.php renamed to libs/component/runtime/src/Shared/PositiveIntId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Boson\Internal;
5+
namespace Boson\Shared;
66

77
use Boson\Contracts\Id\IntIdInterface;
88

libs/component/runtime/src/Internal/StructPointerId.php renamed to libs/component/runtime/src/Shared/StructPointerId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Boson\Internal;
5+
namespace Boson\Shared;
66

77
use Boson\Component\Saucer\SaucerInterface;
88
use Boson\Contracts\Id\IntIdInterface;

libs/component/runtime/src/WebView/Api/Data/DataRetriever.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ final class DataRetriever extends LoadedWebViewExtension implements
5656
*/
5757
private readonly IdValueGeneratorInterface $ids;
5858

59-
/**
60-
* An application events poller interface.
61-
*/
62-
private readonly PollerInterface $poller;
63-
6459
/**
6560
* Registry of pending request results.
6661
*
@@ -81,7 +76,6 @@ public function __construct(
8176
parent::__construct($context, $listener);
8277

8378
$this->ids = clone $info->ids;
84-
$this->poller = $this->app->poller;
8579

8680
$bindings->bind($info->callback, $this->onResponseReceived(...));
8781
$bindings->bind($info->failureCallback, $this->onFailureReceived(...));

libs/component/runtime/src/WebView/Api/LoadedWebViewExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Boson\Contracts\Id\IdentifiableInterface;
88
use Boson\Dispatcher\EventListener;
9-
use Boson\Internal\StructPointerId;
9+
use Boson\Shared\StructPointerId;
1010
use Boson\WebView\Exception\WebViewApiDereferenceException;
1111
use Boson\WebView\WebView;
1212
use Boson\Window\Api\LoadedWindowExtension;

libs/component/runtime/src/WebView/Api/Scripts/LoadedScriptId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
namespace Boson\WebView\Api\Scripts;
66

7-
use Boson\Internal\PositiveIntId;
7+
use Boson\Shared\PositiveIntId;
88

99
final readonly class LoadedScriptId extends PositiveIntId {}

0 commit comments

Comments
 (0)