2021-04-12 06:18:30 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import { cloneDeep, isEqual } from "lodash-es";
|
|
|
|
import { get, Readable, readable, Writable, writable } from "svelte/store";
|
|
|
|
|
2021-10-07 15:31:49 +02:00
|
|
|
import { localeCompare } from "../lib/i18n";
|
2022-02-04 09:36:34 +01:00
|
|
|
import { DeckConfig, deckConfig } from "../lib/proto";
|
update to latest rules_nodejs & switch to ts_project
ts_library() is deprecated and will presumably be dropped from a
future rules_nodejs, and it wasn't working with the jest tests
after updating, so we switch over to ts_project().
There are some downsides:
- It's a bit slower, as the worker mode doesn't appear to function
at the moment.
- Getting it working with a mix of source files and generated files
was quite tricky, especially as things behave differently on Windows,
and differently when editing with VS Code. Solved with a small patch
to the rules, and a wrapper script that copies everything into the
bin folder first. To keep VS Code working correctly as well, the built
files are symlinked into the source folder.
- TS libraries are not implicitly linked to node_modules, so they
can't be imported with an absolute name like "lib/proto" - we need
to use relative paths like "../lib/proto" instead. Adjusting "paths"
in tsconfig.json makes it work for TS compilation, but then it fails
at the esbuild stage. We could resolve it by wrapping the TS
libraries in a subsequent js_library() call, but that has the downside
of losing the transient dependencies, meaning they need to be listed
again. Alternatively we might be able to solve it in the future by
adjusting esbuild, but for now the paths have been made relative to
keep things simple.
Upsides:
- Along with updates to the Svelte tooling, Svelte typing has improved.
All exports made in a Svelte file are now visible to other files that
import them, and we no longer rebuild the Svelte files when TS files
are updated, as the Svelte files do no type checking themselves, and
are just a simple transpilation. Svelte-check now works on Windows again,
and there should be no errors when editing in VS Code after you've
built the project. The only downside seems to be that cmd+clicking
on a Svelte imports jumps to the .d.ts file instead of the original now;
presumably they'll fix that in a future plugin update.
- Each subfolder now has its own tsconfig.json, and tsc can be called
directly for testing purposes (but beware it will place build products
in the source tree): ts/node_modules/.bin/tsc -b ts
- We can drop the custom esbuild_toolchain, as it's included in the
latest rules_nodejs.
Other changes:
- "image_module_support" is moved into lib/, and imported with
<reference types=...>
- Images are now imported directly from their npm package; the
extra copy step has been removed.
Windows users may need to use "bazel clean" before building this,
due to old files lying around in the build folder.
2021-09-30 14:16:29 +02:00
|
|
|
import type { DynamicSvelteComponent } from "../sveltelib/dynamicComponent";
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export type DeckOptionsId = number;
|
2021-04-12 06:18:30 +02:00
|
|
|
|
|
|
|
export interface ConfigWithCount {
|
2021-07-10 12:44:22 +02:00
|
|
|
config: DeckConfig.DeckConfig;
|
2021-04-12 06:18:30 +02:00
|
|
|
useCount: number;
|
|
|
|
}
|
|
|
|
|
2021-04-17 04:53:59 +02:00
|
|
|
export interface ParentLimits {
|
|
|
|
newCards: number;
|
|
|
|
reviews: number;
|
|
|
|
}
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
/// Info for showing the top selector
|
|
|
|
export interface ConfigListEntry {
|
|
|
|
idx: number;
|
|
|
|
name: string;
|
|
|
|
useCount: number;
|
|
|
|
current: boolean;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export class DeckOptionsState {
|
2022-02-27 08:35:07 +01:00
|
|
|
readonly currentConfig: Writable<DeckConfig.DeckConfig.Config>;
|
2021-04-24 02:14:54 +02:00
|
|
|
readonly currentAuxData: Writable<Record<string, unknown>>;
|
2021-04-16 15:29:21 +02:00
|
|
|
readonly configList: Readable<ConfigListEntry[]>;
|
2021-04-17 04:53:59 +02:00
|
|
|
readonly parentLimits: Readable<ParentLimits>;
|
2021-06-24 06:38:10 +02:00
|
|
|
readonly cardStateCustomizer: Writable<string>;
|
2021-07-10 12:44:22 +02:00
|
|
|
readonly currentDeck: DeckConfig.DeckConfigsForUpdate.CurrentDeck;
|
2022-07-19 10:27:25 +02:00
|
|
|
readonly deckLimits: Writable<DeckConfig.DeckConfigsForUpdate.CurrentDeck.Limits>;
|
2022-02-27 08:35:07 +01:00
|
|
|
readonly defaults: DeckConfig.DeckConfig.Config;
|
2021-04-24 02:14:54 +02:00
|
|
|
readonly addonComponents: Writable<DynamicSvelteComponent[]>;
|
2021-05-13 07:23:16 +02:00
|
|
|
readonly v3Scheduler: boolean;
|
2021-04-16 15:29:21 +02:00
|
|
|
|
2021-04-20 11:50:05 +02:00
|
|
|
private targetDeckId: number;
|
2021-04-16 15:29:21 +02:00
|
|
|
private configs: ConfigWithCount[];
|
|
|
|
private selectedIdx: number;
|
2021-04-17 13:00:10 +02:00
|
|
|
private configListSetter!: (val: ConfigListEntry[]) => void;
|
|
|
|
private parentLimitsSetter!: (val: ParentLimits) => void;
|
2021-04-25 10:40:02 +02:00
|
|
|
private modifiedConfigs: Set<DeckOptionsId> = new Set();
|
|
|
|
private removedConfigs: DeckOptionsId[] = [];
|
2021-04-18 03:56:41 +02:00
|
|
|
private schemaModified: boolean;
|
2021-04-16 15:29:21 +02:00
|
|
|
|
2021-07-10 12:44:22 +02:00
|
|
|
constructor(targetDeckId: number, data: DeckConfig.DeckConfigsForUpdate) {
|
2021-04-20 11:50:05 +02:00
|
|
|
this.targetDeckId = targetDeckId;
|
2022-02-27 08:35:07 +01:00
|
|
|
this.currentDeck = data.currentDeck!;
|
|
|
|
this.defaults = data.defaults!.config!;
|
2021-04-16 15:29:21 +02:00
|
|
|
this.configs = data.allConfig.map((config) => {
|
2022-02-27 08:35:07 +01:00
|
|
|
const configInner = config.config!;
|
|
|
|
|
2021-04-12 06:18:30 +02:00
|
|
|
return {
|
2021-04-24 02:14:54 +02:00
|
|
|
config: configInner,
|
2021-04-12 06:18:30 +02:00
|
|
|
useCount: config.useCount!,
|
|
|
|
};
|
2021-04-16 15:29:21 +02:00
|
|
|
});
|
2021-04-17 08:38:45 +02:00
|
|
|
this.selectedIdx = Math.max(
|
|
|
|
0,
|
2021-10-19 01:06:00 +02:00
|
|
|
this.configs.findIndex((c) => c.config.id === this.currentDeck.configId),
|
2021-04-17 08:38:45 +02:00
|
|
|
);
|
2022-11-03 03:49:58 +01:00
|
|
|
this.sortConfigs();
|
2021-05-13 07:23:16 +02:00
|
|
|
this.v3Scheduler = data.v3Scheduler;
|
2021-06-24 06:38:10 +02:00
|
|
|
this.cardStateCustomizer = writable(data.cardStateCustomizer);
|
2022-07-19 10:27:25 +02:00
|
|
|
this.deckLimits = writable(data.currentDeck?.limits ?? createLimits());
|
2021-04-17 08:38:45 +02:00
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
// decrement the use count of the starting item, as we'll apply +1 to currently
|
|
|
|
// selected one at display time
|
|
|
|
this.configs[this.selectedIdx].useCount -= 1;
|
|
|
|
this.currentConfig = writable(this.getCurrentConfig());
|
2021-04-24 02:14:54 +02:00
|
|
|
this.currentAuxData = writable(this.getCurrentAuxData());
|
2021-04-16 15:29:21 +02:00
|
|
|
this.configList = readable(this.getConfigList(), (set) => {
|
|
|
|
this.configListSetter = set;
|
2021-04-17 04:53:59 +02:00
|
|
|
return;
|
|
|
|
});
|
|
|
|
this.parentLimits = readable(this.getParentLimits(), (set) => {
|
|
|
|
this.parentLimitsSetter = set;
|
|
|
|
return;
|
2021-04-16 15:29:21 +02:00
|
|
|
});
|
2021-04-18 03:56:41 +02:00
|
|
|
this.schemaModified = data.schemaModified;
|
2021-04-24 02:14:54 +02:00
|
|
|
this.addonComponents = writable([]);
|
2021-04-17 13:00:10 +02:00
|
|
|
|
2021-04-17 13:44:33 +02:00
|
|
|
// create a temporary subscription to force our setters to be set immediately,
|
|
|
|
// so unit tests don't get stale results
|
2021-04-17 13:00:10 +02:00
|
|
|
get(this.configList);
|
|
|
|
get(this.parentLimits);
|
2021-04-17 13:44:33 +02:00
|
|
|
|
|
|
|
// update our state when the current config is changed
|
|
|
|
this.currentConfig.subscribe((val) => this.onCurrentConfigChanged(val));
|
2021-04-24 02:14:54 +02:00
|
|
|
this.currentAuxData.subscribe((val) => this.onCurrentAuxDataChanged(val));
|
2021-04-16 15:29:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setCurrentIndex(index: number): void {
|
|
|
|
this.selectedIdx = index;
|
|
|
|
this.updateCurrentConfig();
|
|
|
|
// use counts have changed
|
|
|
|
this.updateConfigList();
|
|
|
|
}
|
|
|
|
|
|
|
|
getCurrentName(): string {
|
|
|
|
return this.configs[this.selectedIdx].config.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
setCurrentName(name: string): void {
|
|
|
|
if (this.configs[this.selectedIdx].config.name === name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const uniqueName = this.ensureNewNameUnique(name);
|
2021-04-20 01:00:25 +02:00
|
|
|
const config = this.configs[this.selectedIdx].config;
|
|
|
|
config.name = uniqueName;
|
|
|
|
if (config.id) {
|
|
|
|
this.modifiedConfigs.add(config.id);
|
|
|
|
}
|
2022-11-03 03:49:58 +01:00
|
|
|
this.sortConfigs();
|
2021-04-16 15:29:21 +02:00
|
|
|
this.updateConfigList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Adds a new config, making it current.
|
|
|
|
addConfig(name: string): void {
|
2021-05-26 05:20:24 +02:00
|
|
|
this.addConfigFrom(name, this.defaults);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clone the current config, making it current.
|
|
|
|
cloneConfig(name: string): void {
|
|
|
|
this.addConfigFrom(name, this.configs[this.selectedIdx].config.config!);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Clone the current config, making it current.
|
2021-07-10 12:44:22 +02:00
|
|
|
private addConfigFrom(name: string, source: DeckConfig.DeckConfig.IConfig): void {
|
2021-04-16 15:29:21 +02:00
|
|
|
const uniqueName = this.ensureNewNameUnique(name);
|
2021-07-10 12:44:22 +02:00
|
|
|
const config = DeckConfig.DeckConfig.create({
|
2021-04-16 15:29:21 +02:00
|
|
|
id: 0,
|
|
|
|
name: uniqueName,
|
2022-02-27 08:35:07 +01:00
|
|
|
config: DeckConfig.DeckConfig.Config.create(cloneDeep(source)),
|
2021-04-16 15:29:21 +02:00
|
|
|
});
|
|
|
|
const configWithCount = { config, useCount: 0 };
|
|
|
|
this.configs.push(configWithCount);
|
|
|
|
this.selectedIdx = this.configs.length - 1;
|
2022-11-03 03:49:58 +01:00
|
|
|
this.sortConfigs();
|
2021-04-16 15:29:21 +02:00
|
|
|
this.updateCurrentConfig();
|
|
|
|
this.updateConfigList();
|
|
|
|
}
|
|
|
|
|
2021-04-18 03:56:41 +02:00
|
|
|
removalWilLForceFullSync(): boolean {
|
|
|
|
return !this.schemaModified && this.configs[this.selectedIdx].config.id !== 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultConfigSelected(): boolean {
|
|
|
|
return this.configs[this.selectedIdx].config.id === 1;
|
|
|
|
}
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
/// Will throw if the default deck is selected.
|
|
|
|
removeCurrentConfig(): void {
|
|
|
|
const currentId = this.configs[this.selectedIdx].config.id;
|
|
|
|
if (currentId === 1) {
|
2021-04-20 11:50:05 +02:00
|
|
|
throw Error("can't remove default config");
|
2021-04-16 15:29:21 +02:00
|
|
|
}
|
|
|
|
if (currentId !== 0) {
|
|
|
|
this.removedConfigs.push(currentId);
|
2021-04-18 03:56:41 +02:00
|
|
|
this.schemaModified = true;
|
2021-04-16 15:29:21 +02:00
|
|
|
}
|
|
|
|
this.configs.splice(this.selectedIdx, 1);
|
|
|
|
this.selectedIdx = Math.max(0, this.selectedIdx - 1);
|
|
|
|
this.updateCurrentConfig();
|
|
|
|
this.updateConfigList();
|
|
|
|
}
|
|
|
|
|
2022-01-21 12:32:39 +01:00
|
|
|
dataForSaving(
|
|
|
|
applyToChildren: boolean,
|
|
|
|
): NonNullable<DeckConfig.IUpdateDeckConfigsRequest> {
|
2021-04-20 11:50:05 +02:00
|
|
|
const modifiedConfigsExcludingCurrent = this.configs
|
|
|
|
.map((c) => c.config)
|
|
|
|
.filter((c, idx) => {
|
|
|
|
return (
|
|
|
|
idx !== this.selectedIdx &&
|
|
|
|
(c.id === 0 || this.modifiedConfigs.has(c.id))
|
|
|
|
);
|
|
|
|
});
|
|
|
|
const configs = [
|
|
|
|
...modifiedConfigsExcludingCurrent,
|
|
|
|
// current must come last, even if unmodified
|
|
|
|
this.configs[this.selectedIdx].config,
|
|
|
|
];
|
2022-01-21 12:32:39 +01:00
|
|
|
return {
|
2021-04-20 11:50:05 +02:00
|
|
|
targetDeckId: this.targetDeckId,
|
|
|
|
removedConfigIds: this.removedConfigs,
|
|
|
|
configs,
|
|
|
|
applyToChildren,
|
2021-06-24 06:38:10 +02:00
|
|
|
cardStateCustomizer: get(this.cardStateCustomizer),
|
2022-07-19 10:27:25 +02:00
|
|
|
limits: get(this.deckLimits),
|
2022-01-21 12:32:39 +01:00
|
|
|
};
|
2021-04-20 11:50:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async save(applyToChildren: boolean): Promise<void> {
|
2022-02-27 08:35:07 +01:00
|
|
|
await deckConfig.updateDeckConfigs(
|
|
|
|
DeckConfig.UpdateDeckConfigsRequest.create(
|
|
|
|
this.dataForSaving(applyToChildren),
|
|
|
|
),
|
|
|
|
);
|
2021-04-20 11:50:05 +02:00
|
|
|
}
|
|
|
|
|
2022-02-27 08:35:07 +01:00
|
|
|
private onCurrentConfigChanged(config: DeckConfig.DeckConfig.Config): void {
|
2021-04-24 02:14:54 +02:00
|
|
|
const configOuter = this.configs[this.selectedIdx].config;
|
|
|
|
if (!isEqual(config, configOuter.config)) {
|
|
|
|
configOuter.config = config;
|
|
|
|
if (configOuter.id) {
|
|
|
|
this.modifiedConfigs.add(configOuter.id);
|
|
|
|
}
|
2021-04-17 13:44:33 +02:00
|
|
|
}
|
|
|
|
this.parentLimitsSetter?.(this.getParentLimits());
|
|
|
|
}
|
|
|
|
|
2021-04-24 02:14:54 +02:00
|
|
|
private onCurrentAuxDataChanged(data: Record<string, unknown>): void {
|
|
|
|
const current = this.getCurrentAuxData();
|
|
|
|
if (!isEqual(current, data)) {
|
|
|
|
this.currentConfig.update((config) => {
|
|
|
|
const asBytes = new TextEncoder().encode(JSON.stringify(data));
|
|
|
|
config.other = asBytes;
|
|
|
|
return config;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
private ensureNewNameUnique(name: string): string {
|
2021-04-17 13:00:10 +02:00
|
|
|
const idx = this.configs.findIndex((e) => e.config.name === name);
|
|
|
|
if (idx !== -1) {
|
2021-04-16 15:29:21 +02:00
|
|
|
return name + (new Date().getTime() / 1000).toFixed(0);
|
|
|
|
} else {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateCurrentConfig(): void {
|
|
|
|
this.currentConfig.set(this.getCurrentConfig());
|
2021-04-24 02:14:54 +02:00
|
|
|
this.currentAuxData.set(this.getCurrentAuxData());
|
2021-04-17 04:53:59 +02:00
|
|
|
this.parentLimitsSetter?.(this.getParentLimits());
|
2021-04-16 15:29:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private updateConfigList(): void {
|
|
|
|
this.configListSetter?.(this.getConfigList());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns a copy of the currently selected config.
|
2022-02-27 08:35:07 +01:00
|
|
|
private getCurrentConfig(): DeckConfig.DeckConfig.Config {
|
|
|
|
return cloneDeep(this.configs[this.selectedIdx].config.config!);
|
2021-04-16 15:29:21 +02:00
|
|
|
}
|
|
|
|
|
2021-04-24 02:14:54 +02:00
|
|
|
/// Extra data associated with current config (for add-ons)
|
|
|
|
private getCurrentAuxData(): Record<string, unknown> {
|
2022-02-27 08:35:07 +01:00
|
|
|
const conf = this.configs[this.selectedIdx].config.config!;
|
2021-04-24 02:14:54 +02:00
|
|
|
return bytesToObject(conf.other);
|
|
|
|
}
|
|
|
|
|
2022-11-03 03:49:58 +01:00
|
|
|
private sortConfigs() {
|
|
|
|
const currentConfigName = this.configs[this.selectedIdx].config.name;
|
|
|
|
this.configs.sort((a, b) =>
|
|
|
|
localeCompare(a.config.name, b.config.name, { sensitivity: "base" }),
|
|
|
|
);
|
|
|
|
this.selectedIdx = this.configs.findIndex(
|
|
|
|
(c) => c.config.name == currentConfigName,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-16 15:29:21 +02:00
|
|
|
private getConfigList(): ConfigListEntry[] {
|
|
|
|
const list: ConfigListEntry[] = this.configs.map((c, idx) => {
|
|
|
|
const useCount = c.useCount + (idx === this.selectedIdx ? 1 : 0);
|
|
|
|
return {
|
|
|
|
name: c.config.name,
|
|
|
|
current: idx === this.selectedIdx,
|
|
|
|
idx,
|
|
|
|
useCount,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
return list;
|
|
|
|
}
|
2021-04-17 04:53:59 +02:00
|
|
|
|
|
|
|
private getParentLimits(): ParentLimits {
|
|
|
|
const parentConfigs = this.configs.filter((c) =>
|
2021-10-19 01:06:00 +02:00
|
|
|
this.currentDeck.parentConfigIds.includes(c.config.id),
|
2021-04-17 04:53:59 +02:00
|
|
|
);
|
|
|
|
const newCards = parentConfigs.reduce(
|
|
|
|
(previous, current) =>
|
|
|
|
Math.min(previous, current.config.config?.newPerDay ?? 0),
|
2021-10-19 01:06:00 +02:00
|
|
|
2 ** 31,
|
2021-04-17 04:53:59 +02:00
|
|
|
);
|
|
|
|
const reviews = parentConfigs.reduce(
|
|
|
|
(previous, current) =>
|
|
|
|
Math.min(previous, current.config.config?.reviewsPerDay ?? 0),
|
2021-10-19 01:06:00 +02:00
|
|
|
2 ** 31,
|
2021-04-17 04:53:59 +02:00
|
|
|
);
|
|
|
|
return {
|
|
|
|
newCards,
|
|
|
|
reviews,
|
|
|
|
};
|
|
|
|
}
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
2021-04-24 02:14:54 +02:00
|
|
|
|
|
|
|
function bytesToObject(bytes: Uint8Array): Record<string, unknown> {
|
|
|
|
if (!bytes.length) {
|
2022-02-27 08:35:07 +01:00
|
|
|
return {};
|
2021-04-24 02:14:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let obj: Record<string, unknown>;
|
2022-02-27 08:35:07 +01:00
|
|
|
|
2021-04-24 02:14:54 +02:00
|
|
|
try {
|
2022-02-27 08:35:07 +01:00
|
|
|
obj = JSON.parse(new TextDecoder().decode(bytes));
|
2021-04-24 02:14:54 +02:00
|
|
|
} catch (err) {
|
|
|
|
console.log(`invalid json in deck config`);
|
2022-02-27 08:35:07 +01:00
|
|
|
return {};
|
2021-04-24 02:14:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.constructor !== Object) {
|
|
|
|
console.log(`invalid object in deck config`);
|
2022-02-27 08:35:07 +01:00
|
|
|
return {};
|
2021-04-24 02:14:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
2022-07-19 10:27:25 +02:00
|
|
|
|
|
|
|
export function createLimits(): DeckConfig.DeckConfigsForUpdate.CurrentDeck.Limits {
|
|
|
|
return DeckConfig.DeckConfigsForUpdate.CurrentDeck.Limits.create({});
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ValueTab {
|
|
|
|
readonly title: string;
|
|
|
|
value: number | null;
|
|
|
|
private setter: (value: number | null) => void;
|
|
|
|
private disabledValue: number | null;
|
|
|
|
private startValue: number | null;
|
|
|
|
private initialValue: number | null;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
title: string,
|
|
|
|
value: number | null,
|
|
|
|
setter: (value: number | null) => void,
|
|
|
|
disabledValue: number | null,
|
|
|
|
startValue: number | null,
|
|
|
|
) {
|
|
|
|
this.title = title;
|
|
|
|
this.value = this.initialValue = value;
|
|
|
|
this.setter = setter;
|
|
|
|
this.disabledValue = disabledValue;
|
|
|
|
this.startValue = startValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
reset(): void {
|
|
|
|
this.setter(this.initialValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
disable(): void {
|
|
|
|
this.setter(this.disabledValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
enable(fallbackValue: number): void {
|
|
|
|
this.value = this.value ?? this.startValue ?? fallbackValue;
|
|
|
|
this.setter(this.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
setValue(value: number): void {
|
|
|
|
this.value = value;
|
|
|
|
this.setter(value);
|
|
|
|
}
|
|
|
|
}
|