Signed-off-by: Jess Frazelle <github@jessfraz.com> clear scene Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> cleanups Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> delete unused shit Signed-off-by: Jess Frazelle <github@jessfraz.com> add comments 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 linter Signed-off-by: Jess Frazelle <github@jessfraz.com> format moved to plugin Signed-off-by: Jess Frazelle <github@jessfraz.com> arc the fs Signed-off-by: Jess Frazelle <github@jessfraz.com> update units Signed-off-by: Jess Frazelle <github@jessfraz.com> fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> tests for folding range Signed-off-by: Jess Frazelle <github@jessfraz.com> start of folding 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> get rid of old re-execute 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> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) lint Signed-off-by: Jess Frazelle <github@jessfraz.com> fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> test for recast bug fixed Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> udpates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix rust test Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix 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> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) recreate the planes Signed-off-by: Jess Frazelle <github@jessfraz.com> console Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) get rid of unnessary executions Signed-off-by: Jess Frazelle <github@jessfraz.com> add test Signed-off-by: Jess Frazelle <github@jessfraz.com> add test Signed-off-by: Jess Frazelle <github@jessfraz.com> get rid of unnessary executions Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> fix race on engine execute Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> better naming; Signed-off-by: Jess Frazelle <github@jessfraz.com> fix planes 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> errors pane Signed-off-by: Jess Frazelle <github@jessfraz.com> add errors for tokenizer Signed-off-by: Jess Frazelle <github@jessfraz.com> fix docs 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> fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> planes in engine Signed-off-by: Jess Frazelle <github@jessfraz.com> use the default planes Signed-off-by: Jess Frazelle <github@jessfraz.com> better size 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> fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> ffix load local storage Signed-off-by: Jess Frazelle <github@jessfraz.com> fix Signed-off-by: Jess Frazelle <github@jessfraz.com> dont wait for execute on exit Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) add back in bs Signed-off-by: Jess Frazelle <github@jessfraz.com> Revert "dont wait for execute on exit" This reverts commit efcaca150ae589ba6ac293765b8302d0fd0c3bf8. A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> updates Signed-off-by: Jess Frazelle <github@jessfraz.com> add endpoint for setcanexecute Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) fixed tests Signed-off-by: Jess Frazelle <github@jessfraz.com> fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> add back in debounce for now 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> better debounce Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> Bump syn from 2.0.58 to 2.0.59 in /src/wasm-lib (#2106) Bumps [syn](https://github.com/dtolnay/syn) from 2.0.58 to 2.0.59. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/2.0.58...2.0.59) --- updated-dependencies: - dependency-name: syn dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) updates Signed-off-by: Jess Frazelle <github@jessfraz.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) mepty A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) empty updates Signed-off-by: Jess Frazelle <github@jessfraz.com> Bump vitest from 1.4.0 to 1.5.0 (#2111) Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v1.5.0/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Bump @testing-library/react from 15.0.1 to 15.0.2 (#2112) Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 15.0.1 to 15.0.2. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](https://github.com/testing-library/react-testing-library/compare/v15.0.1...v15.0.2) --- updated-dependencies: - dependency-name: "@testing-library/react" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Bump @wdio/mocha-framework from 8.35.0 to 8.36.0 (#2110) Bumps [@wdio/mocha-framework](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-mocha-framework) from 8.35.0 to 8.36.0. - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v8.36.0/packages/wdio-mocha-framework) --- updated-dependencies: - dependency-name: "@wdio/mocha-framework" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) empty updates Signed-off-by: Jess Frazelle <github@jessfraz.com> deferrer Signed-off-by: Jess Frazelle <github@jessfraz.com>
155 lines
4.9 KiB
TypeScript
155 lines
4.9 KiB
TypeScript
import { assign, createMachine } from 'xstate'
|
|
import { Themes, getSystemTheme, setThemeClass } from 'lib/theme'
|
|
import { createSettings, settings } from 'lib/settings/initialSettings'
|
|
import {
|
|
BaseUnit,
|
|
SetEventTypes,
|
|
SettingsLevel,
|
|
SettingsPaths,
|
|
WildcardSetEvent,
|
|
} from 'lib/settings/settingsTypes'
|
|
|
|
export const settingsMachine = createMachine(
|
|
{
|
|
/** @xstate-layout N4IgpgJg5mDOIC5QGUwBc0EsB2VYDpMIAbMAYlnXwFsB7CMYnKfAV20zVgG0AGAXUSgADrVidMtbEJAAPRABYAHAFZ8vAEwA2FVq0aNAZgCcARl0B2ADQgAnolO8LvfBYUXT+48YW+tCgF8Am1QMZgIiUgoqAENhYXw0AAswajA+QSQQUXEsKRl5BCM1DQUDMo0VQwVjJxt7BFMDJXwNWo0LFSU3c0DgkFCsXAiScgAlOHQAAkow4YyZHIl8rMKAWn18Q39q3ScVFQ1NFXqHXiVTfGNqhSdeXi1DJQ1TIJD0IbxCUbIAKgWsks8tJVopjFp8KZjEpqi9lKZDE0TnYzgZXO5PG0fH4+u85l9IuRQlMYsRiFNsGAAO4zD7hAEiMTLEGgda6fAKJoIiyIkwWYwWawoxpGFxaHkKFS1a7woL9bD0OAyQbhRZM4EFRBrUyOLY7SVafaHTSnBDGDqQiz6DRKbwqTxvAZ04bfUhq3KSFlyBxHdQIhR6HTQmoC02OUwKPW7GrPdy8QxygJAA */
|
|
id: 'Settings',
|
|
predictableActionArguments: true,
|
|
context: {} as ReturnType<typeof createSettings>,
|
|
initial: 'idle',
|
|
states: {
|
|
idle: {
|
|
entry: ['setThemeClass', 'setClientSideSceneUnits', 'persistSettings'],
|
|
|
|
on: {
|
|
'*': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: ['setSettingAtLevel', 'toastSuccess', 'persistSettings'],
|
|
},
|
|
|
|
'set.app.onboardingStatus': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: ['setSettingAtLevel', 'persistSettings'], // No toast
|
|
},
|
|
'set.app.themeColor': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: ['setSettingAtLevel', 'persistSettings'], // No toast
|
|
},
|
|
|
|
'set.modeling.defaultUnit': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: [
|
|
'setSettingAtLevel',
|
|
'toastSuccess',
|
|
'setClientSideSceneUnits',
|
|
'persistSettings',
|
|
],
|
|
},
|
|
|
|
'set.app.theme': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: [
|
|
'setSettingAtLevel',
|
|
'toastSuccess',
|
|
'setThemeClass',
|
|
'setEngineTheme',
|
|
'persistSettings',
|
|
],
|
|
},
|
|
|
|
'Reset settings': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: [
|
|
'resetSettings',
|
|
'setThemeClass',
|
|
'setEngineTheme',
|
|
'setClientSideSceneUnits',
|
|
'persistSettings',
|
|
],
|
|
},
|
|
|
|
'Set all settings': {
|
|
target: 'idle',
|
|
internal: true,
|
|
actions: [
|
|
'setAllSettings',
|
|
'setThemeClass',
|
|
'setEngineTheme',
|
|
'setClientSideSceneUnits',
|
|
'persistSettings',
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
tsTypes: {} as import('./settingsMachine.typegen').Typegen0,
|
|
schema: {
|
|
events: {} as
|
|
| WildcardSetEvent<SettingsPaths>
|
|
| SetEventTypes
|
|
| {
|
|
type: 'set.app.theme'
|
|
data: { level: SettingsLevel; value: Themes }
|
|
}
|
|
| {
|
|
type: 'set.modeling.units'
|
|
data: { level: SettingsLevel; value: BaseUnit }
|
|
}
|
|
| { type: 'Reset settings'; defaultDirectory: string }
|
|
| { type: 'Set all settings'; settings: typeof settings },
|
|
},
|
|
},
|
|
{
|
|
actions: {
|
|
resetSettings: assign((context, { defaultDirectory }) => {
|
|
// Reset everything except onboarding status,
|
|
// which should be preserved
|
|
const newSettings = createSettings()
|
|
if (context.app.onboardingStatus.user) {
|
|
newSettings.app.onboardingStatus.user =
|
|
context.app.onboardingStatus.user
|
|
}
|
|
// We instead pass in the default directory since it's asynchronous
|
|
// to re-initialize, and that can be done by the caller.
|
|
newSettings.app.projectDirectory.default = defaultDirectory
|
|
|
|
return newSettings
|
|
}),
|
|
setAllSettings: assign((_, event) => {
|
|
return event.settings
|
|
}),
|
|
setSettingAtLevel: assign((context, event) => {
|
|
const { level, value } = event.data
|
|
const [category, setting] = event.type
|
|
.replace(/^set./, '')
|
|
.split('.') as [keyof typeof settings, string]
|
|
|
|
// @ts-ignore
|
|
context[category][setting][level] = value
|
|
|
|
const newContext = {
|
|
...context,
|
|
[category]: {
|
|
...context[category],
|
|
// @ts-ignore
|
|
[setting]: context[category][setting],
|
|
},
|
|
}
|
|
|
|
return newContext
|
|
}),
|
|
setThemeClass: (context) => {
|
|
const currentTheme = context.app.theme.current ?? Themes.System
|
|
setThemeClass(
|
|
currentTheme === Themes.System ? getSystemTheme() : currentTheme
|
|
)
|
|
},
|
|
},
|
|
}
|
|
)
|