@qodin-co/sol 0.1.4 → 0.1.6

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.
@@ -1,4 +1,4 @@
1
- import { a as getSessionIsLive, c as setSessionTimeMinutes, i as clearSessionTimeMinutes, n as useSolarTheme, o as getSessionTimeMinutes, s as setSessionLive } from "../solar-theme-provider-DSYQUslj.js";
1
+ import { a as getSessionIsLive, c as setSessionTimeMinutes, i as clearSessionTimeMinutes, n as useSolarTheme, o as getSessionTimeMinutes, s as setSessionLive } from "../solar-theme-provider-Dyalcxas.js";
2
2
  import { useCallback, useEffect, useMemo, useState } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { createPortal } from "react-dom";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from "react";
2
- import * as react_jsx_runtime1 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/hooks/useSolarPosition.d.ts
5
5
 
@@ -108,7 +108,7 @@ declare function CompactWidget({
108
108
  timezone,
109
109
  simulatedDate: simulatedDateProp,
110
110
  className
111
- }: CompactWidgetProps): react_jsx_runtime1.JSX.Element;
111
+ }: CompactWidgetProps): react_jsx_runtime0.JSX.Element;
112
112
  //#endregion
113
113
  //#region src/widgets/solar-widget.shell.d.ts
114
114
  type ExpandDirection = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
@@ -144,7 +144,7 @@ declare function SolarWidget({
144
144
  weatherCategoryOverride,
145
145
  simulatedDate: simulatedDateProp,
146
146
  forceExpanded
147
- }: SolarWidgetProps): react_jsx_runtime1.JSX.Element;
147
+ }: SolarWidgetProps): react_jsx_runtime0.JSX.Element;
148
148
  //#endregion
149
149
  //#region src/skins/types/widget-skin.types.d.ts
150
150
  interface ShaderImage {
@@ -356,7 +356,7 @@ declare function SolarThemeProvider({
356
356
  children,
357
357
  initialDesign,
358
358
  isolated
359
- }: Props): react_jsx_runtime1.JSX.Element;
359
+ }: Props): react_jsx_runtime0.JSX.Element;
360
360
  //#endregion
361
361
  export { type CompactSize, CompactWidget, type DesignMode, type ExpandDirection, type SkinDefinition, type SolarBlend, type SolarPhase, type SolarTheme, SolarThemeProvider, SolarWidget, type WeatherCategory, type WidgetPalette, type WidgetSize, useSolarTheme };
362
362
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { l as lerpHex, n as useSolarTheme, r as SKINS, t as SolarThemeProvider } from "./solar-theme-provider-DSYQUslj.js";
1
+ import { l as lerpHex, n as useSolarTheme, r as SKINS, t as SolarThemeProvider } from "./solar-theme-provider-Dyalcxas.js";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -700,44 +700,23 @@ function useSolarPosition(options = {}) {
700
700
  const lon = longitude ?? DEFAULT_LON;
701
701
  const tz = timezone ?? DEFAULT_TZ;
702
702
  simulatedDate?.getTime();
703
- const [position, setPosition] = useState(() => {
704
- if (typeof window !== "undefined" && typeof document !== "undefined") try {
705
- const date = simulatedDate ?? /* @__PURE__ */ new Date();
706
- return computeSolarPosition(date, lat, lon, utcOffsetFromTimezone(tz, date));
707
- } catch {}
708
- return {
709
- altitude: 45,
710
- azimuth: 180,
711
- dayProgress: .5,
712
- nightProgress: .5,
713
- isDaytime: true,
714
- phase: "morning",
715
- times: {
716
- sunrise: 360,
717
- solarNoon: 720,
718
- sunset: 1080,
719
- dawnCivil: 330,
720
- duskCivil: 1110
721
- },
722
- localMinutes: 720
723
- };
703
+ const [position, setPosition] = useState({
704
+ altitude: 45,
705
+ azimuth: 180,
706
+ dayProgress: .5,
707
+ nightProgress: .5,
708
+ isDaytime: true,
709
+ phase: "morning",
710
+ times: {
711
+ sunrise: 360,
712
+ solarNoon: 720,
713
+ sunset: 1080,
714
+ dawnCivil: 330,
715
+ duskCivil: 1110
716
+ },
717
+ localMinutes: 720
724
718
  });
725
- const [isReady, setIsReady] = useState(() => typeof window !== "undefined");
726
- const prevCoordsRef = useRef(null);
727
- if (typeof window !== "undefined" && typeof document !== "undefined") {
728
- const prev = prevCoordsRef.current;
729
- if (prev === null || prev.lat !== lat || prev.lon !== lon || prev.tz !== tz) {
730
- prevCoordsRef.current = {
731
- lat,
732
- lon,
733
- tz
734
- };
735
- if (prev !== null) {
736
- const date = simulatedDate ?? /* @__PURE__ */ new Date();
737
- setPosition(computeSolarPosition(date, lat, lon, utcOffsetFromTimezone(tz, date)));
738
- }
739
- }
740
- }
719
+ const [isReady, setIsReady] = useState(false);
741
720
  useEffect(() => {
742
721
  const update = (d) => {
743
722
  setPosition(computeSolarPosition(d, lat, lon, utcOffsetFromTimezone(tz, d)));
@@ -53464,9 +53443,6 @@ let _scopeCounter = 0;
53464
53443
  function nextScopeId() {
53465
53444
  return `sol-scope-${++_scopeCounter}`;
53466
53445
  }
53467
- function isValidSkin(value) {
53468
- return typeof value === "string" && value in SKINS;
53469
- }
53470
53446
  function htmlClassFromMode(mode) {
53471
53447
  return mode === "light" ? "light" : "dark";
53472
53448
  }
@@ -53596,11 +53572,9 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
53596
53572
  const [design, setDesignState] = useState(initialDesign);
53597
53573
  useEffect(() => {
53598
53574
  if (isolated) return;
53599
- const domSkin = document.documentElement.getAttribute("data-solar-skin");
53600
- if (isValidSkin(domSkin) && domSkin !== design) setDesignState(domSkin);
53601
- else try {
53602
- const stored = localStorage.getItem(DESIGN_STORAGE_KEY);
53603
- if (isValidSkin(stored) && stored !== design) setDesignState(stored);
53575
+ try {
53576
+ document.documentElement.setAttribute("data-solar-skin", design);
53577
+ localStorage.setItem(DESIGN_STORAGE_KEY, design);
53604
53578
  } catch {}
53605
53579
  }, []);
53606
53580
  const [overridePhase, setOverridePhaseState] = useState(() => {
@@ -53698,12 +53672,14 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
53698
53672
  document.getElementById(`solar-runtime-theme-${scopeId}`)?.remove();
53699
53673
  };
53700
53674
  }, [scopeId]);
53675
+ const palette = activeSkin.widgetPalettes[activePhase] ?? activeSkin.widgetPalettes.morning;
53676
+ const phaseVars = activeSkin.phaseVars[activePhase] ?? activeSkin.phaseVars.morning;
53701
53677
  const theme = {
53702
53678
  phase: activePhase,
53703
53679
  isDaytime: PHASE_IS_DAYTIME[activePhase],
53704
53680
  brightness: BRIGHTNESS[activePhase],
53705
- mode: activeSkin.widgetPalettes[activePhase].mode,
53706
- accentColor: activeSkin.phaseVars[activePhase].accent,
53681
+ mode: palette.mode,
53682
+ accentColor: phaseVars.accent,
53707
53683
  solarPosition: solar,
53708
53684
  timezone,
53709
53685
  latitude,
@@ -53736,4 +53712,4 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
53736
53712
 
53737
53713
  //#endregion
53738
53714
  export { getSessionIsLive as a, setSessionTimeMinutes as c, clearSessionTimeMinutes as i, lerpHex as l, useSolarTheme as n, getSessionTimeMinutes as o, SKINS as r, setSessionLive as s, SolarThemeProvider as t };
53739
- //# sourceMappingURL=solar-theme-provider-DSYQUslj.js.map
53715
+ //# sourceMappingURL=solar-theme-provider-Dyalcxas.js.map