rockin 0.0.37 → 0.0.39

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/dist/provider.js CHANGED
@@ -1,13 +1,124 @@
1
1
  "use client";
2
2
  import {
3
- Provider,
4
- browserThemeColors
5
- } from "./chunk-54ZJAEO5.js";
6
- import "./chunk-GBVAFFZR.js";
7
- import "./chunk-3ZGQJTWY.js";
8
- import "./chunk-RT2YVQ2Y.js";
9
- import "./chunk-ATPUW3SQ.js";
3
+ TooltipProvider
4
+ } from "./chunk-GBVAFFZR.js";
5
+ import {
6
+ useFullscreen,
7
+ useNative
8
+ } from "./chunk-WR27Y55B.js";
9
+ import "./chunk-2LD63YUK.js";
10
+ import {
11
+ PreferencesProvider,
12
+ usePreferences,
13
+ useTheme
14
+ } from "./chunk-G3RYS466.js";
15
+ import {
16
+ TopLoader
17
+ } from "./chunk-3ZGQJTWY.js";
18
+ import "./chunk-X56ZEDOW.js";
19
+
20
+ // src/provider.tsx
21
+ import * as React from "react";
22
+ import { usePreference } from "@ui-sdk/react/preferences";
23
+ import { useShortcut } from "@ui-sdk/react/shortcuts";
24
+ import { GooeyToaster } from "goey-toast";
25
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
26
+ var browserThemeColors = {
27
+ light: "#ffffff",
28
+ dark: "#000000"
29
+ };
30
+ function BrowserChrome({ light, dark }) {
31
+ const { colorScheme } = usePreferences();
32
+ const { value, resolved } = usePreference(colorScheme);
33
+ React.useEffect(() => {
34
+ if (resolved === "unknown") return;
35
+ const style = resolved === "dark" ? "black-translucent" : "default";
36
+ for (const meta of document.head.querySelectorAll(
37
+ 'meta[name="apple-mobile-web-app-status-bar-style"]'
38
+ ))
39
+ meta.content = style;
40
+ window.dispatchEvent(
41
+ new CustomEvent("kdpower:theme-change", { detail: { theme: resolved } })
42
+ );
43
+ }, [resolved]);
44
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
45
+ value === "system" ? /* @__PURE__ */ jsxs(Fragment, { children: [
46
+ /* @__PURE__ */ jsx(
47
+ "meta",
48
+ {
49
+ name: "theme-color",
50
+ media: "(prefers-color-scheme: light)",
51
+ content: light
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ "meta",
56
+ {
57
+ name: "theme-color",
58
+ media: "(prefers-color-scheme: dark)",
59
+ content: dark
60
+ }
61
+ )
62
+ ] }) : /* @__PURE__ */ jsx("meta", { name: "theme-color", content: value === "dark" ? dark : light }),
63
+ /* @__PURE__ */ jsx("style", { href: `rockin-chrome-${light}-${dark}`, precedence: "default", children: `:root{background-color:light-dark(${light},${dark})}` })
64
+ ] });
65
+ }
66
+ function ClientProvider({
67
+ children,
68
+ light = browserThemeColors.light,
69
+ dark = browserThemeColors.dark,
70
+ fullscreen = true,
71
+ cookie
72
+ }) {
73
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(PreferencesProvider, { cookie, children: /* @__PURE__ */ jsxs(TopLoader, { children: [
74
+ /* @__PURE__ */ jsx(AppToaster, {}),
75
+ /* @__PURE__ */ jsx(AppStatusBarBackground, {}),
76
+ /* @__PURE__ */ jsx(BrowserChrome, { light, dark }),
77
+ /* @__PURE__ */ jsx(ThemeHotkey, {}),
78
+ fullscreen ? /* @__PURE__ */ jsx(FullscreenHotkey, {}) : null,
79
+ children
80
+ ] }) }) });
81
+ }
82
+ function AppToaster() {
83
+ const { resolvedTheme } = useTheme();
84
+ const toasterTheme = resolvedTheme === "dark" ? "dark" : "light";
85
+ return /* @__PURE__ */ jsx(
86
+ GooeyToaster,
87
+ {
88
+ theme: toasterTheme,
89
+ position: "bottom-right",
90
+ closeButton: "top-left"
91
+ },
92
+ toasterTheme
93
+ );
94
+ }
95
+ function AppStatusBarBackground() {
96
+ return /* @__PURE__ */ jsx(
97
+ "div",
98
+ {
99
+ "aria-hidden": true,
100
+ className: "fixed inset-x-0 top-0 z-50 hidden h-(--app-safe-top) bg-background/80 backdrop-blur-xl standalone:block native:block"
101
+ }
102
+ );
103
+ }
104
+ function ThemeHotkey() {
105
+ const { resolvedTheme, setTheme } = useTheme();
106
+ useShortcut(
107
+ "d",
108
+ () => setTheme(resolvedTheme === "dark" ? "light" : "dark"),
109
+ { description: "Toggle dark mode" }
110
+ );
111
+ return null;
112
+ }
113
+ function FullscreenHotkey() {
114
+ const isNative = useNative();
115
+ const { toggleFullscreen } = useFullscreen();
116
+ useShortcut(isNative ? null : "f", () => void toggleFullscreen(), {
117
+ description: "Toggle full screen"
118
+ });
119
+ return null;
120
+ }
10
121
  export {
11
- Provider,
122
+ ClientProvider,
12
123
  browserThemeColors
13
124
  };