Skip to content

Commit

Permalink
[desktop]: Improve Angular build times with isolated modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Aug 19, 2024
1 parent 88dfda9 commit 6866473
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion desktop/src/app/calculator/formula/formula.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core'
import { CalculatorFormula } from '../../../shared/types/calculator.types'
import type { CalculatorFormula } from '../../../shared/types/calculator.types'

@Component({
selector: 'neb-formula',
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/camera/exposure-time.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewInit, ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewEncapsulation } from '@angular/core'
import { MenuItem } from '../../shared/components/menu-item/menu-item.component'
import { ExposureTimeUnit } from '../../shared/types/camera.types'
import type { ExposureTimeUnit } from '../../shared/types/camera.types'

@Component({
selector: 'neb-exposure-time',
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/indi/property/indi-property.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterContentInit, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'
import { INDIProperty, INDIPropertyItem, INDISendProperty, INDISendPropertyItem } from '../../../shared/types/device.types'
import type { INDIProperty, INDIPropertyItem, INDISendProperty, INDISendPropertyItem } from '../../../shared/types/device.types'

@Component({
selector: 'neb-indi-property',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'
import { CameraStartCapture } from '../../types/camera.types'
import { Wheel } from '../../types/wheel.types'
import type { CameraStartCapture } from '../../types/camera.types'
import type { Wheel } from '../../types/wheel.types'

@Component({
selector: 'neb-camera-info',
Expand Down
3 changes: 2 additions & 1 deletion desktop/src/shared/components/location/location.dialog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AfterViewInit, Component, EventEmitter, Input, Optional, Output, ViewChild } from '@angular/core'
import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog'
import { DEFAULT_LOCATION, Location } from '../../types/atlas.types'
import type { Location } from '../../types/atlas.types'
import { DEFAULT_LOCATION } from '../../types/atlas.types'
import { MapComponent } from '../map/map.component'

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, TemplateRef, ViewEncapsulation } from '@angular/core'
import { Nullable } from '../../utils/types'
import type { Nullable } from '../../utils/types'
import { MenuItemCommandEvent, SlideMenuItem } from '../menu-item/menu-item.component'

@Component({
Expand Down
38 changes: 25 additions & 13 deletions desktop/src/shared/services/preference.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,31 @@ export class PreferenceData<T> {

@Injectable({ providedIn: 'root' })
export class PreferenceService {
constructor(private readonly storage: LocalStorageService) {}
readonly home: PreferenceData<HomePreference>
readonly imagePreference: PreferenceData<ImagePreference>
readonly skyAtlasPreference: PreferenceData<SkyAtlasPreference>
readonly alignment: PreferenceData<AlignmentPreference>
readonly calibrationPreference: PreferenceData<CalibrationPreference>
readonly sequencerPreference: PreferenceData<SequencerPreference>
readonly stacker: PreferenceData<StackerPreference>
readonly guider: PreferenceData<GuiderPreference>
readonly framing: PreferenceData<FramingPreference>
readonly settings: PreferenceData<SettingsPreference>
readonly pathChooser: PreferenceData<PathChooserPreference>

constructor(private readonly storage: LocalStorageService) {
this.home = new PreferenceData<HomePreference>(storage, 'home', () => structuredClone(DEFAULT_HOME_PREFERENCE), homePreferenceWithDefault)
this.imagePreference = new PreferenceData<ImagePreference>(storage, 'image', () => structuredClone(DEFAULT_IMAGE_PREFERENCE), imagePreferenceWithDefault)
this.skyAtlasPreference = new PreferenceData<SkyAtlasPreference>(storage, 'atlas', () => structuredClone(DEFAULT_SKY_ATLAS_PREFERENCE), skyAtlasPreferenceWithDefault)
this.alignment = new PreferenceData<AlignmentPreference>(storage, 'alignment', () => structuredClone(DEFAULT_ALIGNMENT_PREFERENCE), alignmentPreferenceWithDefault)
this.calibrationPreference = new PreferenceData<CalibrationPreference>(storage, 'calibration', () => structuredClone(DEFAULT_CALIBRATION_PREFERENCE), calibrationPreferenceWithDefault)
this.sequencerPreference = new PreferenceData<SequencerPreference>(storage, 'sequencer', () => structuredClone(DEFAULT_SEQUENCER_PREFERENCE), sequencerPreferenceWithDefault)
this.stacker = new PreferenceData<StackerPreference>(storage, 'stacker', () => structuredClone(DEFAULT_STACKER_PREFERENCE), stackerPreferenceWithDefault)
this.guider = new PreferenceData<GuiderPreference>(storage, 'guider', () => structuredClone(DEFAULT_GUIDER_PREFERENCE), guiderPreferenceWithDefault)
this.framing = new PreferenceData<FramingPreference>(storage, 'framing', () => structuredClone(DEFAULT_FRAMING_PREFERENCE), framingPreferenceWithDefault)
this.settings = new PreferenceData<SettingsPreference>(storage, 'settings', () => structuredClone(DEFAULT_SETTINGS_PREFERENCE), settingsPreferenceWithDefault)
this.pathChooser = new PreferenceData<PathChooserPreference>(storage, 'pathChooser', () => structuredClone(DEFAULT_PATH_CHOOSER_PREFERENCE))
}

wheel(wheel: Wheel) {
return new PreferenceData<WheelPreference>(this.storage, `wheel.${wheel.name}`, () => structuredClone(DEFAULT_WHEEL_PREFERENCE), wheelPreferenceWithDefault)
Expand Down Expand Up @@ -81,16 +105,4 @@ export class PreferenceService {
autoFocus(camera: Camera) {
return new PreferenceData<AutoFocusPreference>(this.storage, `autoFocus.${camera.name}`, () => structuredClone(DEFAULT_AUTO_FOCUS_PREFERENCE), autoFocusPreferenceWithDefault)
}

readonly home = new PreferenceData<HomePreference>(this.storage, 'home', () => structuredClone(DEFAULT_HOME_PREFERENCE), homePreferenceWithDefault)
readonly imagePreference = new PreferenceData<ImagePreference>(this.storage, 'image', () => structuredClone(DEFAULT_IMAGE_PREFERENCE), imagePreferenceWithDefault)
readonly skyAtlasPreference = new PreferenceData<SkyAtlasPreference>(this.storage, 'atlas', () => structuredClone(DEFAULT_SKY_ATLAS_PREFERENCE), skyAtlasPreferenceWithDefault)
readonly alignment = new PreferenceData<AlignmentPreference>(this.storage, 'alignment', () => structuredClone(DEFAULT_ALIGNMENT_PREFERENCE), alignmentPreferenceWithDefault)
readonly calibrationPreference = new PreferenceData<CalibrationPreference>(this.storage, 'calibration', () => structuredClone(DEFAULT_CALIBRATION_PREFERENCE), calibrationPreferenceWithDefault)
readonly sequencerPreference = new PreferenceData<SequencerPreference>(this.storage, 'sequencer', () => structuredClone(DEFAULT_SEQUENCER_PREFERENCE), sequencerPreferenceWithDefault)
readonly stacker = new PreferenceData<StackerPreference>(this.storage, 'stacker', () => structuredClone(DEFAULT_STACKER_PREFERENCE), stackerPreferenceWithDefault)
readonly guider = new PreferenceData<GuiderPreference>(this.storage, 'guider', () => structuredClone(DEFAULT_GUIDER_PREFERENCE), guiderPreferenceWithDefault)
readonly framing = new PreferenceData<FramingPreference>(this.storage, 'framing', () => structuredClone(DEFAULT_FRAMING_PREFERENCE), framingPreferenceWithDefault)
readonly settings = new PreferenceData<SettingsPreference>(this.storage, 'settings', () => structuredClone(DEFAULT_SETTINGS_PREFERENCE), settingsPreferenceWithDefault)
readonly pathChooser = new PreferenceData<PathChooserPreference>(this.storage, 'pathChooser', () => structuredClone(DEFAULT_PATH_CHOOSER_PREFERENCE))
}
3 changes: 2 additions & 1 deletion desktop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"target": "ES2022",
"typeRoots": ["node_modules/@types"],
"lib": ["es2022", "es2018", "es2017", "es2016", "es2015", "dom"],
"useDefineForClassFields": false
"isolatedModules": true,
"useDefineForClassFields": true
},
"exclude": ["node_modules"],
"angularCompilerOptions": {
Expand Down

0 comments on commit 6866473

Please sign in to comment.