Replace the Vue frontend with Svelte

This commit is contained in:
Keavon Chambers
2023-03-10 03:54:39 -08:00
parent e539e43483
commit 6e20ea538b
83 changed files with 10013 additions and 19687 deletions
+23 -13
View File
@@ -5,7 +5,7 @@ import { Transform, Type, plainToClass } from "class-transformer";
import { type IconName, type IconSize } from "@/utility-functions/icons";
import { type WasmEditorInstance, type WasmRawInstance } from "@/wasm-communication/editor";
import type MenuList from "@/components/floating-menus/MenuList.vue";
import type MenuList from "@/components/floating-menus/MenuList.svelte";
export class JsMessage {
// The marker provides a way to check if an object is a sub-class constructor for a jsMessage.
@@ -496,7 +496,7 @@ const mouseCursorIconCSSNames = {
Rotate: "custom-rotate",
} as const;
export type MouseCursor = keyof typeof mouseCursorIconCSSNames;
export type MouseCursorIcon = (typeof mouseCursorIconCSSNames)[MouseCursor];
export type MouseCursorIcon = typeof mouseCursorIconCSSNames[MouseCursor];
export class UpdateMouseCursor extends JsMessage {
@Transform(({ value }: { value: MouseCursor }) => mouseCursorIconCSSNames[value] || "alias")
@@ -810,7 +810,7 @@ export class TriggerViewportResize extends JsMessage {}
// WIDGET PROPS
export abstract class WidgetProps {
kind!: string;
kind!: WidgetPropsNames;
}
export class CheckboxInput extends WidgetProps {
@@ -860,7 +860,7 @@ export type MenuListEntry = MenuEntryCommon & {
disabled?: boolean;
tooltip?: string;
font?: URL;
ref?: InstanceType<typeof MenuList>;
ref?: MenuList;
};
export class DropdownInput extends WidgetProps {
@@ -993,7 +993,7 @@ export class OptionalInput extends WidgetProps {
}
export class PopoverButton extends WidgetProps {
icon!: string | undefined;
icon!: IconName | undefined;
disabled!: boolean;
@@ -1065,7 +1065,7 @@ export class ParameterExposeButton extends WidgetProps {
export class TextButton extends WidgetProps {
label!: string;
icon!: string | undefined;
icon!: IconName | undefined;
emphasized!: boolean;
@@ -1096,7 +1096,7 @@ export type TextButtonWidget = {
};
export class BreadcrumbTrailButtons extends WidgetProps {
labels!: string;
labels!: string[];
disabled!: boolean;
@@ -1149,6 +1149,7 @@ export class PivotAssist extends WidgetProps {
// WIDGET
const widgetSubTypes = [
{ value: BreadcrumbTrailButtons, name: "BreadcrumbTrailButtons"},
{ value: CheckboxInput, name: "CheckboxInput" },
{ value: ColorInput, name: "ColorInput" },
{ value: DropdownInput, name: "DropdownInput" },
@@ -1158,18 +1159,27 @@ const widgetSubTypes = [
{ value: LayerReferenceInput, name: "LayerReferenceInput" },
{ value: NumberInput, name: "NumberInput" },
{ value: OptionalInput, name: "OptionalInput" },
{ value: ParameterExposeButton, name: "ParameterExposeButton" },
{ value: PivotAssist, name: "PivotAssist" },
{ value: PopoverButton, name: "PopoverButton" },
{ value: RadioInput, name: "RadioInput" },
{ value: Separator, name: "Separator" },
{ value: SwatchPairInput, name: "SwatchPairInput" },
{ value: TextAreaInput, name: "TextAreaInput" },
{ value: TextButton, name: "TextButton" },
{ value: ParameterExposeButton, name: "ParameterExposeButton" },
{ value: TextInput, name: "TextInput" },
{ value: TextLabel, name: "TextLabel" },
{ value: PivotAssist, name: "PivotAssist" },
];
export type WidgetPropsSet = InstanceType<(typeof widgetSubTypes)[number]["value"]>;
] as const;
type WidgetSubTypes = typeof widgetSubTypes[number];
type WidgetKindMap = { [T in WidgetSubTypes as T["name"]]: InstanceType<T["value"]> };
export type WidgetPropsNames = keyof WidgetKindMap;
export type WidgetPropsSet = WidgetKindMap[WidgetPropsNames];
export function narrowWidgetProps<K extends WidgetPropsNames>(props: WidgetPropsSet, kind: K) {
if (props.kind === kind) return props as WidgetKindMap[K]
else return undefined;
}
export class Widget {
constructor(props: WidgetPropsSet, widgetId: bigint) {
@@ -1177,7 +1187,7 @@ export class Widget {
this.widgetId = widgetId;
}
@Type(() => WidgetProps, { discriminator: { property: "kind", subTypes: widgetSubTypes }, keepDiscriminatorProperty: true })
@Type(() => WidgetProps, { discriminator: { property: "kind", subTypes: [...widgetSubTypes] }, keepDiscriminatorProperty: true })
props!: WidgetPropsSet;
widgetId!: bigint;
@@ -1226,7 +1236,7 @@ export function defaultWidgetLayout(): WidgetLayout {
}
// Updates a widget layout based on a list of updates, returning the new layout
export function patchWidgetLayout(layout: WidgetLayout, updates: WidgetDiffUpdate): void {
export function patchWidgetLayout(/* mut */ layout: WidgetLayout, updates: WidgetDiffUpdate): void {
layout.layoutTarget = updates.layoutTarget;
updates.diff.forEach((update) => {