Skip to content

Commit

Permalink
more fucking typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
saboooor committed Jun 14, 2024
1 parent c058e67 commit f416afc
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/components/partytown/partytown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export interface PartytownProps extends PartytownConfig { }
* @public
* You can pass setting with props
*/
export const QwikPartytown = (props: PartytownProps): any => {
export const QwikPartytown = (props: PartytownProps) => {
return <script dangerouslySetInnerHTML={partytownSnippet(props)} />;
};
7 changes: 0 additions & 7 deletions src/components/util/flags/safeJSON.ts

This file was deleted.

12 changes: 6 additions & 6 deletions src/data/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,18 @@ export const flags: Flags = {
};

export const extraFlags: ExtraFlags = {
'vectors': {
'supports': ['aikars'],
'generate': ({ existingFlags }) => {
vectors: {
supports: ['aikars'],
generate: ({ existingFlags }) => {
return [
...existingFlags,
'--add-modules=jdk.incubator.vector',
];
},
},
'benchmarkedGraalVM': {
'supports': ['benchmarkedG1GC'],
'generate': ({ existingFlags }) => {
benchmarkedGraalVM: {
supports: ['benchmarkedG1GC'],
generate: ({ existingFlags }) => {
return [
...existingFlags,
'-XX:+UnlockExperimentalVMOptions',
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/v2/docs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default component$(() => {
<h3 class="flex gap-4 items-center text-gray-100 text-lg sm:text-2xl font-bold mb-2 drop-shadow-lg">
{path}
</h3>
{Object.entries(endpoints[path].methods).map(([method, description]: any) =>
{(Object.entries(endpoints[path].methods) as [string, string][]).map(([method, description]) =>
<p key={method} class="flex gap-4 items-center text-gray-400 sm:text-lg drop-shadow-lg">
{method}: {description}
</p>,
Expand Down
6 changes: 3 additions & 3 deletions src/routes/resources/animtab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default component$(() => {
</TextInput>

<Dropdown id="type" class={{ 'w-full': true }} onChange$={(e, el) => { animtabstore.type = Number(el.value); }}
values={types.map((type: any) => ({ name: type.name, value: type.value }))}
values={types}
value={animtabstore.type}>
{t('animtab.outputType@@Output Type')}
</Dropdown>
Expand Down Expand Up @@ -403,7 +403,7 @@ export default component$(() => {
} values={[
...Object.keys(presets).map(preset => ({ name: preset, value: preset })),
{ name: t('color.custom@@Custom'), value: 'custom' },
]} value={Object.keys(presets).find((preset: any) => presets[preset as keyof typeof presets].toString() == store.colors.toString()) ?? 'custom'}>
]} value={(Object.keys(presets) as Array<keyof typeof presets>).find((preset) => presets[preset].toString() == store.colors.toString()) ?? 'custom'}>
{t('color.colorPreset@@Color Preset')}
</Dropdown>
<TextInput id="prefixsuffix" value={store.prefixsuffix} placeholder={'welcome to $t'} onInput$={(e, el) => { store.prefixsuffix = el.value; }}>
Expand All @@ -416,7 +416,7 @@ export default component$(() => {
<Toggle id="advanced" checked={store.customFormat}
onChange$={(e, el) => { store.customFormat = el.checked; }}
label={<p class="flex flex-col"><span>Show advanced settings</span><span class="text-sm">These settings are hidden, only use them if you're trying to use this tool for a different plugin or know what you're doing.</span></p>} />
{tempstore.alerts.map((alert: any, i: number) => (
{tempstore.alerts.map((alert, i) => (
<p key={`preset-alert${i}`} class={alert.class} dangerouslySetInnerHTML={t(alert.text)} />
))}
{
Expand Down
145 changes: 70 additions & 75 deletions src/routes/resources/animtexture/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,31 @@ export default component$(() => {
document.head.appendChild(script);
});

useOn(
'change',
$((event) => {
const { files } = event.target as HTMLInputElement;
if (!files) return;
Array.from(files).forEach(file => {
const f = new FileReader();
f.readAsDataURL(file);
f.onloadend = async (e) => {
const b64 = e!.target!.result;
const type = b64!.toString().split(',')[0].split(';')[0].split(':')[1];
if (type == 'image/gif') {
// @ts-ignore
const gifframes = await gifFrames({ url: b64, frames: 'all', cumulative: store.cumulative });
gifframes.forEach((frame: any) => {
const contentStream = frame.getImage();
const imageData = window.btoa(String.fromCharCode.apply(null, contentStream._obj));
const b64frame = `data:image/png;base64,${imageData}`;

store.frames.push({ img: b64frame, delay: Math.ceil(20 * frame.frameInfo.delay / 100) });
});
return;
}
store.frames.push({ img: b64, delay: 20 });
};
});
}),
);
useOn('change', $((e, el) => {
const { files } = el as HTMLInputElement;
if (!files) return;
Array.from(files).forEach(file => {
const f = new FileReader();
f.readAsDataURL(file);
f.onloadend = async (e) => {
const b64 = e!.target!.result;
const type = b64!.toString().split(',')[0].split(';')[0].split(':')[1];
if (type == 'image/gif') {
// @ts-ignore
const gifframes = await gifFrames({ url: b64, frames: 'all', cumulative: store.cumulative });
gifframes.forEach((frame: any) => {
const contentStream = frame.getImage();
const imageData = window.btoa(String.fromCharCode.apply(null, contentStream._obj));
const b64frame = `data:image/png;base64,${imageData}`;

store.frames.push({ img: b64frame, delay: Math.ceil(20 * frame.frameInfo.delay / 100) });
});
return;
}
store.frames.push({ img: b64, delay: 20 });
};
});
}));
return (
<section class="flex mx-auto max-w-4xl px-6 items-center justify-center min-h-svh pt-[72px]">
<div class="my-10 min-h-[60px] w-full">
Expand Down Expand Up @@ -82,56 +79,54 @@ export default component$(() => {
</TextInput>

<Toggle id="Cumulative" checked={store.cumulative}
onChange$={(event: any) => { store.cumulative = event.target.checked; }}
onChange$={(e, el) => { store.cumulative = el.checked; }}
label={t('animtexture.cumulative@@Cumulative (Turn this on if gif frames are broken)')} />

<Button class={{ 'my-6': true }} onClick$={
() => {
const canvas: any = document.getElementById('c')!;
canvas.classList.add('sm:flex');
const imglist: any = document.getElementById('imgs')!;
const ctx = canvas.getContext('2d');
const imgs = imglist.getElementsByTagName('IMG');
let max = 0;
for (let i = 0; i != imgs.length; i++) {
if (imgs[i].naturalWidth > max) max = imgs[i].naturalWidth;
}
canvas.width = max;
canvas.height = max * imgs.length;
ctx.imageSmoothingEnabled = false;
for (let i = 0; i != imgs.length; i++) {
ctx.drawImage(imgs[i], 0, i * max);
ctx.drawImage(imgs[i], 0, max * i, max, max);
}
const b64 = canvas.toDataURL();
const pngd: any = document.getElementById('pngd')!;
const mcmeta: any = document.getElementById('mcmeta')!;
pngd.href = b64;
pngd.download = store.textureName + '.png';
mcmeta.download = store.textureName + '.png.mcmeta';

const start = '{"animation":{"frames": [';
const frameBase = '{"index": ';
const frameMid = ', "time": ';
const frameEnd = '},';
let res = start;
for (let i = 0; i != store.frames.length; i++) {
let tmp = frameBase;
tmp += i;
tmp += frameMid;
tmp += store.frames[i].delay;
tmp += frameEnd;
res += tmp;
}
res = res.substring(0, res.length - 1);
res += ']}}';

mcmeta.href = 'data:text/plain;charset=utf-8,' + res;

const links = document.getElementById('links')!;
links.className = 'inline';
<Button class={{ 'my-6': true }} onClick$={() => {
const canvas = document.getElementById('c') as HTMLCanvasElement;
canvas.classList.add('sm:flex');
const imglist = document.getElementById('imgs') as HTMLDivElement;
const ctx = canvas.getContext('2d')!;
const imgs = imglist.getElementsByTagName('IMG') as HTMLCollectionOf<HTMLImageElement>;
let max = 0;
for (let i = 0; i != imgs.length; i++) {
if (imgs[i].naturalWidth > max) max = imgs[i].naturalWidth;
}
canvas.width = max;
canvas.height = max * imgs.length;
ctx.imageSmoothingEnabled = false;
for (let i = 0; i != imgs.length; i++) {
ctx.drawImage(imgs[i], 0, i * max);
ctx.drawImage(imgs[i], 0, max * i, max, max);
}
}>
const b64 = canvas.toDataURL();
const pngd = document.getElementById('pngd') as HTMLAnchorElement;
const mcmeta = document.getElementById('mcmeta') as HTMLAnchorElement;
pngd.href = b64;
pngd.download = store.textureName + '.png';
mcmeta.download = store.textureName + '.png.mcmeta';

const start = '{"animation":{"frames": [';
const frameBase = '{"index": ';
const frameMid = ', "time": ';
const frameEnd = '},';
let res = start;
for (let i = 0; i != store.frames.length; i++) {
let tmp = frameBase;
tmp += i;
tmp += frameMid;
tmp += store.frames[i].delay;
tmp += frameEnd;
res += tmp;
}
res = res.substring(0, res.length - 1);
res += ']}}';

mcmeta.href = 'data:text/plain;charset=utf-8,' + res;

const links = document.getElementById('links')!;
links.className = 'inline';
}}>
{t('animtexture.generate@@Generate')}
</Button>

Expand Down
4 changes: 2 additions & 2 deletions src/routes/resources/flags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const defaults = {
gui: false,
variables: false,
autoRestart: false,
extraFlags: [] as Array<keyof typeof extFlags>,
extraFlags: [] as string[],
fileName: 'server.jar',
flags: 'aikars' as keyof typeof flagTypes,
withResult: true,
Expand Down Expand Up @@ -265,7 +265,7 @@ export default component$(() => {
</div>

{/* charlimit={256} */}
<TextArea output class={{ 'h-96 mt-2': true }} id="Output" value={((p: any) => generateResult(p).script)(store)}>
<TextArea output class={{ 'h-96 mt-2': true }} id="Output" value={generateResult(store).script}>
<Header subheader={t('flags.script.description@@The resulting script that can be used to start your server. Place this file in the same location as {{fileName}}, then execute it!', { fileName: store.fileName })}>
{t('flags.script.label@@Script')}
</Header>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/resources/rgb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export default component$(() => {
} values={[
...Object.keys(presets).map(preset => ({ name: preset, value: preset })),
{ name: t('color.custom@@Custom'), value: 'custom' },
]} value={Object.keys(presets).find((preset: any) => presets[preset as keyof typeof presets].toString() == store.colors.toString()) ?? 'custom'}>
]} value={(Object.keys(presets) as Array<keyof typeof presets>).find((preset) => presets[preset].toString() == store.colors.toString()) ?? 'custom'}>
{t('color.colorPreset@@Color Preset')}
</Dropdown>
<TextInput id="prefixsuffix" value={store.prefixsuffix} placeholder={'/nick $t'} onInput$={(e, el) => { store.prefixsuffix = el.value; }}>
Expand All @@ -420,7 +420,7 @@ export default component$(() => {
<Toggle id="trimspaces" checked={store.trimspaces}
onChange$={(e, el) => { store.trimspaces = el.checked; }}
label={<p class="flex flex-col"><span>Trim color codes from spaces</span><span class="text-sm">Turn this off if you're using empty underlines / strikethroughs</span></p>} />
{tempstore.alerts.map((alert: any, i: number) => (
{tempstore.alerts.map((alert, i) => (
<p key={`preset-alert${i}`} class={alert.class} dangerouslySetInnerHTML={t(alert.text)} />
))}
</div>
Expand Down

0 comments on commit f416afc

Please sign in to comment.