* add package.json Signed-off-by: Jess Frazelle <github@jessfraz.com> initial run; Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> more fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> clientsidescne Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> paths Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix styles Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> combine Signed-off-by: Jess Frazelle <github@jessfraz.com> eslint rule Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> my ocd Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> constants file Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> no more import sceneInfra Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> try fix circular import Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
// Some command argument payloads are objects with a value field that is a KCL expression.
|
|
// That object also contains some metadata about what to do with the KCL expression,
|
|
// such as whether we need to create a new variable for it.
|
|
// This function extracts the value field from those arg payloads and returns
|
|
import type { Command } from '@src/lib/commandTypes'
|
|
|
|
// The arg object with all its field as natural values that the command to be executed will expect.
|
|
export function getCommandArgumentKclValuesOnly(args: Record<string, unknown>) {
|
|
return Object.fromEntries(
|
|
Object.entries(args).map(([key, value]) => {
|
|
if (value !== null && typeof value === 'object' && 'value' in value) {
|
|
return [key, value.value]
|
|
}
|
|
return [key, value]
|
|
})
|
|
)
|
|
}
|
|
|
|
export interface CommandWithDisabledState {
|
|
command: Command
|
|
disabled: boolean
|
|
}
|
|
|
|
/**
|
|
* Sorting logic for commands in the command combo box.
|
|
*/
|
|
export function sortCommands(
|
|
a: CommandWithDisabledState,
|
|
b: CommandWithDisabledState
|
|
) {
|
|
// Disabled commands should be at the bottom
|
|
if (a.disabled && !b.disabled) {
|
|
return 1
|
|
}
|
|
if (b.disabled && !a.disabled) {
|
|
return -1
|
|
}
|
|
// Settings commands should be next-to-last
|
|
if (a.command.groupId === 'settings' && b.command.groupId !== 'settings') {
|
|
return 1
|
|
}
|
|
if (b.command.groupId === 'settings' && a.command.groupId !== 'settings') {
|
|
return -1
|
|
}
|
|
// Modeling commands should be first
|
|
if (a.command.groupId === 'modeling' && b.command.groupId !== 'modeling') {
|
|
return -1
|
|
}
|
|
if (b.command.groupId === 'modeling' && a.command.groupId !== 'modeling') {
|
|
return 1
|
|
}
|
|
// Sort alphabetically
|
|
return (a.command.displayName || a.command.name).localeCompare(
|
|
b.command.displayName || b.command.name
|
|
)
|
|
}
|