@deseteral/biurko 0.1.0 → 0.2.0-SNAPSHOT.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deseteral/biurko",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-SNAPSHOT.1",
4
4
  "description": "A browser window manager with React and SolidJS adapters.",
5
5
  "homepage": "https://github.com/Deseteral/biurko#readme",
6
6
  "bugs": {
@@ -1,53 +0,0 @@
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 };
@@ -1,65 +0,0 @@
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 };
@@ -1,53 +0,0 @@
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 };
@@ -1,89 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
1
- export { t as WindowManager } from "./window-manager-BIsSCt3U.js";