@nous-research/ui 0.13.1 → 0.14.0
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 +4 -1
- 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/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/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 +43 -25
- 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
package/README.md
CHANGED
|
@@ -53,9 +53,12 @@ pnpm dev # next dev on http://localhost:3000 → redirects to /ds
|
|
|
53
53
|
|
|
54
54
|
```
|
|
55
55
|
pnpm build # tsc → dist/ + copies css / fonts / assets
|
|
56
|
-
pnpm release # runs scripts/release.sh (must be on main, clean tree)
|
|
57
56
|
```
|
|
58
57
|
|
|
58
|
+
releases are published automatically when PRs merge to `main`. the github
|
|
59
|
+
workflow bumps the package version from the merged PR labels (`major`, `minor`,
|
|
60
|
+
or `patch`), pushes the tag, and publishes to npm via trusted publishing.
|
|
61
|
+
|
|
59
62
|
the published tarball only ships `dist/` and `README.md` (see `files` in
|
|
60
63
|
`package.json`). `.d.ts.map` + inline sources are emitted so consumers can
|
|
61
64
|
"go to definition" straight into the TypeScript source.
|
|
Binary file
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface StaticImageData {
|
|
2
|
+
src: string
|
|
3
|
+
height: number
|
|
4
|
+
width: number
|
|
5
|
+
blurDataURL?: string
|
|
6
|
+
blurWidth?: number
|
|
7
|
+
blurHeight?: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '*.jpg' {
|
|
11
|
+
const content: StaticImageData
|
|
12
|
+
export default content
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module '*.jpeg' {
|
|
16
|
+
const content: StaticImageData
|
|
17
|
+
export default content
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '*.png' {
|
|
21
|
+
const content: StaticImageData
|
|
22
|
+
export default content
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module '*.svg' {
|
|
26
|
+
const content: StaticImageData
|
|
27
|
+
export default content
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module '*.gif' {
|
|
31
|
+
const content: StaticImageData
|
|
32
|
+
export default content
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '*.webp' {
|
|
36
|
+
const content: StaticImageData
|
|
37
|
+
export default content
|
|
38
|
+
}
|
package/dist/fonts.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export declare const FONT_MONO = "--font-mono";
|
|
|
4
4
|
export declare const FONT_RULES_COMPRESSED = "--font-rules-compressed";
|
|
5
5
|
export declare const FONT_RULES_EXPANDED = "--font-rules-expanded";
|
|
6
6
|
export declare const FONT_MONDWEST = "--font-mondwest";
|
|
7
|
-
//# sourceMappingURL=fonts.d.ts.map
|
package/dist/fonts.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const FONT_MONDWEST = '--font-mondwest';
|
|
7
|
-
//# sourceMappingURL=fonts.js.map
|
|
1
|
+
export const FONT_SANS = "--font-sans";
|
|
2
|
+
export const FONT_MONO = "--font-mono";
|
|
3
|
+
export const FONT_RULES_COMPRESSED = "--font-rules-compressed";
|
|
4
|
+
export const FONT_RULES_EXPANDED = "--font-rules-expanded";
|
|
5
|
+
export const FONT_MONDWEST = "--font-mondwest";
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import { useFrame, useThree } from
|
|
3
|
-
import { useRef } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFrame, useThree } from "@react-three/fiber";
|
|
3
|
+
import { useRef } from "react";
|
|
4
4
|
export function useCappedFrame(cb, max) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const last = useRef(performance.now());
|
|
6
|
+
const { size } = useThree();
|
|
7
|
+
const interval = 1e3 / (max ?? (size.width < 1024 ? 60 : 120));
|
|
8
|
+
useFrame((st, delta) => {
|
|
9
|
+
if (performance.now() - last.current > interval) {
|
|
10
|
+
last.current = performance.now();
|
|
11
|
+
cb(st, delta);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
14
|
}
|
|
15
|
-
//# sourceMappingURL=use-capped-frame.js.map
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import { useEffect } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
3
|
export function useCssVarDims(name, ref) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!ref.current) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const update = (width2, height2) => {
|
|
9
|
+
document.documentElement.style.setProperty(
|
|
10
|
+
`--${name}-width`,
|
|
11
|
+
`${width2}px`
|
|
12
|
+
);
|
|
13
|
+
document.documentElement.style.setProperty(
|
|
14
|
+
`--${name}-height`,
|
|
15
|
+
`${height2}px`
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
const { height, width } = ref.current.getBoundingClientRect();
|
|
19
|
+
update(width, height);
|
|
20
|
+
const ro = new ResizeObserver((entries) => {
|
|
21
|
+
for (const entry of entries) {
|
|
22
|
+
update(entry.contentRect.width, entry.contentRect.height);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
ro.observe(ref.current);
|
|
26
|
+
return () => ro.disconnect();
|
|
27
|
+
}, [name, ref]);
|
|
22
28
|
}
|
|
23
|
-
//# sourceMappingURL=use-css-var-dims.js.map
|
|
@@ -1,122 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
import { useStore } from
|
|
3
|
-
import { atom } from
|
|
4
|
-
/**
|
|
5
|
-
* Tiers:
|
|
6
|
-
* 0 — no WebGL / software renderer / prefers-reduced-motion / WebGL ctx creation failed
|
|
7
|
-
* 1 — low-end GPU (integrated, mobile, or failed perf benchmark)
|
|
8
|
-
* 2 — capable GPU (discrete / high-end integrated)
|
|
9
|
-
*
|
|
10
|
-
* Detection runs **synchronously** the first time this module is evaluated
|
|
11
|
-
* on the client (see the IIFE at the bottom of the file). That means any
|
|
12
|
-
* consumer reading `$gpuTier` during its first render already sees the
|
|
13
|
-
* post-detection value, so WebGL components can avoid trying to create a
|
|
14
|
-
* `THREE.WebGLRenderer` on hardware where context creation will fail.
|
|
15
|
-
*
|
|
16
|
-
* The previous version ran the probe inside `nanostores`'s `onMount`
|
|
17
|
-
* lifecycle, which fires from a microtask after the first listener
|
|
18
|
-
* subscribes — i.e. after the first React commit. By that point overlay
|
|
19
|
-
* components had already executed `new THREE.WebGLRenderer(...)` against
|
|
20
|
-
* the optimistic default, logged `Error creating WebGL context`, and only
|
|
21
|
-
* unmounted on a follow-up render. Eager module-load detection closes that
|
|
22
|
-
* race.
|
|
23
|
-
*/
|
|
1
|
+
"use client";
|
|
2
|
+
import { useStore } from "@nanostores/react";
|
|
3
|
+
import { atom } from "nanostores";
|
|
24
4
|
export const $gpuTier = atom(2);
|
|
25
5
|
const SOFTWARE_PATTERNS = /swiftshader|llvmpipe|softpipe|software|microsoft basic/i;
|
|
26
6
|
const LOW_END_PATTERNS = /intel.*hd|intel.*uhd|intel.*iris|mali|adreno\s?[1-5]|powervr|apple gpu/i;
|
|
27
7
|
let detected = false;
|
|
28
8
|
function detectGpuTier() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
gl.getExtension('WEBGL_lose_context')?.loseContext();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
$gpuTier.set(2);
|
|
69
|
-
runBenchmark(gl)
|
|
70
|
-
.then(fps => $gpuTier.set(fps < 30 ? 1 : 2))
|
|
71
|
-
.catch(() => $gpuTier.set(1))
|
|
72
|
-
.finally(() => gl?.getExtension('WEBGL_lose_context')?.loseContext());
|
|
9
|
+
if (detected || typeof window === "undefined") {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
detected = true;
|
|
13
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
14
|
+
$gpuTier.set(0);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let gl = null;
|
|
18
|
+
try {
|
|
19
|
+
const canvas = document.createElement("canvas");
|
|
20
|
+
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
21
|
+
} catch {
|
|
22
|
+
$gpuTier.set(0);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!gl) {
|
|
26
|
+
$gpuTier.set(0);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const ext = gl.getExtension("WEBGL_debug_renderer_info");
|
|
30
|
+
const renderer = String(
|
|
31
|
+
ext ? gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER)
|
|
32
|
+
);
|
|
33
|
+
if (SOFTWARE_PATTERNS.test(renderer)) {
|
|
34
|
+
$gpuTier.set(0);
|
|
35
|
+
gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (LOW_END_PATTERNS.test(renderer)) {
|
|
39
|
+
$gpuTier.set(1);
|
|
40
|
+
gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
$gpuTier.set(2);
|
|
44
|
+
runBenchmark(gl).then((fps) => $gpuTier.set(fps < 30 ? 1 : 2)).catch(() => $gpuTier.set(1)).finally(() => gl?.getExtension("WEBGL_lose_context")?.loseContext());
|
|
73
45
|
}
|
|
74
|
-
if (typeof window !==
|
|
75
|
-
|
|
46
|
+
if (typeof window !== "undefined") {
|
|
47
|
+
detectGpuTier();
|
|
76
48
|
}
|
|
77
49
|
function runBenchmark(gl) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
50
|
+
return new Promise((resolve) => {
|
|
51
|
+
const vs = gl.createShader(gl.VERTEX_SHADER);
|
|
52
|
+
const fs = gl.createShader(gl.FRAGMENT_SHADER);
|
|
53
|
+
gl.shaderSource(
|
|
54
|
+
vs,
|
|
55
|
+
"attribute vec2 a;void main(){gl_Position=vec4(a,0,1);}"
|
|
56
|
+
);
|
|
57
|
+
gl.shaderSource(
|
|
58
|
+
fs,
|
|
59
|
+
"precision highp float;uniform float t;void main(){float v=0.;for(int i=0;i<64;i++)v+=sin(float(i)*t*.01);gl_FragColor=vec4(v*.001);}"
|
|
60
|
+
);
|
|
61
|
+
gl.compileShader(vs);
|
|
62
|
+
gl.compileShader(fs);
|
|
63
|
+
const prog = gl.createProgram();
|
|
64
|
+
gl.attachShader(prog, vs);
|
|
65
|
+
gl.attachShader(prog, fs);
|
|
66
|
+
gl.linkProgram(prog);
|
|
67
|
+
gl.useProgram(prog);
|
|
68
|
+
const buf = gl.createBuffer();
|
|
69
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
|
70
|
+
gl.bufferData(
|
|
71
|
+
gl.ARRAY_BUFFER,
|
|
72
|
+
new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
|
|
73
|
+
gl.STATIC_DRAW
|
|
74
|
+
);
|
|
75
|
+
const a = gl.getAttribLocation(prog, "a");
|
|
76
|
+
gl.enableVertexAttribArray(a);
|
|
77
|
+
gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
|
|
78
|
+
const uT = gl.getUniformLocation(prog, "t");
|
|
79
|
+
let frames = 0;
|
|
80
|
+
const start = performance.now();
|
|
81
|
+
const tick = () => {
|
|
82
|
+
gl.uniform1f(uT, frames);
|
|
83
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
84
|
+
gl.finish();
|
|
85
|
+
frames++;
|
|
86
|
+
if (performance.now() - start < 200) {
|
|
116
87
|
requestAnimationFrame(tick);
|
|
117
|
-
|
|
88
|
+
} else {
|
|
89
|
+
const elapsed = performance.now() - start;
|
|
90
|
+
gl.deleteProgram(prog);
|
|
91
|
+
gl.deleteShader(vs);
|
|
92
|
+
gl.deleteShader(fs);
|
|
93
|
+
gl.deleteBuffer(buf);
|
|
94
|
+
resolve(frames / elapsed * 1e3);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
requestAnimationFrame(tick);
|
|
98
|
+
});
|
|
118
99
|
}
|
|
119
100
|
export function useGpuTier() {
|
|
120
|
-
|
|
101
|
+
return useStore($gpuTier);
|
|
121
102
|
}
|
|
122
|
-
//# sourceMappingURL=use-gpu-tier.js.map
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
export function runRenderLoop({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
io.observe(el);
|
|
27
|
-
document.addEventListener('visibilitychange', onVisibility);
|
|
28
|
-
const tick = () => {
|
|
29
|
-
if (!running)
|
|
30
|
-
return;
|
|
31
|
-
if (!visible || !inView) {
|
|
32
|
-
// Don't reschedule — we'll be re-kicked by visibilitychange or IO.
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const now = performance.now();
|
|
36
|
-
const delta = (now - last) / 1000;
|
|
37
|
-
last = now;
|
|
38
|
-
onFrame(delta);
|
|
1
|
+
"use client";
|
|
2
|
+
export function runRenderLoop({
|
|
3
|
+
el,
|
|
4
|
+
minIntervalMs = 0,
|
|
5
|
+
onFrame
|
|
6
|
+
}) {
|
|
7
|
+
let running = true;
|
|
8
|
+
let visible = !document.hidden;
|
|
9
|
+
let inView = true;
|
|
10
|
+
let last = performance.now();
|
|
11
|
+
let raf = 0;
|
|
12
|
+
let timer;
|
|
13
|
+
const onVisibility = () => {
|
|
14
|
+
visible = !document.hidden;
|
|
15
|
+
if (visible) {
|
|
16
|
+
last = performance.now();
|
|
17
|
+
schedule();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const io = new IntersectionObserver(
|
|
21
|
+
(entries) => {
|
|
22
|
+
const wasInView = inView;
|
|
23
|
+
inView = entries.some((e) => e.isIntersecting);
|
|
24
|
+
if (!wasInView && inView) {
|
|
25
|
+
last = performance.now();
|
|
39
26
|
schedule();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{ threshold: 0 }
|
|
30
|
+
);
|
|
31
|
+
io.observe(el);
|
|
32
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
33
|
+
const tick = () => {
|
|
34
|
+
if (!running) return;
|
|
35
|
+
if (!visible || !inView) {
|
|
36
|
+
return;
|
|
50
37
|
}
|
|
38
|
+
const now = performance.now();
|
|
39
|
+
const delta = (now - last) / 1e3;
|
|
40
|
+
last = now;
|
|
41
|
+
onFrame(delta);
|
|
51
42
|
schedule();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
};
|
|
44
|
+
function schedule() {
|
|
45
|
+
if (!running || !visible || !inView) return;
|
|
46
|
+
if (minIntervalMs > 0) {
|
|
47
|
+
timer = setTimeout(tick, minIntervalMs);
|
|
48
|
+
} else {
|
|
49
|
+
raf = requestAnimationFrame(tick);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
schedule();
|
|
53
|
+
return () => {
|
|
54
|
+
running = false;
|
|
55
|
+
io.disconnect();
|
|
56
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
57
|
+
cancelAnimationFrame(raf);
|
|
58
|
+
if (timer !== void 0) {
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
61
62
|
}
|
|
62
|
-
//# sourceMappingURL=use-render-loop.js.map
|