@domicile-desktop/react 0.0.0-alpha-e645e06bdc39 → 0.0.0-alpha-a16de299b35e
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/README.md +2 -0
- package/package.json +7 -3
- package/src/elements.d.ts +48 -0
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ const Focused = () => <p>{useFocusedWindow() ?? "the shell"}</p>;
|
|
|
15
15
|
export const Shell = mount(Focused);
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
- `./elements`: JSX types for the engine's `<app>` and `<webview>`. Load
|
|
19
|
+
them once with `/// <reference types="@domicile-desktop/react/elements" />`.
|
|
18
20
|
- `./mount`: `mount(App)` is a shell's `Shell` or an app's `main`. Draws `App`
|
|
19
21
|
synchronously (the page draws nothing until `Shell` returns) in an element
|
|
20
22
|
of its own with `display: contents`, under `StrictMode`, an error boundary
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@cprussin/option-result": "^2.0.1",
|
|
4
|
-
"@domicile-desktop/sdk": "0.0.0-alpha-
|
|
4
|
+
"@domicile-desktop/sdk": "0.0.0-alpha-a16de299b35e"
|
|
5
5
|
},
|
|
6
6
|
"description": "React for a Domicile shell or app: mount it on the desktop, read the desktop from context, and follow its state with hooks.",
|
|
7
7
|
"devDependencies": {
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"types": "./dist/domicile-provider.d.ts",
|
|
33
33
|
"default": "./dist/domicile-provider.js"
|
|
34
34
|
},
|
|
35
|
+
"./elements": {
|
|
36
|
+
"types": "./src/elements.d.ts"
|
|
37
|
+
},
|
|
35
38
|
"./fake-domicile": {
|
|
36
39
|
"types": "./dist/fake-domicile.d.ts",
|
|
37
40
|
"default": "./dist/fake-domicile.js"
|
|
@@ -74,7 +77,8 @@
|
|
|
74
77
|
}
|
|
75
78
|
},
|
|
76
79
|
"files": [
|
|
77
|
-
"dist/**"
|
|
80
|
+
"dist/**",
|
|
81
|
+
"src/elements.d.ts"
|
|
78
82
|
],
|
|
79
83
|
"license": "MIT",
|
|
80
84
|
"name": "@domicile-desktop/react",
|
|
@@ -92,7 +96,7 @@
|
|
|
92
96
|
"test:unit": "bun test"
|
|
93
97
|
},
|
|
94
98
|
"type": "module",
|
|
95
|
-
"version": "0.0.0-alpha-
|
|
99
|
+
"version": "0.0.0-alpha-a16de299b35e",
|
|
96
100
|
"repository": {
|
|
97
101
|
"type": "git",
|
|
98
102
|
"url": "git+https://github.com/cprussin/domicile.git",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// JSX types for the engine's `<app>` element and `<webview>` attributes, which
|
|
2
|
+
// React does not know. A shell loads them with
|
|
3
|
+
// `/// <reference types="@domicile-desktop/react/elements" />`.
|
|
4
|
+
//
|
|
5
|
+
// Only `app-id`, `frame` and `resizing` are declared. `<app>` has no hyphen, so
|
|
6
|
+
// React treats it as a plain HTML element and will not set unknown properties
|
|
7
|
+
// or bind its custom event; use `addEventListener` for it.
|
|
8
|
+
//
|
|
9
|
+
// `HTMLAppElement` is the SDK's global, so React's `ref` type and
|
|
10
|
+
// `document.querySelector("app")` agree. An exported interface would be a
|
|
11
|
+
// different type.
|
|
12
|
+
|
|
13
|
+
// The SDK declares the elements' DOM types, `HTMLAppElement` and
|
|
14
|
+
// `HTMLWebViewElement`, as globals.
|
|
15
|
+
import type {} from "@domicile-desktop/sdk/app-element";
|
|
16
|
+
import type {} from "@domicile-desktop/sdk/webview-element";
|
|
17
|
+
import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
|
18
|
+
|
|
19
|
+
declare module "react" {
|
|
20
|
+
// `<webview>` attributes missing from React's Electron-era types: `window`
|
|
21
|
+
// makes a view show a browser window (see `WEBVIEW_WINDOW_ATTRIBUTE`),
|
|
22
|
+
// `extensionpopup`, by its presence, makes it an extension's action popup,
|
|
23
|
+
// `private`, by its presence, makes its page private, and `resizing`, by its
|
|
24
|
+
// presence, marks an interactive resize.
|
|
25
|
+
interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
26
|
+
extensionpopup?: string | undefined;
|
|
27
|
+
private?: string | undefined;
|
|
28
|
+
resizing?: string | undefined;
|
|
29
|
+
window?: string | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// biome-ignore lint/style/noNamespace: React declares its JSX types as a namespace; augmenting IntrinsicElements has to match that shape
|
|
33
|
+
namespace JSX {
|
|
34
|
+
// biome-ignore lint/style/useConsistentTypeDefinitions: declaration merging into IntrinsicElements requires an interface
|
|
35
|
+
interface IntrinsicElements {
|
|
36
|
+
/**
|
|
37
|
+
* A Wayland client's window. `app-id` is the host's ID for it.
|
|
38
|
+
* `frame` is the synced frame it shows (`DomicileWindow.frame`).
|
|
39
|
+
* `resizing`, by its presence, marks an interactive resize.
|
|
40
|
+
*/
|
|
41
|
+
app: DetailedHTMLProps<HTMLAttributes<HTMLAppElement>, HTMLAppElement> & {
|
|
42
|
+
"app-id": string;
|
|
43
|
+
frame?: string | undefined;
|
|
44
|
+
resizing?: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|