* chore: saving off skeleton * fix: saving skeleton * chore: skeleton for loading projects from project directory path * chore: cleaning up useless state transition to be an on event direct to action state * fix: new structure for web vs desktop vs react machine provider code * chore: saving off skeleton * fix: skeleton logic for react? going to move it from a string to obj.string * fix: trying to prevent error element unmount on global react components. This is bricking JS state * fix: we are so back * chore: implemented navigating to specfic KCL file * chore: implementing renaming project * chore: deleting project * fix: auto fixes * fix: old debug/testing file oops * chore: generic create new file * chore: skeleton for web create file provide * chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest? * chore: save off progress before deleting other project implementation, a few missing features still * chore: trying a different init skeleton? most likely will migrate * chore: first attempt of purging projects context provider * chore: enabling toast for some machine state * chore: enabling more toast success and error * chore: writing read write state to the system io based on the project path * fix: tsc fixes * fix: use file system watcher, navigate to project after creation via the requestProjectName * chore: open project command, hooks vs snapshot context helpers * chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now. * fix: codespell fixes * chore: implementing more project commands * chore: PR improvements for root.tsx * chore: leaving comment about new Router.tsx layout * fix: removing debugging code * fix: rewriting component for readability * fix: improving web initialization * chore: implementing import file from url which is not actually that? * fix: clearing search params on import file from url * fix: fixed two e2e tests, forgot needsReview when making new command * fix: fixing some import from url business logic to pass e2e tests * chore: script for diffing circular deps +/- * fix: formatting * fix: massive fix for circular depsga! * fix: trying to fix some errors and auto fmt * fix: updating deps * fix: removing debugging code * fix: big clean up * fix: more deletion * fix: tsc cleanup * fix: TSC TSC TSC TSC! * fix: typo fix * fix: clear query params on web only, desktop not required * fix: removing unused code * fmt * Bring back `trap` removed in merge * Use explicit types instead of `any`s on arg configs * Add project commands directly to command palette * fix: deleting debugging code, from PR review * fix: this got added back(?) * fix: using referred type * fix: more PR clean up * fix: big block comment for xstate architecture decision * fix: more pr comment fixes * fix: merge conflict just added them back why dude * fix: more PR comments * fix: big ciruclar deps fix, commandBarActor in appActor --------- Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
138 lines
3.5 KiB
TypeScript
138 lines
3.5 KiB
TypeScript
import type { FileEntry, Project } from '@src/lib/project'
|
|
import type CodeManager from '@src/lang/codeManager'
|
|
import type { EngineCommandManager } from '@src/lang/std/engineConnection'
|
|
import type { KclManager } from '@src/lang/KclSingleton'
|
|
import type { SceneInfra } from '@src/clientSideScene/sceneInfra'
|
|
import type { SceneEntities } from '@src/clientSideScene/sceneEntities'
|
|
import type { engineStreamMachine } from '@src/machines/engineStreamMachine'
|
|
import type { authMachine } from '@src/machines/authMachine'
|
|
import type { settingsMachine } from '@src/machines/settingsMachine'
|
|
import type { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
|
import type { ActorRefFrom } from 'xstate'
|
|
import type { commandBarMachine } from '@src/machines/commandBarMachine'
|
|
|
|
export type IndexLoaderData = {
|
|
code: string | null
|
|
project?: Project
|
|
file?: FileEntry
|
|
}
|
|
|
|
export type FileLoaderData = {
|
|
code: string | null
|
|
project?: FileEntry | Project
|
|
file?: FileEntry
|
|
}
|
|
|
|
export type HomeLoaderData = Record<string, never>
|
|
|
|
// From the very helpful @jcalz on StackOverflow: https://stackoverflow.com/a/58436959/22753272
|
|
type Join<K, P> = K extends string | number
|
|
? P extends string | number
|
|
? `${K}${'' extends P ? '' : '.'}${P}`
|
|
: never
|
|
: never
|
|
|
|
type Prev = [
|
|
never,
|
|
0,
|
|
1,
|
|
2,
|
|
3,
|
|
4,
|
|
5,
|
|
6,
|
|
7,
|
|
8,
|
|
9,
|
|
10,
|
|
11,
|
|
12,
|
|
13,
|
|
14,
|
|
15,
|
|
16,
|
|
17,
|
|
18,
|
|
19,
|
|
20,
|
|
...0[],
|
|
]
|
|
|
|
export type Paths<T, D extends number = 10> = [D] extends [never]
|
|
? never
|
|
: T extends object
|
|
? {
|
|
[K in keyof T]-?: K extends string | number
|
|
? `${K}` | Join<K, Paths<T[K], Prev[D]>>
|
|
: never
|
|
}[keyof T]
|
|
: ''
|
|
|
|
type Idx<T, K> = K extends keyof T
|
|
? T[K]
|
|
: number extends keyof T
|
|
? K extends `${number}`
|
|
? T[number]
|
|
: never
|
|
: never
|
|
|
|
export type PathValue<
|
|
T,
|
|
P extends Paths<T, 1>,
|
|
> = P extends `${infer Key}.${infer Rest}`
|
|
? Rest extends Paths<Idx<T, Key>, 1>
|
|
? PathValue<Idx<T, Key>, Rest>
|
|
: never
|
|
: Idx<T, P>
|
|
|
|
export type Leaves<T, D extends number = 10> = [D] extends [never]
|
|
? never
|
|
: T extends object
|
|
? { [K in keyof T]-?: Join<K, Leaves<T[K], Prev[D]>> }[keyof T]
|
|
: ''
|
|
|
|
// Thanks to @micfan on StackOverflow for this utility type:
|
|
// https://stackoverflow.com/a/57390160/22753272
|
|
export type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>
|
|
|
|
export function isEnumMember<T extends Record<string, unknown>>(
|
|
v: unknown,
|
|
e: T
|
|
) {
|
|
return Object.values(e).includes(v)
|
|
}
|
|
|
|
// utility type to make all *nested* object properties optional
|
|
// https://www.geodev.me/blog/deeppartial-in-typescript
|
|
export type DeepPartial<T> = {
|
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
|
}
|
|
|
|
/**
|
|
* Replace a function's return type with another type.
|
|
*/
|
|
export type WithReturnType<F extends (...args: any[]) => any, NewReturn> = (
|
|
...args: Parameters<F>
|
|
) => NewReturn
|
|
|
|
/**
|
|
* Assert that a function type is async, preserving its parameter types.
|
|
*/
|
|
export type AsyncFn<F extends (...args: any[]) => any> = WithReturnType<
|
|
F,
|
|
Promise<unknown>
|
|
>
|
|
|
|
export type AppMachineContext = {
|
|
codeManager: CodeManager
|
|
kclManager: KclManager
|
|
engineCommandManager: EngineCommandManager
|
|
sceneInfra: SceneInfra
|
|
sceneEntitiesManager: SceneEntities
|
|
authActor?: ActorRefFrom<typeof authMachine>
|
|
settingsActor?: ActorRefFrom<typeof settingsMachine>
|
|
systemIOActor?: ActorRefFrom<typeof systemIOMachine>
|
|
engineStreamActor?: ActorRefFrom<typeof engineStreamMachine>
|
|
commandBarActor?: ActorRefFrom<typeof commandBarMachine>
|
|
}
|