@qodin-co/sol 0.1.6 → 0.1.7

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-Dyalcxas.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-B3Pya6MA.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_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime1 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_runtime0.JSX.Element;
111
+ }: CompactWidgetProps): react_jsx_runtime1.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_runtime0.JSX.Element;
147
+ }: SolarWidgetProps): react_jsx_runtime1.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_runtime0.JSX.Element;
359
+ }: Props): react_jsx_runtime1.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-Dyalcxas.js";
1
+ import { l as lerpHex, n as useSolarTheme, r as SKINS, t as SolarThemeProvider } from "./solar-theme-provider-B3Pya6MA.js";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -700,23 +700,29 @@ 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
- 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
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
+ };
718
724
  });
719
- const [isReady, setIsReady] = useState(false);
725
+ const [isReady, setIsReady] = useState(() => typeof window !== "undefined" && typeof document !== "undefined");
720
726
  useEffect(() => {
721
727
  const update = (d) => {
722
728
  setPosition(computeSolarPosition(d, lat, lon, utcOffsetFromTimezone(tz, d)));
@@ -53712,4 +53718,4 @@ function SolarThemeProvider({ children, initialDesign = "foundry", isolated = fa
53712
53718
 
53713
53719
  //#endregion
53714
53720
  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 };
53715
- //# sourceMappingURL=solar-theme-provider-Dyalcxas.js.map
53721
+ //# sourceMappingURL=solar-theme-provider-B3Pya6MA.js.map