@circadian/sol 0.2.9 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -1
- package/dist/devtools/index.js +1 -1
- package/dist/index.d.ts +117 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/{solar-theme-provider-CSustvmw.js → solar-theme-provider-cxO4tmFT.js} +353 -20
- package/dist/solar-theme-provider-cxO4tmFT.js.map +1 -0
- package/dist/styles-no-preflight.css +2 -2
- package/dist/styles.css +2 -2
- package/package.json +1 -1
- package/dist/solar-theme-provider-CSustvmw.js.map +0 -1
|
@@ -497,7 +497,7 @@ var require_tz = /* @__PURE__ */ __commonJS({ "node_modules/tz-lookup/tz.js": ((
|
|
|
497
497
|
const RAD = Math.PI / 180;
|
|
498
498
|
const DEG = 180 / Math.PI;
|
|
499
499
|
/** Day of year (1–366) */
|
|
500
|
-
function dayOfYear(date) {
|
|
500
|
+
function dayOfYear$1(date) {
|
|
501
501
|
const start = new Date(date.getFullYear(), 0, 0);
|
|
502
502
|
const diff = date.getTime() - start.getTime();
|
|
503
503
|
return Math.floor(diff / 864e5);
|
|
@@ -548,7 +548,7 @@ function riseSetMinutes(latRad, declRad, altitudeDeg, longitudeDeg, utcOffsetMin
|
|
|
548
548
|
* Compute full solar position for a given date + location
|
|
549
549
|
*/
|
|
550
550
|
function computeSolarPosition(date, latitudeDeg, longitudeDeg, utcOffsetMinutes) {
|
|
551
|
-
const { eot, decl } = equationOfTimeAndDeclination(dayOfYear(date));
|
|
551
|
+
const { eot, decl } = equationOfTimeAndDeclination(dayOfYear$1(date));
|
|
552
552
|
const latRad = latitudeDeg * RAD;
|
|
553
553
|
const declRad = decl * RAD;
|
|
554
554
|
const localMinutes = date.getHours() * 60 + date.getMinutes() + date.getSeconds() / 60;
|
|
@@ -6818,6 +6818,207 @@ function injectWidgetCSS() {
|
|
|
6818
6818
|
injected = true;
|
|
6819
6819
|
}
|
|
6820
6820
|
|
|
6821
|
+
//#endregion
|
|
6822
|
+
//#region src/lib/reverse-geocode.ts
|
|
6823
|
+
const BDC_ENDPOINT = "https://api.bigdatacloud.net/data/reverse-geocode-client";
|
|
6824
|
+
/**
|
|
6825
|
+
* Fetches the nearest locality/city name for the given coordinates.
|
|
6826
|
+
* Returns null on any error so callers can fall back gracefully.
|
|
6827
|
+
*
|
|
6828
|
+
* @param lat Latitude (precise — from browser geolocation, not centroid)
|
|
6829
|
+
* @param lng Longitude
|
|
6830
|
+
* @param signal Optional AbortSignal to cancel in-flight requests on cleanup
|
|
6831
|
+
*/
|
|
6832
|
+
async function fetchReverseGeocode(lat, lng, signal) {
|
|
6833
|
+
try {
|
|
6834
|
+
const url = `${BDC_ENDPOINT}?latitude=${lat}&longitude=${lng}&localityLanguage=en`;
|
|
6835
|
+
const res = await fetch(url, signal ? { signal } : void 0);
|
|
6836
|
+
if (!res.ok) return null;
|
|
6837
|
+
const data$1 = await res.json();
|
|
6838
|
+
return data$1.locality?.trim() || data$1.city?.trim() || data$1.principalSubdivision?.trim() || null;
|
|
6839
|
+
} catch {
|
|
6840
|
+
return null;
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
/**
|
|
6844
|
+
* Parse an instant (no-fetch) city name from an IANA timezone string.
|
|
6845
|
+
* Used as the initial value before geolocation resolves.
|
|
6846
|
+
*
|
|
6847
|
+
* "Europe/Copenhagen" → "Copenhagen"
|
|
6848
|
+
* "America/New_York" → "New York"
|
|
6849
|
+
* "Asia/Ho_Chi_Minh" → "Ho Chi Minh"
|
|
6850
|
+
*/
|
|
6851
|
+
function cityFromTimezone(tz) {
|
|
6852
|
+
if (!tz) return null;
|
|
6853
|
+
return (tz.split("/").pop() ?? "").replace(/_/g, " ").trim() || null;
|
|
6854
|
+
}
|
|
6855
|
+
|
|
6856
|
+
//#endregion
|
|
6857
|
+
//#region src/lib/seasonal-blend.ts
|
|
6858
|
+
const IDENTITY_MODIFIER = {
|
|
6859
|
+
saturationScale: 1,
|
|
6860
|
+
lightnessShift: 0,
|
|
6861
|
+
hueRotateDeg: 0,
|
|
6862
|
+
tintStrength: 0
|
|
6863
|
+
};
|
|
6864
|
+
const UNIVERSAL_SEASON_MODIFIERS = {
|
|
6865
|
+
spring: {
|
|
6866
|
+
saturationScale: 1.1,
|
|
6867
|
+
lightnessShift: .02,
|
|
6868
|
+
hueRotateDeg: 8,
|
|
6869
|
+
tintColor: "#a8d8a0",
|
|
6870
|
+
tintStrength: .06
|
|
6871
|
+
},
|
|
6872
|
+
summer: {
|
|
6873
|
+
saturationScale: 1.18,
|
|
6874
|
+
lightnessShift: .03,
|
|
6875
|
+
hueRotateDeg: 10,
|
|
6876
|
+
tintColor: "#ffe066",
|
|
6877
|
+
tintStrength: .07
|
|
6878
|
+
},
|
|
6879
|
+
autumn: {
|
|
6880
|
+
saturationScale: .9,
|
|
6881
|
+
lightnessShift: -.03,
|
|
6882
|
+
hueRotateDeg: -18,
|
|
6883
|
+
tintColor: "#c8692a",
|
|
6884
|
+
tintStrength: .1
|
|
6885
|
+
},
|
|
6886
|
+
winter: {
|
|
6887
|
+
saturationScale: .82,
|
|
6888
|
+
lightnessShift: -.04,
|
|
6889
|
+
hueRotateDeg: -25,
|
|
6890
|
+
tintColor: "#8ab4d4",
|
|
6891
|
+
tintStrength: .08
|
|
6892
|
+
}
|
|
6893
|
+
};
|
|
6894
|
+
function hexToRgb$2(hex$1) {
|
|
6895
|
+
const clean = hex$1.replace("#", "");
|
|
6896
|
+
return [
|
|
6897
|
+
Number.parseInt(clean.slice(0, 2), 16) / 255,
|
|
6898
|
+
Number.parseInt(clean.slice(2, 4), 16) / 255,
|
|
6899
|
+
Number.parseInt(clean.slice(4, 6), 16) / 255
|
|
6900
|
+
];
|
|
6901
|
+
}
|
|
6902
|
+
function rgbToHsl(r, g, b) {
|
|
6903
|
+
const max = Math.max(r, g, b);
|
|
6904
|
+
const min = Math.min(r, g, b);
|
|
6905
|
+
const l = (max + min) / 2;
|
|
6906
|
+
let h = 0;
|
|
6907
|
+
let s = 0;
|
|
6908
|
+
if (max !== min) {
|
|
6909
|
+
const d = max - min;
|
|
6910
|
+
s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
6911
|
+
switch (max) {
|
|
6912
|
+
case r:
|
|
6913
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
6914
|
+
break;
|
|
6915
|
+
case g:
|
|
6916
|
+
h = ((b - r) / d + 2) / 6;
|
|
6917
|
+
break;
|
|
6918
|
+
case b:
|
|
6919
|
+
h = ((r - g) / d + 4) / 6;
|
|
6920
|
+
break;
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
6923
|
+
return [
|
|
6924
|
+
h,
|
|
6925
|
+
s,
|
|
6926
|
+
l
|
|
6927
|
+
];
|
|
6928
|
+
}
|
|
6929
|
+
function hslToRgb(h, s, l) {
|
|
6930
|
+
if (s === 0) return [
|
|
6931
|
+
l,
|
|
6932
|
+
l,
|
|
6933
|
+
l
|
|
6934
|
+
];
|
|
6935
|
+
const hue2rgb = (p$1, q$1, _t) => {
|
|
6936
|
+
let t = _t;
|
|
6937
|
+
if (t < 0) t += 1;
|
|
6938
|
+
if (t > 1) t -= 1;
|
|
6939
|
+
if (t < 1 / 6) return p$1 + (q$1 - p$1) * 6 * t;
|
|
6940
|
+
if (t < 1 / 2) return q$1;
|
|
6941
|
+
if (t < 2 / 3) return p$1 + (q$1 - p$1) * (2 / 3 - t) * 6;
|
|
6942
|
+
return p$1;
|
|
6943
|
+
};
|
|
6944
|
+
const q = l < .5 ? l * (1 + s) : l + s - l * s;
|
|
6945
|
+
const p = 2 * l - q;
|
|
6946
|
+
return [
|
|
6947
|
+
hue2rgb(p, q, h + 1 / 3),
|
|
6948
|
+
hue2rgb(p, q, h),
|
|
6949
|
+
hue2rgb(p, q, h - 1 / 3)
|
|
6950
|
+
];
|
|
6951
|
+
}
|
|
6952
|
+
function rgbToHex(r, g, b) {
|
|
6953
|
+
const toHex = (x) => Math.round(Math.max(0, Math.min(1, x)) * 255).toString(16).padStart(2, "0");
|
|
6954
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
6955
|
+
}
|
|
6956
|
+
function lerpNum$6(a, b, t) {
|
|
6957
|
+
return a + (b - a) * t;
|
|
6958
|
+
}
|
|
6959
|
+
/**
|
|
6960
|
+
* Apply a SeasonalModifier to a single hex color.
|
|
6961
|
+
* Works in HSL space for hue rotation + saturation + lightness,
|
|
6962
|
+
* then blends toward tintColor if provided.
|
|
6963
|
+
*/
|
|
6964
|
+
function shiftColor(hex$1, mod) {
|
|
6965
|
+
if (!hex$1 || hex$1.length < 7) return hex$1;
|
|
6966
|
+
const [r, g, b] = hexToRgb$2(hex$1);
|
|
6967
|
+
let [h, s, l] = rgbToHsl(r, g, b);
|
|
6968
|
+
h = ((h + mod.hueRotateDeg / 360) % 1 + 1) % 1;
|
|
6969
|
+
s = Math.max(0, Math.min(1, s * mod.saturationScale));
|
|
6970
|
+
l = Math.max(0, Math.min(1, l + mod.lightnessShift));
|
|
6971
|
+
const [sr$5, sg, sb] = hslToRgb(h, s, l);
|
|
6972
|
+
let result = rgbToHex(sr$5, sg, sb);
|
|
6973
|
+
if (mod.tintColor && mod.tintStrength > 0) {
|
|
6974
|
+
const [tr, tg, tb] = hexToRgb$2(mod.tintColor);
|
|
6975
|
+
const [fr, fg, fb] = hexToRgb$2(result);
|
|
6976
|
+
result = rgbToHex(lerpNum$6(fr, tr, mod.tintStrength), lerpNum$6(fg, tg, mod.tintStrength), lerpNum$6(fb, tb, mod.tintStrength));
|
|
6977
|
+
}
|
|
6978
|
+
return result;
|
|
6979
|
+
}
|
|
6980
|
+
/**
|
|
6981
|
+
* Linearly interpolate between two SeasonalModifiers.
|
|
6982
|
+
* Used for smooth crossfades at solstice/equinox boundaries.
|
|
6983
|
+
*/
|
|
6984
|
+
function lerpModifier(a, b, t) {
|
|
6985
|
+
return {
|
|
6986
|
+
saturationScale: lerpNum$6(a.saturationScale, b.saturationScale, t),
|
|
6987
|
+
lightnessShift: lerpNum$6(a.lightnessShift, b.lightnessShift, t),
|
|
6988
|
+
hueRotateDeg: lerpNum$6(a.hueRotateDeg, b.hueRotateDeg, t),
|
|
6989
|
+
tintStrength: lerpNum$6(a.tintStrength, b.tintStrength, t),
|
|
6990
|
+
tintColor: t < .5 ? a.tintColor : b.tintColor
|
|
6991
|
+
};
|
|
6992
|
+
}
|
|
6993
|
+
/**
|
|
6994
|
+
* Apply a SeasonalModifier to every color in a ShaderPalette.
|
|
6995
|
+
* Returns a new palette — the original is not mutated.
|
|
6996
|
+
*
|
|
6997
|
+
* The modifier shifts hue, saturation, and lightness then applies a tint wash.
|
|
6998
|
+
* The result is blended back toward the original at `strength` 0→1:
|
|
6999
|
+
* 0 = identity, 1 = fully modified.
|
|
7000
|
+
*/
|
|
7001
|
+
function applySeasonalModifier(palette, mod, strength = 1) {
|
|
7002
|
+
if (strength <= 0) return palette;
|
|
7003
|
+
const effective = strength < 1 ? lerpModifier(IDENTITY_MODIFIER, mod, strength) : mod;
|
|
7004
|
+
return {
|
|
7005
|
+
...palette,
|
|
7006
|
+
colors: palette.colors.map((c) => shiftColor(c, effective)),
|
|
7007
|
+
colorBack: shiftColor(palette.colorBack, effective),
|
|
7008
|
+
vignette: shiftColor(palette.vignette, effective)
|
|
7009
|
+
};
|
|
7010
|
+
}
|
|
7011
|
+
/**
|
|
7012
|
+
* Given a SeasonalBlend and a modifier map, return the interpolated modifier
|
|
7013
|
+
* ready to pass to applySeasonalModifier.
|
|
7014
|
+
*
|
|
7015
|
+
* @param blend The SeasonalBlend from useSeason()
|
|
7016
|
+
* @param modifiers Per-season modifier map (skin's or universal default)
|
|
7017
|
+
*/
|
|
7018
|
+
function resolveSeasonalModifier(blend, modifiers = UNIVERSAL_SEASON_MODIFIERS) {
|
|
7019
|
+
return lerpModifier(modifiers[blend.season] ?? IDENTITY_MODIFIER, modifiers[blend.nextSeason] ?? IDENTITY_MODIFIER, blend.t);
|
|
7020
|
+
}
|
|
7021
|
+
|
|
6821
7022
|
//#endregion
|
|
6822
7023
|
//#region src/lib/solar-lerp.ts
|
|
6823
7024
|
/**
|
|
@@ -7316,6 +7517,96 @@ function getBrowserTimezone() {
|
|
|
7316
7517
|
}
|
|
7317
7518
|
}
|
|
7318
7519
|
|
|
7520
|
+
//#endregion
|
|
7521
|
+
//#region src/lib/useSeason.ts
|
|
7522
|
+
/** Day-of-year for each northern hemisphere season start (approximate). */
|
|
7523
|
+
const SEASON_STARTS_NORTH = {
|
|
7524
|
+
spring: 79,
|
|
7525
|
+
summer: 172,
|
|
7526
|
+
autumn: 265,
|
|
7527
|
+
winter: 355
|
|
7528
|
+
};
|
|
7529
|
+
/** Days either side of a transition within which to apply crossfade. */
|
|
7530
|
+
const CROSSFADE_DAYS = 14;
|
|
7531
|
+
const SEASON_ORDER = [
|
|
7532
|
+
"spring",
|
|
7533
|
+
"summer",
|
|
7534
|
+
"autumn",
|
|
7535
|
+
"winter"
|
|
7536
|
+
];
|
|
7537
|
+
function dayOfYear(date) {
|
|
7538
|
+
const start = new Date(date.getFullYear(), 0, 0);
|
|
7539
|
+
const diff = date.getTime() - start.getTime();
|
|
7540
|
+
return Math.floor(diff / 864e5);
|
|
7541
|
+
}
|
|
7542
|
+
function daysInYear(year) {
|
|
7543
|
+
return new Date(year, 1, 29).getMonth() === 1 ? 366 : 365;
|
|
7544
|
+
}
|
|
7545
|
+
function computeSeasonalBlend(doy, isNorthern, totalDays) {
|
|
7546
|
+
const adjustedDoy = isNorthern ? doy : (doy + 182) % totalDays || totalDays;
|
|
7547
|
+
let currentSeason = "winter";
|
|
7548
|
+
let currentIdx = 0;
|
|
7549
|
+
for (let i$1 = SEASON_ORDER.length - 1; i$1 >= 0; i$1--) if (adjustedDoy >= SEASON_STARTS_NORTH[SEASON_ORDER[i$1]]) {
|
|
7550
|
+
currentSeason = SEASON_ORDER[i$1];
|
|
7551
|
+
currentIdx = i$1;
|
|
7552
|
+
break;
|
|
7553
|
+
}
|
|
7554
|
+
const nextSeason = SEASON_ORDER[(currentIdx + 1) % SEASON_ORDER.length];
|
|
7555
|
+
let daysToNext = SEASON_STARTS_NORTH[nextSeason] - adjustedDoy;
|
|
7556
|
+
if (daysToNext < 0) daysToNext += totalDays;
|
|
7557
|
+
let t = 0;
|
|
7558
|
+
if (daysToNext <= CROSSFADE_DAYS) {
|
|
7559
|
+
const raw = (CROSSFADE_DAYS - daysToNext) / CROSSFADE_DAYS;
|
|
7560
|
+
const clamped = Math.max(0, Math.min(1, raw));
|
|
7561
|
+
t = clamped * clamped * (3 - 2 * clamped);
|
|
7562
|
+
}
|
|
7563
|
+
return {
|
|
7564
|
+
season: currentSeason,
|
|
7565
|
+
nextSeason,
|
|
7566
|
+
t
|
|
7567
|
+
};
|
|
7568
|
+
}
|
|
7569
|
+
/**
|
|
7570
|
+
* Pure function — compute the SeasonalBlend for a given date and latitude.
|
|
7571
|
+
*
|
|
7572
|
+
* @param date The date to evaluate (default: now)
|
|
7573
|
+
* @param latitudeN Decimal degrees, positive = north (default: 0)
|
|
7574
|
+
* @param override Force a fixed season, bypassing computation
|
|
7575
|
+
*/
|
|
7576
|
+
function getSeasonalBlend(date = /* @__PURE__ */ new Date(), latitudeN = 0, override) {
|
|
7577
|
+
if (override) return {
|
|
7578
|
+
season: override,
|
|
7579
|
+
nextSeason: SEASON_ORDER[(SEASON_ORDER.indexOf(override) + 1) % SEASON_ORDER.length],
|
|
7580
|
+
t: 0
|
|
7581
|
+
};
|
|
7582
|
+
const isNorthern = latitudeN >= 0;
|
|
7583
|
+
return computeSeasonalBlend(dayOfYear(date), isNorthern, daysInYear(date.getFullYear()));
|
|
7584
|
+
}
|
|
7585
|
+
/**
|
|
7586
|
+
* Hook — returns the current SeasonalBlend, re-evaluated once per hour.
|
|
7587
|
+
*
|
|
7588
|
+
* @param latitudeN Decimal degrees, positive = north.
|
|
7589
|
+
* Pass null while coordinates are still loading.
|
|
7590
|
+
* @param override Force a specific season (for dev previews / user settings).
|
|
7591
|
+
* @param simulatedDate Use a specific date instead of now (for SolarDevTools).
|
|
7592
|
+
*/
|
|
7593
|
+
function useSeason(latitudeN, override, simulatedDate) {
|
|
7594
|
+
const [blend, setBlend] = useState(() => getSeasonalBlend(simulatedDate ?? /* @__PURE__ */ new Date(), latitudeN ?? 0, override));
|
|
7595
|
+
useEffect(() => {
|
|
7596
|
+
const recompute = () => {
|
|
7597
|
+
setBlend(getSeasonalBlend(simulatedDate ?? /* @__PURE__ */ new Date(), latitudeN ?? 0, override));
|
|
7598
|
+
};
|
|
7599
|
+
recompute();
|
|
7600
|
+
const id$2 = setInterval(recompute, 3600 * 1e3);
|
|
7601
|
+
return () => clearInterval(id$2);
|
|
7602
|
+
}, [
|
|
7603
|
+
latitudeN,
|
|
7604
|
+
override,
|
|
7605
|
+
simulatedDate
|
|
7606
|
+
]);
|
|
7607
|
+
return blend;
|
|
7608
|
+
}
|
|
7609
|
+
|
|
7319
7610
|
//#endregion
|
|
7320
7611
|
//#region node_modules/motion/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs
|
|
7321
7612
|
const LayoutGroupContext = createContext({});
|
|
@@ -54528,7 +54819,7 @@ function getAccentFg(accent) {
|
|
|
54528
54819
|
* - scopeId = undefined → writes to :root (global / singleton mode)
|
|
54529
54820
|
* - scopeId = "sol-scope-3" → writes to #sol-scope-3 (isolated mode)
|
|
54530
54821
|
* The scoped vars override :root vars for all descendants of that wrapper div. */
|
|
54531
|
-
function writeCssVars(skin, phase, t = 0, nextPhase, scopeId) {
|
|
54822
|
+
function writeCssVars(skin, phase, t = 0, nextPhase, scopeId, seasonal) {
|
|
54532
54823
|
if (typeof document === "undefined") return;
|
|
54533
54824
|
const from = skin.phaseVars[phase];
|
|
54534
54825
|
const to = skin.phaseVars[nextPhase ?? phase];
|
|
@@ -54541,9 +54832,22 @@ function writeCssVars(skin, phase, t = 0, nextPhase, scopeId) {
|
|
|
54541
54832
|
const surface = lerp(from.surface, to.surface);
|
|
54542
54833
|
const shaderPalFrom = skin.shaderPalettes[phase];
|
|
54543
54834
|
const shaderPalTo = skin.shaderPalettes[nextPhase ?? phase];
|
|
54544
|
-
|
|
54545
|
-
|
|
54835
|
+
let shaderVignette = t > 0 ? lerpHex(shaderPalFrom.vignette, shaderPalTo.vignette, t) : shaderPalFrom.vignette;
|
|
54836
|
+
let shaderColorBack = t > 0 ? lerpHex(shaderPalFrom.colorBack, shaderPalTo.colorBack, t) : shaderPalFrom.colorBack;
|
|
54546
54837
|
const shaderFallback = shaderPalFrom.cssFallback;
|
|
54838
|
+
if (seasonal && !seasonal.disabled) {
|
|
54839
|
+
const mod = resolveSeasonalModifier(seasonal.blend, {
|
|
54840
|
+
...UNIVERSAL_SEASON_MODIFIERS,
|
|
54841
|
+
...skin.seasonalModifiers
|
|
54842
|
+
});
|
|
54843
|
+
const tempPalette = applySeasonalModifier({
|
|
54844
|
+
...shaderPalFrom,
|
|
54845
|
+
vignette: shaderVignette,
|
|
54846
|
+
colorBack: shaderColorBack
|
|
54847
|
+
}, mod);
|
|
54848
|
+
shaderVignette = tempPalette.vignette;
|
|
54849
|
+
shaderColorBack = tempPalette.colorBack;
|
|
54850
|
+
}
|
|
54547
54851
|
if (!scopeId) {
|
|
54548
54852
|
const root = document.documentElement;
|
|
54549
54853
|
if (root.getAttribute("data-solar-skin") !== skin.id) root.setAttribute("data-solar-skin", skin.id);
|
|
@@ -54573,6 +54877,7 @@ const SolarThemeCtx = createContext({
|
|
|
54573
54877
|
latitude: null,
|
|
54574
54878
|
longitude: null,
|
|
54575
54879
|
coordsReady: false,
|
|
54880
|
+
city: null,
|
|
54576
54881
|
setOverridePhase: noop,
|
|
54577
54882
|
blend: {
|
|
54578
54883
|
phase: SSR_PHASE,
|
|
@@ -54585,12 +54890,19 @@ const SolarThemeCtx = createContext({
|
|
|
54585
54890
|
simulatedDate: void 0,
|
|
54586
54891
|
setSimulatedDate: noop,
|
|
54587
54892
|
customPalettes: void 0,
|
|
54588
|
-
setCustomPalettes: noop
|
|
54893
|
+
setCustomPalettes: noop,
|
|
54894
|
+
season: "spring",
|
|
54895
|
+
seasonalBlend: {
|
|
54896
|
+
season: "spring",
|
|
54897
|
+
nextSeason: "spring",
|
|
54898
|
+
t: 0
|
|
54899
|
+
},
|
|
54900
|
+
setSeasonOverride: noop
|
|
54589
54901
|
});
|
|
54590
54902
|
function useSolarTheme() {
|
|
54591
54903
|
return useContext(SolarThemeCtx);
|
|
54592
54904
|
}
|
|
54593
|
-
function SolarThemeProvider({ children, initialDesign = "foundry", isolated = false }) {
|
|
54905
|
+
function SolarThemeProvider({ children, initialDesign = "foundry", isolated = false, seasonOverride: seasonOverrideProp, disableSeasonalBlend = false }) {
|
|
54594
54906
|
const geo = useCountryCodeFromGeolocation({ immediate: true });
|
|
54595
54907
|
const scopeId = useRef(isolated ? nextScopeId() : void 0).current;
|
|
54596
54908
|
const wrapperRef = useRef(null);
|
|
@@ -54598,6 +54910,7 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54598
54910
|
const [longitude, setLongitude] = useState(null);
|
|
54599
54911
|
const [timezone, setTimezone] = useState(null);
|
|
54600
54912
|
const [coordsReady, setCoordsReady] = useState(false);
|
|
54913
|
+
const [city, setCity] = useState(null);
|
|
54601
54914
|
const [simulatedDate, setSimulatedDate] = useState(void 0);
|
|
54602
54915
|
const [customPalettes, setCustomPalettes] = useState(void 0);
|
|
54603
54916
|
const [design, setDesignState] = useState(initialDesign);
|
|
@@ -54619,6 +54932,7 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54619
54932
|
useLayoutEffect(() => {
|
|
54620
54933
|
const browserTZ = getBrowserTimezone();
|
|
54621
54934
|
setTimezone(browserTZ);
|
|
54935
|
+
setCity(cityFromTimezone(browserTZ));
|
|
54622
54936
|
const coords = fallbackCoordsFromTZ(browserTZ);
|
|
54623
54937
|
if (coords) {
|
|
54624
54938
|
setLatitude(coords[0]);
|
|
@@ -54639,19 +54953,29 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54639
54953
|
}
|
|
54640
54954
|
}, [isolated]);
|
|
54641
54955
|
const activeSkin = SKINS[design];
|
|
54956
|
+
const [seasonOverrideState, setSeasonOverrideState] = useState(seasonOverrideProp);
|
|
54957
|
+
const seasonalBlend = useSeason(latitude, seasonOverrideProp ?? seasonOverrideState, simulatedDate);
|
|
54958
|
+
const setSeasonOverride = useCallback((s) => setSeasonOverrideState(s ?? void 0), []);
|
|
54642
54959
|
const setOverridePhase = useCallback((phase) => {
|
|
54643
54960
|
setOverridePhaseState(phase);
|
|
54644
54961
|
if (!isolated) setSessionPhaseOverride(phase);
|
|
54645
54962
|
}, [isolated]);
|
|
54646
54963
|
useEffect(() => {
|
|
54647
|
-
if (geo.position?.coords)
|
|
54648
|
-
|
|
54649
|
-
|
|
54650
|
-
|
|
54651
|
-
|
|
54652
|
-
|
|
54653
|
-
|
|
54654
|
-
|
|
54964
|
+
if (!geo.position?.coords) return;
|
|
54965
|
+
const { latitude: lat, longitude: lon } = geo.position.coords;
|
|
54966
|
+
setLatitude(lat);
|
|
54967
|
+
setLongitude(lon);
|
|
54968
|
+
setCoordsReady(true);
|
|
54969
|
+
const tz = coordsToTimezone(lat, lon);
|
|
54970
|
+
if (tz) {
|
|
54971
|
+
setTimezone(tz);
|
|
54972
|
+
setCity(cityFromTimezone(tz));
|
|
54973
|
+
}
|
|
54974
|
+
const controller = new AbortController();
|
|
54975
|
+
fetchReverseGeocode(lat, lon, controller.signal).then((name) => {
|
|
54976
|
+
if (name) setCity(name);
|
|
54977
|
+
});
|
|
54978
|
+
return () => controller.abort();
|
|
54655
54979
|
}, [geo.position]);
|
|
54656
54980
|
useEffect(() => {
|
|
54657
54981
|
if (coordsReady) return;
|
|
@@ -54690,7 +55014,10 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54690
55014
|
isolated
|
|
54691
55015
|
]);
|
|
54692
55016
|
useLayoutEffect(() => {
|
|
54693
|
-
writeCssVars(activeSkin, activeBlend.phase, activeBlend.t, activeBlend.nextPhase, scopeId
|
|
55017
|
+
writeCssVars(activeSkin, activeBlend.phase, activeBlend.t, activeBlend.nextPhase, scopeId, {
|
|
55018
|
+
blend: seasonalBlend,
|
|
55019
|
+
disabled: disableSeasonalBlend
|
|
55020
|
+
});
|
|
54694
55021
|
if (!isolated && !document.documentElement.hasAttribute("data-solar-ready")) requestAnimationFrame(() => {
|
|
54695
55022
|
document.documentElement.setAttribute("data-solar-ready", "");
|
|
54696
55023
|
});
|
|
@@ -54698,7 +55025,9 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54698
55025
|
activeSkin,
|
|
54699
55026
|
activeBlend,
|
|
54700
55027
|
scopeId,
|
|
54701
|
-
isolated
|
|
55028
|
+
isolated,
|
|
55029
|
+
seasonalBlend,
|
|
55030
|
+
disableSeasonalBlend
|
|
54702
55031
|
]);
|
|
54703
55032
|
useEffect(() => {
|
|
54704
55033
|
if (!scopeId) return;
|
|
@@ -54719,6 +55048,7 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54719
55048
|
latitude,
|
|
54720
55049
|
longitude,
|
|
54721
55050
|
coordsReady,
|
|
55051
|
+
city,
|
|
54722
55052
|
setOverridePhase,
|
|
54723
55053
|
blend: activeBlend,
|
|
54724
55054
|
design,
|
|
@@ -54727,7 +55057,10 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54727
55057
|
simulatedDate,
|
|
54728
55058
|
setSimulatedDate,
|
|
54729
55059
|
customPalettes,
|
|
54730
|
-
setCustomPalettes
|
|
55060
|
+
setCustomPalettes,
|
|
55061
|
+
season: seasonalBlend.season,
|
|
55062
|
+
seasonalBlend,
|
|
55063
|
+
setSeasonOverride
|
|
54731
55064
|
};
|
|
54732
55065
|
if (isolated) return /* @__PURE__ */ jsx(SolarThemeCtx.Provider, {
|
|
54733
55066
|
value: theme,
|
|
@@ -54747,5 +55080,5 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
|
|
|
54747
55080
|
}
|
|
54748
55081
|
|
|
54749
55082
|
//#endregion
|
|
54750
|
-
export {
|
|
54751
|
-
//# sourceMappingURL=solar-theme-provider-
|
|
55083
|
+
export { resolveSeasonalModifier as _, useSeason as a, getSessionTimeMinutes as c, lerpColor as d, lerpHex as f, lerpModifier as g, applySeasonalModifier as h, getSeasonalBlend as i, setSessionLive as l, UNIVERSAL_SEASON_MODIFIERS as m, useSolarTheme as n, clearSessionTimeMinutes as o, IDENTITY_MODIFIER as p, SKINS as r, getSessionIsLive as s, SolarThemeProvider as t, setSessionTimeMinutes as u };
|
|
55084
|
+
//# sourceMappingURL=solar-theme-provider-cxO4tmFT.js.map
|