@deseteral/biurko 0.0.0-stage → 0.1.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/LICENSE +7 -0
- package/README.md +50 -2
- package/dist/adapters/react/index.d.ts +53 -0
- package/dist/adapters/react/index.js +65 -0
- package/dist/adapters/solid-js/index.d.ts +53 -0
- package/dist/adapters/solid-js/index.js +89 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/window-manager-BIsSCt3U.js +841 -0
- package/dist/window-manager-X3GN3wrq.d.ts +524 -0
- package/package.json +79 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright Deseteral <github.com/deseteral>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# biurko
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install --save @deseteral/biurko
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Development
|
|
10
|
+
|
|
11
|
+
### Setup
|
|
12
|
+
|
|
13
|
+
- Node.js `^22.18.0 || ^24.11.0 || >=26.0.0` for [Vite+](https://viteplus.dev/).
|
|
14
|
+
- npm 11.20.0 (the version pinned in `package.json` and used by CI and orb setup).
|
|
15
|
+
|
|
16
|
+
If needed, install the pinned npm version with `npm install --global npm@11.20.0`, then run `npm ci` to install dependencies from `package-lock.json`. Vite+ is installed locally; no global `vp` installation is required.
|
|
17
|
+
|
|
18
|
+
The project’s `.npmrc` saves exact dependency versions, disables install lifecycle scripts, and requires newly resolved package versions to be at least 31 days old. The release-age setting requires npm 11.10.0 or newer.
|
|
19
|
+
|
|
20
|
+
| Command | Description |
|
|
21
|
+
| ---------------------- | ------------------------------------------------------ |
|
|
22
|
+
| `npm run build` | Build the ESM library and declarations with `vp pack`. |
|
|
23
|
+
| `npm run build:demo` | Build all three demo pages with `vp build`. |
|
|
24
|
+
| `npm run demo` | Start the Vite+ dev server with the demo app. |
|
|
25
|
+
| `npm run typecheck` | Run TypeScript type checking. |
|
|
26
|
+
| `npm run lint` | Run Oxlint rules and type checking. |
|
|
27
|
+
| `npm run check` | Check formatting, lint rules, and types together. |
|
|
28
|
+
| `npm run format` | Format the project with Vite+ (Oxfmt). |
|
|
29
|
+
| `npm run format:check` | Check formatting without modifying files. |
|
|
30
|
+
|
|
31
|
+
`vp pack` builds the library; `vp build demo/` builds the demo application. To run these local commands directly, use `npm exec --no -- vp`. There are currently no tests or test script.
|
|
32
|
+
|
|
33
|
+
Formatting uses the `fmt` block in `vite.config.ts` and the existing `.editorconfig` style. Linting uses Oxlint's default rules with type-aware linting and type checking enabled in the `lint` block. Linting includes the library and demo code, excluding generated output. `vp check` checks formatting, lint rules, and types together; TypeScript checking remains available separately through `npm run typecheck`.
|
|
34
|
+
|
|
35
|
+
CI runs formatting checks, type checking, and both builds on pushes and pull requests. Orb setup installs the pinned npm version when needed and runs `npm ci`; resume requires no additional setup.
|
|
36
|
+
|
|
37
|
+
### Demo app
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm run demo
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This starts a local dev server serving the `demo/` directory. There are three demo apps available:
|
|
44
|
+
|
|
45
|
+
- `/` - vanilla DOM demo
|
|
46
|
+
- `/react.html` - React integration demo
|
|
47
|
+
- `/solid.html` - SolidJS integration demo
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
This project is licensed under the [MIT license](LICENSE).
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as WindowManagerOptions, p as WindowHandle, t as WindowManager } from "../../window-manager-X3GN3wrq.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link BiurkoDesktop} component.
|
|
5
|
+
*/
|
|
6
|
+
interface BiurkoDesktopProps {
|
|
7
|
+
/** CSS class name applied to the desktop container. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Child components rendered inside the desktop.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options passed to the underlying {@link WindowManager}.
|
|
15
|
+
* Read only when the manager is initialized; later changes do not reconfigure it.
|
|
16
|
+
*/
|
|
17
|
+
options?: WindowManagerOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Optional render function to wrap each window's content with custom chrome (title bar, close button, etc.).
|
|
20
|
+
*
|
|
21
|
+
* @param handle - The handle of the window being rendered.
|
|
22
|
+
* @param content - A function that returns the window's content (the render function passed to `createWindow`).
|
|
23
|
+
* @returns The decorated window content to be portaled into the window surface.
|
|
24
|
+
*/
|
|
25
|
+
renderWindow?: (handle: WindowHandle, content: () => ReactNode) => ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The root desktop component for the React adapter.
|
|
29
|
+
* Initializes a {@link WindowManager} and provides it via React context. All windows created through
|
|
30
|
+
* the manager are rendered as React portals into their respective surface elements.
|
|
31
|
+
*
|
|
32
|
+
* Place your application UI (taskbar, menus, controls) as `children` - they will have access to
|
|
33
|
+
* the window manager through the {@link useWindowManager} hook.
|
|
34
|
+
* Pass a content render function as the second argument to the manager's `createWindow` method.
|
|
35
|
+
*
|
|
36
|
+
* @param props - Desktop configuration, child UI, and optional window content decorator.
|
|
37
|
+
* @returns The desktop container with child UI and window portals once initialized.
|
|
38
|
+
*/
|
|
39
|
+
export declare function BiurkoDesktop(props: BiurkoDesktopProps): ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* A `WindowManager` instance typed for the React adapter.
|
|
42
|
+
* Each window's attached data is a render function returning a React node.
|
|
43
|
+
*/
|
|
44
|
+
type ReactWindowManager = WindowManager<() => ReactNode>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the {@link WindowManager} instance from the nearest `<BiurkoDesktop>` ancestor.
|
|
47
|
+
* Use this hook to create, close, or inspect windows from any component within the desktop tree.
|
|
48
|
+
*
|
|
49
|
+
* @returns The desktop's window manager, with a content render function attached to each window.
|
|
50
|
+
* @throws Error if called outside of a `<BiurkoDesktop>` component tree.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useWindowManager(): ReactWindowManager;
|
|
53
|
+
export type { BiurkoDesktopProps };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { t as WindowManager } from "../../window-manager-BIsSCt3U.js";
|
|
2
|
+
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/adapters/react/biurko-context.ts
|
|
6
|
+
const BiurkoContext = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Returns the {@link WindowManager} instance from the nearest `<BiurkoDesktop>` ancestor.
|
|
9
|
+
* Use this hook to create, close, or inspect windows from any component within the desktop tree.
|
|
10
|
+
*
|
|
11
|
+
* @returns The desktop's window manager, with a content render function attached to each window.
|
|
12
|
+
* @throws Error if called outside of a `<BiurkoDesktop>` component tree.
|
|
13
|
+
*/
|
|
14
|
+
function useWindowManager() {
|
|
15
|
+
const windowManager = useContext(BiurkoContext);
|
|
16
|
+
if (!windowManager) throw new Error("useWindowManager must be used within React adapter context.");
|
|
17
|
+
return windowManager;
|
|
18
|
+
}
|
|
19
|
+
// src/adapters/react/BiurkoDesktop.tsx
|
|
20
|
+
/**
|
|
21
|
+
* The root desktop component for the React adapter.
|
|
22
|
+
* Initializes a {@link WindowManager} and provides it via React context. All windows created through
|
|
23
|
+
* the manager are rendered as React portals into their respective surface elements.
|
|
24
|
+
*
|
|
25
|
+
* Place your application UI (taskbar, menus, controls) as `children` - they will have access to
|
|
26
|
+
* the window manager through the {@link useWindowManager} hook.
|
|
27
|
+
* Pass a content render function as the second argument to the manager's `createWindow` method.
|
|
28
|
+
*
|
|
29
|
+
* @param props - Desktop configuration, child UI, and optional window content decorator.
|
|
30
|
+
* @returns The desktop container with child UI and window portals once initialized.
|
|
31
|
+
*/
|
|
32
|
+
function BiurkoDesktop(props) {
|
|
33
|
+
const [windowManager, setWindowManager] = useState(null);
|
|
34
|
+
const [windows, setWindows] = useState([]);
|
|
35
|
+
const managerRef = useRef(null);
|
|
36
|
+
const initRef = useCallback((el) => {
|
|
37
|
+
if (!el || managerRef.current) return;
|
|
38
|
+
const manager = new WindowManager(el, props.options);
|
|
39
|
+
manager.addEventListener("window-opened", (e) => {
|
|
40
|
+
const { handle } = e.detail;
|
|
41
|
+
const surface = manager.getWindowSurface(handle);
|
|
42
|
+
const render = manager.getWindowData(handle);
|
|
43
|
+
if (!surface || !render) return;
|
|
44
|
+
setWindows((prev) => [...prev, {
|
|
45
|
+
handle,
|
|
46
|
+
surface,
|
|
47
|
+
render
|
|
48
|
+
}]);
|
|
49
|
+
});
|
|
50
|
+
manager.addEventListener("window-closed", (e) => {
|
|
51
|
+
setWindows((prev) => prev.filter((w) => w.handle !== e.detail.handle));
|
|
52
|
+
});
|
|
53
|
+
managerRef.current = manager;
|
|
54
|
+
setWindowManager(manager);
|
|
55
|
+
}, []);
|
|
56
|
+
return /* @__PURE__ */ jsx("div", {
|
|
57
|
+
ref: initRef,
|
|
58
|
+
className: props.className,
|
|
59
|
+
children: windowManager && /* @__PURE__ */ jsxs(BiurkoContext.Provider, {
|
|
60
|
+
value: windowManager,
|
|
61
|
+
children: [props.children, windows.map((w) => createPortal(props.renderWindow ? props.renderWindow(w.handle, w.render) : w.render(), w.surface, w.handle))]
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export { BiurkoDesktop, useWindowManager };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as WindowManagerOptions, p as WindowHandle, t as WindowManager } from "../../window-manager-X3GN3wrq.js";
|
|
2
|
+
import { JSX } from "solid-js";
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link BiurkoDesktop} component.
|
|
5
|
+
*/
|
|
6
|
+
interface BiurkoDesktopProps {
|
|
7
|
+
/** CSS class name applied to the desktop container. */
|
|
8
|
+
class?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Child components rendered inside the desktop.
|
|
11
|
+
*/
|
|
12
|
+
children: JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options passed to the underlying {@link WindowManager}.
|
|
15
|
+
* Read only when the manager is initialized; later changes do not reconfigure it.
|
|
16
|
+
*/
|
|
17
|
+
options?: WindowManagerOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Optional render function to wrap each window's content with custom chrome (title bar, close button, etc.).
|
|
20
|
+
*
|
|
21
|
+
* @param handle - The handle of the window being rendered.
|
|
22
|
+
* @param content - A function that returns the window's content (the render function passed to `createWindow`).
|
|
23
|
+
* @returns The decorated window content to be portaled into the window surface.
|
|
24
|
+
*/
|
|
25
|
+
renderWindow?: (handle: WindowHandle, content: () => JSX.Element) => JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The root desktop component for the SolidJS adapter.
|
|
29
|
+
* Initializes a {@link WindowManager} and provides it via SolidJS context. All windows created through
|
|
30
|
+
* the manager are rendered as SolidJS portals into their respective surface elements.
|
|
31
|
+
*
|
|
32
|
+
* Place your application UI (taskbar, menus, controls) as `children` - they will have access to
|
|
33
|
+
* the window manager through the {@link useWindowManager} function.
|
|
34
|
+
* Pass a content render function as the second argument to the manager's `createWindow` method.
|
|
35
|
+
*
|
|
36
|
+
* @param props - Desktop configuration, child UI, and optional window content decorator.
|
|
37
|
+
* @returns The desktop container with child UI and window portals once initialized.
|
|
38
|
+
*/
|
|
39
|
+
export declare function BiurkoDesktop(props: BiurkoDesktopProps): JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* A `WindowManager` instance typed for the Solid.js adapter.
|
|
42
|
+
* Each window's attached data is a render function returning a Solid.js JSX element.
|
|
43
|
+
*/
|
|
44
|
+
type SolidJsWindowManager = WindowManager<() => JSX.Element>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the {@link WindowManager} instance from the nearest `<BiurkoDesktop>` ancestor.
|
|
47
|
+
* Use this to create, close, or inspect windows from any component within the desktop tree.
|
|
48
|
+
*
|
|
49
|
+
* @returns The desktop's window manager, with a content render function attached to each window.
|
|
50
|
+
* @throws Error if called outside of a `<BiurkoDesktop>` component tree.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useWindowManager(): SolidJsWindowManager;
|
|
53
|
+
export type { BiurkoDesktopProps };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { t as WindowManager } from "../../window-manager-BIsSCt3U.js";
|
|
2
|
+
import { Portal, className, createComponent, effect, insert, memo, template, use } from "solid-js/web";
|
|
3
|
+
import { For, Show, createContext, createSignal, useContext } from "solid-js";
|
|
4
|
+
// src/adapters/solid-js/biurko-context.ts
|
|
5
|
+
const BiurkoContext = createContext();
|
|
6
|
+
/**
|
|
7
|
+
* Returns the {@link WindowManager} instance from the nearest `<BiurkoDesktop>` ancestor.
|
|
8
|
+
* Use this to create, close, or inspect windows from any component within the desktop tree.
|
|
9
|
+
*
|
|
10
|
+
* @returns The desktop's window manager, with a content render function attached to each window.
|
|
11
|
+
* @throws Error if called outside of a `<BiurkoDesktop>` component tree.
|
|
12
|
+
*/
|
|
13
|
+
function useWindowManager() {
|
|
14
|
+
const windowManager = useContext(BiurkoContext);
|
|
15
|
+
if (!windowManager) throw new Error("useWindowManager must be used within Solid.js adapter context.");
|
|
16
|
+
return windowManager;
|
|
17
|
+
}
|
|
18
|
+
// src/adapters/solid-js/BiurkoDesktop.tsx
|
|
19
|
+
/** @jsxImportSource solid-js */
|
|
20
|
+
var _tmpl$ = /*#__PURE__*/ template(`<div>`);
|
|
21
|
+
/**
|
|
22
|
+
* The root desktop component for the SolidJS adapter.
|
|
23
|
+
* Initializes a {@link WindowManager} and provides it via SolidJS context. All windows created through
|
|
24
|
+
* the manager are rendered as SolidJS portals into their respective surface elements.
|
|
25
|
+
*
|
|
26
|
+
* Place your application UI (taskbar, menus, controls) as `children` - they will have access to
|
|
27
|
+
* the window manager through the {@link useWindowManager} function.
|
|
28
|
+
* Pass a content render function as the second argument to the manager's `createWindow` method.
|
|
29
|
+
*
|
|
30
|
+
* @param props - Desktop configuration, child UI, and optional window content decorator.
|
|
31
|
+
* @returns The desktop container with child UI and window portals once initialized.
|
|
32
|
+
*/
|
|
33
|
+
function BiurkoDesktop(props) {
|
|
34
|
+
const [windowManager, setWindowManager] = createSignal();
|
|
35
|
+
const [windows, setWindows] = createSignal([]);
|
|
36
|
+
const initRef = (el) => {
|
|
37
|
+
const manager = new WindowManager(el, props.options);
|
|
38
|
+
manager.addEventListener("window-opened", (e) => {
|
|
39
|
+
const { handle } = e.detail;
|
|
40
|
+
const surface = manager.getWindowSurface(handle);
|
|
41
|
+
const render = manager.getWindowData(handle);
|
|
42
|
+
if (!surface || !render) return;
|
|
43
|
+
setWindows((prev) => [...prev, {
|
|
44
|
+
handle,
|
|
45
|
+
surface,
|
|
46
|
+
render
|
|
47
|
+
}]);
|
|
48
|
+
});
|
|
49
|
+
manager.addEventListener("window-closed", (e) => {
|
|
50
|
+
setWindows((prev) => prev.filter((w) => w.handle !== e.detail.handle));
|
|
51
|
+
});
|
|
52
|
+
setWindowManager(manager);
|
|
53
|
+
};
|
|
54
|
+
return (() => {
|
|
55
|
+
var _el$ = _tmpl$();
|
|
56
|
+
use(initRef, _el$);
|
|
57
|
+
insert(_el$, createComponent(Show, {
|
|
58
|
+
get when() {
|
|
59
|
+
return windowManager();
|
|
60
|
+
},
|
|
61
|
+
children: (manager) => createComponent(BiurkoContext.Provider, {
|
|
62
|
+
get value() {
|
|
63
|
+
return manager();
|
|
64
|
+
},
|
|
65
|
+
get children() {
|
|
66
|
+
return [memo(() => props.children), createComponent(For, {
|
|
67
|
+
get each() {
|
|
68
|
+
return windows();
|
|
69
|
+
},
|
|
70
|
+
children: (w) => createComponent(Portal, {
|
|
71
|
+
get mount() {
|
|
72
|
+
return w.surface;
|
|
73
|
+
},
|
|
74
|
+
ref: (el) => {
|
|
75
|
+
el.style.display = "contents";
|
|
76
|
+
},
|
|
77
|
+
get children() {
|
|
78
|
+
return memo(() => !!props.renderWindow)() ? props.renderWindow(w.handle, w.render) : w.render();
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
})];
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}));
|
|
85
|
+
effect(() => className(_el$, props.class));
|
|
86
|
+
return _el$;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
export { BiurkoDesktop, useWindowManager };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as WindowFocusedEventDetail, c as WindowOpenedEventDetail, d as CreateWindowOptions, f as DesktopMode, g as WindowRect, h as WindowPositionStrategy, i as WindowClosedEventDetail, l as WindowParentChangedEventDetail, m as WindowParentOptions, n as WindowManagerOptions, o as WindowManagerEventMap, p as WindowHandle, r as ViewportTranslatedEventDetail, s as WindowMovedEventDetail, t as WindowManager, u as WindowResizedEventDetail } from "./window-manager-X3GN3wrq.js";
|
|
2
|
+
export { type CreateWindowOptions, type DesktopMode, type ViewportTranslatedEventDetail, type WindowClosedEventDetail, type WindowFocusedEventDetail, type WindowHandle, WindowManager, type WindowManagerEventMap, type WindowManagerOptions, type WindowMovedEventDetail, type WindowOpenedEventDetail, type WindowParentChangedEventDetail, type WindowParentOptions, type WindowPositionStrategy, type WindowRect, type WindowResizedEventDetail };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as WindowManager } from "./window-manager-BIsSCt3U.js";
|