[update] Comfyui + react

This commit is contained in:
kim98828 2024-07-12 11:58:15 +09:00
parent 71e3b17ad4
commit f10f2fb722
52 changed files with 21563 additions and 0 deletions

View File

@ -0,0 +1,3 @@
.idea
app/build
app/node_modules

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,17 @@
# ComfyUI-React-SDK
# 🚦 WIP 🚦
This project is for building React application as an overlay upon ComfyUI.
Providing an ability to run custom UI levraging ComfyUI API and workflows.
Inspired by: https://github.com/cubiq/Comfy_Dungeon
## Getting started
To view the demo of this repo, just clone it to custom_nodes, restart comfy and enter the browser at \<your-comfy-url>/root.
### Example screen shot
![pic](.meta/screen-shot.png)

View File

@ -0,0 +1,23 @@
from .base import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
import os
import server
from aiohttp import web
# Set your web app name here, this will result access to it via <compfy-url>/<your-app-name>
# Note! you shoud set the same value in app/.env file for react app to build to the same path!.
APP_NAME="root" # <- CHANGE ME
WEBROOT = os.path.join(os.path.dirname(os.path.realpath(__file__)), "web")
APP_ROOT_URI="/"+APP_NAME
@server.PromptServer.instance.routes.get(APP_ROOT_URI)
def entrance(request):
return web.FileResponse(os.path.join(WEBROOT, "index.html"))
server.PromptServer.instance.routes.static(APP_ROOT_URI+"/static/css/", path=os.path.join(WEBROOT, "static/css"))
server.PromptServer.instance.routes.static(APP_ROOT_URI+"/static/js/", path=os.path.join(WEBROOT, "static/js"))
# server.PromptServer.instance.routes.static(APP_ROOT_URI+"/static/media/", path=os.path.join(WEBROOT, "static/media"))
server.PromptServer.instance.routes.static(APP_ROOT_URI,WEBROOT)
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']

View File

@ -0,0 +1,3 @@
PUBLIC_URL=/root
BUILD_PATH=../web
; WDS_SOCKET_PATH=wsreact # not working yet!

View File

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.idea
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
./build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@ -0,0 +1,46 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).

View File

@ -0,0 +1,8 @@
// module.exports = function override(config, env) {
// config.webSocketServer = config.webSocketServer || {}
// config.webSocketServer.options = {
// ...config.webSocketServer.options,
// path: process.env.WDS_SOCKET_PATH,
// }
// return config
// }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.16.1",
"@mui/material": "^5.16.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.89",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"axios": "^1.6.7",
"framer-motion": "^11.0.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"http-proxy-middleware": "^2.0.6",
"react-app-rewired": "^2.2.1"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "SoulxLogo.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "SoulxLogo.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -0,0 +1,38 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@ -0,0 +1,8 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -0,0 +1,19 @@
import React from 'react';
import './App.css';
import Dashboard from './dashboard/dashboard';
import { ComfyProvider } from './comfy/ComfyProvider';
interface AppProps {
colorMode: 'light' | 'dark';
setColorMode: React.Dispatch<React.SetStateAction<'light' | 'dark'>>;
}
const App: React.FC<AppProps> = ({ colorMode, setColorMode }) => {
return (
<ComfyProvider>
<Dashboard colorMode={colorMode} setColorMode={setColorMode} />
</ComfyProvider>
);
};
export default App;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,69 @@
import React, {createContext, useContext, useState, ReactNode, useEffect} from 'react';
import axios from "axios";
import {DashboardGenParams, GetWebSocket, Root, WORKFLOW} from "./api";
interface DataContextProps {
fetchCheckpoints: () => Promise<string[][]>;
queuePrompt: (params: DashboardGenParams) => Promise<any>;
}
const DataContext = createContext<DataContextProps | undefined>(undefined);
interface DataProviderProps {
children: ReactNode;
}
const fetchCheckpoints = async () => {
// Implement your API fetching logic here
return axios.get<Root>('object_info/CheckpointLoaderSimple', {
headers: {
'Content-Type': 'application/json'
}
}).then(res=>{
return res.data.CheckpointLoaderSimple.input.required.ckpt_name;
})
};
export const ComfyProvider: React.FC<DataProviderProps> = ({ children }) => {
useEffect(() => {
GetWebSocket()
}, []);
const queuePrompt = async (params: DashboardGenParams) => {
console.log(params)
WORKFLOW["3"].inputs.seed = params.seed
WORKFLOW["3"].inputs.cfg = params.cfg
WORKFLOW["3"].inputs.steps = params.steps
WORKFLOW["4"].inputs.ckpt_name = params.checkpoint
WORKFLOW["5"].inputs.height = params.height
WORKFLOW["5"].inputs.width = params.width
WORKFLOW["6"].inputs.text = params.positivePrompt
WORKFLOW["7"].inputs.text = params.negativePrompt
const data = { 'prompt': WORKFLOW, 'client_id': "1122"};
const response = await fetch('/prompt', {
method: 'POST',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
return response.json();
}
return (
<DataContext.Provider value={{fetchCheckpoints ,queuePrompt}}>
{children}
</DataContext.Provider>
);
};
export const useComfy = (): DataContextProps => {
const context = useContext(DataContext);
if (!context) {
throw new Error('useData must be used within a DataProvider');
}
return context;
};

View File

@ -0,0 +1,186 @@
export const WS_MESSAGE_TYPE_EXECUTING="executing"
export const WS_MESSAGE_TYPE_EXECUTED="executed"
export const WS_MESSAGE_TYPE_STATUS="status"
export const WS_MESSAGE_TYPE_PROGRESS="progress"
export const WS_MESSAGE_TYPE_EXECUTION_START="execution_start"
export const WS_MESSAGE_TYPE_EXECUTION_CACHED="execution_cached"
interface Callbacks {
[key: string]: (message: any) => void;
}
const subscribers: Callbacks = {}
let webseocket: WebSocket
export function Subscribe(key: string, callback:(message: any) => void){
subscribers[key] = callback
}
export function UnSubscribe(key: string){
delete subscribers[key];
}
export function GetWebSocket(){
if (webseocket) {
return webseocket
}
let { hostname, port } = window.location;
if(process.env.NODE_ENV === "development"){ // temp fix until more normal way to proxy web socket.
hostname = "localhost"
port = "8188"
}
webseocket = new WebSocket("ws://"+hostname+":"+port+"/ws?clientId=1122");
// Define event handlers for the WebSocket connection
webseocket.onopen = () => {
console.log('WebSocket connected');
};
webseocket.onmessage = (event) =>{
Object.entries(subscribers).forEach(([key, callback]) => {
callback(event); // Call the function
});
}
webseocket.onclose = () => {
console.log('WebSocket disconnected');
};
return webseocket
}
export interface DashboardGenParams {
cfg: number
steps: number
seed: number
checkpoint: string
height: number
width: number
positivePrompt: string
negativePrompt: string
}
export interface Root {
CheckpointLoaderSimple: CheckpointLoaderSimple
}
export interface Input {
required: Required
}
export interface Required {
ckpt_name: string[][]
}
export interface CheckpointLoaderSimple {
input: Input
output: string[]
output_is_list: boolean[]
output_name: string[]
name: string
display_name: string
description: string
category: string
output_node: boolean
}
// #This is the ComfyUI api prompt format.
//
// #If you want it for a specific workflow you can "enable dev mode options"
// #in the settings of the UI (gear beside the "Queue Size: ") this will enable
// #a button on the UI to save workflows in api format.
//
// #keep in mind ComfyUI is pre alpha software so this format will change a bit.
//
// #this is the one for the default workflow
export const WORKFLOW =
{
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 3,
"denoise": 1,
"latent_image": [
"5",
0
],
"model": [
"4",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": Math.round(Math.random()*100000),
"steps": 5
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "DreamShaperXL_Turbo_v2_1.safetensors"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": 1024,
"width": 1024
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "masterpiece best quality fish"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "bad hands"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"4",
2
]
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
}
}
};

View File

@ -0,0 +1,47 @@
import React, { useEffect } from 'react';
import { IconButton } from '@mui/material';
import { Brightness4 as MoonIcon, Brightness7 as SunIcon } from '@mui/icons-material';
import { useTheme } from '@mui/material/styles';
import { useMediaQuery } from '@mui/material';
interface ToggleColorModeProps {
colorMode: 'light' | 'dark';
setColorMode: React.Dispatch<React.SetStateAction<'light' | 'dark'>>;
}
const ToggleColorMode: React.FC<ToggleColorModeProps> = ({ colorMode, setColorMode }) => {
const theme = useTheme();
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
useEffect(() => {
setColorMode(prefersDarkMode ? 'dark' : 'light');
}, [prefersDarkMode, setColorMode]);
const toggleColorMode = () => {
setColorMode(prevMode => (prevMode === 'light' ? 'dark' : 'light'));
};
useEffect(() => {
document.body.style.backgroundColor = colorMode === 'dark'
? theme.palette.background.default
: '#fff';
}, [colorMode, theme.palette.background.default]);
return (
<IconButton
onClick={toggleColorMode}
style={{
position: 'absolute',
top: '0',
right: '0',
margin: '1rem',
color:colorMode === 'dark' ? 'white' : 'inherit',
}}
>
{colorMode === 'dark' ? <SunIcon /> : <MoonIcon />}
</IconButton>
);
};
export default ToggleColorMode;

View File

@ -0,0 +1,174 @@
import React, { useEffect, useState } from 'react';
import { useComfy } from '../comfy/ComfyProvider';
import {
Box,
Button,
Select,
MenuItem,
Stack,
TextField,
LinearProgress,
FormControl,
FormLabel,
FormControlLabel,
Checkbox,
Slider,
useTheme,
} from '@mui/material';
import { Subscribe, UnSubscribe, WS_MESSAGE_TYPE_EXECUTED, WS_MESSAGE_TYPE_PROGRESS } from '../comfy/api';
import { base } from './image';
import ToggleColorMode from './ToggleColorMode';
import { Image } from '@mui/icons-material';
interface DashboardProps {
colorMode: 'light' | 'dark';
setColorMode: React.Dispatch<React.SetStateAction<'light' | 'dark'>>;
}
const Dashboard: React.FC<DashboardProps> = ({ colorMode, setColorMode }) => {
const theme = useTheme();
const { queuePrompt, fetchCheckpoints } = useComfy();
const [rand, setRand] = useState<number>(Math.random());
const [image, setImage] = useState<string | null>(null);
const [checkpoints, setCheckpoints] = useState<string[]>([]); // 수정된 부분
const [selectedCheckpoint, setSelectedCheckpoint] = useState<string>('');
const [cfg, setCfg] = useState(5);
const [steps, setSteps] = useState(25);
const [seed, setSeed] = useState(Math.round(Math.random() * Number.MAX_SAFE_INTEGER));
const [randomSeed, setRandomSeed] = useState(true);
const [height, setHeight] = useState(512);
const [width, setWidth] = useState(512);
const [positivePrompt, setPositivePrompt] = useState('');
const [negativePrompt, setNegativePrompt] = useState('');
const [inProgress, setInProgress] = useState(false);
const [progress, setProgress] = useState(0);
useEffect(() => {
updateCheckpoint();
Subscribe('dashboard', (event) => {
const message = JSON.parse(event.data);
if (message.type === WS_MESSAGE_TYPE_EXECUTED) {
setRand(Math.random());
setImage(message.data.output.images[0].filename);
setInProgress(false);
setProgress(0);
} else if (message.type === WS_MESSAGE_TYPE_PROGRESS) {
setProgress(Math.floor((message.data.value / message.data.max) * 100));
}
});
return () => {
UnSubscribe('dashboard');
};
}, []);
const updateCheckpoint = () => {
fetchCheckpoints().then((fetchedCheckpoints) => {
setCheckpoints(fetchedCheckpoints[0]); // 수정된 부분
});
};
const generate = () => {
if (!selectedCheckpoint) {
alert('No Checkpoint is selected');
return;
}
queuePrompt({
cfg,
steps,
seed,
checkpoint: selectedCheckpoint,
height,
width,
positivePrompt,
negativePrompt,
}).then((res) => {
if (res.prompt_id) {
alert(`Prompt Submitted: ${res.prompt_id}`);
setInProgress(true);
}
});
if (randomSeed) {
setSeed(Math.round(Math.random() * Number.MAX_SAFE_INTEGER));
}
};
return (
<div>
<Stack direction="row" spacing={2} style={{ width: '100%' }}>
<Box flex="1" style={{ padding: '20px' }}>
<Stack direction="column" spacing={6} style={{ marginTop: '5vh' }}>
<ToggleColorMode colorMode={colorMode} setColorMode={setColorMode} />
<img src='./SoulxLogo.png'/>
<FormControl fullWidth>
<Select value={selectedCheckpoint} onChange={(e) => setSelectedCheckpoint(e.target.value)} displayEmpty>
<MenuItem value="" disabled>Select Checkpoint</MenuItem>
{checkpoints.map((option, index) => (
<MenuItem key={index} value={option}>{option}</MenuItem>
))}
</Select>
</FormControl>
<FormControl>
<FormLabel>CFG ({cfg})</FormLabel>
<Slider value={cfg} min={1} max={10} step={0.5} onChange={(e, value) => setCfg(value as number)} valueLabelDisplay="auto" />
</FormControl>
<FormControl>
<FormLabel>Steps ({steps})</FormLabel>
<Slider value={steps} min={1} max={100} step={1} onChange={(e, value) => setSteps(value as number)} valueLabelDisplay="auto" />
</FormControl>
<Stack direction="row" spacing={5}>
<TextField
label="Seed"
type="number"
value={seed}
onChange={(e) => setSeed(Number(e.target.value))}
InputProps={{ inputProps: { min: 1, max: Number.MAX_SAFE_INTEGER } }}
fullWidth
/>
<FormControlLabel
control={<Checkbox checked={randomSeed} onChange={(e) => setRandomSeed(e.target.checked)} />}
label="Random Seed"
/>
</Stack>
<Stack direction="row" spacing={5}>
<TextField label="Height" type="number" value={height} onChange={(e) => setHeight(Number(e.target.value))} fullWidth />
<TextField label="Width" type="number" value={width} onChange={(e) => setWidth(Number(e.target.value))} fullWidth />
</Stack>
<TextField label="Positive Prompt" multiline rows={4} value={positivePrompt} onChange={(e) => setPositivePrompt(e.target.value)} fullWidth />
<TextField label="Negative Prompt" multiline rows={4} value={negativePrompt} onChange={(e) => setNegativePrompt(e.target.value)} fullWidth />
<Button variant="contained" color="primary" onClick={generate}>Generate</Button>
{inProgress && <LinearProgress variant="determinate" value={progress} />}
</Stack>
</Box>
<Box flex="2" display="flex" alignItems="center" justifyContent="center" height="100vh">
<Box
component="div"
minWidth="80%"
maxWidth="80%"
border="2px solid black"
p="4"
borderRadius="md"
style={{ aspectRatio: '1/1' }}
>
{image ? (
<img
src={`/view?filename=${image}&type=output&rand=${rand}`}
alt=""
style={{ width: '100%', height: '100%', objectFit: 'contain' }}
/>
) : (
<img src={base} alt="Red dot" style={{ width: '100%', height: '100%', objectFit: 'contain' }} />
)}
</Box>
</Box>
<Box flex="1"></Box>
</Stack>
</div>
);
};
export default Dashboard;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View File

@ -0,0 +1,41 @@
import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { ThemeProvider } from '@mui/material/styles';
import { lightTheme, darkTheme } from './theme';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
const Index: React.FC = () => {
const [colorMode, setColorMode] = useState<'light' | 'dark'>('light');
useEffect(() => {
const savedMode = localStorage.getItem('colorMode') as 'light' | 'dark';
setColorMode(savedMode ? savedMode : 'light');
}, []);
useEffect(() => {
localStorage.setItem('colorMode', colorMode);
}, [colorMode]);
const theme = colorMode === 'dark' ? darkTheme : lightTheme;
return (
<ThemeProvider theme={theme}>
<App colorMode={colorMode} setColorMode={setColorMode} />
</ThemeProvider>
);
};
root.render(
<React.StrictMode>
<Index />
</React.StrictMode>
);
// Performance measuring
reportWebVitals();

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1 @@
/// <reference types="react-scripts" />

View File

@ -0,0 +1,15 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -0,0 +1,25 @@
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/object_info/',
createProxyMiddleware({
target: 'http://localhost:8188',
changeOrigin: true,
})
);
app.use(
'/prompt/',
createProxyMiddleware({
target: 'http://localhost:8188',
changeOrigin: true,
})
);
app.use(
'/view',
createProxyMiddleware({
target: 'http://localhost:8188',
changeOrigin: true,
})
);
};

View File

@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

View File

@ -0,0 +1,142 @@
// theme.js
import { createTheme, ThemeOptions } from '@mui/material/styles';
// Light Theme Options
const lightThemeOptions: ThemeOptions = {
palette: {
mode: 'light',
background: {
default: '#ffffff',
paper: '#f5f5f5',
},
primary: {
main: '#1976d2',
},
secondary: {
main: '#dc004e',
},
text: {
primary: '#000000',
secondary: '#555555',
},
},
typography: {
fontFamily: [
'-apple-system',
'BlinkMacSystemFont',
'"Segoe UI"',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'"Fira Sans"',
'"Droid Sans"',
'"Helvetica Neue"',
'sans-serif',
].join(','),
fontSize: 14,
h1: {
fontSize: '2.5rem',
},
h2: {
fontSize: '2rem',
},
body1: {
fontSize: '1rem',
},
},
components: {
MuiCssBaseline: {
styleOverrides: {
body: {
margin: 0,
WebkitFontSmoothing: 'antialiased',
MozOsxFontSmoothing: 'grayscale',
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
},
code: {
fontFamily: 'source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace',
},
},
},
MuiButton: {
styleOverrides: {
root: {
borderRadius: '8px',
},
},
},
},
};
// Dark Theme Options
const darkThemeOptions: ThemeOptions = {
palette: {
mode: 'dark',
background: {
default: '#121212',
paper: '#1e1e1e',
},
primary: {
main: '#BB86FC',
},
secondary: {
main: '#03DAC6',
},
text: {
primary: '#ffffff',
secondary: '#e0e0e0',
},
},
typography: {
fontFamily: [
'-apple-system',
'BlinkMacSystemFont',
'"Segoe UI"',
'Roboto',
'Oxygen',
'Ubuntu',
'Cantarell',
'"Fira Sans"',
'"Droid Sans"',
'"Helvetica Neue"',
'sans-serif',
].join(','),
fontSize: 14,
h1: {
fontSize: '2.5rem',
},
h2: {
fontSize: '2rem',
},
body1: {
fontSize: '1rem',
},
},
components: {
MuiCssBaseline: {
styleOverrides: {
body: {
margin: 0,
WebkitFontSmoothing: 'antialiased',
MozOsxFontSmoothing: 'grayscale',
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
},
code: {
fontFamily: 'source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace',
},
},
},
MuiButton: {
styleOverrides: {
root: {
borderRadius: '8px',
},
},
},
},
};
// Create both themes
export const lightTheme = createTheme(lightThemeOptions);
export const darkTheme = createTheme(darkThemeOptions);

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}

View File

@ -0,0 +1,3 @@
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,15 @@
{
"files": {
"main.css": "/root/static/css/main.f855e6bc.css",
"main.js": "/root/static/js/main.6730d030.js",
"static/js/453.5565870f.chunk.js": "/root/static/js/453.5565870f.chunk.js",
"index.html": "/root/index.html",
"main.f855e6bc.css.map": "/root/static/css/main.f855e6bc.css.map",
"main.6730d030.js.map": "/root/static/js/main.6730d030.js.map",
"453.5565870f.chunk.js.map": "/root/static/js/453.5565870f.chunk.js.map"
},
"entrypoints": [
"static/css/main.f855e6bc.css",
"static/js/main.6730d030.js"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/root/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/root/logo192.png"/><link rel="manifest" href="/root/manifest.json"/><title>React App</title><script defer="defer" src="/root/static/js/main.6730d030.js"></script><link href="/root/static/css/main.f855e6bc.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "SoulxLogo.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "SoulxLogo.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -0,0 +1,2 @@
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}.App{text-align:center}.App-logo{height:40vmin;pointer-events:none}@media (prefers-reduced-motion:no-preference){.App-logo{animation:App-logo-spin 20s linear infinite}}.App-header{align-items:center;background-color:#282c34;color:#fff;display:flex;flex-direction:column;font-size:calc(10px + 2vmin);justify-content:center;min-height:100vh}.App-link{color:#61dafb}@keyframes App-logo-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
/*# sourceMappingURL=main.f855e6bc.css.map*/

View File

@ -0,0 +1 @@
{"version":3,"file":"static/css/main.f855e6bc.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF,CCZA,KACE,iBACF,CAEA,UACE,aAAc,CACd,mBACF,CAEA,8CACE,UACE,2CACF,CACF,CAEA,YAKE,kBAAmB,CAJnB,wBAAyB,CAOzB,UAAY,CALZ,YAAa,CACb,qBAAsB,CAGtB,4BAA6B,CAD7B,sBAAuB,CAJvB,gBAOF,CAEA,UACE,aACF,CAEA,yBACE,GACE,sBACF,CACA,GACE,uBACF,CACF","sources":["index.css","App.css"],"sourcesContent":["body {\r\n margin: 0;\r\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\r\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\r\n sans-serif;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n}\r\n\r\ncode {\r\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\r\n monospace;\r\n}\r\n",".App {\r\n text-align: center;\r\n}\r\n\r\n.App-logo {\r\n height: 40vmin;\r\n pointer-events: none;\r\n}\r\n\r\n@media (prefers-reduced-motion: no-preference) {\r\n .App-logo {\r\n animation: App-logo-spin infinite 20s linear;\r\n }\r\n}\r\n\r\n.App-header {\r\n background-color: #282c34;\r\n min-height: 100vh;\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n font-size: calc(10px + 2vmin);\r\n color: white;\r\n}\r\n\r\n.App-link {\r\n color: #61dafb;\r\n}\r\n\r\n@keyframes App-logo-spin {\r\n from {\r\n transform: rotate(0deg);\r\n }\r\n to {\r\n transform: rotate(360deg);\r\n }\r\n}\r\n"],"names":[],"sourceRoot":""}

View File

@ -0,0 +1,2 @@
"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[453],{6453:(e,t,n)=>{n.r(t),n.d(t,{getCLS:()=>y,getFCP:()=>g,getFID:()=>C,getLCP:()=>P,getTTFB:()=>D});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,p=function(){return"hidden"===document.visibilityState?0:1/0},d=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=p(),d(),s((function(){setTimeout((function(){v=p(),d()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},p=c("layout-shift",v);p&&(n=m(i,r,t),f((function(){p.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),p=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},d=c("first-input",p);n=m(e,v,t),d&&f((function(){d.takeRecords().map(p),d.disconnect()}),!0),d&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=p,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=453.5565870f.chunk.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,58 @@
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long