gantry-web 0.3.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +43 -43
- package/src/ResizeFrame.tsx +43 -40
- package/src/app.tsx +368 -276
- package/src/bridge.ts +95 -94
- package/src/index.ts +32 -32
- package/src/router.tsx +180 -160
- package/src/socket.ts +227 -209
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gantry-web",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Frontend half of the Gantry desktop app framework: window chrome, native bridge, Tea runtime, Vite plugin",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/B-Commissions/Gantry.git",
|
|
9
|
-
"directory": "web"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/B-Commissions/Gantry",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"gantry",
|
|
14
|
-
"desktop",
|
|
15
|
-
"webview",
|
|
16
|
-
"go",
|
|
17
|
-
"react",
|
|
18
|
-
"vite-plugin"
|
|
19
|
-
],
|
|
20
|
-
"type": "module",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": "./src/index.ts",
|
|
23
|
-
"./tea": "./src/tea/index.ts",
|
|
24
|
-
"./vite": "./src/vite/index.js",
|
|
25
|
-
"./styles.css": "./src/styles.css",
|
|
26
|
-
"./types": "./types/index.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"src",
|
|
30
|
-
"types"
|
|
31
|
-
],
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"lucide-react": "*",
|
|
34
|
-
"react": ">=18",
|
|
35
|
-
"react-dom": ">=18",
|
|
36
|
-
"vite": ">=5"
|
|
37
|
-
},
|
|
38
|
-
"peerDependenciesMeta": {
|
|
39
|
-
"vite": {
|
|
40
|
-
"optional": true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gantry-web",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Frontend half of the Gantry desktop app framework: window chrome, native bridge, Tea runtime, Vite plugin",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/B-Commissions/Gantry.git",
|
|
9
|
+
"directory": "web"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/B-Commissions/Gantry",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"gantry",
|
|
14
|
+
"desktop",
|
|
15
|
+
"webview",
|
|
16
|
+
"go",
|
|
17
|
+
"react",
|
|
18
|
+
"vite-plugin"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./src/index.ts",
|
|
23
|
+
"./tea": "./src/tea/index.ts",
|
|
24
|
+
"./vite": "./src/vite/index.js",
|
|
25
|
+
"./styles.css": "./src/styles.css",
|
|
26
|
+
"./types": "./types/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"src",
|
|
30
|
+
"types"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"lucide-react": "*",
|
|
34
|
+
"react": ">=18",
|
|
35
|
+
"react-dom": ">=18",
|
|
36
|
+
"vite": ">=5"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"vite": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/ResizeFrame.tsx
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
import { useShell, useShellCaps } from "./hooks";
|
|
2
|
-
|
|
3
|
-
const EDGES = [
|
|
4
|
-
{ edge: "n", style: { top: 0, left: 8, right: 8, height: 5, cursor: "ns-resize" } },
|
|
5
|
-
{ edge: "s", style: { bottom: 0, left: 8, right: 8, height: 5, cursor: "ns-resize" } },
|
|
6
|
-
{ edge: "w", style: { left: 0, top: 8, bottom: 8, width: 5, cursor: "ew-resize" } },
|
|
7
|
-
{ edge: "e", style: { right: 0, top: 8, bottom: 8, width: 5, cursor: "ew-resize" } },
|
|
8
|
-
{ edge: "nw", style: { top: 0, left: 0, width: 10, height: 10, cursor: "nwse-resize" } },
|
|
9
|
-
{ edge: "ne", style: { top: 0, right: 0, width: 10, height: 10, cursor: "nesw-resize" } },
|
|
10
|
-
{ edge: "sw", style: { bottom: 0, left: 0, width: 10, height: 10, cursor: "nesw-resize" } },
|
|
11
|
-
{ edge: "se", style: { bottom: 0, right: 0, width: 10, height: 10, cursor: "nwse-resize" } },
|
|
12
|
-
] as const;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* ResizeFrame renders invisible edge strips that start a native
|
|
16
|
-
* interactive resize
|
|
17
|
-
* no OS
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
1
|
+
import { useShell, useShellCaps } from "./hooks";
|
|
2
|
+
|
|
3
|
+
const EDGES = [
|
|
4
|
+
{ edge: "n", style: { top: 0, left: 8, right: 8, height: 5, cursor: "ns-resize" } },
|
|
5
|
+
{ edge: "s", style: { bottom: 0, left: 8, right: 8, height: 5, cursor: "ns-resize" } },
|
|
6
|
+
{ edge: "w", style: { left: 0, top: 8, bottom: 8, width: 5, cursor: "ew-resize" } },
|
|
7
|
+
{ edge: "e", style: { right: 0, top: 8, bottom: 8, width: 5, cursor: "ew-resize" } },
|
|
8
|
+
{ edge: "nw", style: { top: 0, left: 0, width: 10, height: 10, cursor: "nwse-resize" } },
|
|
9
|
+
{ edge: "ne", style: { top: 0, right: 0, width: 10, height: 10, cursor: "nesw-resize" } },
|
|
10
|
+
{ edge: "sw", style: { bottom: 0, left: 0, width: 10, height: 10, cursor: "nesw-resize" } },
|
|
11
|
+
{ edge: "se", style: { bottom: 0, right: 0, width: 10, height: 10, cursor: "nwse-resize" } },
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ResizeFrame renders invisible edge strips that start a native
|
|
16
|
+
* interactive resize and carry the resize cursor. A frameless window has
|
|
17
|
+
* no draggable OS frame: on Linux the compositor offers no hit-test, and
|
|
18
|
+
* on Windows the WebView2 child covers the client area and swallows the
|
|
19
|
+
* parent's WM_NCHITTEST resize margin - so on both the frontend draws the
|
|
20
|
+
* strips and calls the ResizeEdge binding on mousedown. Framed windows
|
|
21
|
+
* (and the browser) render nothing.
|
|
22
|
+
*/
|
|
23
|
+
export function ResizeFrame({ prefix }: { prefix?: string }) {
|
|
24
|
+
const shell = useShell(prefix);
|
|
25
|
+
const caps = useShellCaps(prefix);
|
|
26
|
+
const native = caps?.platform === "linux" || caps?.platform === "windows";
|
|
27
|
+
if (!native || !caps?.frameless) return null;
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
{EDGES.map(({ edge, style }) => (
|
|
31
|
+
<div
|
|
32
|
+
key={edge}
|
|
33
|
+
style={{ position: "fixed", zIndex: 40, ...style }}
|
|
34
|
+
onMouseDown={(e) => {
|
|
35
|
+
if (e.button !== 0) return;
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
shell.resizeEdge(edge);
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
))}
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
}
|