@orangecheck/design 0.26.0 → 0.27.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/dist/chrome.js.map +1 -1
- package/dist/chrome.mjs.map +1 -1
- package/dist/components.js.map +1 -1
- package/dist/components.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +457 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +456 -6
- package/dist/index.mjs.map +1 -1
- package/dist/primitives.d.mts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/styles/aurora.css +29 -0
- package/dist/tokens.d.mts +19 -2
- package/dist/tokens.d.ts +19 -2
- package/dist/tokens.js +457 -4
- package/dist/tokens.js.map +1 -1
- package/dist/tokens.mjs +456 -6
- package/dist/tokens.mjs.map +1 -1
- package/package.json +1 -1
package/dist/primitives.d.mts
CHANGED
|
@@ -17,7 +17,7 @@ import { ToasterProps } from 'sonner';
|
|
|
17
17
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
18
18
|
|
|
19
19
|
declare const buttonVariants: (props?: ({
|
|
20
|
-
variant?: "
|
|
20
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | "onBrand" | "onBrandOutline" | null | undefined;
|
|
21
21
|
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
22
22
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
23
23
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
package/dist/primitives.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { ToasterProps } from 'sonner';
|
|
|
17
17
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
18
18
|
|
|
19
19
|
declare const buttonVariants: (props?: ({
|
|
20
|
-
variant?: "
|
|
20
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | "onBrand" | "onBrandOutline" | null | undefined;
|
|
21
21
|
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
22
22
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
23
23
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
package/dist/styles/aurora.css
CHANGED
|
@@ -258,3 +258,32 @@
|
|
|
258
258
|
:root[data-oc-motion='off'] .oc-ambient {
|
|
259
259
|
animation-play-state: paused !important;
|
|
260
260
|
}
|
|
261
|
+
|
|
262
|
+
/* ── OcAuroraGL (aurora depth R2) ─────────────────────────────────────
|
|
263
|
+
The lazy WebGL2 silk field renders inside the same container, so the radial
|
|
264
|
+
mask, the mode-op × intensity opacity, and ember's --au-* re-hue all govern
|
|
265
|
+
it for free. Once the first GL frame lands (`--gl-live`), the CSS blobs
|
|
266
|
+
pause AND hide — dimming alone does not stop blur rasterization; the page
|
|
267
|
+
pays for exactly one aurora at any moment. Any demotion removes the class
|
|
268
|
+
and the blobs resume, invisibly. */
|
|
269
|
+
.oc-aurora__gl {
|
|
270
|
+
position: absolute;
|
|
271
|
+
inset: 0;
|
|
272
|
+
width: 100%;
|
|
273
|
+
height: 100%;
|
|
274
|
+
opacity: 0;
|
|
275
|
+
transition: opacity 0.5s ease;
|
|
276
|
+
}
|
|
277
|
+
.oc-aurora--gl-live .oc-aurora__gl {
|
|
278
|
+
opacity: 1;
|
|
279
|
+
}
|
|
280
|
+
.oc-aurora--gl-live .oc-aurora__blob {
|
|
281
|
+
visibility: hidden;
|
|
282
|
+
animation-play-state: paused;
|
|
283
|
+
}
|
|
284
|
+
/* Canvas raster is NOT stripped by forced colors the way gradients are. */
|
|
285
|
+
@media (forced-colors: active) {
|
|
286
|
+
.oc-aurora__gl {
|
|
287
|
+
display: none;
|
|
288
|
+
}
|
|
289
|
+
}
|
package/dist/tokens.d.mts
CHANGED
|
@@ -38,6 +38,7 @@ interface OcThemeProviderProps {
|
|
|
38
38
|
defaultSkin?: string;
|
|
39
39
|
aurora?: boolean | {
|
|
40
40
|
intensity?: number;
|
|
41
|
+
gl?: boolean;
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
declare function OcThemeProvider({ children, defaultSkin, aurora, }: OcThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
@@ -69,8 +70,24 @@ declare function OcAppearanceMenu({ className, triggerClassName, popoverClassNam
|
|
|
69
70
|
|
|
70
71
|
interface OcAuroraProps {
|
|
71
72
|
intensity?: number;
|
|
73
|
+
gl?: boolean;
|
|
72
74
|
className?: string;
|
|
73
75
|
}
|
|
74
|
-
declare function OcAurora({ intensity, className }: OcAuroraProps): react_jsx_runtime.JSX.Element;
|
|
76
|
+
declare function OcAurora({ intensity, gl, className }: OcAuroraProps): react_jsx_runtime.JSX.Element;
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
interface OcSceneRGB {
|
|
79
|
+
r: number;
|
|
80
|
+
g: number;
|
|
81
|
+
b: number;
|
|
82
|
+
}
|
|
83
|
+
interface OcSceneTokens {
|
|
84
|
+
palette: [OcSceneRGB, OcSceneRGB, OcSceneRGB, OcSceneRGB];
|
|
85
|
+
background: OcSceneRGB;
|
|
86
|
+
isDark: boolean;
|
|
87
|
+
motionOff: boolean;
|
|
88
|
+
}
|
|
89
|
+
declare function normalizeHue(c: OcSceneRGB, isDark: boolean): OcSceneRGB;
|
|
90
|
+
declare function readOcSceneTokens(host: HTMLElement): OcSceneTokens | null;
|
|
91
|
+
declare function subscribeOcTheme(cb: () => void): () => void;
|
|
92
|
+
|
|
93
|
+
export { AppearanceControls, DEFAULT_OC_THEME, OC_DEFAULT_ACCENT, OC_MOTION_COOKIE, OC_SKIN_COOKIE, OC_THEMES, OcAppearanceMenu, type OcAppearanceMenuProps, OcAurora, type OcAuroraProps, type OcMotion, type OcSceneRGB, type OcSceneTokens, type OcTheme, OcThemeBridge, type OcThemeId, OcThemePicker, type OcThemePickerProps, OcThemeProvider, type OcThemeProviderProps, accentFor, cn, getOcThemeInitScript, isKnownTheme, normalizeHue, readOcSceneTokens, resolveTheme, subscribeOcTheme, useOcMotion, useOcSkin };
|
package/dist/tokens.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ interface OcThemeProviderProps {
|
|
|
38
38
|
defaultSkin?: string;
|
|
39
39
|
aurora?: boolean | {
|
|
40
40
|
intensity?: number;
|
|
41
|
+
gl?: boolean;
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
declare function OcThemeProvider({ children, defaultSkin, aurora, }: OcThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
@@ -69,8 +70,24 @@ declare function OcAppearanceMenu({ className, triggerClassName, popoverClassNam
|
|
|
69
70
|
|
|
70
71
|
interface OcAuroraProps {
|
|
71
72
|
intensity?: number;
|
|
73
|
+
gl?: boolean;
|
|
72
74
|
className?: string;
|
|
73
75
|
}
|
|
74
|
-
declare function OcAurora({ intensity, className }: OcAuroraProps): react_jsx_runtime.JSX.Element;
|
|
76
|
+
declare function OcAurora({ intensity, gl, className }: OcAuroraProps): react_jsx_runtime.JSX.Element;
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
interface OcSceneRGB {
|
|
79
|
+
r: number;
|
|
80
|
+
g: number;
|
|
81
|
+
b: number;
|
|
82
|
+
}
|
|
83
|
+
interface OcSceneTokens {
|
|
84
|
+
palette: [OcSceneRGB, OcSceneRGB, OcSceneRGB, OcSceneRGB];
|
|
85
|
+
background: OcSceneRGB;
|
|
86
|
+
isDark: boolean;
|
|
87
|
+
motionOff: boolean;
|
|
88
|
+
}
|
|
89
|
+
declare function normalizeHue(c: OcSceneRGB, isDark: boolean): OcSceneRGB;
|
|
90
|
+
declare function readOcSceneTokens(host: HTMLElement): OcSceneTokens | null;
|
|
91
|
+
declare function subscribeOcTheme(cb: () => void): () => void;
|
|
92
|
+
|
|
93
|
+
export { AppearanceControls, DEFAULT_OC_THEME, OC_DEFAULT_ACCENT, OC_MOTION_COOKIE, OC_SKIN_COOKIE, OC_THEMES, OcAppearanceMenu, type OcAppearanceMenuProps, OcAurora, type OcAuroraProps, type OcMotion, type OcSceneRGB, type OcSceneTokens, type OcTheme, OcThemeBridge, type OcThemeId, OcThemePicker, type OcThemePickerProps, OcThemeProvider, type OcThemeProviderProps, accentFor, cn, getOcThemeInitScript, isKnownTheme, normalizeHue, readOcSceneTokens, resolveTheme, subscribeOcTheme, useOcMotion, useOcSkin };
|
package/dist/tokens.js
CHANGED
|
@@ -7,7 +7,381 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
var nextThemes = require('next-themes');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __esm = (fn, res) => function __init() {
|
|
13
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
|
+
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/tokens/scene-tokens.ts
|
|
21
|
+
function parseColor(value) {
|
|
22
|
+
let m = value.match(/color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)/);
|
|
23
|
+
if (m?.[1] != null && m[2] != null && m[3] != null) {
|
|
24
|
+
return { r: +m[1], g: +m[2], b: +m[3] };
|
|
25
|
+
}
|
|
26
|
+
m = value.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/);
|
|
27
|
+
if (m?.[1] != null && m[2] != null && m[3] != null) {
|
|
28
|
+
return { r: +m[1] / 255, g: +m[2] / 255, b: +m[3] / 255 };
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function srgbToOklab({ r, g, b }) {
|
|
33
|
+
const lin = (c) => c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
34
|
+
const lr = lin(r);
|
|
35
|
+
const lg = lin(g);
|
|
36
|
+
const lb = lin(b);
|
|
37
|
+
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
38
|
+
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
39
|
+
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
40
|
+
return {
|
|
41
|
+
L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
42
|
+
a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
43
|
+
b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function oklabToSrgb(L, a, bb) {
|
|
47
|
+
const l = Math.pow(L + 0.3963377774 * a + 0.2158037573 * bb, 3);
|
|
48
|
+
const m = Math.pow(L - 0.1055613458 * a - 0.0638541728 * bb, 3);
|
|
49
|
+
const s = Math.pow(L - 0.0894841775 * a - 1.291485548 * bb, 3);
|
|
50
|
+
const lr = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
|
|
51
|
+
const lg = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
|
|
52
|
+
const lb = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
53
|
+
const un = (c) => Math.min(1, Math.max(0, c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055));
|
|
54
|
+
return { r: un(lr), g: un(lg), b: un(lb) };
|
|
55
|
+
}
|
|
56
|
+
function normalizeHue(c, isDark) {
|
|
57
|
+
const { L, a, b } = srgbToOklab(c);
|
|
58
|
+
const C = Math.hypot(a, b);
|
|
59
|
+
const targetL = isDark ? Math.min(0.75, Math.max(0.55, L)) : Math.min(0.95, Math.max(0.82, L + 0.25));
|
|
60
|
+
const scale = C > 1e-6 ? Math.min(C, 0.14) / C : 0;
|
|
61
|
+
return oklabToSrgb(targetL, a * scale, b * scale);
|
|
62
|
+
}
|
|
63
|
+
function readOcSceneTokens(host) {
|
|
64
|
+
if (typeof document === "undefined") return null;
|
|
65
|
+
const probe = document.createElement("div");
|
|
66
|
+
probe.setAttribute("aria-hidden", "true");
|
|
67
|
+
probe.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;";
|
|
68
|
+
const cells = SLOTS.map((slot) => {
|
|
69
|
+
const cell = document.createElement("span");
|
|
70
|
+
cell.style.color = `color-mix(in srgb, var(${slot}), var(${slot}))`;
|
|
71
|
+
probe.appendChild(cell);
|
|
72
|
+
return cell;
|
|
73
|
+
});
|
|
74
|
+
host.appendChild(probe);
|
|
75
|
+
try {
|
|
76
|
+
const parsed = cells.map((cell) => parseColor(getComputedStyle(cell).color));
|
|
77
|
+
const [orange, green, blue, violet, background] = parsed;
|
|
78
|
+
if (!orange || !green || !blue || !violet || !background) return null;
|
|
79
|
+
const root = document.documentElement;
|
|
80
|
+
return {
|
|
81
|
+
palette: [orange, green, blue, violet],
|
|
82
|
+
background,
|
|
83
|
+
isDark: root.classList.contains("dark"),
|
|
84
|
+
motionOff: root.getAttribute("data-oc-motion") === "off"
|
|
85
|
+
};
|
|
86
|
+
} finally {
|
|
87
|
+
host.removeChild(probe);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function subscribeOcTheme(cb) {
|
|
91
|
+
if (typeof document === "undefined") return () => {
|
|
92
|
+
};
|
|
93
|
+
let raf1 = 0;
|
|
94
|
+
let raf2 = 0;
|
|
95
|
+
const schedule = () => {
|
|
96
|
+
cancelAnimationFrame(raf1);
|
|
97
|
+
cancelAnimationFrame(raf2);
|
|
98
|
+
raf1 = requestAnimationFrame(() => {
|
|
99
|
+
raf2 = requestAnimationFrame(cb);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const mo = new MutationObserver(schedule);
|
|
103
|
+
mo.observe(document.documentElement, {
|
|
104
|
+
attributes: true,
|
|
105
|
+
attributeFilter: ["class", "data-oc-theme", "data-oc-motion"]
|
|
106
|
+
});
|
|
107
|
+
return () => {
|
|
108
|
+
mo.disconnect();
|
|
109
|
+
cancelAnimationFrame(raf1);
|
|
110
|
+
cancelAnimationFrame(raf2);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
var SLOTS;
|
|
114
|
+
var init_scene_tokens = __esm({
|
|
115
|
+
"src/tokens/scene-tokens.ts"() {
|
|
116
|
+
SLOTS = ["--au-orange", "--au-green", "--au-blue", "--au-violet", "--background"];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// src/tokens/aurora-gl.ts
|
|
121
|
+
var aurora_gl_exports = {};
|
|
122
|
+
__export(aurora_gl_exports, {
|
|
123
|
+
mountAuroraGL: () => mountAuroraGL
|
|
124
|
+
});
|
|
125
|
+
function killFlagged() {
|
|
126
|
+
try {
|
|
127
|
+
const raw = localStorage.getItem(KILL_KEY);
|
|
128
|
+
if (!raw) return false;
|
|
129
|
+
if (Date.now() - Number(raw) > KILL_TTL_MS) {
|
|
130
|
+
localStorage.removeItem(KILL_KEY);
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
} catch {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function setKillFlag() {
|
|
139
|
+
try {
|
|
140
|
+
localStorage.setItem(KILL_KEY, String(Date.now()));
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function cypherFinish() {
|
|
145
|
+
const skin = document.documentElement.getAttribute("data-oc-theme");
|
|
146
|
+
return skin !== null && skin !== "ember";
|
|
147
|
+
}
|
|
148
|
+
function samplePalette(host) {
|
|
149
|
+
const tokens = readOcSceneTokens(host);
|
|
150
|
+
if (!tokens) return null;
|
|
151
|
+
return {
|
|
152
|
+
hues: tokens.palette.map((h) => normalizeHue(h, tokens.isDark)),
|
|
153
|
+
bg: tokens.background,
|
|
154
|
+
isDark: tokens.isDark,
|
|
155
|
+
finish: cypherFinish() ? 1 : 0
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function mountAuroraGL(container) {
|
|
159
|
+
if (killFlagged()) return null;
|
|
160
|
+
if (getComputedStyle(container).getPropertyValue("--oc-aurora-gl").trim() === "off") {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
const canvas = document.createElement("canvas");
|
|
164
|
+
canvas.className = "oc-aurora__gl";
|
|
165
|
+
const glMaybe = canvas.getContext("webgl2", {
|
|
166
|
+
antialias: false,
|
|
167
|
+
depth: false,
|
|
168
|
+
stencil: false,
|
|
169
|
+
alpha: false,
|
|
170
|
+
powerPreference: "low-power",
|
|
171
|
+
failIfMajorPerformanceCaveat: true
|
|
172
|
+
// SwiftShader/blocklist → CSS floor, free
|
|
173
|
+
});
|
|
174
|
+
if (!glMaybe) return null;
|
|
175
|
+
const gl = glMaybe;
|
|
176
|
+
const first = samplePalette(container);
|
|
177
|
+
if (!first) return null;
|
|
178
|
+
let prog;
|
|
179
|
+
const uni = {};
|
|
180
|
+
try {
|
|
181
|
+
const compile = (type, src) => {
|
|
182
|
+
const s = gl.createShader(type);
|
|
183
|
+
gl.shaderSource(s, src);
|
|
184
|
+
gl.compileShader(s);
|
|
185
|
+
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error("compile");
|
|
186
|
+
return s;
|
|
187
|
+
};
|
|
188
|
+
prog = gl.createProgram();
|
|
189
|
+
gl.attachShader(prog, compile(gl.VERTEX_SHADER, VS));
|
|
190
|
+
gl.attachShader(prog, compile(gl.FRAGMENT_SHADER, FS));
|
|
191
|
+
gl.linkProgram(prog);
|
|
192
|
+
if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) throw new Error("link");
|
|
193
|
+
gl.useProgram(prog);
|
|
194
|
+
const buf = gl.createBuffer();
|
|
195
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
|
196
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
|
|
197
|
+
const loc = gl.getAttribLocation(prog, "p");
|
|
198
|
+
gl.enableVertexAttribArray(loc);
|
|
199
|
+
gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
|
200
|
+
for (const k of ["uRes", "uT", "uIsDark", "uFinish", "uMix", "uA0", "uA1", "uA2", "uA3", "uB0", "uB1", "uB2", "uB3", "uBg"]) {
|
|
201
|
+
uni[k] = gl.getUniformLocation(prog, k);
|
|
202
|
+
}
|
|
203
|
+
} catch {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
container.appendChild(canvas);
|
|
207
|
+
let palFrom = first;
|
|
208
|
+
let palTo = first;
|
|
209
|
+
let mixStart = 0;
|
|
210
|
+
let raf = 0;
|
|
211
|
+
let lastFrame = 0;
|
|
212
|
+
let clock = 0;
|
|
213
|
+
let lastTick = 0;
|
|
214
|
+
let lastInput = performance.now();
|
|
215
|
+
let live = false;
|
|
216
|
+
let disposed = false;
|
|
217
|
+
let slowStreak = 0;
|
|
218
|
+
const setVec = (k, c) => gl.uniform3f(uni[k] ?? null, c.r, c.g, c.b);
|
|
219
|
+
function resize() {
|
|
220
|
+
const coarse = matchMedia("(pointer: coarse)").matches;
|
|
221
|
+
const dpr = Math.min(devicePixelRatio || 1, coarse ? 1.5 : 2) * 0.75;
|
|
222
|
+
const w = Math.max(1, Math.round(container.clientWidth * dpr));
|
|
223
|
+
const hgt = Math.max(1, Math.round(container.clientHeight * dpr));
|
|
224
|
+
if (canvas.width !== w || canvas.height !== hgt) {
|
|
225
|
+
canvas.width = w;
|
|
226
|
+
canvas.height = hgt;
|
|
227
|
+
gl.viewport(0, 0, w, hgt);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function draw(now) {
|
|
231
|
+
raf = requestAnimationFrame(draw);
|
|
232
|
+
if (now - lastFrame < FRAME_MS) return;
|
|
233
|
+
const frameGap = now - lastFrame;
|
|
234
|
+
lastFrame = now;
|
|
235
|
+
if (frameGap > FRAME_MS * 2.5) {
|
|
236
|
+
if (++slowStreak > 90) {
|
|
237
|
+
setKillFlag();
|
|
238
|
+
dispose();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
} else if (slowStreak > 0) slowStreak--;
|
|
242
|
+
const settled = now - lastInput > SETTLE_MS;
|
|
243
|
+
if (!settled) {
|
|
244
|
+
clock += Math.min(now - lastTick, 100) / 1e3;
|
|
245
|
+
}
|
|
246
|
+
lastTick = now;
|
|
247
|
+
if (settled && live && mixDone(now)) return;
|
|
248
|
+
resize();
|
|
249
|
+
const mix = Math.min(1, (now - mixStart) / CROSSFADE_MS);
|
|
250
|
+
gl.uniform2f(uni.uRes ?? null, canvas.width, canvas.height);
|
|
251
|
+
gl.uniform1f(uni.uT ?? null, clock);
|
|
252
|
+
gl.uniform1f(uni.uIsDark ?? null, palTo.isDark ? 1 : 0);
|
|
253
|
+
gl.uniform1f(uni.uFinish ?? null, palTo.finish);
|
|
254
|
+
gl.uniform1f(uni.uMix ?? null, mix);
|
|
255
|
+
setVec("uA0", palFrom.hues[0]);
|
|
256
|
+
setVec("uA1", palFrom.hues[1]);
|
|
257
|
+
setVec("uA2", palFrom.hues[2]);
|
|
258
|
+
setVec("uA3", palFrom.hues[3]);
|
|
259
|
+
setVec("uB0", palTo.hues[0]);
|
|
260
|
+
setVec("uB1", palTo.hues[1]);
|
|
261
|
+
setVec("uB2", palTo.hues[2]);
|
|
262
|
+
setVec("uB3", palTo.hues[3]);
|
|
263
|
+
setVec("uBg", palTo.bg);
|
|
264
|
+
gl.drawArrays(gl.TRIANGLES, 0, 3);
|
|
265
|
+
if (!live) {
|
|
266
|
+
live = true;
|
|
267
|
+
container.classList.add("oc-aurora--gl-live");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function mixDone(now) {
|
|
271
|
+
return now - mixStart >= CROSSFADE_MS;
|
|
272
|
+
}
|
|
273
|
+
const onInput = () => {
|
|
274
|
+
lastInput = performance.now();
|
|
275
|
+
};
|
|
276
|
+
const onVisibility = () => {
|
|
277
|
+
if (document.hidden) {
|
|
278
|
+
cancelAnimationFrame(raf);
|
|
279
|
+
raf = 0;
|
|
280
|
+
} else if (!raf && !disposed) {
|
|
281
|
+
lastFrame = 0;
|
|
282
|
+
lastTick = performance.now();
|
|
283
|
+
raf = requestAnimationFrame(draw);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const onContextLost = (e) => {
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
cancelAnimationFrame(raf);
|
|
289
|
+
raf = 0;
|
|
290
|
+
};
|
|
291
|
+
const onContextRestored = () => {
|
|
292
|
+
dispose();
|
|
293
|
+
};
|
|
294
|
+
const unsubscribeTheme = subscribeOcTheme(() => {
|
|
295
|
+
if (disposed) return;
|
|
296
|
+
const root = document.documentElement;
|
|
297
|
+
if (root.getAttribute("data-oc-motion") === "off") {
|
|
298
|
+
dispose();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const next = samplePalette(container);
|
|
302
|
+
if (!next) return;
|
|
303
|
+
palFrom = { ...palTo, hues: [...palTo.hues] };
|
|
304
|
+
palTo = next;
|
|
305
|
+
mixStart = performance.now();
|
|
306
|
+
lastInput = performance.now();
|
|
307
|
+
});
|
|
308
|
+
window.addEventListener("pointermove", onInput, { passive: true });
|
|
309
|
+
window.addEventListener("scroll", onInput, { passive: true });
|
|
310
|
+
window.addEventListener("keydown", onInput, { passive: true });
|
|
311
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
312
|
+
canvas.addEventListener("webglcontextlost", onContextLost);
|
|
313
|
+
canvas.addEventListener("webglcontextrestored", onContextRestored);
|
|
314
|
+
function dispose() {
|
|
315
|
+
if (disposed) return;
|
|
316
|
+
disposed = true;
|
|
317
|
+
cancelAnimationFrame(raf);
|
|
318
|
+
unsubscribeTheme();
|
|
319
|
+
window.removeEventListener("pointermove", onInput);
|
|
320
|
+
window.removeEventListener("scroll", onInput);
|
|
321
|
+
window.removeEventListener("keydown", onInput);
|
|
322
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
323
|
+
canvas.removeEventListener("webglcontextlost", onContextLost);
|
|
324
|
+
canvas.removeEventListener("webglcontextrestored", onContextRestored);
|
|
325
|
+
container.classList.remove("oc-aurora--gl-live");
|
|
326
|
+
canvas.remove();
|
|
327
|
+
const ext = gl.getExtension("WEBGL_lose_context");
|
|
328
|
+
if (ext) ext.loseContext();
|
|
329
|
+
}
|
|
330
|
+
resize();
|
|
331
|
+
mixStart = performance.now();
|
|
332
|
+
lastTick = performance.now();
|
|
333
|
+
raf = requestAnimationFrame(draw);
|
|
334
|
+
return dispose;
|
|
335
|
+
}
|
|
336
|
+
var KILL_KEY, KILL_TTL_MS, SETTLE_MS, FRAME_MS, CROSSFADE_MS, VS, FS;
|
|
337
|
+
var init_aurora_gl = __esm({
|
|
338
|
+
"src/tokens/aurora-gl.ts"() {
|
|
339
|
+
init_scene_tokens();
|
|
340
|
+
KILL_KEY = "oc-aurora-gl-kill:1";
|
|
341
|
+
KILL_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
342
|
+
SETTLE_MS = 9e4;
|
|
343
|
+
FRAME_MS = 33;
|
|
344
|
+
CROSSFADE_MS = 250;
|
|
345
|
+
VS = `#version 300 es
|
|
346
|
+
in vec2 p;void main(){gl_Position=vec4(p,0.,1.);}`;
|
|
347
|
+
FS = `#version 300 es
|
|
348
|
+
precision highp float;
|
|
349
|
+
out vec4 o;
|
|
350
|
+
uniform vec2 uRes;uniform float uT,uIsDark,uFinish,uMix;
|
|
351
|
+
uniform vec3 uA0,uA1,uA2,uA3,uB0,uB1,uB2,uB3,uBg;
|
|
352
|
+
float h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}
|
|
353
|
+
float n2(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);
|
|
354
|
+
return mix(mix(h(i),h(i+vec2(1,0)),f.x),mix(h(i+vec2(0,1)),h(i+vec2(1,1)),f.x),f.y);}
|
|
355
|
+
float fbm(vec2 p){float v=0.,a=.55;for(int i=0;i<3;i++){v+=a*n2(p);p=p*2.03+vec2(1.7,9.2);a*=.5;}return v;}
|
|
356
|
+
float B2(vec2 a){a=floor(a);return fract(a.x/2.+a.y*a.y*.75);}
|
|
357
|
+
// OKLab mix (Ottosson) so skin crossfades never transit gray-brown.
|
|
358
|
+
vec3 l2s(vec3 c){return mix(12.92*c,1.055*pow(c,vec3(1./2.4))-.055,step(.0031308,c));}
|
|
359
|
+
vec3 s2l(vec3 c){return mix(c/12.92,pow((c+.055)/1.055,vec3(2.4)),step(.04045,c));}
|
|
360
|
+
vec3 okmix(vec3 a,vec3 b,float t){
|
|
361
|
+
vec3 la=s2l(a),lb=s2l(b);
|
|
362
|
+
mat3 M1=mat3(.4122214708,.2119034982,.0883024619,.5363325363,.6806995451,.2817188376,.0514459929,.1073969566,.6299787005);
|
|
363
|
+
mat3 M2=mat3(4.0767416621,-1.2684380046,-.0041960863,-3.3077115913,2.6097574011,-.7034186147,.2309699292,-.3413193965,1.707614701);
|
|
364
|
+
vec3 ka=pow(M1*la,vec3(1./3.)),kb=pow(M1*lb,vec3(1./3.));
|
|
365
|
+
vec3 k=mix(ka,kb,t);return clamp(l2s(M2*(k*k*k)),0.,1.);}
|
|
366
|
+
void main(){
|
|
367
|
+
vec2 uv=gl_FragCoord.xy/uRes;
|
|
368
|
+
vec2 p=(uv-.5)*vec2(uRes.x/uRes.y,1.)*1.9;
|
|
369
|
+
float t=uT*.018;
|
|
370
|
+
vec2 w=vec2(fbm(p+vec2(0.,t)),fbm(p+vec2(5.2,1.3)-t*.7));
|
|
371
|
+
float f=fbm(p+1.9*w+vec2(t*.5,-t*.3));
|
|
372
|
+
float g=fbm(p*.6+w*1.2+vec2(9.1,3.7));
|
|
373
|
+
vec3 c0=okmix(uA0,uB0,uMix),c1=okmix(uA1,uB1,uMix),c2=okmix(uA2,uB2,uMix),c3=okmix(uA3,uB3,uMix);
|
|
374
|
+
vec3 c=mix(mix(c0,c1,smoothstep(.25,.55,g)),mix(c2,c3,smoothstep(.45,.8,g)),smoothstep(.4,.7,g));
|
|
375
|
+
float e=smoothstep(.32,.9,f);
|
|
376
|
+
if(uFinish>.5){
|
|
377
|
+
float b=B2(.125*gl_FragCoord.xy)*.0625+B2(.25*gl_FragCoord.xy)*.25+B2(.5*gl_FragCoord.xy);
|
|
378
|
+
e=floor(e*5.+b*.8-.4)/5.;}
|
|
379
|
+
// container CSS already applies the mode-op \xD7 intensity opacity + radial mask
|
|
380
|
+
vec3 col=(uIsDark>.5)?clamp(uBg+c*e*1.15,0.,1.):mix(uBg,c,e);
|
|
381
|
+
col+=(fract(52.9829189*fract(dot(gl_FragCoord.xy,vec2(0.06711056,0.00583715))))-.5)/255.;
|
|
382
|
+
o=vec4(col,1.);}`;
|
|
383
|
+
}
|
|
384
|
+
});
|
|
11
385
|
function cn(...inputs) {
|
|
12
386
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
13
387
|
}
|
|
@@ -59,9 +433,76 @@ function resolveTheme(id) {
|
|
|
59
433
|
var OC_SKIN_COOKIE = "oc_skin";
|
|
60
434
|
var OC_MOTION_COOKIE = "oc_motion";
|
|
61
435
|
var BLOBS = [1, 2, 3, 4, 5];
|
|
62
|
-
function
|
|
436
|
+
function onIdle(cb, timeout) {
|
|
437
|
+
if (typeof requestIdleCallback === "function") {
|
|
438
|
+
const id2 = requestIdleCallback(cb, { timeout });
|
|
439
|
+
return () => cancelIdleCallback(id2);
|
|
440
|
+
}
|
|
441
|
+
const id = setTimeout(cb, timeout);
|
|
442
|
+
return () => clearTimeout(id);
|
|
443
|
+
}
|
|
444
|
+
function OcAurora({ intensity, gl = false, className }) {
|
|
445
|
+
const hostRef = react.useRef(null);
|
|
446
|
+
react.useEffect(() => {
|
|
447
|
+
if (!gl) return;
|
|
448
|
+
const host = hostRef.current;
|
|
449
|
+
if (!host) return;
|
|
450
|
+
let disposed = false;
|
|
451
|
+
let disposeScene = null;
|
|
452
|
+
let cancelIdle = null;
|
|
453
|
+
const prm = matchMedia("(prefers-reduced-motion: reduce)");
|
|
454
|
+
const forced = matchMedia("(forced-colors: active)");
|
|
455
|
+
function gatesPass() {
|
|
456
|
+
if (prm.matches || forced.matches) return false;
|
|
457
|
+
if (document.documentElement.getAttribute("data-oc-motion") === "off") return false;
|
|
458
|
+
const nav = navigator;
|
|
459
|
+
if (nav.connection?.saveData === true) return false;
|
|
460
|
+
if (typeof nav.deviceMemory === "number" && nav.deviceMemory <= 4) return false;
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
function boot() {
|
|
464
|
+
cancelIdle = onIdle(async () => {
|
|
465
|
+
if (disposed || disposeScene || !gatesPass()) return;
|
|
466
|
+
try {
|
|
467
|
+
const mod = await Promise.resolve().then(() => (init_aurora_gl(), aurora_gl_exports));
|
|
468
|
+
if (disposed || disposeScene || !gatesPass()) return;
|
|
469
|
+
disposeScene = mod.mountAuroraGL(host);
|
|
470
|
+
} catch {
|
|
471
|
+
}
|
|
472
|
+
}, 2e3);
|
|
473
|
+
}
|
|
474
|
+
function teardownScene() {
|
|
475
|
+
disposeScene?.();
|
|
476
|
+
disposeScene = null;
|
|
477
|
+
}
|
|
478
|
+
const onPrmChange = () => {
|
|
479
|
+
if (prm.matches) teardownScene();
|
|
480
|
+
else if (!disposeScene) boot();
|
|
481
|
+
};
|
|
482
|
+
prm.addEventListener?.("change", onPrmChange);
|
|
483
|
+
const mo = new MutationObserver(() => {
|
|
484
|
+
const off = document.documentElement.getAttribute("data-oc-motion") === "off";
|
|
485
|
+
if (!off && !disposeScene && !disposed) boot();
|
|
486
|
+
});
|
|
487
|
+
mo.observe(document.documentElement, {
|
|
488
|
+
attributes: true,
|
|
489
|
+
attributeFilter: ["data-oc-motion"]
|
|
490
|
+
});
|
|
491
|
+
if (document.readyState === "complete") boot();
|
|
492
|
+
else {
|
|
493
|
+
const onLoad = () => boot();
|
|
494
|
+
window.addEventListener("load", onLoad, { once: true });
|
|
495
|
+
}
|
|
496
|
+
return () => {
|
|
497
|
+
disposed = true;
|
|
498
|
+
cancelIdle?.();
|
|
499
|
+
prm.removeEventListener?.("change", onPrmChange);
|
|
500
|
+
mo.disconnect();
|
|
501
|
+
teardownScene();
|
|
502
|
+
};
|
|
503
|
+
}, [gl]);
|
|
63
504
|
const style = intensity == null ? void 0 : { "--oc-aurora-intensity": String(intensity) };
|
|
64
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("oc-aurora", className), style, "aria-hidden": "true", children: [
|
|
505
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: hostRef, className: cn("oc-aurora", className), style, "aria-hidden": "true", children: [
|
|
65
506
|
BLOBS.map((n) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `oc-aurora__blob oc-aurora__blob-${n}` }, n)),
|
|
66
507
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oc-aurora__grain" })
|
|
67
508
|
] });
|
|
@@ -200,7 +641,13 @@ function OcThemeProvider({
|
|
|
200
641
|
[skin, setSkin, motion, setMotion]
|
|
201
642
|
);
|
|
202
643
|
return /* @__PURE__ */ jsxRuntime.jsxs(OcSkinContext.Provider, { value, children: [
|
|
203
|
-
aurora !== false && /* @__PURE__ */ jsxRuntime.jsx(
|
|
644
|
+
aurora !== false && /* @__PURE__ */ jsxRuntime.jsx(
|
|
645
|
+
OcAurora,
|
|
646
|
+
{
|
|
647
|
+
intensity: typeof aurora === "object" ? aurora.intensity : void 0,
|
|
648
|
+
gl: typeof aurora === "object" ? aurora.gl : void 0
|
|
649
|
+
}
|
|
650
|
+
),
|
|
204
651
|
children
|
|
205
652
|
] });
|
|
206
653
|
}
|
|
@@ -486,6 +933,9 @@ function OcAppearanceMenu({
|
|
|
486
933
|
] });
|
|
487
934
|
}
|
|
488
935
|
|
|
936
|
+
// src/tokens/index.ts
|
|
937
|
+
init_scene_tokens();
|
|
938
|
+
|
|
489
939
|
exports.AppearanceControls = AppearanceControls;
|
|
490
940
|
exports.DEFAULT_OC_THEME = DEFAULT_OC_THEME;
|
|
491
941
|
exports.OC_DEFAULT_ACCENT = OC_DEFAULT_ACCENT;
|
|
@@ -501,7 +951,10 @@ exports.accentFor = accentFor;
|
|
|
501
951
|
exports.cn = cn;
|
|
502
952
|
exports.getOcThemeInitScript = getOcThemeInitScript;
|
|
503
953
|
exports.isKnownTheme = isKnownTheme;
|
|
954
|
+
exports.normalizeHue = normalizeHue;
|
|
955
|
+
exports.readOcSceneTokens = readOcSceneTokens;
|
|
504
956
|
exports.resolveTheme = resolveTheme;
|
|
957
|
+
exports.subscribeOcTheme = subscribeOcTheme;
|
|
505
958
|
exports.useOcMotion = useOcMotion;
|
|
506
959
|
exports.useOcSkin = useOcSkin;
|
|
507
960
|
//# sourceMappingURL=tokens.js.map
|