this.gui 0.0.0 → 0.0.2
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 +15 -0
- package/babel.config.json +3 -0
- package/index.js +0 -0
- package/jsdoc.json +53 -0
- package/package.json +44 -23
- package/tsconfig.json +19 -0
- package/typedoc.json +13 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -38
- package/public/manifest.json +0 -15
- package/src/App.tsx +0 -22
- package/src/components/AvatarWithStatus.tsx +0 -26
- package/src/components/ChatBubble.tsx +0 -135
- package/src/components/ChatListItem.tsx +0 -87
- package/src/components/ChatsPane.tsx +0 -110
- package/src/components/ColorSchemeToggle.tsx +0 -61
- package/src/components/Header.tsx +0 -47
- package/src/components/MessageInput.tsx +0 -97
- package/src/components/MessagesPane.tsx +0 -87
- package/src/components/MessagesPaneHeader.tsx +0 -105
- package/src/components/MuiLogo.tsx +0 -34
- package/src/components/MyMessages.tsx +0 -49
- package/src/components/Sidebar.tsx +0 -320
- package/src/createServiceWorker.js +0 -52
- package/src/data.tsx +0 -272
- package/src/index.tsx +0 -12
- package/src/package.json +0 -22
- package/src/public/index.html +0 -22
- package/src/tsconfig.json +0 -25
- package/src/types.tsx +0 -25
- package/src/useScript.ts +0 -101
- package/src/utils.ts +0 -53
package/src/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"allowSyntheticDefaultImports": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"module": "esnext",
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"noEmit": true,
|
|
20
|
-
"jsx": "react"
|
|
21
|
-
},
|
|
22
|
-
"include": [
|
|
23
|
-
"src"
|
|
24
|
-
]
|
|
25
|
-
}
|
package/src/types.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type UserProps = {
|
|
2
|
-
name: string;
|
|
3
|
-
username: string;
|
|
4
|
-
avatar: string;
|
|
5
|
-
online: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type MessageProps = {
|
|
9
|
-
id: string;
|
|
10
|
-
content: string;
|
|
11
|
-
timestamp: string;
|
|
12
|
-
unread?: boolean;
|
|
13
|
-
sender: UserProps | 'You';
|
|
14
|
-
attachment?: {
|
|
15
|
-
fileName: string;
|
|
16
|
-
type: string;
|
|
17
|
-
size: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ChatProps = {
|
|
22
|
-
id: string;
|
|
23
|
-
sender: UserProps;
|
|
24
|
-
messages: MessageProps[];
|
|
25
|
-
};
|
package/src/useScript.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export type UseScriptStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
4
|
-
|
|
5
|
-
// Cached script statuses
|
|
6
|
-
const cachedScriptStatuses: Record<string, UseScriptStatus | undefined> = {};
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Simplified version of https://usehooks-ts.com/react-hook/use-script
|
|
10
|
-
*/
|
|
11
|
-
function getScriptNode(src: string) {
|
|
12
|
-
const node: HTMLScriptElement | null = document.querySelector(`script[src="${src}"]`);
|
|
13
|
-
const status = node?.getAttribute('data-status') as UseScriptStatus | undefined;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
node,
|
|
17
|
-
status,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function useScript(src: string): UseScriptStatus {
|
|
22
|
-
const [status, setStatus] = React.useState<UseScriptStatus>(() => {
|
|
23
|
-
if (typeof window === 'undefined') {
|
|
24
|
-
// SSR Handling - always return 'loading'
|
|
25
|
-
return 'loading';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return cachedScriptStatuses[src] ?? 'loading';
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
const cachedScriptStatus = cachedScriptStatuses[src];
|
|
33
|
-
if (cachedScriptStatus === 'ready' || cachedScriptStatus === 'error') {
|
|
34
|
-
// If the script is already cached, set its status immediately
|
|
35
|
-
setStatus(cachedScriptStatus);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Fetch existing script element by src
|
|
40
|
-
// It may have been added by another instance of this hook
|
|
41
|
-
const script = getScriptNode(src);
|
|
42
|
-
let scriptNode = script.node;
|
|
43
|
-
|
|
44
|
-
if (!scriptNode) {
|
|
45
|
-
// Create script element and add it to document body
|
|
46
|
-
scriptNode = document.createElement('script');
|
|
47
|
-
scriptNode.src = src;
|
|
48
|
-
scriptNode.async = true;
|
|
49
|
-
scriptNode.setAttribute('data-status', 'loading');
|
|
50
|
-
document.body.appendChild(scriptNode);
|
|
51
|
-
|
|
52
|
-
// Store status in attribute on script
|
|
53
|
-
// This can be read by other instances of this hook
|
|
54
|
-
const setAttributeFromEvent = (event: Event) => {
|
|
55
|
-
const scriptStatus: UseScriptStatus = event.type === 'load' ? 'ready' : 'error';
|
|
56
|
-
|
|
57
|
-
scriptNode?.setAttribute('data-status', scriptStatus);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
scriptNode.addEventListener('load', setAttributeFromEvent);
|
|
61
|
-
scriptNode.addEventListener('error', setAttributeFromEvent);
|
|
62
|
-
} else {
|
|
63
|
-
// Grab existing script status from attribute and set to state.
|
|
64
|
-
setStatus(script.status ?? cachedScriptStatus ?? 'loading');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Script event handler to update status in state
|
|
68
|
-
// Note: Even if the script already exists we still need to add
|
|
69
|
-
// event handlers to update the state for *this* hook instance.
|
|
70
|
-
const setStateFromEvent = (event: Event) => {
|
|
71
|
-
const newStatus = event.type === 'load' ? 'ready' : 'error';
|
|
72
|
-
setStatus(newStatus);
|
|
73
|
-
cachedScriptStatuses[src] = newStatus;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Add event listeners
|
|
77
|
-
scriptNode.addEventListener('load', setStateFromEvent);
|
|
78
|
-
scriptNode.addEventListener('error', setStateFromEvent);
|
|
79
|
-
|
|
80
|
-
// Remove event listeners on cleanup
|
|
81
|
-
// eslint-disable-next-line consistent-return
|
|
82
|
-
return () => {
|
|
83
|
-
if (scriptNode) {
|
|
84
|
-
scriptNode.removeEventListener('load', setStateFromEvent);
|
|
85
|
-
scriptNode.removeEventListener('error', setStateFromEvent);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (scriptNode) {
|
|
89
|
-
try {
|
|
90
|
-
scriptNode.remove();
|
|
91
|
-
} catch (error) {
|
|
92
|
-
// ignore error
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}, [src]);
|
|
97
|
-
|
|
98
|
-
return status;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default useScript;
|
package/src/utils.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export const openSidebar = () => {
|
|
2
|
-
if (typeof document !== 'undefined') {
|
|
3
|
-
document.body.style.overflow = 'hidden';
|
|
4
|
-
document.documentElement.style.setProperty('--SideNavigation-slideIn', '1');
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const closeSidebar = () => {
|
|
9
|
-
if (typeof document !== 'undefined') {
|
|
10
|
-
document.documentElement.style.removeProperty('--SideNavigation-slideIn');
|
|
11
|
-
document.body.style.removeProperty('overflow');
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const toggleSidebar = () => {
|
|
16
|
-
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
17
|
-
const slideIn = window
|
|
18
|
-
.getComputedStyle(document.documentElement)
|
|
19
|
-
.getPropertyValue('--SideNavigation-slideIn');
|
|
20
|
-
if (slideIn) {
|
|
21
|
-
closeSidebar();
|
|
22
|
-
} else {
|
|
23
|
-
openSidebar();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const openMessagesPane = () => {
|
|
29
|
-
if (typeof document !== 'undefined') {
|
|
30
|
-
document.body.style.overflow = 'hidden';
|
|
31
|
-
document.documentElement.style.setProperty('--MessagesPane-slideIn', '1');
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const closeMessagesPane = () => {
|
|
36
|
-
if (typeof document !== 'undefined') {
|
|
37
|
-
document.documentElement.style.removeProperty('--MessagesPane-slideIn');
|
|
38
|
-
document.body.style.removeProperty('overflow');
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const toggleMessagesPane = () => {
|
|
43
|
-
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
44
|
-
const slideIn = window
|
|
45
|
-
.getComputedStyle(document.documentElement)
|
|
46
|
-
.getPropertyValue('--MessagesPane-slideIn');
|
|
47
|
-
if (slideIn) {
|
|
48
|
-
closeMessagesPane();
|
|
49
|
-
} else {
|
|
50
|
-
openMessagesPane();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|