web-window-manager 1.0.3 → 1.0.5
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 +155 -0
- package/package.json +1 -1
- package/lib/WindowManagerCache/index.d.ts +0 -29
- package/lib/WindowManagerCache/index.js +0 -87
- package/lib/index.d.ts +0 -65
- package/lib/index.js +0 -122
package/README.md
CHANGED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# TODO
|
|
2
|
+
- [x] Add appropriate readme boilerplate
|
|
3
|
+
- [ ] Add complete readme details
|
|
4
|
+
- [ ] Add examples
|
|
5
|
+
- [ ] abstract cache manager to new npm package
|
|
6
|
+
|
|
7
|
+
<br/>
|
|
8
|
+
|
|
9
|
+
# Web-Window-Manager
|
|
10
|
+
|
|
11
|
+
TODO: put descriptino here
|
|
12
|
+
|
|
13
|
+
### Badges
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/storybook-addon-next)
|
|
16
|
+
|
|
17
|
+
TODO: add release detials here
|
|
18
|
+
|
|
19
|
+
<div id="top"></div>
|
|
20
|
+
|
|
21
|
+
### Externals
|
|
22
|
+
|
|
23
|
+
[![Contributors][contributors-shield]][contributors-url]
|
|
24
|
+
[![Forks][forks-shield]][forks-url]
|
|
25
|
+
[![Stargazers][stars-shield]][stars-url]
|
|
26
|
+
[![Issues][issues-shield]][issues-url]
|
|
27
|
+
[![MIT License][license-shield]][license-url]
|
|
28
|
+
[![LinkedIn][linkedin-shield]][linkedin-url]
|
|
29
|
+
|
|
30
|
+
<!-- PROJECT LOGO -->
|
|
31
|
+
<br />
|
|
32
|
+
|
|
33
|
+
<!-- TABLE OF CONTENTS -->
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Table of Contents</summary>
|
|
36
|
+
<ol>
|
|
37
|
+
<li>
|
|
38
|
+
<a href="#about-the-project">About The Project</a>
|
|
39
|
+
<ul>
|
|
40
|
+
<li><a href="#built-with">Built With</a></li>
|
|
41
|
+
</ul>
|
|
42
|
+
</li>
|
|
43
|
+
<li>
|
|
44
|
+
<a href="#getting-started">Getting Started</a>
|
|
45
|
+
<ul>
|
|
46
|
+
<li><a href="#prerequisites">Prerequisites</a></li>
|
|
47
|
+
<li><a href="#installation">Installation</a></li>
|
|
48
|
+
</ul>
|
|
49
|
+
</li>
|
|
50
|
+
<li><a href="#usage">Usage</a></li>
|
|
51
|
+
<li><a href="#roadmap">Roadmap</a></li>
|
|
52
|
+
<li><a href="#contributing">Contributing</a></li>
|
|
53
|
+
<li><a href="#license">License</a></li>
|
|
54
|
+
<li><a href="#contact">Contact</a></li>
|
|
55
|
+
<li><a href="#acknowledgments">Acknowledgments</a></li>
|
|
56
|
+
</ol>
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
<br/>
|
|
60
|
+
|
|
61
|
+
<!-- ABOUT THE PROJECT -->
|
|
62
|
+
|
|
63
|
+
## About The Project
|
|
64
|
+
|
|
65
|
+
TODO: put about the project here
|
|
66
|
+
|
|
67
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
68
|
+
|
|
69
|
+
### Built With
|
|
70
|
+
|
|
71
|
+
- [TypeScript](https://www.typescriptlang.org/)
|
|
72
|
+
|
|
73
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
74
|
+
|
|
75
|
+
<!-- GETTING STARTED -->
|
|
76
|
+
|
|
77
|
+
## Getting Started
|
|
78
|
+
|
|
79
|
+
To get the package included in your project, follow these steps
|
|
80
|
+
|
|
81
|
+
### Installation
|
|
82
|
+
|
|
83
|
+
using [npm](https://www.npmjs.com/):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm i web-window-manager
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
90
|
+
|
|
91
|
+
<!-- USAGE EXAMPLES -->
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
TODO: Add how to use this package
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
_Check out the [examples](https://github.com/Tarmstrong95/WindowManger/tree/main/src/examples) folder for more details_
|
|
99
|
+
|
|
100
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
101
|
+
|
|
102
|
+
<hr>
|
|
103
|
+
|
|
104
|
+
See the [open issues](https://github.com/Tarmstrong95/WebWindowManager/issues) for a full list of proposed features (and known issues).
|
|
105
|
+
|
|
106
|
+
<!-- CONTRIBUTING -->
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
|
111
|
+
|
|
112
|
+
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
|
|
113
|
+
Don't forget to give the project a star! Thanks again!
|
|
114
|
+
|
|
115
|
+
1. Fork the Project
|
|
116
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
117
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
118
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
119
|
+
5. Open a Pull Request
|
|
120
|
+
|
|
121
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
122
|
+
|
|
123
|
+
<!-- LICENSE -->
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
Distributed under the MIT License. See `LICENSE.txt` for more information.
|
|
128
|
+
|
|
129
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
130
|
+
|
|
131
|
+
<!-- CONTACT -->
|
|
132
|
+
|
|
133
|
+
## Contact
|
|
134
|
+
|
|
135
|
+
Me - [@Triston08227721](https://twitter.com/Triston08227721) - triston95strong@gmail.com
|
|
136
|
+
|
|
137
|
+
Project Link: [https://github.com/Tarmstrong95/WebWindowManager](https://github.com/Tarmstrong95/WebWindowManager)
|
|
138
|
+
|
|
139
|
+
<p align="right">(<a href="#top">back to top</a>)</p>
|
|
140
|
+
|
|
141
|
+
<!-- MARKDOWN LINKS & IMAGES -->
|
|
142
|
+
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
|
|
143
|
+
|
|
144
|
+
[contributors-shield]: https://img.shields.io/github/contributors/Tarmstrong95/WebWindowManager.svg?style=for-the-badge
|
|
145
|
+
[contributors-url]: https://github.com/Tarmstrong95/WebWindowManager/graphs/contributors
|
|
146
|
+
[forks-shield]: https://img.shields.io/github/forks/Tarmstrong95/WebWindowManager.svg?style=for-the-badge
|
|
147
|
+
[forks-url]: https://github.com/Tarmstrong95/WebWindowManager/network/members
|
|
148
|
+
[stars-shield]: https://img.shields.io/github/stars/Tarmstrong95/WebWindowManager.svg?style=for-the-badge
|
|
149
|
+
[stars-url]: https://github.com/Tarmstrong95/WebWindowManager/stargazers
|
|
150
|
+
[issues-shield]: https://img.shields.io/github/issues/Tarmstrong95/WebWindowManager.svg?style=for-the-badge
|
|
151
|
+
[issues-url]: https://github.com/Tarmstrong95/WebWindowManager/issues
|
|
152
|
+
[license-shield]: https://img.shields.io/github/license/Tarmstrong95/WebWindowManager.svg?style=for-the-badge
|
|
153
|
+
[license-url]: https://github.com/Tarmstrong95/WebWindowManager/blob/main/LICENSE
|
|
154
|
+
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
|
|
155
|
+
[linkedin-url]: https://linkedin.com/in/triston95strong
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { CacheObject, WindowManagerCacheType } from './WindowManagerCache';
|
|
2
|
-
declare class WindowManagerCache extends Object implements WindowManagerCacheType {
|
|
3
|
-
#private;
|
|
4
|
-
constructor(win: Window);
|
|
5
|
-
removeItemFromCache(item: string): void;
|
|
6
|
-
addItemToCache(item: string): void;
|
|
7
|
-
getCache(): CacheObject;
|
|
8
|
-
init(): this;
|
|
9
|
-
/**
|
|
10
|
-
* Takes in an array of window names and sets the key of `this.#win.name` to the new array
|
|
11
|
-
* @param data an array of window names
|
|
12
|
-
*/
|
|
13
|
-
private hardSetCache;
|
|
14
|
-
/**
|
|
15
|
-
* sets the cache to an empty array
|
|
16
|
-
*/
|
|
17
|
-
private clearCache;
|
|
18
|
-
/**
|
|
19
|
-
* Adds a CacheObject to session storage for window name persistance
|
|
20
|
-
* @param data the CacheObject to update the browser cache to
|
|
21
|
-
*/
|
|
22
|
-
private updateStorage;
|
|
23
|
-
/**
|
|
24
|
-
* pulls the cache from session storage. If there is no cache, returns a falsy value
|
|
25
|
-
* @returns a CacheObject or undefined
|
|
26
|
-
*/
|
|
27
|
-
private getFromStorage;
|
|
28
|
-
}
|
|
29
|
-
export default WindowManagerCache;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _WindowManagerCache_dataKey, _WindowManagerCache_win, _WindowManagerCache_cache;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const lodash_1 = require("lodash");
|
|
16
|
-
class WindowManagerCache extends Object {
|
|
17
|
-
constructor(win) {
|
|
18
|
-
super();
|
|
19
|
-
_WindowManagerCache_dataKey.set(this, void 0);
|
|
20
|
-
_WindowManagerCache_win.set(this, void 0);
|
|
21
|
-
_WindowManagerCache_cache.set(this, void 0);
|
|
22
|
-
__classPrivateFieldSet(this, _WindowManagerCache_dataKey, 'window_manager_cache', "f");
|
|
23
|
-
__classPrivateFieldSet(this, _WindowManagerCache_win, win, "f");
|
|
24
|
-
__classPrivateFieldSet(this, _WindowManagerCache_cache, new Proxy({ [__classPrivateFieldGet(this, _WindowManagerCache_win, "f").name]: [] }, {
|
|
25
|
-
get: (target, property) => target[property],
|
|
26
|
-
set: (target, property, value) => {
|
|
27
|
-
target[property] = value;
|
|
28
|
-
this.updateStorage(target);
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}), "f");
|
|
32
|
-
}
|
|
33
|
-
removeItemFromCache(item) {
|
|
34
|
-
const cache = this.getCache();
|
|
35
|
-
if ((0, lodash_1.isEmpty)(cache))
|
|
36
|
-
return;
|
|
37
|
-
this.hardSetCache(cache[__classPrivateFieldGet(this, _WindowManagerCache_win, "f").name].filter(name => item !== name));
|
|
38
|
-
}
|
|
39
|
-
addItemToCache(item) {
|
|
40
|
-
const cache = this.getCache();
|
|
41
|
-
const temp = cache[__classPrivateFieldGet(this, _WindowManagerCache_win, "f").name];
|
|
42
|
-
cache[__classPrivateFieldGet(this, _WindowManagerCache_win, "f").name] = [...temp, item];
|
|
43
|
-
}
|
|
44
|
-
getCache() {
|
|
45
|
-
return __classPrivateFieldGet(this, _WindowManagerCache_cache, "f");
|
|
46
|
-
}
|
|
47
|
-
init() {
|
|
48
|
-
const cacheData = this.getFromStorage();
|
|
49
|
-
cacheData
|
|
50
|
-
? this.hardSetCache((0, lodash_1.get)(cacheData, __classPrivateFieldGet(this, _WindowManagerCache_win, "f").name, []))
|
|
51
|
-
: this.clearCache();
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Takes in an array of window names and sets the key of `this.#win.name` to the new array
|
|
56
|
-
* @param data an array of window names
|
|
57
|
-
*/
|
|
58
|
-
hardSetCache(data) {
|
|
59
|
-
__classPrivateFieldGet(this, _WindowManagerCache_cache, "f")[__classPrivateFieldGet(this, _WindowManagerCache_win, "f").name] = data;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* sets the cache to an empty array
|
|
63
|
-
*/
|
|
64
|
-
clearCache() {
|
|
65
|
-
this.hardSetCache([]);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Adds a CacheObject to session storage for window name persistance
|
|
69
|
-
* @param data the CacheObject to update the browser cache to
|
|
70
|
-
*/
|
|
71
|
-
updateStorage(data) {
|
|
72
|
-
sessionStorage.setItem(__classPrivateFieldGet(this, _WindowManagerCache_dataKey, "f"), JSON.stringify(data));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* pulls the cache from session storage. If there is no cache, returns a falsy value
|
|
76
|
-
* @returns a CacheObject or undefined
|
|
77
|
-
*/
|
|
78
|
-
getFromStorage() {
|
|
79
|
-
const data = sessionStorage.getItem(__classPrivateFieldGet(this, _WindowManagerCache_dataKey, "f"));
|
|
80
|
-
if (!data)
|
|
81
|
-
return;
|
|
82
|
-
const cache = JSON.parse(data);
|
|
83
|
-
return cache;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
_WindowManagerCache_dataKey = new WeakMap(), _WindowManagerCache_win = new WeakMap(), _WindowManagerCache_cache = new WeakMap();
|
|
87
|
-
exports.default = WindowManagerCache;
|
package/lib/index.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { WindowManagerType } from './WindowManager';
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
/**
|
|
5
|
-
* A window manager that keeps track of all open child windows, opened by this instance.
|
|
6
|
-
* It is responsible for traversing the tree of windows and closing from furthest depth first.
|
|
7
|
-
*
|
|
8
|
-
* This class will instantiate itself and attach itself to the window object on first import
|
|
9
|
-
*
|
|
10
|
-
* Add an import to your entry file like so:
|
|
11
|
-
* ``` typescript
|
|
12
|
-
* import 'PATH_TO_WINDOW_MANAGER'
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* Then use the managers available functions by accessing it via the window object
|
|
16
|
-
* ``` typescript
|
|
17
|
-
* window.WindowManager.CallFunction()
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example ``` typescript
|
|
21
|
-
* // you can use this when logging out if you want to ensure all child windows are closed
|
|
22
|
-
* const logout = () => {
|
|
23
|
-
* // do some stuff
|
|
24
|
-
* window.WindowManager.recursivelyCloseChildren()
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
WindowManager: WindowManager;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A window manager that keeps track of all open child windows, opened by this instance.
|
|
33
|
-
*/
|
|
34
|
-
declare class WindowManager implements WindowManagerType {
|
|
35
|
-
#private;
|
|
36
|
-
constructor(win: Window);
|
|
37
|
-
openWindow: ({ link, name }: {
|
|
38
|
-
link: string;
|
|
39
|
-
name?: string | undefined;
|
|
40
|
-
}) => void;
|
|
41
|
-
popThisWindowFromParent: (childWindowName: string) => void;
|
|
42
|
-
recursivelyCloseChildren: (id?: number) => void;
|
|
43
|
-
newUnloadCallback(cb: () => void): void;
|
|
44
|
-
init: () => this;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the length of `this.#children` and type casts it to boolean
|
|
47
|
-
* @returns boolean
|
|
48
|
-
*/
|
|
49
|
-
private get hasChildren();
|
|
50
|
-
/**
|
|
51
|
-
* Calls `this.#win.close()` on this instance to close itself
|
|
52
|
-
*/
|
|
53
|
-
private close;
|
|
54
|
-
/**
|
|
55
|
-
* Takes a window reference and adds it
|
|
56
|
-
*/
|
|
57
|
-
private setChild;
|
|
58
|
-
/**
|
|
59
|
-
* Removes this window from the parent window's window manager.
|
|
60
|
-
* It calls each callback assigned to `this.#onUnloadCallbacks`
|
|
61
|
-
*/
|
|
62
|
-
private handleUnload;
|
|
63
|
-
}
|
|
64
|
-
declare const NewWindowManagerInstance: WindowManager;
|
|
65
|
-
export default NewWindowManagerInstance;
|
package/lib/index.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _WindowManager_win, _WindowManager_newWindowDetails, _WindowManager_children, _WindowManager_windowManagerCache, _WindowManager_onUnloadCallbacks, _WindowManager_parent;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const WindowManagerCache_1 = require("./WindowManagerCache");
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
17
|
-
/**
|
|
18
|
-
* A window manager that keeps track of all open child windows, opened by this instance.
|
|
19
|
-
*/
|
|
20
|
-
class WindowManager {
|
|
21
|
-
constructor(win) {
|
|
22
|
-
_WindowManager_win.set(this, void 0);
|
|
23
|
-
_WindowManager_newWindowDetails.set(this, void 0);
|
|
24
|
-
_WindowManager_children.set(this, void 0);
|
|
25
|
-
_WindowManager_windowManagerCache.set(this, void 0);
|
|
26
|
-
_WindowManager_onUnloadCallbacks.set(this, void 0);
|
|
27
|
-
_WindowManager_parent.set(this, void 0);
|
|
28
|
-
this.openWindow = ({ link, name }) => {
|
|
29
|
-
var _a, _b, _c;
|
|
30
|
-
const childWindow = __classPrivateFieldGet(this, _WindowManager_win, "f").open(link, name || link, `
|
|
31
|
-
width=${__classPrivateFieldGet(this, _WindowManager_newWindowDetails, "f").WIDTH},
|
|
32
|
-
height=${__classPrivateFieldGet(this, _WindowManager_newWindowDetails, "f").HEIGHT},
|
|
33
|
-
left=${__classPrivateFieldGet(this, _WindowManager_newWindowDetails, "f").LEFT},
|
|
34
|
-
top=${__classPrivateFieldGet(this, _WindowManager_newWindowDetails, "f").TOP},
|
|
35
|
-
resizable=yes,
|
|
36
|
-
scrollbars=yes
|
|
37
|
-
`);
|
|
38
|
-
if (!childWindow)
|
|
39
|
-
return;
|
|
40
|
-
this.setChild(childWindow);
|
|
41
|
-
if (link)
|
|
42
|
-
return (_a = __classPrivateFieldGet(this, _WindowManager_windowManagerCache, "f")) === null || _a === void 0 ? void 0 : _a.addItemToCache(childWindow.name);
|
|
43
|
-
if (((_b = childWindow.document) === null || _b === void 0 ? void 0 : _b.URL) !== 'about:blank')
|
|
44
|
-
return;
|
|
45
|
-
childWindow.close();
|
|
46
|
-
(_c = __classPrivateFieldGet(this, _WindowManager_windowManagerCache, "f")) === null || _c === void 0 ? void 0 : _c.removeItemFromCache(name);
|
|
47
|
-
};
|
|
48
|
-
this.popThisWindowFromParent = (childWindowName) => {
|
|
49
|
-
var _a;
|
|
50
|
-
__classPrivateFieldSet(this, _WindowManager_children, (0, lodash_1.remove)(__classPrivateFieldGet(this, _WindowManager_children, "f"), kid => kid.name !== childWindowName), "f");
|
|
51
|
-
(_a = __classPrivateFieldGet(this, _WindowManager_windowManagerCache, "f")) === null || _a === void 0 ? void 0 : _a.removeItemFromCache(childWindowName);
|
|
52
|
-
};
|
|
53
|
-
this.recursivelyCloseChildren = (id = 0) => {
|
|
54
|
-
if (this.hasChildren) {
|
|
55
|
-
const copy = [...__classPrivateFieldGet(this, _WindowManager_children, "f")];
|
|
56
|
-
(0, lodash_1.forEachRight)(copy, child => {
|
|
57
|
-
var _a;
|
|
58
|
-
(_a = child === null || child === void 0 ? void 0 : child.WindowManager) === null || _a === void 0 ? void 0 : _a.recursivelyCloseChildren(id + 1);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (!id)
|
|
62
|
-
return;
|
|
63
|
-
this.close();
|
|
64
|
-
};
|
|
65
|
-
this.init = () => {
|
|
66
|
-
window.addEventListener('beforeunload', e => this.handleUnload());
|
|
67
|
-
__classPrivateFieldGet(this, _WindowManager_win, "f").WindowManager = this;
|
|
68
|
-
if (!__classPrivateFieldGet(this, _WindowManager_win, "f").name)
|
|
69
|
-
__classPrivateFieldGet(this, _WindowManager_win, "f").name = 'main';
|
|
70
|
-
__classPrivateFieldSet(this, _WindowManager_windowManagerCache, new WindowManagerCache_1.default(__classPrivateFieldGet(this, _WindowManager_win, "f")).init(), "f");
|
|
71
|
-
(0, lodash_1.forEach)(__classPrivateFieldGet(this, _WindowManager_windowManagerCache, "f").getCache()[__classPrivateFieldGet(this, _WindowManager_win, "f").name], name => this.openWindow({ link: '', name }));
|
|
72
|
-
return this;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Calls `this.#win.close()` on this instance to close itself
|
|
76
|
-
*/
|
|
77
|
-
this.close = () => {
|
|
78
|
-
const p = __classPrivateFieldGet(this, _WindowManager_parent, "f");
|
|
79
|
-
if (!!p)
|
|
80
|
-
p.WindowManager.popThisWindowFromParent(__classPrivateFieldGet(this, _WindowManager_win, "f").name);
|
|
81
|
-
__classPrivateFieldGet(this, _WindowManager_win, "f").close();
|
|
82
|
-
};
|
|
83
|
-
__classPrivateFieldSet(this, _WindowManager_win, win, "f");
|
|
84
|
-
__classPrivateFieldSet(this, _WindowManager_parent, win.opener, "f");
|
|
85
|
-
__classPrivateFieldSet(this, _WindowManager_children, [], "f");
|
|
86
|
-
__classPrivateFieldSet(this, _WindowManager_onUnloadCallbacks, [], "f");
|
|
87
|
-
__classPrivateFieldSet(this, _WindowManager_newWindowDetails, {
|
|
88
|
-
WIDTH: 900,
|
|
89
|
-
HEIGHT: 600,
|
|
90
|
-
LEFT: 0,
|
|
91
|
-
RIGHT: 0
|
|
92
|
-
}, "f");
|
|
93
|
-
}
|
|
94
|
-
newUnloadCallback(cb) {
|
|
95
|
-
__classPrivateFieldGet(this, _WindowManager_onUnloadCallbacks, "f").push(cb);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Gets the length of `this.#children` and type casts it to boolean
|
|
99
|
-
* @returns boolean
|
|
100
|
-
*/
|
|
101
|
-
get hasChildren() {
|
|
102
|
-
return !!__classPrivateFieldGet(this, _WindowManager_children, "f").length;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Takes a window reference and adds it
|
|
106
|
-
*/
|
|
107
|
-
setChild(child) {
|
|
108
|
-
__classPrivateFieldSet(this, _WindowManager_children, [...new Set([...__classPrivateFieldGet(this, _WindowManager_children, "f"), child])].filter(kid => !kid.closed), "f");
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Removes this window from the parent window's window manager.
|
|
112
|
-
* It calls each callback assigned to `this.#onUnloadCallbacks`
|
|
113
|
-
*/
|
|
114
|
-
handleUnload() {
|
|
115
|
-
__classPrivateFieldGet(this, _WindowManager_parent, "f").WindowManager.popThisWindowFromParent(__classPrivateFieldGet(this, _WindowManager_win, "f").name);
|
|
116
|
-
(0, lodash_1.forEach)(__classPrivateFieldGet(this, _WindowManager_onUnloadCallbacks, "f"), cb => cb());
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
_WindowManager_win = new WeakMap(), _WindowManager_newWindowDetails = new WeakMap(), _WindowManager_children = new WeakMap(), _WindowManager_windowManagerCache = new WeakMap(), _WindowManager_onUnloadCallbacks = new WeakMap(), _WindowManager_parent = new WeakMap();
|
|
120
|
-
const NewWindowManagerInstance = new WindowManager(window).init();
|
|
121
|
-
window.WindowManager = NewWindowManagerInstance;
|
|
122
|
-
exports.default = NewWindowManagerInstance;
|