@domicile-desktop/react 0.0.0-alpha-77fd63181766 → 0.0.0-alpha-7a29c8f7f7ea
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 +4 -0
- package/dist/nested-shell.d.ts +12 -0
- package/dist/nested-shell.js +22 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -21,6 +21,10 @@ export const Shell = mount(Focused);
|
|
|
21
21
|
synchronously (the page draws nothing until `Shell` returns) in an element
|
|
22
22
|
of its own with `display: contents`, under `StrictMode`, an error boundary
|
|
23
23
|
that shows what threw, and `<DomicileProvider>`.
|
|
24
|
+
- `./nested-shell`: `<NestedShell shell>` runs another shell, such as an npm
|
|
25
|
+
package's `Shell` or `runManganese()`, inside this one, on the same desktop.
|
|
26
|
+
It sizes against the element it is placed in. Both shells see every window
|
|
27
|
+
and bind keys, so draw windows and bind keys in only one of them.
|
|
24
28
|
- `./domicile-provider`: `<DomicileProvider domicile>`, `useDomicile()` (a
|
|
25
29
|
shell's `Domicile`; throws under an app's) and `useAppDomicile()`.
|
|
26
30
|
- `./use-watch`: `useWatch(namespace, type, read)`, `read` again on each
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Shell } from "@domicile-desktop/sdk/shell";
|
|
2
|
+
/**
|
|
3
|
+
* Runs `shell` in an element of its own, on the desktop above. The element has
|
|
4
|
+
* `display: contents`, so the shell sizes against wherever this is placed.
|
|
5
|
+
*
|
|
6
|
+
* A `Shell` runs once and can't be undone, so this runs it once, when the
|
|
7
|
+
* element is first attached. React passes `null` when it detaches. It runs
|
|
8
|
+
* after React's commit, since a shell may draw synchronously, as `mount` does.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NestedShell: ({ shell }: {
|
|
11
|
+
shell: Shell;
|
|
12
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
import { useDomicile } from "./domicile-provider";
|
|
4
|
+
/**
|
|
5
|
+
* Runs `shell` in an element of its own, on the desktop above. The element has
|
|
6
|
+
* `display: contents`, so the shell sizes against wherever this is placed.
|
|
7
|
+
*
|
|
8
|
+
* A `Shell` runs once and can't be undone, so this runs it once, when the
|
|
9
|
+
* element is first attached. React passes `null` when it detaches. It runs
|
|
10
|
+
* after React's commit, since a shell may draw synchronously, as `mount` does.
|
|
11
|
+
*/
|
|
12
|
+
export const NestedShell = ({ shell }) => {
|
|
13
|
+
const domicile = useDomicile();
|
|
14
|
+
const ran = useRef(false);
|
|
15
|
+
const start = useCallback((element) => {
|
|
16
|
+
if (element !== null && !ran.current) {
|
|
17
|
+
ran.current = true;
|
|
18
|
+
queueMicrotask(() => shell(element, domicile));
|
|
19
|
+
}
|
|
20
|
+
}, [shell, domicile]);
|
|
21
|
+
return _jsx("div", { ref: start, style: { display: "contents" } });
|
|
22
|
+
};
|
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-7a29c8f7f7ea"
|
|
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": {
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"types": "./dist/mount.d.ts",
|
|
44
44
|
"default": "./dist/mount.js"
|
|
45
45
|
},
|
|
46
|
+
"./nested-shell": {
|
|
47
|
+
"types": "./dist/nested-shell.d.ts",
|
|
48
|
+
"default": "./dist/nested-shell.js"
|
|
49
|
+
},
|
|
46
50
|
"./per-desktop": {
|
|
47
51
|
"types": "./dist/per-desktop.d.ts",
|
|
48
52
|
"default": "./dist/per-desktop.js"
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
"test:unit": "bun test"
|
|
97
101
|
},
|
|
98
102
|
"type": "module",
|
|
99
|
-
"version": "0.0.0-alpha-
|
|
103
|
+
"version": "0.0.0-alpha-7a29c8f7f7ea",
|
|
100
104
|
"repository": {
|
|
101
105
|
"type": "git",
|
|
102
106
|
"url": "git+https://github.com/cprussin/domicile.git",
|