Skip to content

Commit 4b02c5f

Browse files
committed
Actualize readme
1 parent 901ae30 commit 4b02c5f

File tree

78 files changed

+1351
-3094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1351
-3094
lines changed

package-lock.json

Lines changed: 1056 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ parameters:
22
level: max
33
scanFiles:
44
- resources/stubs/aliases.stub.php
5-
- resources/stubs/saucer-webview-events.stub.php
6-
- resources/stubs/saucer-window-events.stub.php
7-
- resources/stubs/kernel32.stub.php
8-
- resources/stubs/user32.stub.php
5+
- resources/stubs/saucer.stub.php
6+
- resources/stubs/ffi.stub.php
97
excludePaths:
108
- src/Api/Console/Driver/Windows/Kernel32.php
119
- src/Api/MessageBox/Driver/Windows/User32.php
10+
- src/Api/MessageBox/Driver/MacOS/LibObjectC.php
1211
strictRules:
1312
allRules: true
1413
fileExtensions:

resources/.phpstorm.autocomplete.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ class WebView
8888
*/
8989
public readonly SecurityExtensionInterface $security;
9090

91-
/**
92-
* Gets access to the Web Components API of the webview.
93-
*/
94-
public readonly WebComponentsExtensionInterface $components;
95-
9691
}
9792

9893
}

resources/dist/main--3myKPGT.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/dist/main.js.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var D=r=>{throw TypeError(r)};var I=(r,t,e)=>t.has(r)||D("Cannot "+e);var n=(r,t,e)=>(I(r,t,"read from private field"),e?e.call(r):t.get(r)),s=(r,t,e)=>t.has(r)?D("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,o)=>(I(r,t,"write to private field"),o?o.call(r,e):t.set(r,e),e),i=(r,t,e)=>(I(r,t,"access private method"),e);var E,B;class H{constructor(){s(this,E)}generate(t=16){return Array.from(this.generateByteArray(t)).map(i(this,E,B)).join("")}}E=new WeakSet,B=function(t){return t.toString(16).padStart(2,"0")};var w,u,A;const g=class g extends H{constructor(e){super();s(this,w);d(this,w,e||(function(){throw new Error("Could not load client cryptographic library")})())}static createFromGlobals(){return new g(i(this,u,A).call(this))}static isSupported(){return!!i(this,u,A).call(this)}generateByteArray(e){return n(this,w).getRandomValues(new Uint8Array(e))}};w=new WeakMap,u=new WeakSet,A=function(){return window.crypto||window.msCrypto||window.msrCrypto||void 0},s(g,u);let f=g;class N{static createFromGlobals(){if(f.isSupported())return f.createFromGlobals();throw new Error("Can not select suitable ID generator")}}var c,h,b,a,P,L;class T{constructor(t,e){s(this,a);s(this,c,{});s(this,h);s(this,b);d(this,b,t),d(this,h,e)}resolve(t,e){var o;e instanceof Promise?e.then(l=>this.resolve(t,l)).catch(l=>this.reject(t,l)):(o=i(this,a,P).call(this,t))==null||o.resolve(e)}reject(t,e){var o;(o=i(this,a,P).call(this,t))==null||o.reject(e)}call(t,e){const o=n(this,h).generate(),l=i(this,a,L).call(this,o);return n(this,b).send(JSON.stringify({id:o,method:t,params:e})),l}}c=new WeakMap,h=new WeakMap,b=new WeakMap,a=new WeakSet,P=function(t){const e=n(this,c)[t]??null;try{return e}finally{e!==null&&delete n(this,c)[t]}},L=function(t){return new Promise((e,o)=>n(this,c)[t]={resolve:e,reject:o})};var p;class U{constructor(t){s(this,p);d(this,p,t??(function(){throw new Error("Unsupported transport")})())}send(t){n(this,p).call(this,t)}}p=new WeakMap;var m,S;const x=class x extends U{static createFromGlobals(){return new x(i(this,m,S).call(this))}static isSupported(){return!!i(this,m,S).call(this)}};m=new WeakSet,S=function(){var t,e;return(e=(t=window.chrome)==null?void 0:t.webview)==null?void 0:e.postMessage},s(x,m);let F=x;var y,v;const C=class C extends U{static createFromGlobals(){return new C(i(this,y,v).call(this))}static isSupported(){return!!i(this,y,v).call(this)}};y=new WeakSet,v=function(){var t,e;return(e=(t=window.saucer)==null?void 0:t.internal)==null?void 0:e.send_message},s(C,y);let G=C;class q{static createFromGlobals(){if(F.isSupported())return F.createFromGlobals();if(G.isSupported())return G.createFromGlobals();throw new Error("Can not select suitable IPC transport")}}window.boson||(window.boson={});var R;try{(R=window.boson).io||(R.io=q.createFromGlobals())}catch(r){console.error("Failed to initialize IPC subsystem",r)}var j;try{(j=window.boson).ids||(j.ids=N.createFromGlobals())}catch(r){console.error("Failed to initialize ID generator subsystem",r)}var z;try{if(!window.boson.io||!window.boson.ids)throw new Error("Could not initialize RPC: Requires IPC and ID generator subsystems");(z=window.boson).rpc||(z.rpc=new T(window.boson.io,window.boson.ids))}catch(r){console.error("Failed to initialize RPC subsystem",r)}

resources/src/components/BosonWebComponents.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

resources/src/components/BosonWebComponentsSet.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

resources/src/main.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
import {type BosonWebComponents} from "./components/BosonWebComponents";
3-
import BosonWebComponentsSet from "./components/BosonWebComponentsSet";
4-
51
import type {BosonDataApi} from "./data/BosonDataApi";
62

73
import type IdGeneratorInterface from "./id-generator/IdGeneratorInterface";
@@ -13,49 +9,50 @@ import BosonRpc from "./rpc/BosonRpc";
139
import type {TransportInterface} from "./transport/TransportInterface";
1410
import TransportFactory from "./transport/TransportFactory";
1511

16-
export type BosonClientApi = {
17-
io: TransportInterface,
18-
ids: IdGeneratorInterface<IdType>,
19-
rpc: BosonRpc<IdType>,
20-
data: BosonDataApi<IdType>,
21-
components: BosonWebComponents,
22-
}
23-
2412
declare const window: {
25-
boson: BosonClientApi,
13+
boson: {
14+
io?: TransportInterface,
15+
ids?: IdGeneratorInterface<IdType>,
16+
rpc?: BosonRpc<IdType>,
17+
data?: BosonDataApi<IdType>,
18+
},
2619
};
2720

2821
/**
2922
* Prepare public accessor instance.
3023
*/
31-
window.boson = window.boson || {};
24+
window.boson ||= {};
25+
3226

27+
/**
28+
* Initialize IO subsystem
29+
*/
3330
try {
34-
window.boson.io = TransportFactory.createFromGlobals();
31+
window.boson.io ||= TransportFactory.createFromGlobals();
3532
} catch (e) {
3633
console.error('Failed to initialize IPC subsystem', e);
3734
}
3835

36+
37+
/**
38+
* Initialize IDs generator subsystem
39+
*/
3940
try {
40-
window.boson.ids = IdGeneratorFactory.createFromGlobals();
41+
window.boson.ids ||= IdGeneratorFactory.createFromGlobals();
4142
} catch (e) {
4243
console.error('Failed to initialize ID generator subsystem', e);
4344
}
4445

46+
47+
/**
48+
* Initialize RPC subsystem
49+
*/
4550
try {
4651
if (!window.boson.io || !window.boson.ids) {
4752
throw new Error('Could not initialize RPC: Requires IPC and ID generator subsystems');
4853
}
4954

50-
window.boson.rpc = new BosonRpc(window.boson.io, window.boson.ids);
55+
window.boson.rpc ||= new BosonRpc(window.boson.io, window.boson.ids);
5156
} catch (e) {
5257
console.error('Failed to initialize RPC subsystem', e);
5358
}
54-
55-
window.boson.components = window.boson.components || {};
56-
57-
try {
58-
window.boson.components.instances = new BosonWebComponentsSet();
59-
} catch (e) {
60-
console.error('Failed to initialize Web Components subsystem', e);
61-
}

resources/stubs/ffi.stub.php

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Boson\Api\Console\Driver\Windows {
6+
7+
use FFI\CData;
8+
use FFI\CType;
9+
10+
/**
11+
* @mixin \FFI
12+
* @seal-properties
13+
* @seal-methods
14+
*/
15+
final readonly class Kernel32
16+
{
17+
/**
18+
* @param CType|non-empty-string $type
19+
*/
20+
public function new(CType|string $type, bool $owned = true, bool $persistent = false): CData {}
21+
22+
/**
23+
* @param CType|non-empty-string $type
24+
*/
25+
public function cast(CType|string $type, CData|int|float|bool|null $ptr): CData {}
26+
27+
public function FreeConsole(): bool {}
28+
}
29+
30+
}
31+
32+
namespace Boson\Api\MessageBox\Driver\Windows {
33+
34+
35+
use FFI\CData;
36+
use FFI\CType;
37+
38+
/**
39+
* @mixin \FFI
40+
* @seal-properties
41+
* @seal-methods
42+
*/
43+
final readonly class User32
44+
{
45+
public const int MB_ABORTRETRYIGNORE = 0x00000002;
46+
public const int MB_CANCELTRYCONTINUE = 0x00000006;
47+
public const int MB_HELP = 0x00004000;
48+
public const int MB_OK = 0x00000000;
49+
public const int MB_OKCANCEL = 0x00000001;
50+
public const int MB_RETRYCANCEL = 0x00000005;
51+
public const int MB_YESNO = 0x00000004;
52+
public const int MB_YESNOCANCEL = 0x00000003;
53+
public const int MB_ICONEXCLAMATION = 0x00000030;
54+
public const int MB_ICONWARNING = 0x00000030;
55+
public const int MB_ICONINFORMATION = 0x00000040;
56+
public const int MB_ICONASTERISK = 0x00000040;
57+
public const int MB_ICONQUESTION = 0x00000020;
58+
public const int MB_ICONSTOP = 0x00000010;
59+
public const int MB_ICONERROR = 0x00000010;
60+
public const int MB_ICONHAND = 0x00000010;
61+
public const int MB_DEFBUTTON1 = 0x00000000;
62+
public const int MB_DEFBUTTON2 = 0x00000100;
63+
public const int MB_DEFBUTTON3 = 0x00000200;
64+
public const int MB_DEFBUTTON4 = 0x00000300;
65+
public const int MB_APPLMODAL = 0x00000000;
66+
public const int MB_SYSTEMMODAL = 0x00001000;
67+
public const int MB_TASKMODAL = 0x00002000;
68+
public const int MB_DEFAULT_DESKTOP_ONLY = 0x00020000;
69+
public const int MB_RIGHT = 0x00080000;
70+
public const int MB_RTLREADING = 0x00100000;
71+
public const int MB_SETFOREGROUND = 0x00010000;
72+
public const int MB_TOPMOST = 0x00040000;
73+
public const int MB_SERVICE_NOTIFICATION = 0x00200000;
74+
public const int IDABORT = 3;
75+
public const int IDCANCEL = 2;
76+
public const int IDCONTINUE = 11;
77+
public const int IDIGNORE = 5;
78+
public const int IDNO = 7;
79+
public const int IDOK = 1;
80+
public const int IDRETRY = 4;
81+
public const int IDTRYAGAIN = 10;
82+
public const int IDYES = 6;
83+
84+
/**
85+
* @param CType|non-empty-string $type
86+
*/
87+
public function new(CType|string $type, bool $owned = true, bool $persistent = false): CData {}
88+
89+
/**
90+
* @param CType|non-empty-string $type
91+
*/
92+
public function cast(CType|string $type, CData|int|float|bool|null $ptr): CData {}
93+
94+
public function MessageBoxW(?CData $hWnd, CData $lpText, CData $lpCaption, int $uType): int {}
95+
}
96+
97+
}
98+
99+
namespace Boson\Api\MessageBox\Driver\MacOS {
100+
101+
use FFI\CData;
102+
use FFI\CType;
103+
104+
/**
105+
* @mixin \FFI
106+
* @seal-properties
107+
* @seal-methods
108+
*/
109+
final readonly class LibObjectC
110+
{
111+
/**
112+
* @param CType|non-empty-string $type
113+
*/
114+
public function new(CType|string $type, bool $owned = true, bool $persistent = false): CData {}
115+
116+
/**
117+
* @param CType|non-empty-string $type
118+
*/
119+
public function cast(CType|string $type, CData|int|float|bool|null $ptr): CData {}
120+
121+
/**
122+
* @var CData & callable(mixed...):CData
123+
*/
124+
public CData $objc_msgSend;
125+
126+
/**
127+
* @param non-empty-string $return
128+
* @param non-empty-string ...$types
129+
*
130+
* @return CData & callable(CData, CData, mixed...):mixed
131+
*/
132+
public function getMessageSend(string $return, string ...$types): callable {}
133+
134+
/**
135+
* @param non-empty-string|null $name
136+
*/
137+
public function objc_getClass(?string $name): CData {}
138+
139+
/**
140+
* @param non-empty-string|null $str
141+
*/
142+
public function sel_registerName(?string $str): CData {}
143+
144+
public function objc_msgSend(mixed ...$args): CData {}
145+
146+
}
147+
148+
}

0 commit comments

Comments
 (0)