forked from SamXop123/Paraline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingsStore.js
More file actions
610 lines (558 loc) · 26.4 KB
/
Copy pathsettingsStore.js
File metadata and controls
610 lines (558 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
const fs = require("fs");
const path = require("path");
const DEFAULT_SETTINGS = Object.freeze({
launchOnStartup: false,
selectedTheme: "ambientWave",
colorMode: "manual",
customColors: Object.freeze(["#00f2fe", "#4facfe", "#8ee2ff"]),
themeAutomation: Object.freeze({
enabled: false,
checkIntervalMinutes: 30,
mode: "dayNight",
dayTheme: "ambientWave",
nightTheme: "reactiveBorder"
}),
performanceMode: "balanced",
fpsLimit: "default",
ambientWave: Object.freeze({
tone: "blue",
sensitivity: "medium",
edgeMode: "bottom",
glowStrength: "medium"
}),
reactiveBorder: Object.freeze({
colorStyle: "rainbow",
intensity: "medium",
borderThickness: "thin",
glowStrength: "medium"
}),
flowBorder: Object.freeze({
direction: "clockwise",
speedMode: "balanced",
segmentLength: "medium",
glowStrength: "medium",
colorStyle: "rainbow"
}),
sideBars: Object.freeze({
colorStyle: "multicolor",
barThickness: "thick",
sensitivity: "medium",
barDensity: "medium",
customColors: ["#00f2fe", "#4facfe", "#8ee2ff"],
customThickness: 4,
customGap: 7,
customSensitivity: 30
}),
flatRipples: Object.freeze({
mode: "sideRipples",
intensity: "medium",
colorStyle: "blue",
speed: "calm"
}),
dotParticles: Object.freeze({
density: "medium",
motionStyle: "balanced",
directionBehavior: "beatReactive",
glowStrength: "medium"
}),
rippleFlow: Object.freeze({
mode: "sideRipples",
intensity: "medium",
sensitivity: "medium",
colorStyle: "blue"
}),
snowBubbleParticles: Object.freeze({
fallArea: "middle",
density: "medium",
motionStyle: "balanced",
glowStrength: "medium",
particleSize: "medium"
}),
edgeCrystals: Object.freeze({
flutterStyle: "balanced",
density: "medium",
glowStrength: "medium",
colorStyle: "blue",
edgeMode: "both"
}),
sideBraids: Object.freeze({
braidDensity: "medium",
motionStyle: "balanced",
glowStrength: "medium",
braidWidth: "medium",
colorStyle: "cyanPink",
flowDirection: "topDown",
customColors: ["#00e5ff", "#ff2d7b", "#8ee2ff"],
customThickness: 4,
customGap: 7,
customSensitivity: 30,
customSpeed: 30
}),
focusMode: Object.freeze({
enabled: false,
dimOpacity: 0.1,
idleTimeout: 5
}),
auroraDrift: Object.freeze({
// Standard settings
auroraStyle: "cinematic",
intensity: "balanced",
height: "medium",
glowStrength: "medium",
motionSpeed: "balanced",
colorPalette: "cyanViolet",
audioReactivity: "balanced",
softness: "smooth",
layerDensity: "balanced",
// Advanced Custom settings
gradientStops: Object.freeze([
{ pos: 0.0, color: "#00e5ff" },
{ pos: 0.35, color: "#0077ff" },
{ pos: 0.7, color: "#7f00ff" },
{ pos: 1.0, color: "#ff007f" }
]),
baseGlowRadius: 1.0,
peakGlowRadius: 1.0,
crestBrightness: 1.0,
bloomStrength: 1.0,
glowFalloff: 1.0,
primaryFrequency: 1.0,
secondaryFrequency: 1.0,
turbulenceComplexity: 1.0,
motionSmoothness: 1.0,
driftSpeed: 1.0,
bassInfluence: 1.0,
midInfluence: 1.0,
highShimmer: 1.0,
audioSmoothing: 1.0,
peakSensitivity: 1.0,
ribbonHeight: 1.0,
ribbonWidth: 1.0,
edgeSoftness: 1.0,
layerSeparation: 1.0,
crestSharpness: 1.0,
layerCount: 5,
backgroundHaze: 1.0,
foregroundHighlight: 1.0,
parallaxDepth: 1.0,
ambientOpacity: 1.0,
colorSaturation: 1.0,
atmosphericFade: 1.0,
edgeFeathering: 1.0
})
});
const VALID_MAIN_THEMES = new Set(["ambientWave", "reactiveBorder", "flowBorder", "sideBars", "flatRipples", "dotParticles", "rippleFlow", "snowBubbleParticles", "edgeCrystals", "sideBraids", "auroraDrift"]);
const VALID_COLOR_MODES = new Set(["manual", "adaptive"]);
const VALID_PERFORMANCE_MODES = new Set(["performance", "balanced", "quality"]);
const VALID_FPS_LIMITS = new Set(["default", "battery", "unlocked"]);
const VALID_AMBIENT_TONES = new Set(["blue", "purple", "warm", "custom"]);
const VALID_LEVELS = new Set(["low", "medium", "high", "custom"]);
const VALID_EDGE_MODES = new Set(["top", "bottom", "both"]);
const VALID_GLOW_STRENGTHS = new Set(["soft", "medium", "strong", "custom"]);
const VALID_REACTIVE_COLOR_STYLES = new Set(["rainbow", "neonBlue", "neonPurple", "warmGlow", "custom"]);
const VALID_BORDER_THICKNESS = new Set(["thin", "medium", "thick", "custom"]);
const VALID_FLOW_DIRECTIONS = new Set(["clockwise", "anticlockwise"]);
const VALID_FLOW_SPEEDS = new Set(["calm", "balanced", "energetic", "custom"]);
const VALID_FLOW_SEGMENTS = new Set(["short", "medium", "long", "custom"]);
const VALID_FLOW_COLOR_STYLES = new Set(["rainbow", "cool", "warm", "custom"]);
const VALID_SIDE_BARS_COLOR_STYLES = new Set(["white", "yellow", "aqua", "multicolor", "custom"]);
const VALID_SIDE_BARS_THICKNESS = new Set(["thin", "medium", "thick", "custom"]);
const VALID_SIDE_BARS_DENSITY = new Set(["low", "medium", "high", "custom"]);
const VALID_FLAT_RIPPLES_MODES = new Set(["sideRipples", "flatRipples"]);
const VALID_FLAT_RIPPLES_COLORS = new Set(["red", "blue", "white", "multicolor", "custom"]);
const VALID_FLAT_RIPPLES_SPEEDS = new Set(["calm", "balanced", "energetic", "custom"]);
const VALID_DOT_PARTICLES_MOTION_STYLES = new Set(["calm", "balanced", "energetic", "custom"]);
const VALID_DOT_PARTICLES_DIRECTIONS = new Set(["mostlyClockwise", "mostlyAnticlockwise", "beatReactive"]);
const VALID_RIPPLE_FLOW_MODES = new Set(["sideRipples", "flatRipples"]);
const VALID_RIPPLE_FLOW_COLORS = new Set(["red", "blue", "white", "custom"]);
const VALID_SNOW_FALL_AREAS = new Set(["middle", "fullWidth"]);
const VALID_PARTICLE_SIZES = new Set(["small", "medium", "large", "custom"]);
const VALID_EDGE_FLUTTER_STYLES = new Set(["soft", "balanced", "energetic", "custom"]);
const VALID_EDGE_FLUTTER_COLORS = new Set(["blue", "purple", "red", "white", "custom"]);
const VALID_EDGE_FLUTTER_MODES = new Set(["left", "right", "both"]);
const VALID_BRAID_DENSITY = new Set(["sparse", "medium", "dense", "custom"]);
const VALID_BRAID_WIDTH = new Set(["thin", "medium", "thick", "custom"]);
const VALID_BRAID_MOTION = new Set(["calm", "balanced", "energetic", "custom"]);
const VALID_BRAID_COLORS = new Set(["cyanPink", "bluePurple", "redBlue", "white", "custom"]);
const VALID_BRAID_DIRECTION = new Set(["topDown", "bottomUp"]);
const VALID_AURORA_STYLES = new Set(["ambient", "cinematic", "energetic"]);
const VALID_AURORA_INTENSITIES = new Set(["subtle", "balanced", "vivid"]);
const VALID_AURORA_HEIGHTS = new Set(["low", "medium", "tall"]);
const VALID_AURORA_GLOWS = new Set(["soft", "medium", "strong"]);
const VALID_AURORA_SPEEDS = new Set(["calm", "balanced", "fast"]);
const VALID_AURORA_PALETTES = new Set(["cyanViolet", "emeraldSky", "sunsetDream", "frozenBlue", "monochrome"]);
const VALID_AURORA_AUDIO = new Set(["subtle", "balanced", "responsive"]);
const VALID_AURORA_SOFTNESS = new Set(["misty", "smooth", "defined"]);
const VALID_AURORA_DENSITY = new Set(["light", "balanced", "rich"]);
function createDefaultSettings() {
return {
launchOnStartup: DEFAULT_SETTINGS.launchOnStartup,
selectedTheme: DEFAULT_SETTINGS.selectedTheme,
colorMode: DEFAULT_SETTINGS.colorMode,
themeAutomation: { ...DEFAULT_SETTINGS.themeAutomation },
performanceMode: DEFAULT_SETTINGS.performanceMode,
focusMode: { ...DEFAULT_SETTINGS.focusMode },
fpsLimit: DEFAULT_SETTINGS.fpsLimit,
ambientWave: { ...DEFAULT_SETTINGS.ambientWave },
reactiveBorder: { ...DEFAULT_SETTINGS.reactiveBorder },
flowBorder: { ...DEFAULT_SETTINGS.flowBorder },
sideBars: { ...DEFAULT_SETTINGS.sideBars },
flatRipples: { ...DEFAULT_SETTINGS.flatRipples },
dotParticles: { ...DEFAULT_SETTINGS.dotParticles },
rippleFlow: { ...DEFAULT_SETTINGS.rippleFlow },
snowBubbleParticles: { ...DEFAULT_SETTINGS.snowBubbleParticles },
edgeCrystals: { ...DEFAULT_SETTINGS.edgeCrystals },
sideBraids: { ...DEFAULT_SETTINGS.sideBraids },
auroraDrift: { ...DEFAULT_SETTINGS.auroraDrift }
};
}
function createThemeDefaults() {
return {
ambientWave: { ...DEFAULT_SETTINGS.ambientWave },
reactiveBorder: { ...DEFAULT_SETTINGS.reactiveBorder },
flowBorder: { ...DEFAULT_SETTINGS.flowBorder },
sideBars: { ...DEFAULT_SETTINGS.sideBars },
flatRipples: { ...DEFAULT_SETTINGS.flatRipples },
dotParticles: { ...DEFAULT_SETTINGS.dotParticles },
rippleFlow: { ...DEFAULT_SETTINGS.rippleFlow },
snowBubbleParticles: { ...DEFAULT_SETTINGS.snowBubbleParticles },
edgeCrystals: { ...DEFAULT_SETTINGS.edgeCrystals },
sideBraids: { ...DEFAULT_SETTINGS.sideBraids },
auroraDrift: { ...DEFAULT_SETTINGS.auroraDrift }
};
}
function pick(value, validValues, fallback) {
return validValues.has(value) ? value : fallback;
}
function legacySensitivityToLevel(value) {
if (!Number.isFinite(value)) {
return "medium";
}
if (value < 2.6) {
return "low";
}
if (value < 4.2) {
return "medium";
}
return "high";
}
function sanitizeThemeAutomation(input = {}) {
return {
enabled: typeof input.enabled === "boolean" ? input.enabled : DEFAULT_SETTINGS.themeAutomation.enabled,
checkIntervalMinutes: typeof input.checkIntervalMinutes === "number"
? Math.max(1, Math.min(120, input.checkIntervalMinutes))
: DEFAULT_SETTINGS.themeAutomation.checkIntervalMinutes,
mode: typeof input.mode === "string" ? input.mode : DEFAULT_SETTINGS.themeAutomation.mode,
dayTheme: pick(input.dayTheme, VALID_MAIN_THEMES, DEFAULT_SETTINGS.themeAutomation.dayTheme),
nightTheme: pick(input.nightTheme, VALID_MAIN_THEMES, DEFAULT_SETTINGS.themeAutomation.nightTheme)
};
}
function sanitizeAmbientWave(input = {}) {
return {
tone: pick(input.tone, VALID_AMBIENT_TONES, DEFAULT_SETTINGS.ambientWave.tone),
sensitivity: pick(input.sensitivity, VALID_LEVELS, DEFAULT_SETTINGS.ambientWave.sensitivity),
edgeMode: pick(input.edgeMode, VALID_EDGE_MODES, DEFAULT_SETTINGS.ambientWave.edgeMode),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.ambientWave.glowStrength),
customColors: input.customColors,
customSensitivity: input.customSensitivity
};
}
function sanitizeReactiveBorder(input = {}) {
return {
colorStyle: pick(input.colorStyle, VALID_REACTIVE_COLOR_STYLES, DEFAULT_SETTINGS.reactiveBorder.colorStyle),
intensity: pick(input.intensity, VALID_LEVELS, DEFAULT_SETTINGS.reactiveBorder.intensity),
borderThickness: pick(input.borderThickness, VALID_BORDER_THICKNESS, DEFAULT_SETTINGS.reactiveBorder.borderThickness),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.reactiveBorder.glowStrength),
customColors: input.customColors,
customThickness: input.customThickness,
customSensitivity: input.customSensitivity
};
}
function sanitizeFlowBorder(input = {}) {
return {
direction: pick(input.direction, VALID_FLOW_DIRECTIONS, DEFAULT_SETTINGS.flowBorder.direction),
speedMode: pick(input.speedMode, VALID_FLOW_SPEEDS, DEFAULT_SETTINGS.flowBorder.speedMode),
segmentLength: pick(input.segmentLength, VALID_FLOW_SEGMENTS, DEFAULT_SETTINGS.flowBorder.segmentLength),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.flowBorder.glowStrength),
colorStyle: pick(input.colorStyle, VALID_FLOW_COLOR_STYLES, DEFAULT_SETTINGS.flowBorder.colorStyle),
customColors: input.customColors,
customThickness: input.customThickness,
customSensitivity: input.customSensitivity,
customSpeed: input.customSpeed
};
}
function sanitizeSideBars(input = {}) {
const customColors = Array.isArray(input.customColors) && input.customColors.length === 3
? input.customColors
: DEFAULT_SETTINGS.sideBars.customColors;
return {
colorStyle: pick(input.colorStyle, VALID_SIDE_BARS_COLOR_STYLES, DEFAULT_SETTINGS.sideBars.colorStyle),
barThickness: pick(input.barThickness, VALID_SIDE_BARS_THICKNESS, DEFAULT_SETTINGS.sideBars.barThickness),
sensitivity: pick(input.sensitivity, VALID_LEVELS, DEFAULT_SETTINGS.sideBars.sensitivity),
barDensity: pick(input.barDensity, VALID_SIDE_BARS_DENSITY, DEFAULT_SETTINGS.sideBars.barDensity),
customColors,
customThickness: typeof input.customThickness === "number" ? input.customThickness : DEFAULT_SETTINGS.sideBars.customThickness,
customGap: typeof input.customGap === "number" ? input.customGap : DEFAULT_SETTINGS.sideBars.customGap,
customSensitivity: typeof input.customSensitivity === "number" ? input.customSensitivity : DEFAULT_SETTINGS.sideBars.customSensitivity
};
}
function sanitizeFlatRipples(input = {}) {
return {
mode: pick(input.mode, VALID_FLAT_RIPPLES_MODES, DEFAULT_SETTINGS.flatRipples.mode),
intensity: pick(input.intensity, VALID_LEVELS, DEFAULT_SETTINGS.flatRipples.intensity),
colorStyle: pick(input.colorStyle, VALID_FLAT_RIPPLES_COLORS, DEFAULT_SETTINGS.flatRipples.colorStyle),
speed: pick(input.speed, VALID_FLAT_RIPPLES_SPEEDS, DEFAULT_SETTINGS.flatRipples.speed),
customColors: input.customColors,
customSensitivity: input.customSensitivity,
customSpeed: input.customSpeed
};
}
function sanitizeDotParticles(input = {}) {
return {
density: pick(input.density, VALID_LEVELS, DEFAULT_SETTINGS.dotParticles.density),
motionStyle: pick(input.motionStyle, VALID_DOT_PARTICLES_MOTION_STYLES, DEFAULT_SETTINGS.dotParticles.motionStyle),
directionBehavior: pick(input.directionBehavior, VALID_DOT_PARTICLES_DIRECTIONS, DEFAULT_SETTINGS.dotParticles.directionBehavior),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.dotParticles.glowStrength),
customGap: input.customGap,
customSpeed: input.customSpeed
};
}
function sanitizeRippleFlow(input = {}) {
return {
mode: pick(input.mode, VALID_RIPPLE_FLOW_MODES, DEFAULT_SETTINGS.rippleFlow.mode),
intensity: pick(input.intensity, VALID_LEVELS, DEFAULT_SETTINGS.rippleFlow.intensity),
sensitivity: pick(input.sensitivity, VALID_LEVELS, DEFAULT_SETTINGS.rippleFlow.sensitivity),
colorStyle: pick(input.colorStyle, VALID_RIPPLE_FLOW_COLORS, DEFAULT_SETTINGS.rippleFlow.colorStyle),
customColors: input.customColors,
customSensitivity: input.customSensitivity
};
}
function sanitizeSnowBubbleParticles(input = {}) {
return {
fallArea: pick(input.fallArea, VALID_SNOW_FALL_AREAS, DEFAULT_SETTINGS.snowBubbleParticles.fallArea),
density: pick(input.density, VALID_LEVELS, DEFAULT_SETTINGS.snowBubbleParticles.density),
motionStyle: pick(input.motionStyle, VALID_DOT_PARTICLES_MOTION_STYLES, DEFAULT_SETTINGS.snowBubbleParticles.motionStyle),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.snowBubbleParticles.glowStrength),
particleSize: pick(input.particleSize, VALID_PARTICLE_SIZES, DEFAULT_SETTINGS.snowBubbleParticles.particleSize)
};
}
function sanitizeEdgeCrystals(input = {}) {
return {
flutterStyle: pick(input.flutterStyle, VALID_EDGE_FLUTTER_STYLES, DEFAULT_SETTINGS.edgeCrystals.flutterStyle),
density: pick(input.density, VALID_LEVELS, DEFAULT_SETTINGS.edgeCrystals.density),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.edgeCrystals.glowStrength),
colorStyle: pick(input.colorStyle, VALID_EDGE_FLUTTER_COLORS, DEFAULT_SETTINGS.edgeCrystals.colorStyle),
edgeMode: pick(input.edgeMode, VALID_EDGE_FLUTTER_MODES, DEFAULT_SETTINGS.edgeCrystals.edgeMode),
customColors: input.customColors,
customGap: input.customGap,
customSensitivity: input.customSensitivity,
customSpeed: input.customSpeed
};
}
function sanitizeSideBraids(input = {}) {
return {
braidDensity: pick(input.braidDensity, VALID_BRAID_DENSITY, DEFAULT_SETTINGS.sideBraids.braidDensity),
motionStyle: pick(input.motionStyle, VALID_BRAID_MOTION, DEFAULT_SETTINGS.sideBraids.motionStyle),
glowStrength: pick(input.glowStrength, VALID_GLOW_STRENGTHS, DEFAULT_SETTINGS.sideBraids.glowStrength),
braidWidth: pick(input.braidWidth, VALID_BRAID_WIDTH, DEFAULT_SETTINGS.sideBraids.braidWidth),
colorStyle: pick(input.colorStyle, VALID_BRAID_COLORS, DEFAULT_SETTINGS.sideBraids.colorStyle),
flowDirection: pick(input.flowDirection, VALID_BRAID_DIRECTION, DEFAULT_SETTINGS.sideBraids.flowDirection),
customColors: input.customColors,
customThickness: typeof input.customThickness === "number" ? input.customThickness : DEFAULT_SETTINGS.sideBraids.customThickness,
customGap: typeof input.customGap === "number" ? input.customGap : DEFAULT_SETTINGS.sideBraids.customGap,
customSensitivity: typeof input.customSensitivity === "number" ? input.customSensitivity : DEFAULT_SETTINGS.sideBraids.customSensitivity,
customSpeed: typeof input.customSpeed === "number" ? input.customSpeed : DEFAULT_SETTINGS.sideBraids.customSpeed
};
}
function sanitizeAuroraDrift(input = {}) {
function sanitizeNum(val, fallback, min = 0.0, max = 5.0) {
const num = parseFloat(val);
return Number.isFinite(num) ? Math.max(min, Math.min(max, num)) : fallback;
}
let stops = DEFAULT_SETTINGS.auroraDrift.gradientStops;
if (Array.isArray(input.gradientStops)) {
const parsedStops = input.gradientStops
.map(stop => {
const pos = Math.max(0.0, Math.min(1.0, parseFloat(stop?.pos)));
const color = typeof stop?.color === "string" && /^#[0-9a-fA-F]{6}$/.test(stop.color)
? stop.color
: "#ffffff";
return { pos, color };
})
.filter(stop => Number.isFinite(stop.pos))
.sort((a, b) => a.pos - b.pos);
if (parsedStops.length >= 2 && parsedStops.length <= 6) {
stops = parsedStops;
}
}
return {
auroraStyle: pick(input.auroraStyle, VALID_AURORA_STYLES, DEFAULT_SETTINGS.auroraDrift.auroraStyle),
intensity: pick(input.intensity, VALID_AURORA_INTENSITIES, DEFAULT_SETTINGS.auroraDrift.intensity),
height: pick(input.height, VALID_AURORA_HEIGHTS, DEFAULT_SETTINGS.auroraDrift.height),
glowStrength: pick(input.glowStrength, VALID_AURORA_GLOWS, DEFAULT_SETTINGS.auroraDrift.glowStrength),
motionSpeed: pick(input.motionSpeed, VALID_AURORA_SPEEDS, DEFAULT_SETTINGS.auroraDrift.motionSpeed),
colorPalette: pick(input.colorPalette, VALID_AURORA_PALETTES, DEFAULT_SETTINGS.auroraDrift.colorPalette),
audioReactivity: pick(input.audioReactivity, VALID_AURORA_AUDIO, DEFAULT_SETTINGS.auroraDrift.audioReactivity),
softness: pick(input.softness, VALID_AURORA_SOFTNESS, DEFAULT_SETTINGS.auroraDrift.softness),
layerDensity: pick(input.layerDensity, VALID_AURORA_DENSITY, DEFAULT_SETTINGS.auroraDrift.layerDensity),
gradientStops: stops,
baseGlowRadius: sanitizeNum(input.baseGlowRadius, DEFAULT_SETTINGS.auroraDrift.baseGlowRadius, 0.1, 3.0),
peakGlowRadius: sanitizeNum(input.peakGlowRadius, DEFAULT_SETTINGS.auroraDrift.peakGlowRadius, 0.1, 3.0),
crestBrightness: sanitizeNum(input.crestBrightness, DEFAULT_SETTINGS.auroraDrift.crestBrightness, 0.1, 3.0),
bloomStrength: sanitizeNum(input.bloomStrength, DEFAULT_SETTINGS.auroraDrift.bloomStrength, 0.0, 3.0),
glowFalloff: sanitizeNum(input.glowFalloff, DEFAULT_SETTINGS.auroraDrift.glowFalloff, 0.1, 3.0),
primaryFrequency: sanitizeNum(input.primaryFrequency, DEFAULT_SETTINGS.auroraDrift.primaryFrequency, 0.1, 3.0),
secondaryFrequency: sanitizeNum(input.secondaryFrequency, DEFAULT_SETTINGS.auroraDrift.secondaryFrequency, 0.1, 3.0),
turbulenceComplexity: sanitizeNum(input.turbulenceComplexity, DEFAULT_SETTINGS.auroraDrift.turbulenceComplexity, 0.1, 3.0),
motionSmoothness: sanitizeNum(input.motionSmoothness, DEFAULT_SETTINGS.auroraDrift.motionSmoothness, 0.1, 3.0),
driftSpeed: sanitizeNum(input.driftSpeed, DEFAULT_SETTINGS.auroraDrift.driftSpeed, 0.0, 3.0),
bassInfluence: sanitizeNum(input.bassInfluence, DEFAULT_SETTINGS.auroraDrift.bassInfluence, 0.0, 3.0),
midInfluence: sanitizeNum(input.midInfluence, DEFAULT_SETTINGS.auroraDrift.midInfluence, 0.0, 3.0),
highShimmer: sanitizeNum(input.highShimmer, DEFAULT_SETTINGS.auroraDrift.highShimmer, 0.0, 3.0),
audioSmoothing: sanitizeNum(input.audioSmoothing, DEFAULT_SETTINGS.auroraDrift.audioSmoothing, 0.1, 3.0),
peakSensitivity: sanitizeNum(input.peakSensitivity, DEFAULT_SETTINGS.auroraDrift.peakSensitivity, 0.1, 3.0),
ribbonHeight: sanitizeNum(input.ribbonHeight, DEFAULT_SETTINGS.auroraDrift.ribbonHeight, 0.1, 3.0),
ribbonWidth: sanitizeNum(input.ribbonWidth, DEFAULT_SETTINGS.auroraDrift.ribbonWidth, 0.1, 3.0),
edgeSoftness: sanitizeNum(input.edgeSoftness, DEFAULT_SETTINGS.auroraDrift.edgeSoftness, 0.1, 3.0),
layerSeparation: sanitizeNum(input.layerSeparation, DEFAULT_SETTINGS.auroraDrift.layerSeparation, 0.1, 3.0),
crestSharpness: sanitizeNum(input.crestSharpness, DEFAULT_SETTINGS.auroraDrift.crestSharpness, 0.1, 3.0),
layerCount: Math.round(sanitizeNum(input.layerCount, DEFAULT_SETTINGS.auroraDrift.layerCount, 1, 6)),
backgroundHaze: sanitizeNum(input.backgroundHaze, DEFAULT_SETTINGS.auroraDrift.backgroundHaze, 0.0, 3.0),
foregroundHighlight: sanitizeNum(input.foregroundHighlight, DEFAULT_SETTINGS.auroraDrift.foregroundHighlight, 0.0, 3.0),
parallaxDepth: sanitizeNum(input.parallaxDepth, DEFAULT_SETTINGS.auroraDrift.parallaxDepth, 0.0, 3.0),
ambientOpacity: sanitizeNum(input.ambientOpacity, DEFAULT_SETTINGS.auroraDrift.ambientOpacity, 0.0, 3.0),
colorSaturation: sanitizeNum(input.colorSaturation, DEFAULT_SETTINGS.auroraDrift.colorSaturation, 0.0, 3.0),
atmosphericFade: sanitizeNum(input.atmosphericFade, DEFAULT_SETTINGS.auroraDrift.atmosphericFade, 0.0, 3.0),
edgeFeathering: sanitizeNum(input.edgeFeathering, DEFAULT_SETTINGS.auroraDrift.edgeFeathering, 0.0, 3.0)
};
}
function migrateLegacySettings(input = {}) {
if (VALID_MAIN_THEMES.has(input.selectedTheme) && !input.edgeFlutter) {
return input;
}
const normalizedInput = { ...input };
if (normalizedInput.selectedTheme === "edgeFlutter") {
normalizedInput.selectedTheme = "edgeCrystals";
}
if (normalizedInput.edgeFlutter && !normalizedInput.edgeCrystals) {
normalizedInput.edgeCrystals = normalizedInput.edgeFlutter;
}
if (VALID_MAIN_THEMES.has(normalizedInput.selectedTheme)) {
return normalizedInput;
}
const migrated = createDefaultSettings();
const legacyTheme = normalizedInput.theme;
const legacyLevel = legacySensitivityToLevel(normalizedInput.sensitivity);
migrated.ambientWave.sensitivity = legacyLevel;
if (VALID_EDGE_MODES.has(normalizedInput.edgeMode)) {
migrated.ambientWave.edgeMode = normalizedInput.edgeMode;
}
if (legacyTheme === "purple" || legacyTheme === "warm") {
migrated.ambientWave.tone = legacyTheme;
}
if (legacyTheme === "rainbow") {
migrated.selectedTheme = "reactiveBorder";
migrated.reactiveBorder.intensity = legacyLevel;
} else if (legacyTheme === "flow") {
migrated.selectedTheme = "flowBorder";
} else {
migrated.selectedTheme = "ambientWave";
if (legacyTheme === "blue" || legacyTheme === "purple" || legacyTheme === "warm") {
migrated.ambientWave.tone = legacyTheme;
}
}
return migrated;
}
function sanitizeFocusMode(input = {}) {
const enabled = typeof input.enabled === "boolean" ? input.enabled : DEFAULT_SETTINGS.focusMode.enabled;
const dimOpacity = typeof input.dimOpacity === "number" && input.dimOpacity >= 0 && input.dimOpacity <= 1
? input.dimOpacity
: DEFAULT_SETTINGS.focusMode.dimOpacity;
const idleTimeout = typeof input.idleTimeout === "number" && input.idleTimeout >= 1 && input.idleTimeout <= 60
? input.idleTimeout
: DEFAULT_SETTINGS.focusMode.idleTimeout;
return { enabled, dimOpacity, idleTimeout };
}
function sanitizeSettings(input = {}) {
const source = migrateLegacySettings(input);
const customColors = Array.isArray(source.customColors) && source.customColors.length === 3
? source.customColors
: DEFAULT_SETTINGS.customColors;
return {
launchOnStartup: typeof source.launchOnStartup === "boolean" ? source.launchOnStartup : DEFAULT_SETTINGS.launchOnStartup,
selectedTheme: pick(source.selectedTheme, VALID_MAIN_THEMES, DEFAULT_SETTINGS.selectedTheme),
colorMode: pick(source.colorMode, VALID_COLOR_MODES, DEFAULT_SETTINGS.colorMode),
customColors: customColors,
themeAutomation: sanitizeThemeAutomation(source.themeAutomation),
performanceMode: pick(source.performanceMode, VALID_PERFORMANCE_MODES, DEFAULT_SETTINGS.performanceMode),
fpsLimit: pick(source.fpsLimit, VALID_FPS_LIMITS, DEFAULT_SETTINGS.fpsLimit),
focusMode: sanitizeFocusMode(source.focusMode),
ambientWave: sanitizeAmbientWave(source.ambientWave),
reactiveBorder: sanitizeReactiveBorder(source.reactiveBorder),
flowBorder: sanitizeFlowBorder(source.flowBorder),
sideBars: sanitizeSideBars(source.sideBars),
flatRipples: sanitizeFlatRipples(source.flatRipples),
dotParticles: sanitizeDotParticles(source.dotParticles),
rippleFlow: sanitizeRippleFlow(source.rippleFlow),
snowBubbleParticles: sanitizeSnowBubbleParticles(source.snowBubbleParticles),
edgeCrystals: sanitizeEdgeCrystals(source.edgeCrystals),
sideBraids: sanitizeSideBraids(source.sideBraids),
auroraDrift: sanitizeAuroraDrift(source.auroraDrift)
};
}
function createSettingsStore(userDataPath) {
const settingsPath = path.join(userDataPath, "settings.json");
const profilesPath = path.join(userDataPath, "themeProfiles.json");
function load() {
try {
if (!fs.existsSync(settingsPath)) {
return createDefaultSettings();
}
const fileContent = fs.readFileSync(settingsPath, "utf8");
const parsed = JSON.parse(fileContent);
return sanitizeSettings(parsed);
} catch (_error) {
return createDefaultSettings();
}
}
function save(settings) {
const cleanSettings = sanitizeSettings(settings);
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
fs.writeFileSync(settingsPath, JSON.stringify(cleanSettings, null, 2));
return cleanSettings;
}
function loadProfiles() {
try {
if (!fs.existsSync(profilesPath)) {
return {};
}
const fileContent = fs.readFileSync(profilesPath, "utf8");
return JSON.parse(fileContent);
} catch (_error) {
return {};
}
}
function saveProfiles(profiles) {
fs.mkdirSync(path.dirname(profilesPath), { recursive: true });
fs.writeFileSync(
profilesPath,
JSON.stringify(profiles, null, 2)
);
return profiles;
}
return {
load,
save,
loadProfiles,
saveProfiles,
path: settingsPath,
profilesPath
};
}
module.exports = {
DEFAULT_SETTINGS,
createDefaultSettings,
createThemeDefaults,
createSettingsStore,
sanitizeSettings
};