Move luxon dependency to npm

ElementalAlchemist 3 weeks ago
parent c3448542c4
commit 7de2f807b1

@ -16,9 +16,11 @@
"typescript": "5.6.3", "typescript": "5.6.3",
"url": "0.11.4", "url": "0.11.4",
"vite": "5.4.10", "vite": "5.4.10",
"vite-plugin-solid": "2.10.2" "vite-plugin-solid": "2.10.2",
"@types/luxon": "3.4.2"
}, },
"dependencies": { "dependencies": {
"luxon": "3.4.4",
"solid-js": "1.9.3" "solid-js": "1.9.3"
} }
} }

@ -1,5 +1,4 @@
import { l } from "vite/dist/node/types.d-aGj9QkWt"; import { DateTime } from "luxon";
import { DateTime } from "../external/luxon.min";
export function dateTimeFromWubloaderTime(wubloaderTime: string): DateTime | null { export function dateTimeFromWubloaderTime(wubloaderTime: string): DateTime | null {
const dt = DateTime.fromISO(wubloaderTime, { zone: "UTC" }); const dt = DateTime.fromISO(wubloaderTime, { zone: "UTC" });
@ -86,7 +85,7 @@ export function timeAgoFromDateTime(dateTime: DateTime): string {
timeAgoSeconds = -timeAgoSeconds; timeAgoSeconds = -timeAgoSeconds;
} }
const seconds = (((timeAgoSeconds % 60) * 1000) | 0) / 1000 const seconds = (((timeAgoSeconds % 60) * 1000) | 0) / 1000;
const secondsString = seconds < 10 ? `0${seconds}` : seconds.toString(); const secondsString = seconds < 10 ? `0${seconds}` : seconds.toString();
const minutes = (timeAgoSeconds / 60) % 60 | 0; const minutes = (timeAgoSeconds / 60) % 60 | 0;
const minutesString = minutes < 10 ? `0${minutes}` : minutes.toString(); const minutesString = minutes < 10 ? `0${minutes}` : minutes.toString();

@ -40,7 +40,9 @@ export const GoogleSignIn: Component = () => {
return ( return (
<div> <div>
<div id="google-auth-sign-in" class="g-signin2" data-onsuccess="googleOnSignIn"></div> <div id="google-auth-sign-in" class="g-signin2" data-onsuccess="googleOnSignIn"></div>
<a href="javascript:googleSignOut" id="google-auth-sign-out" class="hidden">Sign Out of Google Account</a> <a href="javascript:googleSignOut" id="google-auth-sign-out" class="hidden">
Sign Out of Google Account
</a>
</div> </div>
); );
}; };

File diff suppressed because one or more lines are too long

@ -41,13 +41,19 @@ const ThumbnailManager: Component = () => {
cropStart: cropStart, cropStart: cropStart,
cropEnd: cropEnd, cropEnd: cropEnd,
locationStart: locationStart, locationStart: locationStart,
locationEnd: locationEnd locationEnd: locationEnd,
}); });
} }
setTemplates(templateList); setTemplates(templateList);
}); });
const submitHandler = async (origName: string, noImageIsError: boolean, errorList: Accessor<string[]>, setErrorList: Setter<string[]>, event: SubmitEvent): Promise<Template | null> => { const submitHandler = async (
origName: string,
noImageIsError: boolean,
errorList: Accessor<string[]>,
setErrorList: Setter<string[]>,
event: SubmitEvent,
): Promise<Template | null> => {
setErrorList([]); setErrorList([]);
const form = event.currentTarget as HTMLFormElement; const form = event.currentTarget as HTMLFormElement;
@ -67,7 +73,16 @@ const ThumbnailManager: Component = () => {
const locEndX = parseInt(formData.get("locendx") as string, 10); const locEndX = parseInt(formData.get("locendx") as string, 10);
const locEndY = parseInt(formData.get("locendy") as string, 10); const locEndY = parseInt(formData.get("locendy") as string, 10);
if (isNaN(cropStartX) || isNaN(cropStartY) || isNaN(cropEndX) || isNaN(cropEndY) || isNaN(locStartX) || isNaN(locStartY) || isNaN(locEndX) || isNaN(locEndY)) { if (
isNaN(cropStartX) ||
isNaN(cropStartY) ||
isNaN(cropEndX) ||
isNaN(cropEndY) ||
isNaN(locStartX) ||
isNaN(locStartY) ||
isNaN(locEndX) ||
isNaN(locEndY)
) {
setErrorList((errors) => { setErrorList((errors) => {
errors.push("All crop and location information must be entered."); errors.push("All crop and location information must be entered.");
return errors; return errors;
@ -108,12 +123,15 @@ const ThumbnailManager: Component = () => {
return null; return null;
} }
const submitURL = (origName === "") ? "/thrimshim/add-template" : `/thrimshim/update-template/${encodeURIComponent(origName)}`; const submitURL =
origName === ""
? "/thrimshim/add-template"
: `/thrimshim/update-template/${encodeURIComponent(origName)}`;
const submitDataJSON = JSON.stringify(Object.fromEntries(submitData)); const submitDataJSON = JSON.stringify(Object.fromEntries(submitData));
const submitResponse = await fetch(submitURL, { const submitResponse = await fetch(submitURL, {
method: "POST", method: "POST",
body: submitDataJSON, body: submitDataJSON,
headers: { "Content-Type": "application/json" } headers: { "Content-Type": "application/json" },
}); });
if (!submitResponse.ok) { if (!submitResponse.ok) {
const errorText = await submitResponse.text(); const errorText = await submitResponse.text();
@ -132,7 +150,7 @@ const ThumbnailManager: Component = () => {
cropStart: { x: cropStartX, y: cropStartY }, cropStart: { x: cropStartX, y: cropStartY },
cropEnd: { x: cropEndX, y: cropEndY }, cropEnd: { x: cropEndX, y: cropEndY },
locationStart: { x: locStartX, y: locStartY }, locationStart: { x: locStartX, y: locStartY },
locationEnd: { x: locEndX, y: locEndY } locationEnd: { x: locEndX, y: locEndY },
}; };
}; };
@ -158,7 +176,13 @@ const ThumbnailManager: Component = () => {
<form <form
class={styles.templatesListRow} class={styles.templatesListRow}
onSubmit={async (event) => { onSubmit={async (event) => {
const submitData = await submitHandler(template().name, false, formErrors, setFormErrors, event); const submitData = await submitHandler(
template().name,
false,
formErrors,
setFormErrors,
event,
);
if (submitData) { if (submitData) {
setTemplates((templateList) => { setTemplates((templateList) => {
templateList[index] = submitData; templateList[index] = submitData;
@ -175,39 +199,30 @@ const ThumbnailManager: Component = () => {
<div>{template().description}</div> <div>{template().description}</div>
<div>{template().attribution}</div> <div>{template().attribution}</div>
<div> <div>
({template().cropStart.x}, {template().cropStart.y}) ({template().cropStart.x}, {template().cropStart.y}) to (
to {template().cropEnd.x}, {template().cropEnd.y})
({template().cropEnd.x}, {template().cropEnd.y})
</div> </div>
<div> <div>
({template().locationStart.x}, {template().locationStart.y}) ({template().locationStart.x}, {template().locationStart.y}) to (
to {template().locationEnd.x}, {template().locationEnd.y})
({template().locationEnd.x}, {template().locationEnd.y})
</div> </div>
<div> <div>
<Show <Show
when={displayImagePreview()} when={displayImagePreview()}
fallback={ fallback={
<a <a href="#" onClick={(event) => setDisplayImagePreview(true)}>
href="#"
onClick={
(event) => setDisplayImagePreview(true)
}
>
Preview Preview
</a> </a>
} }
> >
<img class={styles.templateImagePreview} src={`/thrimshim/template/${encodeURIComponent(template().name)}.png`} /> <img
class={styles.templateImagePreview}
src={`/thrimshim/template/${encodeURIComponent(template().name)}.png`}
/>
</Show> </Show>
</div> </div>
<div> <div>
<button <button type="button" onClick={(event) => setEditing(true)}>
type="button"
onClick={
(event) => setEditing(true)
}
>
Edit Edit
</button> </button>
</div> </div>
@ -226,28 +241,92 @@ const ThumbnailManager: Component = () => {
</div> </div>
<div> <div>
( (
<input type="number" name="cropstartx" placeholder="X" min={0} step={1} class={styles.templateCoord} value={template().cropStart.x} /> <input
type="number"
name="cropstartx"
placeholder="X"
min={0}
step={1}
class={styles.templateCoord}
value={template().cropStart.x}
/>
, ,
<input type="number" name="cropstarty" placeholder="Y" min={0} step={1} class={styles.templateCoord} value={template().cropStart.y} /> <input
type="number"
name="cropstarty"
placeholder="Y"
min={0}
step={1}
class={styles.templateCoord}
value={template().cropStart.y}
/>
) )
<br /> <br />
( (
<input type="number" name="cropendx" placeholder="X" min={0} step={1} class={styles.templateCoord} value={template().cropEnd.x} /> <input
type="number"
name="cropendx"
placeholder="X"
min={0}
step={1}
class={styles.templateCoord}
value={template().cropEnd.x}
/>
, ,
<input type="number" name="cropendy" placeholder="Y" min={0} step={1} class={styles.templateCoord} value={template().cropEnd.y} /> <input
type="number"
name="cropendy"
placeholder="Y"
min={0}
step={1}
class={styles.templateCoord}
value={template().cropEnd.y}
/>
) )
</div> </div>
<div> <div>
( (
<input type="number" name="locstartx" placeholder="X" min={0} step={1} class={styles.templateCoord} value={template().locationStart.x} /> <input
type="number"
name="locstartx"
placeholder="X"
min={0}
step={1}
class={styles.templateCoord}
value={template().locationStart.x}
/>
, ,
<input type="number" name="locstarty" placeholder="Y" min={0} step={1} class={styles.templateCoord} value={template().locationStart.y} /> <input
type="number"
name="locstarty"
placeholder="Y"
min={0}
step={1}
class={styles.templateCoord}
value={template().locationStart.y}
/>
) )
<br /> <br />
( (
<input type="number" name="locendx" placeholder="X" min={0} step={1} class={styles.templateCoord} value={template().locationEnd.x} /> <input
type="number"
name="locendx"
placeholder="X"
min={0}
step={1}
class={styles.templateCoord}
value={template().locationEnd.x}
/>
, ,
<input type="number" name="locendy" placeholder="Y" min={0} step={1} class={styles.templateCoord} value={template().locationEnd.y} /> <input
type="number"
name="locendy"
placeholder="Y"
min={0}
step={1}
class={styles.templateCoord}
value={template().locationEnd.y}
/>
) )
</div> </div>
<div> <div>
@ -270,7 +349,13 @@ const ThumbnailManager: Component = () => {
</div> </div>
<form <form
onSubmit={async (event) => { onSubmit={async (event) => {
const submitData = await submitHandler("", true, newTemplateErrors, setNewTemplateErrors, event); const submitData = await submitHandler(
"",
true,
newTemplateErrors,
setNewTemplateErrors,
event,
);
if (submitData) { if (submitData) {
setTemplates((templateList) => [...templateList, submitData]); setTemplates((templateList) => [...templateList, submitData]);
} }

@ -1,5 +1,5 @@
import { Accessor, Component, createSignal, onCleanup, onMount } from "solid-js"; import { Accessor, Component, createSignal, onCleanup, onMount } from "solid-js";
import { DateTime, Interval } from "../external/luxon.min"; import { DateTime, Interval } from "luxon";
interface ClockProps { interface ClockProps {
busStartTime: Accessor<DateTime | null>; busStartTime: Accessor<DateTime | null>;

@ -1,5 +1,5 @@
import { Accessor, Component, createSignal } from "solid-js"; import { Accessor, Component, createSignal } from "solid-js";
import { DateTime } from "../external/luxon.min"; import { DateTime } from "luxon";
import { import {
dateTimeFromWubloaderTime, dateTimeFromWubloaderTime,
dateTimeFromBusTime, dateTimeFromBusTime,

@ -1,5 +1,5 @@
import { Component, createSignal, onMount } from "solid-js"; import { Component, createSignal, onMount } from "solid-js";
import { DateTime } from "../external/luxon.min"; import { DateTime } from "luxon";
import Clock from "./Clock"; import Clock from "./Clock";
import TimeConverter from "./TimeConverter"; import TimeConverter from "./TimeConverter";

Loading…
Cancel
Save