defuss-desktop 0.0.3 → 0.0.4
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 -4
- package/dist/index.cjs +121 -124
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +122 -125
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -92,10 +92,10 @@ Integrating `defuss-wm` in your project
|
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
94
|
# install a decent package manager
|
|
95
|
-
npm i -g
|
|
95
|
+
npm i -g bun@^1.3.9
|
|
96
96
|
|
|
97
97
|
# from your project root folder, add defuss-wm to your dependencies
|
|
98
|
-
|
|
98
|
+
bun install defuss-wm
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
#### 2. Set up your desktop environment:
|
|
@@ -198,8 +198,8 @@ All commands are run from the root of the project, from a terminal:
|
|
|
198
198
|
|
|
199
199
|
| Command | Action |
|
|
200
200
|
| :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
201
|
+
| `bun build` | Build a new version of the window manager. |
|
|
202
|
+
| `bun test` | Run the test suite for `defuss-wm`. |
|
|
203
203
|
|
|
204
204
|
---
|
|
205
205
|
|
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,124 @@ function Button({
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const defaultTaskbarOptions = {
|
|
28
|
+
position: "bottom",
|
|
29
|
+
stateful: false,
|
|
30
|
+
theme: "default",
|
|
31
|
+
size: "medium"
|
|
32
|
+
};
|
|
33
|
+
class TaskbarManager {
|
|
34
|
+
position;
|
|
35
|
+
theme;
|
|
36
|
+
// e.g., 'windows-xp', 'macos', etc.
|
|
37
|
+
size;
|
|
38
|
+
constructor(options = defaultTaskbarOptions) {
|
|
39
|
+
this.position = options.position || "bottom";
|
|
40
|
+
this.theme = options.theme || "default";
|
|
41
|
+
this.size = options.size || "medium";
|
|
42
|
+
if (options.stateful) ;
|
|
43
|
+
}
|
|
44
|
+
getDimensions() {
|
|
45
|
+
const el = document.querySelector(".taskbar");
|
|
46
|
+
if (!el) {
|
|
47
|
+
return { width: 0, height: 0 };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
width: el.clientWidth,
|
|
51
|
+
height: el.clientHeight
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
globalThis.__defussTaskbarManager = globalThis.__defussTaskbarManager || new TaskbarManager();
|
|
56
|
+
const taskbarManager = globalThis.__defussTaskbarManager;
|
|
57
|
+
|
|
58
|
+
class DefussDesktopAppIcon {
|
|
59
|
+
constructor(config) {
|
|
60
|
+
this.config = config;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const defaultDesktopOptions = {
|
|
64
|
+
icons: [],
|
|
65
|
+
backgroundColor: "#000"
|
|
66
|
+
};
|
|
67
|
+
class DesktopManager {
|
|
68
|
+
constructor(options = defaultDesktopOptions) {
|
|
69
|
+
this.options = options;
|
|
70
|
+
}
|
|
71
|
+
el;
|
|
72
|
+
state;
|
|
73
|
+
resizeObserver;
|
|
74
|
+
resizeCallbacks = /* @__PURE__ */ new Set();
|
|
75
|
+
init(el, options = this.options) {
|
|
76
|
+
this.options = options;
|
|
77
|
+
this.el = el;
|
|
78
|
+
this.state = this.state || {
|
|
79
|
+
icons: this.options.icons.map((icon) => icon.config)
|
|
80
|
+
};
|
|
81
|
+
this.setupResizeObserver();
|
|
82
|
+
this.render(el);
|
|
83
|
+
}
|
|
84
|
+
render(el) {
|
|
85
|
+
el.style.backgroundColor = this.options.backgroundColor;
|
|
86
|
+
if (this.options.backgroundImage) {
|
|
87
|
+
el.style.backgroundImage = `url(${this.options.backgroundImage})`;
|
|
88
|
+
}
|
|
89
|
+
if (this.options.backgroundImageSize) {
|
|
90
|
+
el.style.backgroundSize = this.options.backgroundImageSize || "cover";
|
|
91
|
+
}
|
|
92
|
+
if (this.options.backgroundRepeat) {
|
|
93
|
+
el.style.backgroundRepeat = this.options.backgroundRepeat || "no-repeat";
|
|
94
|
+
}
|
|
95
|
+
if (this.options.backgroundPosition) {
|
|
96
|
+
el.style.backgroundPosition = this.options.backgroundPosition || "center";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
addIcon(icon) {
|
|
100
|
+
this.options.icons.push(icon);
|
|
101
|
+
console.log(`Icon added: ${icon.config.name}`);
|
|
102
|
+
}
|
|
103
|
+
getDimensions() {
|
|
104
|
+
if (!this.el) {
|
|
105
|
+
throw new Error("Desktop not initialized. Call init() first.");
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
width: this.el.offsetWidth,
|
|
109
|
+
height: this.el.offsetHeight - taskbarManager.getDimensions().height
|
|
110
|
+
// destop is root element minus taskbar height
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
setupResizeObserver() {
|
|
114
|
+
if (!this.el) return;
|
|
115
|
+
if (this.resizeObserver) {
|
|
116
|
+
this.resizeObserver.disconnect();
|
|
117
|
+
}
|
|
118
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
119
|
+
const dimensions = this.getDimensions();
|
|
120
|
+
this.resizeCallbacks.forEach((callback) => {
|
|
121
|
+
try {
|
|
122
|
+
callback(dimensions);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("Error in desktop resize callback:", error);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
this.resizeObserver.observe(this.el);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Register a callback for desktop resize events
|
|
132
|
+
* @param callback Function to call when desktop is resized
|
|
133
|
+
* @returns Unregister function to remove the callback
|
|
134
|
+
*/
|
|
135
|
+
onResize(callback) {
|
|
136
|
+
this.resizeCallbacks.add(callback);
|
|
137
|
+
return () => {
|
|
138
|
+
this.resizeCallbacks.delete(callback);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
globalThis.__defussDesktopManager = globalThis.__defussDesktopManager || new DesktopManager();
|
|
143
|
+
const desktopManager = globalThis.__defussDesktopManager;
|
|
144
|
+
|
|
27
145
|
const defaultWindowOptions = {
|
|
28
146
|
title: "Untitled",
|
|
29
147
|
resizable: true,
|
|
@@ -633,93 +751,6 @@ const LogonScreen = ({
|
|
|
633
751
|
] });
|
|
634
752
|
};
|
|
635
753
|
|
|
636
|
-
class DefussDesktopAppIcon {
|
|
637
|
-
constructor(config) {
|
|
638
|
-
this.config = config;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
const defaultDesktopOptions = {
|
|
642
|
-
icons: [],
|
|
643
|
-
backgroundColor: "#000"
|
|
644
|
-
};
|
|
645
|
-
class DesktopManager {
|
|
646
|
-
constructor(options = defaultDesktopOptions) {
|
|
647
|
-
this.options = options;
|
|
648
|
-
}
|
|
649
|
-
el;
|
|
650
|
-
state;
|
|
651
|
-
resizeObserver;
|
|
652
|
-
resizeCallbacks = /* @__PURE__ */ new Set();
|
|
653
|
-
init(el, options = this.options) {
|
|
654
|
-
this.options = options;
|
|
655
|
-
this.el = el;
|
|
656
|
-
this.state = this.state || {
|
|
657
|
-
icons: this.options.icons.map((icon) => icon.config)
|
|
658
|
-
};
|
|
659
|
-
this.setupResizeObserver();
|
|
660
|
-
this.render(el);
|
|
661
|
-
}
|
|
662
|
-
render(el) {
|
|
663
|
-
el.style.backgroundColor = this.options.backgroundColor;
|
|
664
|
-
if (this.options.backgroundImage) {
|
|
665
|
-
el.style.backgroundImage = `url(${this.options.backgroundImage})`;
|
|
666
|
-
}
|
|
667
|
-
if (this.options.backgroundImageSize) {
|
|
668
|
-
el.style.backgroundSize = this.options.backgroundImageSize || "cover";
|
|
669
|
-
}
|
|
670
|
-
if (this.options.backgroundRepeat) {
|
|
671
|
-
el.style.backgroundRepeat = this.options.backgroundRepeat || "no-repeat";
|
|
672
|
-
}
|
|
673
|
-
if (this.options.backgroundPosition) {
|
|
674
|
-
el.style.backgroundPosition = this.options.backgroundPosition || "center";
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
addIcon(icon) {
|
|
678
|
-
this.options.icons.push(icon);
|
|
679
|
-
console.log(`Icon added: ${icon.config.name}`);
|
|
680
|
-
}
|
|
681
|
-
getDimensions() {
|
|
682
|
-
if (!this.el) {
|
|
683
|
-
throw new Error("Desktop not initialized. Call init() first.");
|
|
684
|
-
}
|
|
685
|
-
return {
|
|
686
|
-
width: this.el.offsetWidth,
|
|
687
|
-
height: this.el.offsetHeight - taskbarManager.getDimensions().height
|
|
688
|
-
// destop is root element minus taskbar height
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
setupResizeObserver() {
|
|
692
|
-
if (!this.el) return;
|
|
693
|
-
if (this.resizeObserver) {
|
|
694
|
-
this.resizeObserver.disconnect();
|
|
695
|
-
}
|
|
696
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
697
|
-
const dimensions = this.getDimensions();
|
|
698
|
-
this.resizeCallbacks.forEach((callback) => {
|
|
699
|
-
try {
|
|
700
|
-
callback(dimensions);
|
|
701
|
-
} catch (error) {
|
|
702
|
-
console.error("Error in desktop resize callback:", error);
|
|
703
|
-
}
|
|
704
|
-
});
|
|
705
|
-
});
|
|
706
|
-
this.resizeObserver.observe(this.el);
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Register a callback for desktop resize events
|
|
710
|
-
* @param callback Function to call when desktop is resized
|
|
711
|
-
* @returns Unregister function to remove the callback
|
|
712
|
-
*/
|
|
713
|
-
onResize(callback) {
|
|
714
|
-
this.resizeCallbacks.add(callback);
|
|
715
|
-
return () => {
|
|
716
|
-
this.resizeCallbacks.delete(callback);
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
globalThis.__defussDesktopManager = globalThis.__defussDesktopManager || new DesktopManager();
|
|
721
|
-
const desktopManager = globalThis.__defussDesktopManager;
|
|
722
|
-
|
|
723
754
|
const StartMenu = () => {
|
|
724
755
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { class: "slide-open crt", children: [
|
|
725
756
|
/* @__PURE__ */ jsxRuntime.jsx("div", { class: "top", children: /* @__PURE__ */ jsxRuntime.jsx("h1", { children: "Aron Homberg" }) }),
|
|
@@ -857,15 +888,12 @@ class DequeryWithWindowManager extends defuss.CallChainImpl {
|
|
|
857
888
|
*/
|
|
858
889
|
// register an app to the desktop shell
|
|
859
890
|
createDesktopApp(options) {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
});
|
|
891
|
+
new DefussApp(options);
|
|
892
|
+
return this;
|
|
863
893
|
}
|
|
864
894
|
// create a desktop app icon
|
|
865
895
|
createDesktopAppIcon(options) {
|
|
866
|
-
return
|
|
867
|
-
return new DefussDesktopAppIcon(options);
|
|
868
|
-
});
|
|
896
|
+
return this;
|
|
869
897
|
}
|
|
870
898
|
}
|
|
871
899
|
const $ = defuss.dequery.extend(DequeryWithWindowManager, [
|
|
@@ -874,37 +902,6 @@ const $ = defuss.dequery.extend(DequeryWithWindowManager, [
|
|
|
874
902
|
"createDesktopAppIcon"
|
|
875
903
|
]);
|
|
876
904
|
|
|
877
|
-
const defaultTaskbarOptions = {
|
|
878
|
-
position: "bottom",
|
|
879
|
-
stateful: false,
|
|
880
|
-
theme: "default",
|
|
881
|
-
size: "medium"
|
|
882
|
-
};
|
|
883
|
-
class TaskbarManager {
|
|
884
|
-
position;
|
|
885
|
-
theme;
|
|
886
|
-
// e.g., 'windows-xp', 'macos', etc.
|
|
887
|
-
size;
|
|
888
|
-
constructor(options = defaultTaskbarOptions) {
|
|
889
|
-
this.position = options.position || "bottom";
|
|
890
|
-
this.theme = options.theme || "default";
|
|
891
|
-
this.size = options.size || "medium";
|
|
892
|
-
if (options.stateful) ;
|
|
893
|
-
}
|
|
894
|
-
getDimensions() {
|
|
895
|
-
const el = document.querySelector(".taskbar");
|
|
896
|
-
if (!el) {
|
|
897
|
-
return { width: 0, height: 0 };
|
|
898
|
-
}
|
|
899
|
-
return {
|
|
900
|
-
width: el.clientWidth,
|
|
901
|
-
height: el.clientHeight
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
globalThis.__defussTaskbarManager = globalThis.__defussTaskbarManager || new TaskbarManager();
|
|
906
|
-
const taskbarManager = globalThis.__defussTaskbarManager;
|
|
907
|
-
|
|
908
905
|
const defaultSystemSoundFilePaths = [
|
|
909
906
|
"/sounds/balloon.ogg",
|
|
910
907
|
"/sounds/batterycritical.ogg",
|
package/dist/index.d.cts
CHANGED
|
@@ -97,8 +97,8 @@ declare const StartButton: () => JSX.Element;
|
|
|
97
97
|
declare const StartMenu: () => JSX.Element;
|
|
98
98
|
|
|
99
99
|
declare class DequeryWithWindowManager<NT> extends CallChainImpl<NT, DequeryWithWindowManager<NT> & Dequery<NT>> {
|
|
100
|
-
createDesktopApp(options: DefussAppConfig):
|
|
101
|
-
createDesktopAppIcon(options: DesktopIconConfig):
|
|
100
|
+
createDesktopApp(options: DefussAppConfig): this & Dequery<NT>;
|
|
101
|
+
createDesktopAppIcon(options: DesktopIconConfig): this & Dequery<NT>;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Extended dequery function with window management capabilities.
|
package/dist/index.d.mts
CHANGED
|
@@ -97,8 +97,8 @@ declare const StartButton: () => JSX.Element;
|
|
|
97
97
|
declare const StartMenu: () => JSX.Element;
|
|
98
98
|
|
|
99
99
|
declare class DequeryWithWindowManager<NT> extends CallChainImpl<NT, DequeryWithWindowManager<NT> & Dequery<NT>> {
|
|
100
|
-
createDesktopApp(options: DefussAppConfig):
|
|
101
|
-
createDesktopAppIcon(options: DesktopIconConfig):
|
|
100
|
+
createDesktopApp(options: DefussAppConfig): this & Dequery<NT>;
|
|
101
|
+
createDesktopAppIcon(options: DesktopIconConfig): this & Dequery<NT>;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Extended dequery function with window management capabilities.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRef, $ as $$1, dequery, CallChainImpl
|
|
1
|
+
import { createRef, $ as $$1, dequery, CallChainImpl } from 'defuss';
|
|
2
2
|
import { debounce, throttle } from 'defuss-runtime';
|
|
3
3
|
import { jsx, jsxs } from 'defuss/jsx-runtime';
|
|
4
4
|
import { access, transval, rule } from 'defuss-transval';
|
|
@@ -22,6 +22,124 @@ function Button({
|
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
const defaultTaskbarOptions = {
|
|
26
|
+
position: "bottom",
|
|
27
|
+
stateful: false,
|
|
28
|
+
theme: "default",
|
|
29
|
+
size: "medium"
|
|
30
|
+
};
|
|
31
|
+
class TaskbarManager {
|
|
32
|
+
position;
|
|
33
|
+
theme;
|
|
34
|
+
// e.g., 'windows-xp', 'macos', etc.
|
|
35
|
+
size;
|
|
36
|
+
constructor(options = defaultTaskbarOptions) {
|
|
37
|
+
this.position = options.position || "bottom";
|
|
38
|
+
this.theme = options.theme || "default";
|
|
39
|
+
this.size = options.size || "medium";
|
|
40
|
+
if (options.stateful) ;
|
|
41
|
+
}
|
|
42
|
+
getDimensions() {
|
|
43
|
+
const el = document.querySelector(".taskbar");
|
|
44
|
+
if (!el) {
|
|
45
|
+
return { width: 0, height: 0 };
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
width: el.clientWidth,
|
|
49
|
+
height: el.clientHeight
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
globalThis.__defussTaskbarManager = globalThis.__defussTaskbarManager || new TaskbarManager();
|
|
54
|
+
const taskbarManager = globalThis.__defussTaskbarManager;
|
|
55
|
+
|
|
56
|
+
class DefussDesktopAppIcon {
|
|
57
|
+
constructor(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const defaultDesktopOptions = {
|
|
62
|
+
icons: [],
|
|
63
|
+
backgroundColor: "#000"
|
|
64
|
+
};
|
|
65
|
+
class DesktopManager {
|
|
66
|
+
constructor(options = defaultDesktopOptions) {
|
|
67
|
+
this.options = options;
|
|
68
|
+
}
|
|
69
|
+
el;
|
|
70
|
+
state;
|
|
71
|
+
resizeObserver;
|
|
72
|
+
resizeCallbacks = /* @__PURE__ */ new Set();
|
|
73
|
+
init(el, options = this.options) {
|
|
74
|
+
this.options = options;
|
|
75
|
+
this.el = el;
|
|
76
|
+
this.state = this.state || {
|
|
77
|
+
icons: this.options.icons.map((icon) => icon.config)
|
|
78
|
+
};
|
|
79
|
+
this.setupResizeObserver();
|
|
80
|
+
this.render(el);
|
|
81
|
+
}
|
|
82
|
+
render(el) {
|
|
83
|
+
el.style.backgroundColor = this.options.backgroundColor;
|
|
84
|
+
if (this.options.backgroundImage) {
|
|
85
|
+
el.style.backgroundImage = `url(${this.options.backgroundImage})`;
|
|
86
|
+
}
|
|
87
|
+
if (this.options.backgroundImageSize) {
|
|
88
|
+
el.style.backgroundSize = this.options.backgroundImageSize || "cover";
|
|
89
|
+
}
|
|
90
|
+
if (this.options.backgroundRepeat) {
|
|
91
|
+
el.style.backgroundRepeat = this.options.backgroundRepeat || "no-repeat";
|
|
92
|
+
}
|
|
93
|
+
if (this.options.backgroundPosition) {
|
|
94
|
+
el.style.backgroundPosition = this.options.backgroundPosition || "center";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
addIcon(icon) {
|
|
98
|
+
this.options.icons.push(icon);
|
|
99
|
+
console.log(`Icon added: ${icon.config.name}`);
|
|
100
|
+
}
|
|
101
|
+
getDimensions() {
|
|
102
|
+
if (!this.el) {
|
|
103
|
+
throw new Error("Desktop not initialized. Call init() first.");
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
width: this.el.offsetWidth,
|
|
107
|
+
height: this.el.offsetHeight - taskbarManager.getDimensions().height
|
|
108
|
+
// destop is root element minus taskbar height
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
setupResizeObserver() {
|
|
112
|
+
if (!this.el) return;
|
|
113
|
+
if (this.resizeObserver) {
|
|
114
|
+
this.resizeObserver.disconnect();
|
|
115
|
+
}
|
|
116
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
117
|
+
const dimensions = this.getDimensions();
|
|
118
|
+
this.resizeCallbacks.forEach((callback) => {
|
|
119
|
+
try {
|
|
120
|
+
callback(dimensions);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error("Error in desktop resize callback:", error);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
this.resizeObserver.observe(this.el);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Register a callback for desktop resize events
|
|
130
|
+
* @param callback Function to call when desktop is resized
|
|
131
|
+
* @returns Unregister function to remove the callback
|
|
132
|
+
*/
|
|
133
|
+
onResize(callback) {
|
|
134
|
+
this.resizeCallbacks.add(callback);
|
|
135
|
+
return () => {
|
|
136
|
+
this.resizeCallbacks.delete(callback);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
globalThis.__defussDesktopManager = globalThis.__defussDesktopManager || new DesktopManager();
|
|
141
|
+
const desktopManager = globalThis.__defussDesktopManager;
|
|
142
|
+
|
|
25
143
|
const defaultWindowOptions = {
|
|
26
144
|
title: "Untitled",
|
|
27
145
|
resizable: true,
|
|
@@ -631,93 +749,6 @@ const LogonScreen = ({
|
|
|
631
749
|
] });
|
|
632
750
|
};
|
|
633
751
|
|
|
634
|
-
class DefussDesktopAppIcon {
|
|
635
|
-
constructor(config) {
|
|
636
|
-
this.config = config;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const defaultDesktopOptions = {
|
|
640
|
-
icons: [],
|
|
641
|
-
backgroundColor: "#000"
|
|
642
|
-
};
|
|
643
|
-
class DesktopManager {
|
|
644
|
-
constructor(options = defaultDesktopOptions) {
|
|
645
|
-
this.options = options;
|
|
646
|
-
}
|
|
647
|
-
el;
|
|
648
|
-
state;
|
|
649
|
-
resizeObserver;
|
|
650
|
-
resizeCallbacks = /* @__PURE__ */ new Set();
|
|
651
|
-
init(el, options = this.options) {
|
|
652
|
-
this.options = options;
|
|
653
|
-
this.el = el;
|
|
654
|
-
this.state = this.state || {
|
|
655
|
-
icons: this.options.icons.map((icon) => icon.config)
|
|
656
|
-
};
|
|
657
|
-
this.setupResizeObserver();
|
|
658
|
-
this.render(el);
|
|
659
|
-
}
|
|
660
|
-
render(el) {
|
|
661
|
-
el.style.backgroundColor = this.options.backgroundColor;
|
|
662
|
-
if (this.options.backgroundImage) {
|
|
663
|
-
el.style.backgroundImage = `url(${this.options.backgroundImage})`;
|
|
664
|
-
}
|
|
665
|
-
if (this.options.backgroundImageSize) {
|
|
666
|
-
el.style.backgroundSize = this.options.backgroundImageSize || "cover";
|
|
667
|
-
}
|
|
668
|
-
if (this.options.backgroundRepeat) {
|
|
669
|
-
el.style.backgroundRepeat = this.options.backgroundRepeat || "no-repeat";
|
|
670
|
-
}
|
|
671
|
-
if (this.options.backgroundPosition) {
|
|
672
|
-
el.style.backgroundPosition = this.options.backgroundPosition || "center";
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
addIcon(icon) {
|
|
676
|
-
this.options.icons.push(icon);
|
|
677
|
-
console.log(`Icon added: ${icon.config.name}`);
|
|
678
|
-
}
|
|
679
|
-
getDimensions() {
|
|
680
|
-
if (!this.el) {
|
|
681
|
-
throw new Error("Desktop not initialized. Call init() first.");
|
|
682
|
-
}
|
|
683
|
-
return {
|
|
684
|
-
width: this.el.offsetWidth,
|
|
685
|
-
height: this.el.offsetHeight - taskbarManager.getDimensions().height
|
|
686
|
-
// destop is root element minus taskbar height
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
setupResizeObserver() {
|
|
690
|
-
if (!this.el) return;
|
|
691
|
-
if (this.resizeObserver) {
|
|
692
|
-
this.resizeObserver.disconnect();
|
|
693
|
-
}
|
|
694
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
695
|
-
const dimensions = this.getDimensions();
|
|
696
|
-
this.resizeCallbacks.forEach((callback) => {
|
|
697
|
-
try {
|
|
698
|
-
callback(dimensions);
|
|
699
|
-
} catch (error) {
|
|
700
|
-
console.error("Error in desktop resize callback:", error);
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
this.resizeObserver.observe(this.el);
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Register a callback for desktop resize events
|
|
708
|
-
* @param callback Function to call when desktop is resized
|
|
709
|
-
* @returns Unregister function to remove the callback
|
|
710
|
-
*/
|
|
711
|
-
onResize(callback) {
|
|
712
|
-
this.resizeCallbacks.add(callback);
|
|
713
|
-
return () => {
|
|
714
|
-
this.resizeCallbacks.delete(callback);
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
globalThis.__defussDesktopManager = globalThis.__defussDesktopManager || new DesktopManager();
|
|
719
|
-
const desktopManager = globalThis.__defussDesktopManager;
|
|
720
|
-
|
|
721
752
|
const StartMenu = () => {
|
|
722
753
|
return /* @__PURE__ */ jsxs("div", { class: "slide-open crt", children: [
|
|
723
754
|
/* @__PURE__ */ jsx("div", { class: "top", children: /* @__PURE__ */ jsx("h1", { children: "Aron Homberg" }) }),
|
|
@@ -855,15 +886,12 @@ class DequeryWithWindowManager extends CallChainImpl {
|
|
|
855
886
|
*/
|
|
856
887
|
// register an app to the desktop shell
|
|
857
888
|
createDesktopApp(options) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
});
|
|
889
|
+
new DefussApp(options);
|
|
890
|
+
return this;
|
|
861
891
|
}
|
|
862
892
|
// create a desktop app icon
|
|
863
893
|
createDesktopAppIcon(options) {
|
|
864
|
-
return
|
|
865
|
-
return new DefussDesktopAppIcon(options);
|
|
866
|
-
});
|
|
894
|
+
return this;
|
|
867
895
|
}
|
|
868
896
|
}
|
|
869
897
|
const $ = dequery.extend(DequeryWithWindowManager, [
|
|
@@ -872,37 +900,6 @@ const $ = dequery.extend(DequeryWithWindowManager, [
|
|
|
872
900
|
"createDesktopAppIcon"
|
|
873
901
|
]);
|
|
874
902
|
|
|
875
|
-
const defaultTaskbarOptions = {
|
|
876
|
-
position: "bottom",
|
|
877
|
-
stateful: false,
|
|
878
|
-
theme: "default",
|
|
879
|
-
size: "medium"
|
|
880
|
-
};
|
|
881
|
-
class TaskbarManager {
|
|
882
|
-
position;
|
|
883
|
-
theme;
|
|
884
|
-
// e.g., 'windows-xp', 'macos', etc.
|
|
885
|
-
size;
|
|
886
|
-
constructor(options = defaultTaskbarOptions) {
|
|
887
|
-
this.position = options.position || "bottom";
|
|
888
|
-
this.theme = options.theme || "default";
|
|
889
|
-
this.size = options.size || "medium";
|
|
890
|
-
if (options.stateful) ;
|
|
891
|
-
}
|
|
892
|
-
getDimensions() {
|
|
893
|
-
const el = document.querySelector(".taskbar");
|
|
894
|
-
if (!el) {
|
|
895
|
-
return { width: 0, height: 0 };
|
|
896
|
-
}
|
|
897
|
-
return {
|
|
898
|
-
width: el.clientWidth,
|
|
899
|
-
height: el.clientHeight
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
globalThis.__defussTaskbarManager = globalThis.__defussTaskbarManager || new TaskbarManager();
|
|
904
|
-
const taskbarManager = globalThis.__defussTaskbarManager;
|
|
905
|
-
|
|
906
903
|
const defaultSystemSoundFilePaths = [
|
|
907
904
|
"/sounds/balloon.ogg",
|
|
908
905
|
"/sounds/batterycritical.ogg",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "defuss-desktop",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"type": "git"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"clean": "rm -rf ./dist && rm -rf ./node_modules/.
|
|
23
|
-
"pretest": "
|
|
24
|
-
"prebuild": "
|
|
22
|
+
"clean": "rm -rf ./dist && rm -rf ./node_modules/.bun",
|
|
23
|
+
"pretest": "bun run build",
|
|
24
|
+
"prebuild": "bun run clean",
|
|
25
25
|
"build": "pkgroll",
|
|
26
26
|
"postbuild": "npm run copy-scss",
|
|
27
27
|
"copy-scss": "mkdir -p dist/scss dist/themes && cp index.scss dist/ && cp xp.scss dist/ && cp -r scss/* dist/scss/ && cp -r themes/* dist/themes/",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"node": "^18.17.1 || ^20.3.0 || >=21.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"defuss": "
|
|
57
|
-
"defuss-runtime": "
|
|
58
|
-
"defuss-transval": "
|
|
56
|
+
"defuss": "^3.4.0",
|
|
57
|
+
"defuss-runtime": "^1.3.1",
|
|
58
|
+
"defuss-transval": "^1.3.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@vitest/coverage-v8": "^4.0.17",
|