Skip to content

Commit df55e43

Browse files
committed
🚧 Improve some types, and fix some dialog issues
1 parent 958e209 commit df55e43

27 files changed

+213
-175
lines changed

src/blueprintFormat.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BillboardMode, BoneConfig, LocatorConfig } from './nodeConfigs'
33
import ProjectTitleSvelte from './components/projectTitle.svelte'
44
import { PACKAGE } from './constants'
55
import { events } from './util/events'
6-
import { injectSvelteCompomponent } from './util/injectSvelte'
6+
import { injectSvelteCompomponent } from './util/injectSvelteComponent'
77
import { toSafeFuntionName } from './util/minecraftUtil'
88
import { addProjectToRecentProjects } from './util/misc'
99
import { Valuable } from './util/stores'
@@ -527,8 +527,8 @@ export const BLUEPRINT_FORMAT = new Blockbench.ModelFormat({
527527
created() {
528528
void injectSvelteCompomponent({
529529
elementSelector: () => $('#format_page_animated_java_blueprint_mount')[0],
530-
svelteComponent: FormatPageSvelte,
531-
svelteComponentProperties: { format: BLUEPRINT_FORMAT },
530+
component: FormatPageSvelte,
531+
props: {},
532532
})
533533
},
534534
template: `<div id="format_page_animated_java_blueprint_mount" style="display: flex; flex-direction: column; flex-grow: 1;"></div>`,
@@ -585,8 +585,8 @@ export const BLUEPRINT_FORMAT = new Blockbench.ModelFormat({
585585
}
586586
},
587587
prepend: true,
588-
svelteComponent: ProjectTitleSvelte,
589-
svelteComponentProperties: { pluginMode: thisProject.pluginMode },
588+
component: ProjectTitleSvelte,
589+
props: { pluginMode: thisProject.pluginMode },
590590
})
591591

592592
if (Variant.all.length === 0) new Variant('Default', true)

src/interface/aboutDialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export function openAboutDialog() {
88
id: `${PACKAGE.name}:aboutDialog`,
99
title: translate('dialog.about.title'),
1010
width: 700,
11-
svelteComponent: AboutSvelte,
12-
svelteComponentProperties: {},
11+
component: AboutSvelte,
12+
props: {},
1313
buttons: [translate('dialog.about.close_button')],
1414
preventKeybinds: true,
1515
}).show()

src/interface/animatedJavaLoadingPopup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SvelteComponent } from 'svelte'
22
import AnimatedJavaLoadingPopup from '../components/animatedJavaLoadingPopup.svelte'
3-
import { injectSvelteCompomponent } from '../util/injectSvelte'
3+
import { injectSvelteCompomponent } from '../util/injectSvelteComponent'
44
import { Valuable } from '../util/stores'
55

66
const LOADED = new Valuable(false)
@@ -10,8 +10,8 @@ let activeComponent: SvelteComponent | undefined
1010
export async function showLoadingPopup() {
1111
if (activeComponent) return
1212
activeComponent = await injectSvelteCompomponent({
13-
svelteComponent: AnimatedJavaLoadingPopup,
14-
svelteComponentProperties: {
13+
component: AnimatedJavaLoadingPopup,
14+
props: {
1515
loaded: LOADED,
1616
offline: OFFLINE,
1717
},

src/interface/animationPropertiesDialog.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export const DIALOG_ID = `${PACKAGE.name}:animationPropertiesDialog`
88

99
export function openAnimationPropertiesDialog(animation: _Animation) {
1010
const animationName = new Valuable(animation.name)
11-
const loopMode = new Valuable(animation.loop)
11+
const loopMode = new Valuable(animation.loop as string)
1212
const loopDelay = new Valuable(Number(animation.loop_delay) || 0)
1313
const excludedNodes = new Valuable(animation.excluded_nodes)
1414

1515
new SvelteDialog({
1616
id: DIALOG_ID,
1717
title: translate('dialog.animation_properties.title', animation.name),
1818
width: 600,
19-
svelteComponent: AniamtionPropertiesSvelteComponent,
20-
svelteComponentProperties: {
19+
component: AniamtionPropertiesSvelteComponent,
20+
props: {
2121
animationName,
2222
loopMode,
2323
loopDelay,
@@ -27,7 +27,7 @@ export function openAnimationPropertiesDialog(animation: _Animation) {
2727
onConfirm() {
2828
animation.name = animationName.get()
2929
animation.createUniqueName(Blockbench.Animation.all)
30-
animation.loop = loopMode.get()
30+
animation.loop = loopMode.get() as any
3131
animation.loop_delay = loopDelay.get().toString()
3232
animation.excluded_nodes = excludedNodes.get()
3333
},

src/interface/blueprintLoadingPopup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { translate } from '../util/translation'
77
export const PROGRESS = new Valuable(0)
88
export const MAX_PROGRESS = new Valuable(1)
99

10-
let instance: SvelteDialog | null = null
10+
let instance: SvelteDialog<any, any> | null = null
1111

1212
export function openBlueprintLoadingDialog() {
1313
PROGRESS.set(0)
@@ -17,8 +17,8 @@ export function openBlueprintLoadingDialog() {
1717
id: `${PACKAGE.name}:blueprintLoadingPopup`,
1818
title: translate('dialog.blueprint_loading.title'),
1919
width: 128,
20-
svelteComponent: BlueprintLoadingPopup,
21-
svelteComponentProperties: {
20+
component: BlueprintLoadingPopup,
21+
props: {
2222
progress: PROGRESS,
2323
maxProgress: MAX_PROGRESS,
2424
},

src/interface/blueprintSettingsDialog.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SvelteDialog } from '../util/svelteDialog'
33
import { Valuable } from '../util/stores'
44
import BlueprintSettingsDialogSvelteComponent from '../components/blueprintSettingsDialog.svelte'
55
import { toSafeFuntionName } from '../util/minecraftUtil'
6-
import { defaultValues } from '../blueprintSettings'
6+
import { defaultValues, ExportMode } from '../blueprintSettings'
77
import { translate } from '../util/translation'
88
import { updateBoundingBox } from '../blueprintFormat'
99

@@ -29,8 +29,10 @@ function getSettings() {
2929
}
3030
return toSafeFuntionName(value)
3131
}),
32-
resourcePackExportMode: new Valuable(Project!.animated_java.resource_pack_export_mode),
33-
dataPackExportMode: new Valuable(Project!.animated_java.data_pack_export_mode),
32+
resourcePackExportMode: new Valuable(
33+
Project!.animated_java.resource_pack_export_mode as string
34+
),
35+
dataPackExportMode: new Valuable(Project!.animated_java.data_pack_export_mode as string),
3436
// Resource Pack Settings
3537
displayItem: new Valuable(Project!.animated_java.display_item, value => {
3638
if (!value) {
@@ -75,8 +77,9 @@ function setSettings(settings: ReturnType<typeof getSettings>) {
7577
Project.animated_java.enable_plugin_mode = settings.enablePluginMode.get()
7678
Project.pluginMode.set(settings.enablePluginMode.get()) // Required to update the project title.
7779
Project.animated_java.export_namespace = settings.exportNamespace.get()
78-
Project.animated_java.resource_pack_export_mode = settings.resourcePackExportMode.get()
79-
Project.animated_java.data_pack_export_mode = settings.dataPackExportMode.get()
80+
Project.animated_java.resource_pack_export_mode =
81+
settings.resourcePackExportMode.get() as ExportMode
82+
Project.animated_java.data_pack_export_mode = settings.dataPackExportMode.get() as ExportMode
8083
// Resource Pack Settings
8184
Project.animated_java.display_item = settings.displayItem.get()
8285
Project.animated_java.custom_model_data_offset = settings.customModelDataOffset.get()
@@ -109,8 +112,8 @@ export function openBlueprintSettingsDialog() {
109112
id: `${PACKAGE.name}:blueprintSettingsDialog`,
110113
title: translate('dialog.blueprint_settings.title'),
111114
width: 512,
112-
svelteComponent: BlueprintSettingsDialogSvelteComponent,
113-
svelteComponentProperties: settings,
115+
component: BlueprintSettingsDialogSvelteComponent,
116+
props: settings,
114117
preventKeybinds: true,
115118
onConfirm() {
116119
setSettings(settings)

src/interface/boneConfigDialog.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function openBoneConfigDialog(bone: Group) {
6565

6666
const oldConfig = BoneConfig.fromJSON(boneConfigJSON)
6767

68-
const billboard = new Valuable(oldConfig.billboard)
68+
const billboard = new Valuable(oldConfig.billboard as string)
6969
const overrideBrightness = new Valuable(oldConfig.overrideBrightness)
7070
const brightnessOverride = new Valuable(oldConfig.brightnessOverride)
7171
const enchanted = new Valuable(oldConfig.enchanted)
@@ -83,9 +83,9 @@ export function openBoneConfigDialog(bone: Group) {
8383
id: `${PACKAGE.name}:boneConfig`,
8484
title: translate('dialog.bone_config.title'),
8585
width: 400,
86-
svelteComponent: BoneConfigDialogSvelteComponent,
87-
svelteComponentProperties: {
88-
variant: Variant.selected,
86+
component: BoneConfigDialogSvelteComponent,
87+
props: {
88+
variant: Variant.selected!,
8989
billboard,
9090
overrideBrightness,
9191
brightnessOverride,
@@ -104,7 +104,7 @@ export function openBoneConfigDialog(bone: Group) {
104104
onConfirm() {
105105
const newConfig = new BoneConfig()
106106

107-
newConfig.billboard = billboard.get()
107+
newConfig.billboard = billboard.get() as any
108108
newConfig.overrideBrightness = overrideBrightness.get()
109109
newConfig.brightnessOverride = brightnessOverride.get()
110110
newConfig.enchanted = enchanted.get()

src/interface/customKeyframePanel.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import CustomKeyframePanelSvelteComponent from '../components/customKeyframePanel.svelte'
22
import { CUSTOM_CHANNELS } from '../mods/customKeyframesMod'
33
import { events } from '../util/events'
4-
import { injectSvelteCompomponent } from '../util/injectSvelte'
4+
import { injectSvelteCompomponent } from '../util/injectSvelteComponent'
55
import { Valuable } from '../util/stores'
66
import { translate } from '../util/translation'
77

@@ -24,8 +24,11 @@ export function injectCustomKeyframePanel(selectedKeyframe: _Keyframe) {
2424
}
2525

2626
void injectSvelteCompomponent({
27-
svelteComponent: CustomKeyframePanelSvelteComponent,
28-
svelteComponentProperties: { currentPanel: CURRENT_PANEL, selectedKeyframe },
27+
component: CustomKeyframePanelSvelteComponent,
28+
props: {
29+
currentPanel: CURRENT_PANEL as Valuable<HTMLDivElement>,
30+
selectedKeyframe,
31+
},
2932
elementSelector() {
3033
return element
3134
},

src/interface/exportProgressDialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export function openExportProgressDialog(debug?: boolean) {
2828
id: `${PACKAGE.name}:exportProgressDialog`,
2929
title: translate('dialog.export_progress.title'),
3030
width: 512,
31-
svelteComponent: ExportProgressDialogSvelteComponent,
32-
svelteComponentProperties: {
31+
component: ExportProgressDialogSvelteComponent,
32+
props: {
3333
progress: PROGRESS,
3434
maxProgress: MAX_PROGRESS,
3535
progressDescription: PROGRESS_DESCRIPTION,

src/interface/importAJModelLoader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SvelteComponentDev } from 'svelte/internal'
22
import ImportAjModelLoaderDialog from '../components/importAJModelLoaderDialog.svelte'
33
import { PACKAGE } from '../constants'
4-
import { injectSvelteCompomponent } from '../util/injectSvelte'
4+
import { injectSvelteCompomponent } from '../util/injectSvelteComponent'
55
import { createModelLoader } from '../util/moddingTools'
66
import { translate } from '../util/translation'
77
import { openUnexpectedErrorDialog } from './unexpectedErrorDialog'
@@ -28,8 +28,8 @@ createModelLoader(`${PACKAGE.name}-upgradeAJModelLoader`, {
2828
activeComponent.$destroy()
2929
}
3030
void injectSvelteCompomponent({
31-
svelteComponent: ImportAjModelLoaderDialog,
32-
svelteComponentProperties: {},
31+
component: ImportAjModelLoaderDialog,
32+
props: {},
3333
elementSelector() {
3434
return document.querySelector(`#${PACKAGE.name}-upgradeAJModelLoader-target`)
3535
},

0 commit comments

Comments
 (0)