Fix zip file corruption for deployment
This commit is contained in:
parent
00d5b37d9e
commit
ca1e9c8f45
|
|
@ -10,14 +10,35 @@ import { binaryExtensions } from "../util/binary-ext";
|
|||
// Import archiver for zip creation
|
||||
const archiver = require('archiver');
|
||||
|
||||
// Helper function to process file contents with size limits (now unlimited)
|
||||
// Helper function to process file contents with reasonable size limits
|
||||
function processFileContents(fileData: Record<string, any>, mode: "string" | "binary"): Record<string, any> {
|
||||
const processed: Record<string, any> = {};
|
||||
const MAX_FILE_SIZE = 50 * 1024 * 1024; // 50MB per file limit
|
||||
const MAX_TOTAL_SIZE = 500 * 1024 * 1024; // 500MB total limit
|
||||
let totalSize = 0;
|
||||
|
||||
for (const [fileName, content] of Object.entries(fileData)) {
|
||||
processed[fileName] = content; // No size restrictions - include all files
|
||||
const contentSize = typeof content === 'string' ? content.length :
|
||||
(content instanceof Uint8Array ? content.byteLength :
|
||||
(content instanceof Buffer ? content.length : 0));
|
||||
|
||||
// Skip files that are too large
|
||||
if (contentSize > MAX_FILE_SIZE) {
|
||||
console.warn(`Skipping large file: ${fileName} (${(contentSize / 1024 / 1024).toFixed(2)}MB > ${MAX_FILE_SIZE / 1024 / 1024}MB)`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check total size limit
|
||||
if (totalSize + contentSize > MAX_TOTAL_SIZE) {
|
||||
console.warn(`Skipping file due to total size limit: ${fileName}`);
|
||||
break;
|
||||
}
|
||||
|
||||
processed[fileName] = content;
|
||||
totalSize += contentSize;
|
||||
}
|
||||
|
||||
console.log(`Processed ${Object.keys(processed).length} files, total size: ${(totalSize / 1024 / 1024).toFixed(2)}MB`);
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
|
@ -342,10 +363,19 @@ function encodeVeryLargeData(data: any): Uint8Array {
|
|||
|
||||
let fileCount = 0;
|
||||
|
||||
for (const [fileName, fileContent] of Object.entries(fileData || {})) {
|
||||
const contentSize = typeof fileContent === 'string' ? fileContent.length : fileContent.byteLength;
|
||||
const MAX_FILES = 1000; // Limit number of files
|
||||
const MAX_FILE_SIZE = 50 * 1024 * 1024; // 50MB per file
|
||||
|
||||
for (const [fileName, fileContent] of Object.entries(fileData || {})) {
|
||||
const contentSize = typeof fileContent === 'string' ? fileContent.length :
|
||||
(fileContent && fileContent.byteLength ? fileContent.byteLength : 0);
|
||||
|
||||
// Skip files that are too large or if we've hit the file count limit
|
||||
if (contentSize > MAX_FILE_SIZE || fileCount >= MAX_FILES) {
|
||||
console.warn(`Skipping file: ${fileName} (${fileCount >= MAX_FILES ? 'file count limit' : 'too large'})`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// No size limit per file - include all files regardless of size
|
||||
safeFileData[fileName] = fileContent;
|
||||
fileCount++;
|
||||
}
|
||||
|
|
@ -419,75 +449,97 @@ export const _ = {
|
|||
if (validate(site_id)) {
|
||||
console.log(`Starting zip creation for site: ${site_id}`);
|
||||
|
||||
// Fetch all the site data
|
||||
const result = {
|
||||
layouts: await _db.page.findMany({
|
||||
where: {
|
||||
id_site: site_id,
|
||||
is_deleted: false,
|
||||
name: { startsWith: "layout:" },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
url: true,
|
||||
content_tree: true,
|
||||
is_default_layout: true,
|
||||
},
|
||||
}),
|
||||
pages: await _db.page.findMany({
|
||||
where: {
|
||||
id_site: site_id,
|
||||
is_deleted: false,
|
||||
name: { not: { startsWith: "layout:" } },
|
||||
},
|
||||
select: { id: true, name: true, url: true, content_tree: true },
|
||||
}),
|
||||
comps: await _db.component.findMany({
|
||||
where: {
|
||||
component_group: {
|
||||
OR: [
|
||||
{
|
||||
id: "13143272-d4e3-4301-b790-2b3fd3e524e6",
|
||||
},
|
||||
{ id: "cf81ff60-efe5-41d2-aa41-6f47549082b2" },
|
||||
{
|
||||
component_site: { every: { id_site: site_id } },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
select: { id: true, content_tree: true },
|
||||
}),
|
||||
public: readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "site", "src", "public")
|
||||
),
|
||||
site: await _db.site.findFirst({
|
||||
where: { id: site_id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
config: true,
|
||||
responsive: true,
|
||||
domain: true,
|
||||
},
|
||||
}),
|
||||
code: {
|
||||
server: readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "server", "build")
|
||||
),
|
||||
site: readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "site", "build")
|
||||
),
|
||||
core: readDirectoryRecursively("binary", dir.path(`/app/srv/core`)),
|
||||
},
|
||||
// Add timeout and memory protection
|
||||
const MAX_EXECUTION_TIME = 120000; // 2 minutes timeout
|
||||
const startTime = Date.now();
|
||||
|
||||
const checkTimeout = () => {
|
||||
if (Date.now() - startTime > MAX_EXECUTION_TIME) {
|
||||
throw new Error(`Zip creation timeout after ${MAX_EXECUTION_TIME / 1000} seconds`);
|
||||
}
|
||||
};
|
||||
|
||||
// Create the zip file
|
||||
// Fetch all the site data with timeout checks
|
||||
checkTimeout();
|
||||
const result: any = {};
|
||||
|
||||
result.layouts = await _db.page.findMany({
|
||||
where: {
|
||||
id_site: site_id,
|
||||
is_deleted: false,
|
||||
name: { startsWith: "layout:" },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
url: true,
|
||||
content_tree: true,
|
||||
is_default_layout: true,
|
||||
},
|
||||
});
|
||||
|
||||
checkTimeout();
|
||||
result.pages = await _db.page.findMany({
|
||||
where: {
|
||||
id_site: site_id,
|
||||
is_deleted: false,
|
||||
name: { not: { startsWith: "layout:" } },
|
||||
},
|
||||
select: { id: true, name: true, url: true, content_tree: true },
|
||||
});
|
||||
|
||||
checkTimeout();
|
||||
result.comps = await _db.component.findMany({
|
||||
where: {
|
||||
component_group: {
|
||||
OR: [
|
||||
{
|
||||
id: "13143272-d4e3-4301-b790-2b3fd3e524e6",
|
||||
},
|
||||
{ id: "cf81ff60-efe5-41d2-aa41-6f47549082b2" },
|
||||
{
|
||||
component_site: { every: { id_site: site_id } },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
select: { id: true, content_tree: true },
|
||||
});
|
||||
|
||||
checkTimeout();
|
||||
result.public = readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "site", "src", "public")
|
||||
);
|
||||
|
||||
checkTimeout();
|
||||
result.site = await _db.site.findFirst({
|
||||
where: { id: site_id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
config: true,
|
||||
responsive: true,
|
||||
domain: true,
|
||||
},
|
||||
});
|
||||
|
||||
checkTimeout();
|
||||
result.code = {
|
||||
server: readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "server", "build")
|
||||
),
|
||||
site: readDirectoryRecursively(
|
||||
"binary",
|
||||
code.path(site_id, "site", "build")
|
||||
),
|
||||
core: readDirectoryRecursively("binary", dir.path(`/app/srv/core`)),
|
||||
};
|
||||
|
||||
// Create the zip file with timeout protection
|
||||
console.log(`Creating zip archive with ${Object.keys(result.public || {}).length} public files`);
|
||||
checkTimeout();
|
||||
const zipBuffer = await createSiteZip(site_id, result);
|
||||
|
||||
console.log(`Zip created successfully: ${zipBuffer.length} bytes`);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,27 @@ export const _ = {
|
|||
let url = "";
|
||||
|
||||
const raw = await req.arrayBuffer();
|
||||
const parts = mp(Buffer.from(raw)) as Record<
|
||||
|
||||
// Validate the ArrayBuffer before conversion to prevent corruption
|
||||
if (!raw || raw.byteLength === 0) {
|
||||
throw new Error("Empty or invalid file upload");
|
||||
}
|
||||
|
||||
// Add size limit to prevent memory exhaustion
|
||||
const MAX_UPLOAD_SIZE = 100 * 1024 * 1024; // 100MB
|
||||
if (raw.byteLength > MAX_UPLOAD_SIZE) {
|
||||
throw new Error(`File too large: ${raw.byteLength} bytes > ${MAX_UPLOAD_SIZE} bytes`);
|
||||
}
|
||||
|
||||
// Safely convert ArrayBuffer to Buffer
|
||||
let buffer: Buffer;
|
||||
try {
|
||||
buffer = Buffer.from(raw);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to convert upload data: ${error.message}`);
|
||||
}
|
||||
|
||||
const parts = mp(buffer) as Record<
|
||||
string,
|
||||
{ fileName: string; mime: string; type: string; buffer: Buffer }
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -61,10 +61,28 @@ export const serveStatic = {
|
|||
}
|
||||
|
||||
try {
|
||||
const fileContent = await Bun.file(final_path).arrayBuffer();
|
||||
|
||||
// Validate the file content before caching
|
||||
if (!fileContent || fileContent.byteLength === 0) {
|
||||
console.warn(`Skipping empty file: ${final_path}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add file size limit for caching to prevent memory issues
|
||||
const MAX_CACHE_SIZE = 50 * 1024 * 1024; // 50MB per file
|
||||
if (fileContent.byteLength > MAX_CACHE_SIZE) {
|
||||
console.warn(`Skipping large file for caching: ${final_path} (${fileContent.byteLength} bytes)`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create a copy of the ArrayBuffer to prevent modification
|
||||
const arrayBufferCopy = fileContent.slice(0);
|
||||
|
||||
cache.static[`/${file_path}`] = {
|
||||
type: mime.getType(file_path) || "application/octet-stream",
|
||||
compression: br ? "br" : "",
|
||||
content: await Bun.file(final_path).arrayBuffer(),
|
||||
content: arrayBufferCopy,
|
||||
};
|
||||
} catch (e: any) {
|
||||
console.error(`Failed to load static file: ${final_path}`);
|
||||
|
|
@ -125,7 +143,15 @@ export const serveStatic = {
|
|||
...(file.compression ? { "content-encoding": file.compression } : {}),
|
||||
});
|
||||
|
||||
return rewriteResponse(file.content, {
|
||||
// Create a copy of the ArrayBuffer to prevent modification of cached data
|
||||
let content: ArrayBuffer;
|
||||
if (file.content instanceof ArrayBuffer) {
|
||||
content = file.content.slice(0);
|
||||
} else {
|
||||
content = file.content;
|
||||
}
|
||||
|
||||
return rewriteResponse(content, {
|
||||
headers,
|
||||
opt,
|
||||
});
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
.ContextMenu{background:#fff;border:1px solid #ccc;outline:0}.MenuItem{text-align:left;background:#fff;border-bottom:1px solid #ececeb;outline:0;justify-content:space-between;width:100%;margin:0;padding:3px 5px 3px 10px;font-size:14px;line-height:1.5;display:flex}.MenuItem:hover .hot-key{border-color:#fff!important}.MenuItem:last-child{border-bottom:0}.MenuItem.open{background:#ddd}.MenuItem:disabled{color:#ccc}.MenuItem:focus,.MenuItem:not([disabled]):active{color:#fff;background:#527dff}
|
||||
/*# sourceMappingURL=ed.f0595191.css.map */
|
||||
/*# sourceMappingURL=ed.66a39582.css.map */
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,2 @@
|
|||
@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-cyrillic-ext-400-normal.01f99d06.woff2)format("woff2"),url(jetbrains-mono-cyrillic-ext-400-normal.b19dae56.woff)format("woff");unicode-range:U+460-52F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-cyrillic-400-normal.c27eb9dd.woff2)format("woff2"),url(jetbrains-mono-cyrillic-400-normal.12e183dd.woff)format("woff");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-greek-400-normal.fab63212.woff2)format("woff2"),url(jetbrains-mono-greek-400-normal.69c2db8b.woff)format("woff");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-vietnamese-400-normal.72fde104.woff2)format("woff2"),url(jetbrains-mono-vietnamese-400-normal.cde33dd0.woff)format("woff");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-latin-ext-400-normal.510ef9e7.woff2)format("woff2"),url(jetbrains-mono-latin-ext-400-normal.8522e56b.woff)format("woff");unicode-range:U+100-2AF,U+304,U+308,U+329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:swap;font-weight:400;src:url(jetbrains-mono-latin-400-normal.785c446b.woff2)format("woff2"),url(jetbrains-mono-latin-400-normal.f1e9154a.woff)format("woff");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
|
||||
/*# sourceMappingURL=index.d6a5dd12.css.map */
|
||||
/*# sourceMappingURL=index.28e3176d.css.map */
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-cyrillic-ext-400-normal.092a473c.woff2)format("woff2"),url(source-sans-3-cyrillic-ext-400-normal.ff53f249.woff)format("woff");unicode-range:U+460-52F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-cyrillic-400-normal.f971b9ad.woff2)format("woff2"),url(source-sans-3-cyrillic-400-normal.d31f6c55.woff)format("woff");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-greek-ext-400-normal.2f1e4560.woff2)format("woff2"),url(source-sans-3-greek-ext-400-normal.e253957a.woff)format("woff");unicode-range:U+1F??}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-greek-400-normal.30e09ac6.woff2)format("woff2"),url(source-sans-3-greek-400-normal.a9365509.woff)format("woff");unicode-range:U+370-377,U+37A-37F,U+384-38A,U+38C,U+38E-3A1,U+3A3-3FF}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-vietnamese-400-normal.8175b15f.woff2)format("woff2"),url(source-sans-3-vietnamese-400-normal.a0f67db9.woff)format("woff");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-latin-ext-400-normal.8180fdee.woff2)format("woff2"),url(source-sans-3-latin-ext-400-normal.0483ba2f.woff)format("woff");unicode-range:U+100-2AF,U+304,U+308,U+329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:"Source Sans 3";font-style:normal;font-display:swap;font-weight:400;src:url(source-sans-3-latin-400-normal.43f5aafe.woff2)format("woff2"),url(source-sans-3-latin-400-normal.6f62a854.woff)format("woff");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
|
||||
/*# sourceMappingURL=index.5278b069.css.map */
|
||||
/*# sourceMappingURL=index.5ae44900.css.map */
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0"><title>Prasi: App Builder</title><link rel="stylesheet" href="/index.f3513746.css"><link rel="stylesheet" crossorigin href="/index.d6a5dd12.css"><link rel="stylesheet" crossorigin href="/index.5278b069.css"><script src="/index.runtime.a3d7f961.js"></script><script>window.__REACT_DEVTOOLS_GLOBAL_HOOK__={isDisabled:!0,_renderers:{}};</script></head><body classname="flex-col flex-1 w-full min-h-screen flex opacity-0"> <div id="root"></div> <script src="/index.f9a0b8af.js" defer></script> </body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1.0, minimum-scale=1.0, maximum-scale=1.0"><title>Prasi: App Builder</title><link rel="stylesheet" href="/index.72028da7.css"><link rel="stylesheet" crossorigin href="/index.28e3176d.css"><link rel="stylesheet" crossorigin href="/index.5ae44900.css"><script src="/index.runtime.326a3b14.js"></script><script>window.__REACT_DEVTOOLS_GLOBAL_HOOK__={isDisabled:!0,_renderers:{}};</script></head><body classname="flex-col flex-1 w-full min-h-screen flex opacity-0"> <div id="root"></div> <script src="/index.e9e3d13f.js" defer></script> </body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,2 @@
|
|||
!function(e,r,t,n,o){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof f[n]&&f[n],a=i.cache||{},u="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(r,t){if(!a[r]){if(!e[r]){var o="function"==typeof f[n]&&f[n];if(!t&&o)return o(r,!0);if(i)return i(r,!0);if(u&&"string"==typeof r)return u(r);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}l.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},l.cache={};var d=a[r]=new s.Module(r);e[r][0].call(d.exports,l,d,d.exports,this)}return a[r].exports;function l(e){var r=l.resolve(e);return!1===r?{}:s(r)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.exports={}},s.modules=e,s.cache=a,s.parent=i,s.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(s,"root",{get:function(){return f[n]}}),f[n]=s;for(var c=0;c<r.length;c++)s(r[c])}({hjCSF:[function(e,r,t){e("e07773e1a39ddefe").register(e("d8f2e1634a082791").getBundleURL("9vxuh"),JSON.parse('["9vxuh","index.e9e3d13f.js","6v8Tc","login.9be857a1.js","jXqLX","logout.8b600cab.js","gDSu6","register.bf8057b7.js","2oPKL","all.fc4a35e2.js","3A9t7","ed.7e3c680e.js","j2Wxh","wasm_gzip.922c2de1.wasm","gkiAc","standalone.5fd51c91.js","2SL1o","estree.5af4055d.js","994Cy","typescript.c04a7dce.js","9iIRA","dist.b4c0cacf.js","awHkr","esm.0a7e5ee9.js","k4Oeu","index.module.04a2ea3f.js","dJSMv","ed.66a39582.css","eumeP","sworker.js"]'))},{e07773e1a39ddefe:"4pEAy",d8f2e1634a082791:"3holF"}],"4pEAy":[function(e,r,t){var n=new Map;r.exports.register=function(e,r){for(var t=0;t<r.length-1;t+=2)n.set(r[t],{baseUrl:e,path:r[t+1]})},r.exports.resolve=function(e){var r=n.get(e);if(null==r)throw Error("Could not resolve bundle with id "+e);return new URL(r.path,r.baseUrl).toString()}},{}],"3holF":[function(e,r,t){var n={};function o(e){return(""+e).replace(/^((?:https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/.+)\/[^/]+$/,"$1")+"/"}t.getBundleURL=function(e){var r=n[e];return r||(r=function(){try{throw Error()}catch(r){var e=(""+r.stack).match(/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^)\n]+/g);if(e)return o(e[2])}return"/"}(),n[e]=r),r},t.getBaseURL=o,t.getOrigin=function(e){var r=(""+e).match(/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^/]+/);if(!r)throw Error("Origin not found");return r[0]}},{}]},["hjCSF"],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=index.runtime.326a3b14.js.map
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
!function(e,r,t,n,o){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof f[n]&&f[n],s=i.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(r,t){if(!s[r]){if(!e[r]){var o="function"==typeof f[n]&&f[n];if(!t&&o)return o(r,!0);if(i)return i(r,!0);if(a&&"string"==typeof r)return a(r);var c=Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}l.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},l.cache={};var u=s[r]=new d.Module(r);e[r][0].call(u.exports,l,u,u.exports,this)}return s[r].exports;function l(e){var r=l.resolve(e);return!1===r?{}:d(r)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=e,d.cache=s,d.parent=i,d.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(d,"root",{get:function(){return f[n]}}),f[n]=d;for(var c=0;c<r.length;c++)d(r[c])}({"1gwlL":[function(e,r,t){e("483d81254de90d1c").register(e("e997c0f52321ab57").getBundleURL("5btbX"),JSON.parse('["5btbX","index.f9a0b8af.js","51CIF","login.729781e5.js","lWnYB","logout.150df938.js","h2EQ2","register.46daa674.js","b1ger","all.1ee07229.js","ikCXc","ed.229d9857.js","fG1Xp","wasm_gzip.922c2de1.wasm","a06ck","standalone.d4ef49b4.js","dVyrU","estree.77f58917.js","gkR2P","typescript.264d3a10.js","j1vrr","dist.477afcf4.js","bqVt6","esm.72b78f35.js","hydmX","index.module.f4641cc5.js","8U2pR","ed.f0595191.css","kvQTi","sworker.js"]'))},{"483d81254de90d1c":"6dXzV",e997c0f52321ab57:"1ILkO"}],"6dXzV":[function(e,r,t){var n=new Map;r.exports.register=function(e,r){for(var t=0;t<r.length-1;t+=2)n.set(r[t],{baseUrl:e,path:r[t+1]})},r.exports.resolve=function(e){var r=n.get(e);if(null==r)throw Error("Could not resolve bundle with id "+e);return new URL(r.path,r.baseUrl).toString()}},{}],"1ILkO":[function(e,r,t){var n={};function o(e){return(""+e).replace(/^((?:https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/.+)\/[^/]+$/,"$1")+"/"}t.getBundleURL=function(e){var r=n[e];return r||(r=function(){try{throw Error()}catch(r){var e=(""+r.stack).match(/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^)\n]+/g);if(e)return o(e[2])}return"/"}(),n[e]=r),r},t.getBaseURL=o,t.getOrigin=function(e){var r=(""+e).match(/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^/]+/);if(!r)throw Error("Origin not found");return r[0]}},{}]},["1gwlL"],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=index.runtime.a3d7f961.js.map
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
!function(e,t,r,n,i){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof s[n]&&s[n],o=l.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!o[t]){if(!e[t]){var i="function"==typeof s[n]&&s[n];if(!r&&i)return i(t,!0);if(l)return l(t,!0);if(a&&"string"==typeof t)return a(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}f.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},f.cache={};var c=o[t]=new u.Module(t);e[t][0].call(c.exports,f,c,c.exports,this)}return o[t].exports;function f(e){var t=f.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=o,u.parent=l,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return s[n]}}),s[n]=u;for(var d=0;d<t.length;d++)u(t[d])}({cXyXr:[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var n=e("react/jsx-runtime"),i=e("web-utils"),s=e("../../../utils/ui/loading"),l=e("../../../utils/ui/form.style"),o=e("../../../utils/ui/form/input");r.default=(0,i.page)({url:"/login",component:({})=>{let e=(0,i.useLocal)({username:"",password:"",submitting:!1,init:!1},async()=>{let t=await _api.session();if(t&&t.id){let e=window.redirectTo;e?navigate(e):(localStorage.setItem("prasi-session",JSON.stringify(t)),navigate("/ed/"))}else e.init=!0,e.render()});return e.init?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center",children:(0,n.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),e.submitting=!0,e.render(),"failed"===(await _api.login(e.username,e.password)).status)e.submitting=!1,e.render();else{let e=window.redirectTo;e?(location.href.includes("localhost")&&e.includes("/editor")&&(e=e.replace("/editor","/ed")),navigate(e)):(location.href.includes("localhost"),navigate("/ed"))}},className:cx("border-[3px] border-black",l.formStyle),children:[(0,n.jsx)("div",{className:"title",children:"Login"}),(0,n.jsxs)("label",{className:"mt-3",children:[(0,n.jsx)("span",{children:"Username"}),(0,n.jsx)(o.Input,{form:e,name:"username"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Password"}),(0,n.jsx)(o.Input,{form:e,name:"password",type:"password"})]}),(0,n.jsx)("button",{type:"submit",disabled:e.submitting,children:e.submitting?"Loading...":"Submit"}),(0,n.jsx)("div",{className:"pt-2",children:(0,n.jsx)("a",{href:"/register",className:"cursor-pointer underline",children:"Register"})})]})}):(0,n.jsx)(s.Loading,{})}})},{"react/jsx-runtime":"f4Tol","web-utils":"ccU4J","../../../utils/ui/loading":"loFlS","../../../utils/ui/form.style":"jUQFK","../../../utils/ui/form/input":"1FhYR","@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}],jUQFK:[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"formStyle",()=>i);let i=css`
|
||||
!function(e,t,r,n,i){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof s[n]&&s[n],o=l.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!o[t]){if(!e[t]){var i="function"==typeof s[n]&&s[n];if(!r&&i)return i(t,!0);if(l)return l(t,!0);if(a&&"string"==typeof t)return a(t);var d=Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}f.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},f.cache={};var c=o[t]=new u.Module(t);e[t][0].call(c.exports,f,c,c.exports,this)}return o[t].exports;function f(e){var t=f.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=o,u.parent=l,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return s[n]}}),s[n]=u;for(var d=0;d<t.length;d++)u(t[d])}({cXyXr:[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var n=e("react/jsx-runtime"),i=e("web-utils"),s=e("../../../utils/ui/loading"),l=e("../../../utils/ui/form.style"),o=e("../../../utils/ui/form/input");r.default=(0,i.page)({url:"/login",component:({})=>{let e=(0,i.useLocal)({username:"",password:"",submitting:!1,init:!1},async()=>{let t=await _api.session();if(t&&t.id){let e=window.redirectTo;e?navigate(e):(localStorage.setItem("prasi-session",JSON.stringify(t)),navigate("/ed/"))}else e.init=!0,e.render()});return e.init?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center",children:(0,n.jsxs)("form",{onSubmit:async t=>{if(t.preventDefault(),e.submitting=!0,e.render(),"failed"===(await _api.login(e.username,e.password)).status)e.submitting=!1,e.render();else{let e=window.redirectTo;e?(location.href.includes("localhost")&&e.includes("/editor")&&(e=e.replace("/editor","/ed")),navigate(e)):(location.href.includes("localhost"),navigate("/ed"))}},className:cx("border-[3px] border-black",l.formStyle),children:[(0,n.jsx)("div",{className:"title",children:"Login"}),(0,n.jsxs)("label",{className:"mt-3",children:[(0,n.jsx)("span",{children:"Username"}),(0,n.jsx)(o.Input,{form:e,name:"username"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Password"}),(0,n.jsx)(o.Input,{form:e,name:"password",type:"password"})]}),(0,n.jsx)("button",{type:"submit",disabled:e.submitting,children:e.submitting?"Loading...":"Submit"}),(0,n.jsx)("div",{className:"pt-2",children:(0,n.jsx)("a",{href:"/register",className:"cursor-pointer underline",children:"Register"})})]})}):(0,n.jsx)(s.Loading,{})}})},{"react/jsx-runtime":"2bhZX","web-utils":"bzBzI","../../../utils/ui/loading":"loFlS","../../../utils/ui/form.style":"jUQFK","../../../utils/ui/form/input":"1FhYR","@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}],jUQFK:[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"formStyle",()=>i);let i=css`
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -45,5 +45,5 @@
|
|||
background: #999;
|
||||
}
|
||||
}
|
||||
`},{"@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}],"1FhYR":[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"Input",()=>s);var i=e("react/jsx-runtime");let s=e=>{let t={...e},{form:r,name:n}=e;delete t.form,delete t.name;let s=null;t.onChange&&(s=t.onChange,delete t.onChange);let l=r[n];return l instanceof URL&&(l=l.toString()),(0,i.jsx)("input",{value:l||"",spellCheck:!1,onInput:e=>{if(r[n]=e.currentTarget.value,s){let t=s(e.currentTarget.value);void 0!==t&&(r[n]=t)}r.render()},...t})}},{"react/jsx-runtime":"f4Tol","@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=login.729781e5.js.map
|
||||
`},{"@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}],"1FhYR":[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"Input",()=>s);var i=e("react/jsx-runtime");let s=e=>{let t={...e},{form:r,name:n}=e;delete t.form,delete t.name;let s=null;t.onChange&&(s=t.onChange,delete t.onChange);let l=r[n];return l instanceof URL&&(l=l.toString()),(0,i.jsx)("input",{value:l||"",spellCheck:!1,onInput:e=>{if(r[n]=e.currentTarget.value,s){let t=s(e.currentTarget.value);void 0!==t&&(r[n]=t)}r.render()},...t})}},{"react/jsx-runtime":"2bhZX","@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=login.9be857a1.js.map
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
!function(e,o,r,n,t){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof i[n]&&i[n],u=l.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(o,r){if(!u[o]){if(!e[o]){var t="function"==typeof i[n]&&i[n];if(!r&&t)return t(o,!0);if(l)return l(o,!0);if(f&&"string"==typeof o)return f(o);var a=Error("Cannot find module '"+o+"'");throw a.code="MODULE_NOT_FOUND",a}d.resolve=function(r){var n=e[o][1][r];return null!=n?n:r},d.cache={};var c=u[o]=new s.Module(o);e[o][0].call(c.exports,d,c,c.exports,this)}return u[o].exports;function d(e){var o=d.resolve(e);return!1===o?{}:s(o)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.exports={}},s.modules=e,s.cache=u,s.parent=l,s.register=function(o,r){e[o]=[function(e,o){o.exports=r},{}]},Object.defineProperty(s,"root",{get:function(){return i[n]}}),i[n]=s;for(var a=0;a<o.length;a++)s(o[a])}({"1NKJn":[function(e,o,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var n=e("react/jsx-runtime"),t=e("web-utils"),i=e("../../../utils/ui/loading");r.default=(0,t.page)({url:"/logout",component:({})=>(localStorage.clear(),_api.logout().then(()=>{location.href="/login"}),(0,n.jsx)(i.Loading,{}))})},{"react/jsx-runtime":"f4Tol","web-utils":"ccU4J","../../../utils/ui/loading":"loFlS","@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=logout.150df938.js.map
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
!function(e,n,o,r,t){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof i[r]&&i[r],u=l.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function s(n,o){if(!u[n]){if(!e[n]){var t="function"==typeof i[r]&&i[r];if(!o&&t)return t(n,!0);if(l)return l(n,!0);if(f&&"string"==typeof n)return f(n);var a=Error("Cannot find module '"+n+"'");throw a.code="MODULE_NOT_FOUND",a}c.resolve=function(o){var r=e[n][1][o];return null!=r?r:o},c.cache={};var d=u[n]=new s.Module(n);e[n][0].call(d.exports,c,d,d.exports,this)}return u[n].exports;function c(e){var n=c.resolve(e);return!1===n?{}:s(n)}}s.isParcelRequire=!0,s.Module=function(e){this.id=e,this.bundle=s,this.exports={}},s.modules=e,s.cache=u,s.parent=l,s.register=function(n,o){e[n]=[function(e,n){n.exports=o},{}]},Object.defineProperty(s,"root",{get:function(){return i[r]}}),i[r]=s;for(var a=0;a<n.length;a++)s(n[a])}({"1NKJn":[function(e,n,o){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(o);var r=e("react/jsx-runtime"),t=e("web-utils"),i=e("../../../utils/ui/loading");o.default=(0,t.page)({url:"/logout",component:({})=>(localStorage.clear(),_api.logout().then(()=>{location.href="/login"}),(0,r.jsx)(i.Loading,{}))})},{"react/jsx-runtime":"2bhZX","web-utils":"bzBzI","../../../utils/ui/loading":"loFlS","@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=logout.8b600cab.js.map
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
!function(e,r,t,n,s){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof i[n]&&i[n],o=l.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(r,t){if(!o[r]){if(!e[r]){var s="function"==typeof i[n]&&i[n];if(!t&&s)return s(r,!0);if(l)return l(r,!0);if(a&&"string"==typeof r)return a(r);var d=Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}p.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},p.cache={};var c=o[r]=new u.Module(r);e[r][0].call(c.exports,p,c,c.exports,this)}return o[r].exports;function p(e){var r=p.resolve(e);return!1===r?{}:u(r)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=o,u.parent=l,u.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(u,"root",{get:function(){return i[n]}}),i[n]=u;for(var d=0;d<r.length;d++)u(r[d])}({Pi9M3:[function(e,r,t){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(t);var n=e("react/jsx-runtime"),s=e("web-utils"),i=e("../../../utils/ui/loading"),l=e("../../../utils/ui/form.style"),o=e("../../../utils/ui/form/input");t.default=(0,s.page)({url:"/register",component:({})=>{let e=(0,s.useLocal)({username:"",password:"",email:"",submitting:!1,init:!1},async()=>{let r=await _api.session();r&&r.id?navigate("/ed"):(e.init=!0,e.render())});return e.init?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center",children:(0,n.jsxs)("form",{onSubmit:async r=>{r.preventDefault(),e.submitting=!0,e.render();let t=await _api.register({username:e.username,password:e.password,email:e.email});"failed"===t.status?(e.submitting=!1,e.render(),alert(t.reason)):(await _api.login(e.username,e.password),alert("Registration success!"),navigate("/ed"))},className:cx("border-[3px] border-black",l.formStyle),children:[(0,n.jsx)("div",{className:"title",children:"Register"}),(0,n.jsxs)("label",{className:"mt-3",children:[(0,n.jsx)("span",{children:"Username"}),(0,n.jsx)(o.Input,{form:e,name:"username"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Password"}),(0,n.jsx)(o.Input,{form:e,name:"password",type:"password"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Email"}),(0,n.jsx)(o.Input,{form:e,name:"email"})]}),(0,n.jsx)("button",{type:"submit",disabled:e.submitting,children:e.submitting?"Loading...":"Submit"}),(0,n.jsx)("div",{className:"pt-2",children:(0,n.jsx)("a",{href:"/login",className:"cursor-pointer underline",children:"Login"})})]})}):(0,n.jsx)(i.Loading,{})}})},{"react/jsx-runtime":"f4Tol","web-utils":"ccU4J","../../../utils/ui/loading":"loFlS","../../../utils/ui/form.style":"jUQFK","../../../utils/ui/form/input":"1FhYR","@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}],jUQFK:[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"formStyle",()=>s);let s=css`
|
||||
!function(e,r,t,n,s){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof i[n]&&i[n],a=l.cache||{},o="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(r,t){if(!a[r]){if(!e[r]){var s="function"==typeof i[n]&&i[n];if(!t&&s)return s(r,!0);if(l)return l(r,!0);if(o&&"string"==typeof r)return o(r);var d=Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}p.resolve=function(t){var n=e[r][1][t];return null!=n?n:t},p.cache={};var c=a[r]=new u.Module(r);e[r][0].call(c.exports,p,c,c.exports,this)}return a[r].exports;function p(e){var r=p.resolve(e);return!1===r?{}:u(r)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=a,u.parent=l,u.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]},Object.defineProperty(u,"root",{get:function(){return i[n]}}),i[n]=u;for(var d=0;d<r.length;d++)u(r[d])}({Pi9M3:[function(e,r,t){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(t);var n=e("react/jsx-runtime"),s=e("web-utils"),i=e("../../../utils/ui/loading"),l=e("../../../utils/ui/form.style"),a=e("../../../utils/ui/form/input");t.default=(0,s.page)({url:"/register",component:({})=>{let e=(0,s.useLocal)({username:"",password:"",email:"",submitting:!1,init:!1},async()=>{let r=await _api.session();r&&r.id?navigate("/ed"):(e.init=!0,e.render())});return e.init?(0,n.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center",children:(0,n.jsxs)("form",{onSubmit:async r=>{r.preventDefault(),e.submitting=!0,e.render();let t=await _api.register({username:e.username,password:e.password,email:e.email});"failed"===t.status?(e.submitting=!1,e.render(),alert(t.reason)):(await _api.login(e.username,e.password),alert("Registration success!"),navigate("/ed"))},className:cx("border-[3px] border-black",l.formStyle),children:[(0,n.jsx)("div",{className:"title",children:"Register"}),(0,n.jsxs)("label",{className:"mt-3",children:[(0,n.jsx)("span",{children:"Username"}),(0,n.jsx)(a.Input,{form:e,name:"username"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Password"}),(0,n.jsx)(a.Input,{form:e,name:"password",type:"password"})]}),(0,n.jsxs)("label",{children:[(0,n.jsx)("span",{children:"Email"}),(0,n.jsx)(a.Input,{form:e,name:"email"})]}),(0,n.jsx)("button",{type:"submit",disabled:e.submitting,children:e.submitting?"Loading...":"Submit"}),(0,n.jsx)("div",{className:"pt-2",children:(0,n.jsx)("a",{href:"/login",className:"cursor-pointer underline",children:"Login"})})]})}):(0,n.jsx)(i.Loading,{})}})},{"react/jsx-runtime":"2bhZX","web-utils":"bzBzI","../../../utils/ui/loading":"loFlS","../../../utils/ui/form.style":"jUQFK","../../../utils/ui/form/input":"1FhYR","@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}],jUQFK:[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"formStyle",()=>s);let s=css`
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -45,5 +45,5 @@
|
|||
background: #999;
|
||||
}
|
||||
}
|
||||
`},{"@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}],"1FhYR":[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"Input",()=>i);var s=e("react/jsx-runtime");let i=e=>{let r={...e},{form:t,name:n}=e;delete r.form,delete r.name;let i=null;r.onChange&&(i=r.onChange,delete r.onChange);let l=t[n];return l instanceof URL&&(l=l.toString()),(0,s.jsx)("input",{value:l||"",spellCheck:!1,onInput:e=>{if(t[n]=e.currentTarget.value,i){let r=i(e.currentTarget.value);void 0!==r&&(t[n]=r)}t.render()},...r})}},{"react/jsx-runtime":"f4Tol","@parcel/transformer-js/src/esmodule-helpers.js":"2GYoY"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=register.46daa674.js.map
|
||||
`},{"@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}],"1FhYR":[function(e,r,t){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(t),n.export(t,"Input",()=>i);var s=e("react/jsx-runtime");let i=e=>{let r={...e},{form:t,name:n}=e;delete r.form,delete r.name;let i=null;r.onChange&&(i=r.onChange,delete r.onChange);let l=t[n];return l instanceof URL&&(l=l.toString()),(0,s.jsx)("input",{value:l||"",spellCheck:!1,onInput:e=>{if(t[n]=e.currentTarget.value,i){let r=i(e.currentTarget.value);void 0!==r&&(t[n]=r)}t.render()},...r})}},{"react/jsx-runtime":"2bhZX","@parcel/transformer-js/src/esmodule-helpers.js":"5WnJC"}]},[],0,"parcelRequire2d1f");
|
||||
//# sourceMappingURL=register.bf8057b7.js.map
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue