Skip to content

Commit cb34f9d

Browse files
author
whatevert
committed
m
0 parents  commit cb34f9d

File tree

3 files changed

+193
-0
lines changed

3 files changed

+193
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
src
2+
archive
3+
node_modules
4+
# Copy-Item -Path .\\src\\* -Destination .\\docs\\ -Recurse -Force && esbuild ./docs/main.jsx --outfile=./docs/main.js && javascript-obfuscator ./docs/main.js --output ./docs && rm ./docs/main.jsx && mv ./docs/main.js ./docs/main.jsx

docs/index.html

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZDKSPF6XKK"></script>
6+
<script>
7+
window.dataLayer = window.dataLayer || [];
8+
function gtag() { dataLayer.push(arguments); }
9+
gtag('js', new Date());
10+
11+
gtag('config', 'G-ZDKSPF6XKK');
12+
</script>
13+
14+
<meta charset="utf-8">
15+
<meta name="viewport" content="width=device-width, initial-scale=1">
16+
<title>React</title>
17+
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
18+
19+
20+
21+
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.3/purify.min.js"
23+
integrity="sha512-Ll+TuDvrWDNNRnFFIM8dOiw7Go7dsHyxRp4RutiIFW/wm3DgDmCnRZow6AqbXnCbpWu93yM1O34q+4ggzGeXVA=="
24+
crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
25+
26+
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
27+
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/4.10.38/pdf.min.mjs" type="module"></script>
28+
<script>
29+
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@4.10.38/build/pdf.worker.mjs';
30+
</script> -->
31+
32+
<!-- <script src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
33+
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"
34+
integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA=="
35+
crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
36+
37+
38+
39+
<link rel="stylesheet"
40+
href="https://esm.sh/flexlayout-react/style/dark.css?dev&external=react,react-dom,react-dom/client">
41+
<script type="importmap">
42+
{
43+
"imports": {
44+
"html-to-image": "https://esm.sh/html-to-image?dev",
45+
"react": "https://esm.sh/react@19.0.0?dev",
46+
"react-dom/client": "https://esm.sh/react-dom@19.0.0/client?dev&external=react",
47+
"react-dom": "https://esm.sh/react-dom@19.0.0?dev&external=react",
48+
"react-router-dom": "https://esm.sh/react-router-dom@7.2.0?dev&external=react,react-dom,react-dom/client",
49+
"@monaco-editor/react": "https://esm.sh/@monaco-editor/react?dev&external=react,react-dom,react-dom/client",
50+
"flexlayout-react": "https://esm.sh/flexlayout-react?dev&external=react,react-dom,react-dom/client",
51+
"valtio": "https://esm.sh/valtio?dev&external=react,react-dom,react-dom/client",
52+
"valtio/utils": "https://esm.sh/valtio/utils?dev&external=react,react-dom,react-dom/client",
53+
"react/jsx-runtime": "https://esm.sh/react/jsx-runtime?dev&external=react,react-dom,react-dom/client",
54+
"@emotion/react": "https://esm.sh/@emotion/react@11.11.1?dev&external=react,react-dom,react-dom/client",
55+
"@emotion/styled": "https://esm.sh/@emotion/styled@11.11.0?dev&external=react,react-dom,react-dom/client",
56+
"@mui/material": "https://esm.sh/@mui/material@5.14.12?dev&external=react,react-dom,react-dom/client",
57+
"@mui/icons-material": "https://esm.sh/@mui/icons-material@5.14.12?dev&external=react,react-dom,react-dom/client",
58+
"firebase/app": "https://esm.sh/firebase/app?dev",
59+
"firebase/auth": "https://esm.sh/firebase/auth?dev",
60+
"firebase/firestore": "https://esm.sh/firebase/firestore?dev",
61+
"firebase/messaging": "https://esm.sh/firebase/messaging?dev",
62+
"firebase/storage": "https://esm.sh/firebase/storage?dev"
63+
}
64+
}
65+
</script>
66+
67+
<style>
68+
::-webkit-scrollbar {
69+
width: 10px;
70+
height: 10px;
71+
}
72+
73+
::-webkit-scrollbar-track {
74+
background: #f1f1f1;
75+
border-radius: 5px;
76+
}
77+
78+
::-webkit-scrollbar-thumb {
79+
background: #888;
80+
border-radius: 5px;
81+
}
82+
83+
::-webkit-scrollbar-thumb:hover {
84+
background: #555;
85+
}
86+
87+
::-webkit-scrollbar-button {
88+
display: none;
89+
}
90+
</style>
91+
92+
93+
</head>
94+
95+
<body>
96+
<div id="root"></div>
97+
98+
<!-- production -->
99+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
100+
<!-- <script data-type="module" type="text/babel" src="main.jsx"></script> -->
101+
102+
<!-- apps scipt -->
103+
<!-- persist channel -->
104+
105+
106+
<!-- development -->
107+
<script type="module">
108+
// import * as sucrase from 'https://esm.sh/sucrase'; window.sucrase = sucrase;
109+
window.utils = {
110+
lastCodes: {},
111+
dynamicImport: async (url) => await import(URL.createObjectURL(new Blob([(utils.transform(await (await fetch(url + '?_=' + Date.now())).text()))], { type: 'text/javascript' }))),
112+
transform: typeof sucrase != 'undefined' ? (code) => sucrase.transform(code, { transforms: ['jsx'] }).code : (code) => Babel.transform(code, { presets: ['react'] }).code,
113+
evalScript: (code, type = "text/javascript", document = window.document) => { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.type = type; if (code.startsWith("http")) { script.src = code; script.onload = () => resolve(script); script.onerror = () => reject(new Error(`Failed to load script: ${code}`)); } else { script.textContent = code; script.onload = () => resolve(script); setTimeout(resolve, 0); } document.body.appendChild(script); }); },
114+
styleObjectToCssString: (styleObj) => Object.keys(styleObj).map(key => `${key.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${styleObj[key]};`).join(" "),
115+
chance: (fraction) => Math.random() < fraction,
116+
rand: (minInclusive, maxInclusive) => Math.floor(Math.random() * (maxInclusive - minInclusive) + minInclusive),
117+
lerp: (a, b, t) => (typeof a === 'object') ? Object.entries(a).reduce((acc, [k, v]) => (acc[k] = window.lerp(v, b[k], t), acc), {}) : a + (b - a) * t,
118+
clamp: (value, minInclusive, maxInclusive) => value < minInclusive ? minInclusive : value > maxInclusive ? maxInclusive : value,
119+
log: (...args) => (console.log(...args), args[args.length - 1]),
120+
poll: (fn, interval = 500) => new Promise((r) => { let intv = setInterval(() => (window.tmp = fn()) instanceof Promise ? window.tmp.then(res => res && (clearInterval(intv) || console.log(res) || r(res))) : window.tmp && (clearInterval(intv) || r(window.tmp)), interval) }),
121+
frame: (fn) => new Promise((r) => { const check = () => { const res = fn(); res instanceof Promise ? res.then(x => x ? (console.log(x) || r(x)) : requestAnimationFrame(check)) : res ? r(res) : requestAnimationFrame(check) }; requestAnimationFrame(check); }),
122+
safe: (fn) => { try { return (window.tmp = fn()) instanceof Promise ? new Promise((r) => window.tmp.then(r).catch(e => console.log('[SAFE]', e))) : window.tmp } catch (e) { console.log('[SAFE]', e) } },
123+
subscribe: (fn, cb, interval = 500) => { let last = -Infinity; let intv = setInterval(() => (window.tmp = fn()) instanceof Promise ? window.tmp.then(res => (last != res) && (last = res) & cb(res)) : (last != window.tmp) && (last = window.tmp) & cb(window.tmp), interval) },
124+
getFileUpload: () => new Promise((resolve, reject) => { (window.tmp = document.createElement('input', { type: 'file' })).onchange = (e) => resolve(e.target.files[0]); window.tmp.click(); }),
125+
safeParse: (...args) => { try { return JSON.parse(args[0], (key, value) => (typeof value === "string" && (value.startsWith("function") || value.startsWith("async function") || value.replace(/[\s\r\n]+/g, "").startsWith("()=>") || value.replace(/[\s\r\n]+/g, "").startsWith("async()=>"))) ? eval(`(${value})`) : value); } catch (e) { } },
126+
safeStringify: (obj) => JSON.stringify(obj, (seen => (key, value) => !Array.isArray(obj) && seen.has(value) ? undefined : (seen.add(value), (typeof value === "function" ? (value.prototype ? (Object.getOwnPropertyDescriptor(value, "prototype").writable ? "function" : "class") : value.constructor.name === "AsyncFunction" ? "async" : "arrow") : null) ? ("" + value) : value))(new Set())),
127+
isObject: (obj) => { try { return JSON.stringify(obj) && obj && typeof obj == "object" && !([Date, RegExp, Error, Map, Set, WeakMap, WeakSet, Promise, Symbol, ArrayBuffer, DataView].some((t) => obj instanceof t) || Array.isArray(obj)); } catch (e) { } },
128+
uuid: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => ((r) => (c == "x" ? r : (r & 0x3) | 0x8).toString(16))((Math.random() * 16) | 0)),
129+
join: (...paths) => paths.map(path => path.replace(/\/+$/, '')).join('/').replace(/\/+/g, '/'),
130+
makeReactive: (obj, setter) => { let arrayFunctions = ["copyWithin", "fill", "pop", "push", "reverse", "shift", "sort", "splice", "unshift"]; if (!isObject(obj) && !Array.isArray(obj)) return obj; let handler = { set: function (target, prop, value) { target[prop] = makeReactive(value, setter); setter(); return true; }, }; return new Proxy(Object.entries(obj).map(([key, value]) => [key, makeReactive(value, setter)]), handler); },
131+
toBlob: async (image) => await (await fetch(image)).blob(),
132+
toBase64: async (image) => { let uint8Array = new Uint8Array(await (await toBlob(image)).arrayBuffer()); let binary = ''; const chunkSize = 8192; for (let i = 0; i < uint8Array.length; i += chunkSize) { const chunk = uint8Array.subarray(i, i + chunkSize); binary += String.fromCharCode(...chunk); } return btoa(binary); },
133+
noImageBase64: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAGFBMVEVHcEzLy8u0tLSmpqasrKz////n5+empqZX/FQhAAAABXRSTlMA/b1AiR/80QkAAAFMSURBVDjLhZRNb8MgDIarpX+AToRru69zV/UHVKu0O5NwzlQjnH0I/P0ZiNp8AHsvifTI9gu22Wz+V3P+enm7HtfgfGj7vte76xKcWhUF+jUPSHO0fQBCl0nxg5pq97BxMjMC93zNh5rrdsyHTIKWIRQ0GuMrIpO9T7XWcyHZmK7hGSKDuyeTIbAvlEmFvrPkl8h7ltxGA0ZBrwCUAfqh32ghEm+t4J3l2HHBLEtkayJhcugEonUObGgWXBJBj0DE03cQYiTxOM6HbEIzFGgT2SdiNLBgojcgmWQTkr2EMokOmIZ20FqRadeC53dv4K1kVFrZARGlM5GEk0ovhBV0QnTeoQwx4x10nmwTBY9OoBzGBtGNasVdK5lFrgWhEPNT7UK5c+VulyekPFWVSSxPb3niK1tS3qzyNlY2uLz1lZdigpag8iJVXrGV/gC4fyA4d6TZZgAAAABJRU5ErkJggg==",
134+
downloadImage: (url) => new Promise((resolve, reject) => { let image = new Image(); image.crossOrigin = 'anonymous'; image.onload = () => resolve(image); image.src = url; }),
135+
aiReason: async c => await safe(async () => (await (await fetch("https://api.groq.com/openai/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer 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`, "Content-Type": "application/json" }, body: JSON.stringify({ messages: [{ role: "user", content: c }], model: "deepseek-r1-distill-llama-70b" }) })).json()).choices?.[0]?.message?.content),
136+
aiImage: async (t, w, h, s) => await safe(async () => { const { event_id } = await (await fetch('https://black-forest-labs-flux-1-schnell.hf.space/call/infer', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ data: [t, 0, true, w, h, s] }) })).json(); const r = (await fetch(`https://black-forest-labs-flux-1-schnell.hf.space/call/infer/${event_id}`)).body.getReader(); while (true) { let res = new TextDecoder().decode((await r.read()).value); if (res.slice(6, res.indexOf('\n')).trim() === 'complete') return JSON.parse(res.slice(res.indexOf('\ndata: ') + 6).trim()); } }),
137+
notify: (title = "", body = "", color = "#3B82F6", timeout = 5000) => { const c = document.querySelector(".notifications-container") || (() => { const el = document.createElement("div"); Object.assign(el.style, { position: "fixed", top: "16px", right: "16px", display: "flex", flexDirection: "column", gap: "12px", zIndex: "99999999", maxWidth: "320px", width: "100%" }); el.className = "notifications-container"; document.body.appendChild(el); return el; })(); const n = document.createElement("div"); Object.assign(n.style, { display: "flex", flexDirection: "column", padding: "16px", borderRadius: "8px", boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)", pointerEvents: "auto", transform: "translateY(-15px)", opacity: "0", transition: "transform 0.3s ease-out, opacity 0.3s ease-out", color: "#333", background: "white", border: "1px solid rgba(0, 0, 0, 0.1)", borderLeft: `4px solid ${color}` }); const h = document.createElement("div"); Object.assign(h.style, { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: body ? "8px" : "0" }); const t = document.createElement("div"); t.textContent = title; Object.assign(t.style, { fontWeight: "600", fontSize: "14px" }); const closeBtn = document.createElement("button"); closeBtn.innerHTML = "&#10005;"; Object.assign(closeBtn.style, { background: "none", border: "none", color: "#9CA3AF", cursor: "pointer", fontSize: "14px", padding: "4px", display: "flex", alignItems: "center", justifyContent: "center", width: "20px", height: "20px", borderRadius: "4px", marginLeft: "8px" }); closeBtn.onmouseover = () => { closeBtn.style.backgroundColor = "rgba(0, 0, 0, 0.05)"; }; closeBtn.onmouseout = () => { closeBtn.style.backgroundColor = "transparent"; }; closeBtn.onclick = () => removeNotif(n); h.appendChild(t); h.appendChild(closeBtn); n.appendChild(h); if (body) { const b = document.createElement("div"); b.textContent = body; Object.assign(b.style, { fontSize: "13px", color: "#4B5563", lineHeight: "1.5" }); n.appendChild(b); } c.appendChild(n); requestAnimationFrame(() => { n.style.transform = "translateY(0)"; n.style.opacity = "1"; }); const timeoutRef = setTimeout(() => removeNotif(n), timeout); function removeNotif(element) { clearTimeout(timeoutRef); element.style.height = element.offsetHeight + "px"; element.style.marginBottom = getComputedStyle(element).marginBottom; requestAnimationFrame(() => { element.style.height = "0"; element.style.marginBottom = "0"; element.style.padding = "0"; element.style.opacity = "0"; element.style.overflow = "hidden"; element.style.border = "none"; }); setTimeout(() => element.remove(), 300); Array.from(c.children).forEach(child => { if (child !== element) child.style.transition = "transform 0.3s ease-out"; }); } return n; },
138+
animate: (target, { from = {}, to = {}, duration = 1, delay = 0, ease = 'linear', onUpdate = () => { }, onComplete = () => { } }) => { let startTime = Date.now() + delay * 1000; let endTime = startTime + duration * 1000; let initialValues = {}; let deltas = {}; let hasPropertiesToAnimate = Object.keys(to).length > 0; let animationFrameId; if (hasPropertiesToAnimate) { for (let prop in to) { initialValues[prop] = (from[prop] !== undefined) ? from[prop] : (target[prop] !== undefined ? parseFloat(target[prop]) : 0); deltas[prop] = to[prop] - initialValues[prop]; } } const easeFunctions = { linear: t => t, easeInOut: t => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t }; const animate = () => { let currentTime = Date.now(); if (currentTime < startTime) { animationFrameId = requestAnimationFrame(animate); return; } let t = Math.min(1, (currentTime - startTime) / (duration * 1000)); let easingFunc = easeFunctions[ease] || easeFunctions.linear; if (hasPropertiesToAnimate) { for (let prop in to) { let newValue = initialValues[prop] + deltas[prop] * easingFunc(t); target[prop] = newValue; } } onUpdate(target); if (t < 1) { animationFrameId = requestAnimationFrame(animate); } else { onComplete(); } }; animationFrameId = requestAnimationFrame(animate); return { cancel: () => { cancelAnimationFrame(animationFrameId); console.log('Animation canceled'); } }; },
139+
getErrorBoundary: async (React) => {
140+
return eval((`
141+
(() => {
142+
class ErrorBoundary extends React.Component {
143+
state = { hasError: false, error: null, errorInfo: null, remaining: 5000 };
144+
componentDidCatch(error, errorInfo) {
145+
this.setState({ hasError: true, error, errorInfo, remaining: 5000 }, () => {});
146+
}
147+
render() {
148+
const { hasError, error, errorInfo, remaining } = this.state;
149+
return hasError ? React.createElement("div", { className: "text-xs full border border-red-500 bg-black text-white p-2 break-words w-screen dark:bg-gray-800 dark:text-gray-200" },
150+
React.createElement("div", { className: "font-mono" }, "Retrying in ", remaining, "ms"),
151+
React.createElement("pre", { className: "whitespace-no-wrap overflow-x-scroll" },
152+
React.createElement("div", { className: "text-red-500 text-lg font-bold" }, error?.toString() || "Unknown Error"),
153+
React.createElement("div", { className: "" }, errorInfo?.componentStack.split("\\n").slice(0, 5).join("\\n") || "Stack finding error")
154+
)
155+
) : this.props.children;
156+
}
157+
}
158+
return ErrorBoundary;
159+
})()
160+
`));
161+
}
162+
};
163+
164+
165+
console.image = async (url) => { const image = await window.utils.downloadImage(url); const canvas = document.createElement('canvas'); canvas.height = 100; canvas.width = canvas.height * image.naturalWidth / image.naturalHeight; canvas.getContext('2d').drawImage(image, 0, 0, canvas.width, canvas.height); console.log('%c ', `background: url(${canvas.toDataURL()}) no-repeat; background-size: contain; font-size: 1px; padding: ${canvas.height}px ${canvas.width}px;`); }
166+
if (window.location.protocol == 'http:') window.onerror = (e) => { window.eruda?.init(); window.eruda?.show(); window.utils.notify?.(e.message || ('' + e)); }
167+
168+
await window.utils.evalScript(window.utils.transform(await(await fetch('main.jsx' + '?_=' + Date.now())).text()), 'module');
169+
while (1) {
170+
try {
171+
await Promise.all(['index.html', 'main.jsx'].map(async (fileName) => {
172+
if (window.utils.lastCodes[fileName] && window.utils.lastCodes[fileName] != await (await fetch(fileName + '?_=' + Date.now())).text()) {
173+
if (fileName.slice(-4) == '.jsx') {
174+
// await window.utils.evalScript(window.utils.transform(await (await fetch(fileName+ '?_=' + Date.now())).text()), 'module')
175+
await window.utils.evalScript(utils.transform(await (await fetch('main.jsx' + '?_=' + Date.now())).text()), 'module')
176+
}
177+
else if (fileName.slice(-5) == '.html') location.reload()
178+
console.clear(); console.log("code executed");
179+
}
180+
window.utils.lastCodes[fileName] = await (await fetch(fileName + '?_=' + Date.now())).text();
181+
}))
182+
} catch (e) { console.log(e) }
183+
await new Promise((r) => setTimeout(r, 1000));
184+
}
185+
</script>
186+
</body>
187+
188+
</html>

0 commit comments

Comments
 (0)