@nous-research/ui 0.13.2 → 0.14.1
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 +16 -0
- package/dist/assets/filler-bg0.webp +0 -0
- package/dist/assets.d.ts +38 -0
- package/dist/fonts.d.ts +0 -1
- package/dist/fonts.js +5 -7
- package/dist/hooks/use-capped-frame.d.ts +0 -1
- package/dist/hooks/use-capped-frame.js +12 -13
- package/dist/hooks/use-css-var-dims.d.ts +0 -1
- package/dist/hooks/use-css-var-dims.js +26 -21
- package/dist/hooks/use-gpu-tier.d.ts +0 -1
- package/dist/hooks/use-gpu-tier.js +90 -110
- package/dist/hooks/use-render-loop.d.ts +0 -1
- package/dist/hooks/use-render-loop.js +58 -58
- package/dist/hooks/use-smooth-controls.d.ts +0 -1
- package/dist/hooks/use-smooth-controls.js +204 -206
- package/dist/index.d.ts +0 -1
- package/dist/index.js +84 -58
- package/dist/ui/basic-page.d.ts +1 -2
- package/dist/ui/basic-page.js +15 -7
- package/dist/ui/build.css +1 -0
- package/dist/ui/components/animated-count.d.ts +1 -2
- package/dist/ui/components/animated-count.js +109 -85
- package/dist/ui/components/ascii.d.ts +2 -3
- package/dist/ui/components/ascii.js +75 -59
- package/dist/ui/components/badge.d.ts +1 -2
- package/dist/ui/components/badge.js +35 -18
- package/dist/ui/components/badges/nous-girl.d.ts +1 -2
- package/dist/ui/components/badges/nous-girl.js +80 -3
- package/dist/ui/components/blend-mode.d.ts +1 -2
- package/dist/ui/components/blend-mode.js +55 -63
- package/dist/ui/components/blink.d.ts +1 -2
- package/dist/ui/components/blink.js +15 -6
- package/dist/ui/components/button.d.ts +2 -3
- package/dist/ui/components/button.js +139 -90
- package/dist/ui/components/command-block.d.ts +2 -3
- package/dist/ui/components/command-block.js +52 -24
- package/dist/ui/components/cursor.d.ts +1 -2
- package/dist/ui/components/cursor.js +93 -54
- package/dist/ui/components/dropdown-menu.d.ts +1 -2
- package/dist/ui/components/dropdown-menu.js +99 -51
- package/dist/ui/components/fit-text/index.d.ts +0 -1
- package/dist/ui/components/fit-text/index.js +21 -13
- package/dist/ui/components/graphs/bar-chart.d.ts +1 -2
- package/dist/ui/components/graphs/bar-chart.js +116 -63
- package/dist/ui/components/graphs/index.d.ts +0 -1
- package/dist/ui/components/graphs/index.js +3 -4
- package/dist/ui/components/graphs/line-chart.d.ts +1 -2
- package/dist/ui/components/graphs/line-chart.js +159 -102
- package/dist/ui/components/graphs/utils.d.ts +2 -3
- package/dist/ui/components/graphs/utils.js +147 -114
- package/dist/ui/components/grid/index.d.ts +0 -1
- package/dist/ui/components/grid/index.js +12 -9
- package/dist/ui/components/hover-bg.d.ts +0 -1
- package/dist/ui/components/hover-bg.js +11 -6
- package/dist/ui/components/icons/arrow.d.ts +1 -2
- package/dist/ui/components/icons/arrow.js +42 -5
- package/dist/ui/components/icons/chevron.d.ts +1 -2
- package/dist/ui/components/icons/chevron.js +49 -5
- package/dist/ui/components/icons/discord.d.ts +1 -2
- package/dist/ui/components/icons/discord.js +12 -4
- package/dist/ui/components/icons/eye.d.ts +1 -2
- package/dist/ui/components/icons/eye.js +5 -3
- package/dist/ui/components/icons/gear.d.ts +1 -2
- package/dist/ui/components/icons/gear.js +28 -14
- package/dist/ui/components/icons/github.d.ts +1 -2
- package/dist/ui/components/icons/github.js +12 -4
- package/dist/ui/components/icons/hamburger.d.ts +1 -2
- package/dist/ui/components/icons/hamburger.js +54 -5
- package/dist/ui/components/icons/heart.d.ts +1 -2
- package/dist/ui/components/icons/heart.js +8 -3
- package/dist/ui/components/icons/index.d.ts +0 -1
- package/dist/ui/components/icons/index.js +11 -12
- package/dist/ui/components/icons/link.d.ts +1 -2
- package/dist/ui/components/icons/link.js +10 -3
- package/dist/ui/components/icons/minus.d.ts +1 -2
- package/dist/ui/components/icons/minus.js +10 -3
- package/dist/ui/components/icons/search.d.ts +1 -2
- package/dist/ui/components/icons/search.js +30 -3
- package/dist/ui/components/image-distortion.d.ts +1 -2
- package/dist/ui/components/image-distortion.js +300 -265
- package/dist/ui/components/leva-client.d.ts +1 -2
- package/dist/ui/components/leva-client.js +9 -10
- package/dist/ui/components/list-item.d.ts +0 -1
- package/dist/ui/components/list-item.js +26 -10
- package/dist/ui/components/modal/index.d.ts +1 -2
- package/dist/ui/components/modal/index.js +33 -14
- package/dist/ui/components/overlays/blend-modes.d.ts +0 -1
- package/dist/ui/components/overlays/blend-modes.js +11 -12
- package/dist/ui/components/overlays/glitch.d.ts +1 -2
- package/dist/ui/components/overlays/glitch.js +115 -110
- package/dist/ui/components/overlays/greys.d.ts +1 -2
- package/dist/ui/components/overlays/greys.js +200 -179
- package/dist/ui/components/overlays/index.d.ts +1 -2
- package/dist/ui/components/overlays/index.js +31 -17
- package/dist/ui/components/overlays/lens-layers.d.ts +1 -2
- package/dist/ui/components/overlays/lens-layers.js +89 -65
- package/dist/ui/components/overlays/lens.d.ts +0 -1
- package/dist/ui/components/overlays/lens.js +46 -52
- package/dist/ui/components/overlays/noise.d.ts +1 -2
- package/dist/ui/components/overlays/noise.js +112 -113
- package/dist/ui/components/overlays/vignette.d.ts +1 -2
- package/dist/ui/components/overlays/vignette.js +44 -38
- package/dist/ui/components/poster.d.ts +1 -2
- package/dist/ui/components/poster.js +240 -87
- package/dist/ui/components/progress.d.ts +1 -2
- package/dist/ui/components/progress.js +52 -12
- package/dist/ui/components/scene-canvas.d.ts +1 -2
- package/dist/ui/components/scene-canvas.js +169 -119
- package/dist/ui/components/scramble.d.ts +1 -2
- package/dist/ui/components/scramble.js +60 -59
- package/dist/ui/components/segmented.d.ts +2 -3
- package/dist/ui/components/segmented.js +47 -12
- package/dist/ui/components/select.d.ts +1 -2
- package/dist/ui/components/select.js +207 -120
- package/dist/ui/components/selection-switcher.d.ts +0 -1
- package/dist/ui/components/selection-switcher.js +29 -25
- package/dist/ui/components/shader.d.ts +1 -2
- package/dist/ui/components/shader.js +56 -38
- package/dist/ui/components/socials.d.ts +1 -2
- package/dist/ui/components/socials.js +18 -7
- package/dist/ui/components/spinner.d.ts +1 -2
- package/dist/ui/components/spinner.js +36 -25
- package/dist/ui/components/stats.d.ts +1 -2
- package/dist/ui/components/stats.js +33 -9
- package/dist/ui/components/switch.d.ts +0 -1
- package/dist/ui/components/switch.js +35 -11
- package/dist/ui/components/tabs.d.ts +3 -4
- package/dist/ui/components/tabs.js +38 -12
- package/dist/ui/components/terminal-demo.d.ts +1 -2
- package/dist/ui/components/terminal-demo.js +119 -74
- package/dist/ui/components/theme-toggle.d.ts +1 -2
- package/dist/ui/components/theme-toggle.js +63 -8
- package/dist/ui/components/tier-card.d.ts +1 -2
- package/dist/ui/components/tier-card.js +144 -24
- package/dist/ui/components/tv.d.ts +1 -2
- package/dist/ui/components/tv.js +138 -90
- package/dist/ui/components/typography/h1.d.ts +0 -1
- package/dist/ui/components/typography/h1.js +17 -8
- package/dist/ui/components/typography/h2.d.ts +0 -1
- package/dist/ui/components/typography/h2.js +17 -8
- package/dist/ui/components/typography/index.d.ts +0 -1
- package/dist/ui/components/typography/index.js +35 -24
- package/dist/ui/components/typography/legend.d.ts +1 -2
- package/dist/ui/components/typography/legend.js +18 -6
- package/dist/ui/components/typography/small.d.ts +0 -1
- package/dist/ui/components/typography/small.js +8 -7
- package/dist/ui/components/watchlist.d.ts +1 -2
- package/dist/ui/components/watchlist.js +77 -25
- package/dist/ui/fonts.css +7 -7
- package/dist/ui/footer.d.ts +1 -2
- package/dist/ui/footer.js +61 -25
- package/dist/ui/globals.css +5 -1
- package/dist/ui/header.d.ts +1 -2
- package/dist/ui/header.js +255 -60
- package/dist/ui/layout-wrapper.d.ts +1 -2
- package/dist/ui/layout-wrapper.js +5 -4
- package/dist/utils/color.d.ts +0 -1
- package/dist/utils/color.js +8 -9
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +37 -38
- package/dist/utils/poly.d.ts +0 -1
- package/dist/utils/poly.js +1 -2
- package/package.json +42 -24
- package/dist/assets/filler-bg0.jpg +0 -0
- package/dist/fonts.d.ts.map +0 -1
- package/dist/fonts.js.map +0 -1
- package/dist/hooks/use-capped-frame.d.ts.map +0 -1
- package/dist/hooks/use-capped-frame.js.map +0 -1
- package/dist/hooks/use-css-var-dims.d.ts.map +0 -1
- package/dist/hooks/use-css-var-dims.js.map +0 -1
- package/dist/hooks/use-gpu-tier.d.ts.map +0 -1
- package/dist/hooks/use-gpu-tier.js.map +0 -1
- package/dist/hooks/use-render-loop.d.ts.map +0 -1
- package/dist/hooks/use-render-loop.js.map +0 -1
- package/dist/hooks/use-smooth-controls.d.ts.map +0 -1
- package/dist/hooks/use-smooth-controls.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ui/basic-page.d.ts.map +0 -1
- package/dist/ui/basic-page.js.map +0 -1
- package/dist/ui/components/animated-count.d.ts.map +0 -1
- package/dist/ui/components/animated-count.js.map +0 -1
- package/dist/ui/components/ascii.d.ts.map +0 -1
- package/dist/ui/components/ascii.js.map +0 -1
- package/dist/ui/components/badge.d.ts.map +0 -1
- package/dist/ui/components/badge.js.map +0 -1
- package/dist/ui/components/badges/nous-girl.d.ts.map +0 -1
- package/dist/ui/components/badges/nous-girl.js.map +0 -1
- package/dist/ui/components/blend-mode.d.ts.map +0 -1
- package/dist/ui/components/blend-mode.js.map +0 -1
- package/dist/ui/components/blink.d.ts.map +0 -1
- package/dist/ui/components/blink.js.map +0 -1
- package/dist/ui/components/button.d.ts.map +0 -1
- package/dist/ui/components/button.js.map +0 -1
- package/dist/ui/components/command-block.d.ts.map +0 -1
- package/dist/ui/components/command-block.js.map +0 -1
- package/dist/ui/components/cursor.d.ts.map +0 -1
- package/dist/ui/components/cursor.js.map +0 -1
- package/dist/ui/components/dropdown-menu.d.ts.map +0 -1
- package/dist/ui/components/dropdown-menu.js.map +0 -1
- package/dist/ui/components/fit-text/index.d.ts.map +0 -1
- package/dist/ui/components/fit-text/index.js.map +0 -1
- package/dist/ui/components/graphs/bar-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/bar-chart.js.map +0 -1
- package/dist/ui/components/graphs/index.d.ts.map +0 -1
- package/dist/ui/components/graphs/index.js.map +0 -1
- package/dist/ui/components/graphs/line-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/line-chart.js.map +0 -1
- package/dist/ui/components/graphs/utils.d.ts.map +0 -1
- package/dist/ui/components/graphs/utils.js.map +0 -1
- package/dist/ui/components/grid/index.d.ts.map +0 -1
- package/dist/ui/components/grid/index.js.map +0 -1
- package/dist/ui/components/hover-bg.d.ts.map +0 -1
- package/dist/ui/components/hover-bg.js.map +0 -1
- package/dist/ui/components/icons/arrow.d.ts.map +0 -1
- package/dist/ui/components/icons/arrow.js.map +0 -1
- package/dist/ui/components/icons/chevron.d.ts.map +0 -1
- package/dist/ui/components/icons/chevron.js.map +0 -1
- package/dist/ui/components/icons/discord.d.ts.map +0 -1
- package/dist/ui/components/icons/discord.js.map +0 -1
- package/dist/ui/components/icons/eye.d.ts.map +0 -1
- package/dist/ui/components/icons/eye.js.map +0 -1
- package/dist/ui/components/icons/gear.d.ts.map +0 -1
- package/dist/ui/components/icons/gear.js.map +0 -1
- package/dist/ui/components/icons/github.d.ts.map +0 -1
- package/dist/ui/components/icons/github.js.map +0 -1
- package/dist/ui/components/icons/hamburger.d.ts.map +0 -1
- package/dist/ui/components/icons/hamburger.js.map +0 -1
- package/dist/ui/components/icons/heart.d.ts.map +0 -1
- package/dist/ui/components/icons/heart.js.map +0 -1
- package/dist/ui/components/icons/index.d.ts.map +0 -1
- package/dist/ui/components/icons/index.js.map +0 -1
- package/dist/ui/components/icons/link.d.ts.map +0 -1
- package/dist/ui/components/icons/link.js.map +0 -1
- package/dist/ui/components/icons/minus.d.ts.map +0 -1
- package/dist/ui/components/icons/minus.js.map +0 -1
- package/dist/ui/components/icons/search.d.ts.map +0 -1
- package/dist/ui/components/icons/search.js.map +0 -1
- package/dist/ui/components/image-distortion.d.ts.map +0 -1
- package/dist/ui/components/image-distortion.js.map +0 -1
- package/dist/ui/components/leva-client.d.ts.map +0 -1
- package/dist/ui/components/leva-client.js.map +0 -1
- package/dist/ui/components/list-item.d.ts.map +0 -1
- package/dist/ui/components/list-item.js.map +0 -1
- package/dist/ui/components/modal/index.d.ts.map +0 -1
- package/dist/ui/components/modal/index.js.map +0 -1
- package/dist/ui/components/overlays/blend-modes.d.ts.map +0 -1
- package/dist/ui/components/overlays/blend-modes.js.map +0 -1
- package/dist/ui/components/overlays/glitch.d.ts.map +0 -1
- package/dist/ui/components/overlays/glitch.js.map +0 -1
- package/dist/ui/components/overlays/greys.d.ts.map +0 -1
- package/dist/ui/components/overlays/greys.js.map +0 -1
- package/dist/ui/components/overlays/index.d.ts.map +0 -1
- package/dist/ui/components/overlays/index.js.map +0 -1
- package/dist/ui/components/overlays/lens-layers.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens-layers.js.map +0 -1
- package/dist/ui/components/overlays/lens.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens.js.map +0 -1
- package/dist/ui/components/overlays/noise.d.ts.map +0 -1
- package/dist/ui/components/overlays/noise.js.map +0 -1
- package/dist/ui/components/overlays/vignette.d.ts.map +0 -1
- package/dist/ui/components/overlays/vignette.js.map +0 -1
- package/dist/ui/components/poster.d.ts.map +0 -1
- package/dist/ui/components/poster.js.map +0 -1
- package/dist/ui/components/progress.d.ts.map +0 -1
- package/dist/ui/components/progress.js.map +0 -1
- package/dist/ui/components/scene-canvas.d.ts.map +0 -1
- package/dist/ui/components/scene-canvas.js.map +0 -1
- package/dist/ui/components/scramble.d.ts.map +0 -1
- package/dist/ui/components/scramble.js.map +0 -1
- package/dist/ui/components/segmented.d.ts.map +0 -1
- package/dist/ui/components/segmented.js.map +0 -1
- package/dist/ui/components/select.d.ts.map +0 -1
- package/dist/ui/components/select.js.map +0 -1
- package/dist/ui/components/selection-switcher.d.ts.map +0 -1
- package/dist/ui/components/selection-switcher.js.map +0 -1
- package/dist/ui/components/shader.d.ts.map +0 -1
- package/dist/ui/components/shader.js.map +0 -1
- package/dist/ui/components/socials.d.ts.map +0 -1
- package/dist/ui/components/socials.js.map +0 -1
- package/dist/ui/components/spinner.d.ts.map +0 -1
- package/dist/ui/components/spinner.js.map +0 -1
- package/dist/ui/components/stats.d.ts.map +0 -1
- package/dist/ui/components/stats.js.map +0 -1
- package/dist/ui/components/switch.d.ts.map +0 -1
- package/dist/ui/components/switch.js.map +0 -1
- package/dist/ui/components/tabs.d.ts.map +0 -1
- package/dist/ui/components/tabs.js.map +0 -1
- package/dist/ui/components/terminal-demo.d.ts.map +0 -1
- package/dist/ui/components/terminal-demo.js.map +0 -1
- package/dist/ui/components/theme-toggle.d.ts.map +0 -1
- package/dist/ui/components/theme-toggle.js.map +0 -1
- package/dist/ui/components/tier-card.d.ts.map +0 -1
- package/dist/ui/components/tier-card.js.map +0 -1
- package/dist/ui/components/tv.d.ts.map +0 -1
- package/dist/ui/components/tv.js.map +0 -1
- package/dist/ui/components/typography/h1.d.ts.map +0 -1
- package/dist/ui/components/typography/h1.js.map +0 -1
- package/dist/ui/components/typography/h2.d.ts.map +0 -1
- package/dist/ui/components/typography/h2.js.map +0 -1
- package/dist/ui/components/typography/index.d.ts.map +0 -1
- package/dist/ui/components/typography/index.js.map +0 -1
- package/dist/ui/components/typography/legend.d.ts.map +0 -1
- package/dist/ui/components/typography/legend.js.map +0 -1
- package/dist/ui/components/typography/small.d.ts.map +0 -1
- package/dist/ui/components/typography/small.js.map +0 -1
- package/dist/ui/components/watchlist.d.ts.map +0 -1
- package/dist/ui/components/watchlist.js.map +0 -1
- package/dist/ui/footer.d.ts.map +0 -1
- package/dist/ui/footer.js.map +0 -1
- package/dist/ui/header.d.ts.map +0 -1
- package/dist/ui/header.js.map +0 -1
- package/dist/ui/layout-wrapper.d.ts.map +0 -1
- package/dist/ui/layout-wrapper.js.map +0 -1
- package/dist/utils/color.d.ts.map +0 -1
- package/dist/utils/color.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/poly.d.ts.map +0 -1
- package/dist/utils/poly.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function Modal({ children, className, id, trigger, ...props }: ModalProps): import("react
|
|
1
|
+
export declare function Modal({ children, className, id, trigger, ...props }: ModalProps): import("react").JSX.Element;
|
|
2
2
|
interface ModalProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
|
|
3
3
|
trigger: (controls: {
|
|
4
4
|
close: () => void;
|
|
@@ -6,4 +6,3 @@ interface ModalProps extends Omit<React.ComponentProps<'dialog'>, 'open'> {
|
|
|
6
6
|
}) => React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
export {};
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,15 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from
|
|
4
|
-
import { createPortal } from
|
|
5
|
-
import { cn } from
|
|
6
|
-
export function Modal({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../../../utils/index.js";
|
|
6
|
+
export function Modal({
|
|
7
|
+
children,
|
|
8
|
+
className,
|
|
9
|
+
id,
|
|
10
|
+
trigger,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const ref = useRef(null);
|
|
14
|
+
const [mounted, setMounted] = useState(false);
|
|
15
|
+
useEffect(() => setMounted(true), []);
|
|
16
|
+
const open = useCallback(() => ref.current?.showModal(), []);
|
|
17
|
+
const close = useCallback(() => ref.current?.close(), []);
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
trigger({ close, open }),
|
|
20
|
+
mounted && createPortal(
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
"dialog",
|
|
23
|
+
{
|
|
24
|
+
className: cn("modal", className),
|
|
25
|
+
onClick: (e) => e.target === e.currentTarget && close(),
|
|
26
|
+
...{ id, ref },
|
|
27
|
+
...props,
|
|
28
|
+
children: /* @__PURE__ */ jsx("div", { className: "modal-body post", children })
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
document.body
|
|
32
|
+
)
|
|
33
|
+
] });
|
|
14
34
|
}
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export const BLEND_MODES = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"overlay",
|
|
3
|
+
"multiply",
|
|
4
|
+
"screen",
|
|
5
|
+
"difference",
|
|
6
|
+
"exclusion",
|
|
7
|
+
"color-dodge",
|
|
8
|
+
"color-burn",
|
|
9
|
+
"hard-light",
|
|
10
|
+
"soft-light",
|
|
11
|
+
"darken",
|
|
12
|
+
"lighten"
|
|
13
13
|
];
|
|
14
|
-
//# sourceMappingURL=blend-modes.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export declare function Glitch({ className, style }: GlitchProps): import("react
|
|
1
|
+
export declare function Glitch({ className, style }: GlitchProps): import("react").JSX.Element | null;
|
|
2
2
|
interface GlitchProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: React.CSSProperties;
|
|
5
5
|
}
|
|
6
6
|
export {};
|
|
7
|
-
//# sourceMappingURL=glitch.d.ts.map
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import { useEffect, useRef } from
|
|
4
|
-
import * as THREE from
|
|
5
|
-
import { $gpuTier, useGpuTier } from
|
|
6
|
-
import { runRenderLoop } from
|
|
7
|
-
import { useSmoothControls } from
|
|
8
|
-
import { cn } from
|
|
9
|
-
import { BLEND_MODES } from
|
|
10
|
-
const vert =
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { $gpuTier, useGpuTier } from "../../../hooks/use-gpu-tier.js";
|
|
6
|
+
import { runRenderLoop } from "../../../hooks/use-render-loop.js";
|
|
7
|
+
import { useSmoothControls } from "../../../hooks/use-smooth-controls.js";
|
|
8
|
+
import { cn } from "../../../utils/index.js";
|
|
9
|
+
import { BLEND_MODES } from "./blend-modes.js";
|
|
10
|
+
const vert = (
|
|
11
|
+
/*glsl*/
|
|
12
|
+
`
|
|
11
13
|
varying vec2 vUv;
|
|
12
14
|
void main() {
|
|
13
15
|
vUv = uv;
|
|
14
16
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
`
|
|
19
|
+
);
|
|
20
|
+
const frag = (
|
|
21
|
+
/*glsl*/
|
|
22
|
+
`
|
|
18
23
|
uniform float uTime, uAlpha, uIntensity, uChroma, uSpeed, uSparsity;
|
|
19
24
|
uniform vec3 uColor;
|
|
20
25
|
varying vec2 vUv;
|
|
@@ -100,104 +105,104 @@ const frag = /*glsl*/ `
|
|
|
100
105
|
|
|
101
106
|
gl_FragColor = vec4(col * uAlpha, max(col.r, max(col.g, col.b)) * uAlpha);
|
|
102
107
|
}
|
|
103
|
-
|
|
108
|
+
`
|
|
109
|
+
);
|
|
104
110
|
export function Glitch({ className, style }) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
alpha: true,
|
|
128
|
-
canvas: ref.current
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
// See note in noise.tsx — eager gpu-tier detection should keep us
|
|
133
|
-
// out of here, but if the driver fails the renderer constructor
|
|
134
|
-
// anyway, downgrade so other overlays stop trying too.
|
|
135
|
-
$gpuTier.set(0);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
139
|
-
const geo = new THREE.PlaneGeometry(2, 2);
|
|
140
|
-
const scene = new THREE.Scene();
|
|
141
|
-
const mat = new THREE.ShaderMaterial({
|
|
142
|
-
fragmentShader: frag,
|
|
143
|
-
transparent: true,
|
|
144
|
-
uniforms: {
|
|
145
|
-
uAlpha: { value: c.alpha },
|
|
146
|
-
uChroma: { value: c.chroma },
|
|
147
|
-
uColor: { value: new THREE.Color(c.color) },
|
|
148
|
-
uIntensity: { value: c.intensity },
|
|
149
|
-
uSparsity: { value: c.sparsity },
|
|
150
|
-
uSpeed: { value: c.speed },
|
|
151
|
-
uTime: { value: 0 }
|
|
152
|
-
},
|
|
153
|
-
vertexShader: vert
|
|
154
|
-
});
|
|
155
|
-
scene.add(new THREE.Mesh(geo, mat));
|
|
156
|
-
const resize = () => {
|
|
157
|
-
renderer.setSize(innerWidth, innerHeight);
|
|
158
|
-
// Cap DPR at 1.5 — at full retina (2x) the glitch shader is one
|
|
159
|
-
// of the heaviest fillrate consumers in the app, and the visual
|
|
160
|
-
// difference is tiny because it's a chromatic-noise effect.
|
|
161
|
-
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5));
|
|
162
|
-
};
|
|
163
|
-
resize();
|
|
164
|
-
window.addEventListener('resize', resize);
|
|
165
|
-
let time = 0;
|
|
166
|
-
// gpu-tier 1 → ~10fps (legacy), gpu-tier 2 → ~30fps (was 60fps).
|
|
167
|
-
// Glitch is a background ambient effect; users won't notice 30 vs
|
|
168
|
-
// 60 but the GPU absolutely will.
|
|
169
|
-
const minIntervalMs = gpuTier === 1 ? 100 : 33;
|
|
170
|
-
const dispose = runRenderLoop({
|
|
171
|
-
el: ref.current,
|
|
172
|
-
minIntervalMs,
|
|
173
|
-
onFrame: deltaSeconds => {
|
|
174
|
-
time += deltaSeconds;
|
|
175
|
-
const v = cRef.current;
|
|
176
|
-
mat.uniforms.uTime.value = time;
|
|
177
|
-
mat.uniforms.uAlpha.value = v.alpha;
|
|
178
|
-
mat.uniforms.uChroma.value = v.chroma;
|
|
179
|
-
mat.uniforms.uIntensity.value = v.intensity;
|
|
180
|
-
mat.uniforms.uSparsity.value = v.sparsity;
|
|
181
|
-
mat.uniforms.uSpeed.value = v.speed;
|
|
182
|
-
mat.uniforms.uColor.value.set(v.color);
|
|
183
|
-
renderer.render(scene, camera);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return () => {
|
|
187
|
-
window.removeEventListener('resize', resize);
|
|
188
|
-
dispose();
|
|
189
|
-
mat.dispose();
|
|
190
|
-
geo.dispose();
|
|
191
|
-
renderer.dispose();
|
|
192
|
-
};
|
|
193
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
194
|
-
}, [enabled, gpuTier]);
|
|
195
|
-
if (!enabled) {
|
|
196
|
-
return null;
|
|
111
|
+
const gpuTier = useGpuTier();
|
|
112
|
+
const c = useSmoothControls(
|
|
113
|
+
"Effects/Glitch",
|
|
114
|
+
{
|
|
115
|
+
alpha: { max: 2, min: 0, step: 0.01, value: 0.25 },
|
|
116
|
+
blend: { options: BLEND_MODES, value: "difference" },
|
|
117
|
+
chroma: { max: 3, min: 0, step: 0.01, value: 1.17 },
|
|
118
|
+
color: { value: "#ffe6cb" },
|
|
119
|
+
enabled: { value: true },
|
|
120
|
+
intensity: { max: 1, min: 0, step: 0.01, value: 0.59 },
|
|
121
|
+
sparsity: { max: 1, min: 0, step: 0.01, value: 0.21 },
|
|
122
|
+
speed: { max: 10, min: 0.1, step: 0.1, value: 1 }
|
|
123
|
+
},
|
|
124
|
+
{ collapsed: true }
|
|
125
|
+
);
|
|
126
|
+
const ref = useRef(null);
|
|
127
|
+
const cRef = useRef(c);
|
|
128
|
+
cRef.current = c;
|
|
129
|
+
const enabled = c.enabled && gpuTier > 0;
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!ref.current || !enabled) {
|
|
132
|
+
return;
|
|
197
133
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
134
|
+
let renderer;
|
|
135
|
+
try {
|
|
136
|
+
renderer = new THREE.WebGLRenderer({
|
|
137
|
+
alpha: true,
|
|
138
|
+
canvas: ref.current
|
|
139
|
+
});
|
|
140
|
+
} catch {
|
|
141
|
+
$gpuTier.set(0);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
145
|
+
const geo = new THREE.PlaneGeometry(2, 2);
|
|
146
|
+
const scene = new THREE.Scene();
|
|
147
|
+
const mat = new THREE.ShaderMaterial({
|
|
148
|
+
fragmentShader: frag,
|
|
149
|
+
transparent: true,
|
|
150
|
+
uniforms: {
|
|
151
|
+
uAlpha: { value: c.alpha },
|
|
152
|
+
uChroma: { value: c.chroma },
|
|
153
|
+
uColor: { value: new THREE.Color(c.color) },
|
|
154
|
+
uIntensity: { value: c.intensity },
|
|
155
|
+
uSparsity: { value: c.sparsity },
|
|
156
|
+
uSpeed: { value: c.speed },
|
|
157
|
+
uTime: { value: 0 }
|
|
158
|
+
},
|
|
159
|
+
vertexShader: vert
|
|
160
|
+
});
|
|
161
|
+
scene.add(new THREE.Mesh(geo, mat));
|
|
162
|
+
const resize = () => {
|
|
163
|
+
renderer.setSize(innerWidth, innerHeight);
|
|
164
|
+
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5));
|
|
165
|
+
};
|
|
166
|
+
resize();
|
|
167
|
+
window.addEventListener("resize", resize);
|
|
168
|
+
let time = 0;
|
|
169
|
+
const minIntervalMs = gpuTier === 1 ? 100 : 33;
|
|
170
|
+
const dispose = runRenderLoop({
|
|
171
|
+
el: ref.current,
|
|
172
|
+
minIntervalMs,
|
|
173
|
+
onFrame: (deltaSeconds) => {
|
|
174
|
+
time += deltaSeconds;
|
|
175
|
+
const v = cRef.current;
|
|
176
|
+
mat.uniforms.uTime.value = time;
|
|
177
|
+
mat.uniforms.uAlpha.value = v.alpha;
|
|
178
|
+
mat.uniforms.uChroma.value = v.chroma;
|
|
179
|
+
mat.uniforms.uIntensity.value = v.intensity;
|
|
180
|
+
mat.uniforms.uSparsity.value = v.sparsity;
|
|
181
|
+
mat.uniforms.uSpeed.value = v.speed;
|
|
182
|
+
mat.uniforms.uColor.value.set(v.color);
|
|
183
|
+
renderer.render(scene, camera);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return () => {
|
|
187
|
+
window.removeEventListener("resize", resize);
|
|
188
|
+
dispose();
|
|
189
|
+
mat.dispose();
|
|
190
|
+
geo.dispose();
|
|
191
|
+
renderer.dispose();
|
|
192
|
+
};
|
|
193
|
+
}, [enabled, gpuTier]);
|
|
194
|
+
if (!enabled) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return /* @__PURE__ */ jsx(
|
|
198
|
+
"canvas",
|
|
199
|
+
{
|
|
200
|
+
className: cn("h-full w-full", className),
|
|
201
|
+
ref,
|
|
202
|
+
style: {
|
|
203
|
+
mixBlendMode: c.blend,
|
|
204
|
+
...style
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
);
|
|
202
208
|
}
|
|
203
|
-
//# sourceMappingURL=glitch.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export declare function Greys({ className, style }: GreysProps): import("react
|
|
1
|
+
export declare function Greys({ className, style }: GreysProps): import("react").JSX.Element | null;
|
|
2
2
|
interface GreysProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: React.CSSProperties;
|
|
5
5
|
}
|
|
6
6
|
export {};
|
|
7
|
-
//# sourceMappingURL=greys.d.ts.map
|