@egen-civitas/esm-styleguide 1.2.0 → 1.4.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/CHANGELOG.md +16 -0
- package/dist/assistant/assistant-modes.d.ts +29 -0
- package/dist/assistant/assistant-modes.d.ts.map +1 -0
- package/dist/assistant/assistant-modes.js +143 -0
- package/dist/assistant/index.d.ts +9 -0
- package/dist/assistant/index.d.ts.map +1 -0
- package/dist/assistant/index.js +7 -0
- package/dist/assistant/live-orb.component.d.ts +63 -0
- package/dist/assistant/live-orb.component.d.ts.map +1 -0
- package/dist/assistant/live-orb.component.js +485 -0
- package/dist/assistant/prompt-input.component.d.ts +19 -0
- package/dist/assistant/prompt-input.component.d.ts.map +1 -0
- package/dist/assistant/prompt-input.component.js +1021 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-background.component.d.ts +19 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-background.component.d.ts.map +1 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-background.component.js +127 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-source.d.ts +2 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-source.d.ts.map +1 -0
- package/dist/assistant/recursive-erosion/recursive-erosion-source.js +340 -0
- package/dist/assistant/spline-scene.component.d.ts +9 -0
- package/dist/assistant/spline-scene.component.d.ts.map +1 -0
- package/dist/assistant/spline-scene.component.js +51 -0
- package/dist/assistant/water-glass-modal.component.d.ts +26 -0
- package/dist/assistant/water-glass-modal.component.d.ts.map +1 -0
- package/dist/assistant/water-glass-modal.component.js +46 -0
- package/dist/assistant/xbox-audio.d.ts +88 -0
- package/dist/assistant/xbox-audio.d.ts.map +1 -0
- package/dist/assistant/xbox-audio.js +756 -0
- package/dist/components/_general.scss +52 -15
- package/dist/components/_panel-overrides.scss +5 -7
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -0
- package/dist/public.d.ts +1 -0
- package/dist/public.d.ts.map +1 -1
- package/dist/public.js +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../page-background/page-background.utils.js";
|
|
5
|
+
export const WHITE = {
|
|
6
|
+
color: "#F4F4F5",
|
|
7
|
+
eyeColor: "#09090B"
|
|
8
|
+
};
|
|
9
|
+
export const BLACK = {
|
|
10
|
+
color: "#18181B",
|
|
11
|
+
eyeColor: "#F4F4F5"
|
|
12
|
+
};
|
|
13
|
+
export const CUSTOM_DEFAULT = {
|
|
14
|
+
color: "#7C5CFF",
|
|
15
|
+
eyeColor: "#FAFAFA"
|
|
16
|
+
};
|
|
17
|
+
/** Violet / foam / dust-rose — stock unlit wash. */ export const WEBGL_COLORS = [
|
|
18
|
+
"#7C6AF7",
|
|
19
|
+
"#7DD3C7",
|
|
20
|
+
"#E8B4D4"
|
|
21
|
+
];
|
|
22
|
+
const VERT = `
|
|
23
|
+
attribute vec2 a_position;
|
|
24
|
+
void main() {
|
|
25
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const FRAG = `
|
|
29
|
+
precision highp float;
|
|
30
|
+
|
|
31
|
+
uniform vec2 u_resolution;
|
|
32
|
+
uniform float u_time;
|
|
33
|
+
uniform float u_speed;
|
|
34
|
+
uniform vec2 u_look;
|
|
35
|
+
uniform float u_blink;
|
|
36
|
+
uniform float u_mode;
|
|
37
|
+
uniform vec3 u_body;
|
|
38
|
+
uniform vec3 u_eye;
|
|
39
|
+
uniform vec3 u_c1;
|
|
40
|
+
uniform vec3 u_c2;
|
|
41
|
+
uniform vec3 u_c3;
|
|
42
|
+
|
|
43
|
+
float hash(vec2 p) {
|
|
44
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
float noise(vec2 p) {
|
|
48
|
+
vec2 i = floor(p);
|
|
49
|
+
vec2 f = fract(p);
|
|
50
|
+
float a = hash(i);
|
|
51
|
+
float b = hash(i + vec2(1.0, 0.0));
|
|
52
|
+
float c = hash(i + vec2(0.0, 1.0));
|
|
53
|
+
float d = hash(i + vec2(1.0, 1.0));
|
|
54
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
55
|
+
return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
float fbm(vec2 p) {
|
|
59
|
+
float v = 0.0;
|
|
60
|
+
float a = 0.5;
|
|
61
|
+
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
|
|
62
|
+
for (int i = 0; i < 5; i++) {
|
|
63
|
+
v += a * noise(p);
|
|
64
|
+
p = m * p;
|
|
65
|
+
a *= 0.5;
|
|
66
|
+
}
|
|
67
|
+
return v;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
vec3 orient(vec3 p, vec2 look) {
|
|
71
|
+
float yaw = look.x * 0.92;
|
|
72
|
+
float pitch = -look.y * 0.78;
|
|
73
|
+
float cy = cos(yaw);
|
|
74
|
+
float sy = sin(yaw);
|
|
75
|
+
float cp = cos(pitch);
|
|
76
|
+
float sp = sin(pitch);
|
|
77
|
+
vec3 q = vec3(p.x, p.y * cp - p.z * sp, p.y * sp + p.z * cp);
|
|
78
|
+
return vec3(q.x * cy + q.z * sy, q.y, -q.x * sy + q.z * cy);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
float eyeMask(vec3 n, vec3 e, vec3 right, vec3 up, float halfH, float rad) {
|
|
82
|
+
float facing = dot(n, e);
|
|
83
|
+
float x = dot(n, right) - dot(e, right);
|
|
84
|
+
float y = dot(n, up) - dot(e, up);
|
|
85
|
+
y -= clamp(y, -halfH, halfH);
|
|
86
|
+
float d = length(vec2(x, y)) - rad;
|
|
87
|
+
float fill = 1.0 - smoothstep(-0.01, 0.01, d);
|
|
88
|
+
return fill * smoothstep(0.12, 0.32, facing);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
vec3 wash(vec3 n, float t) {
|
|
92
|
+
vec2 q = n.xy * 2.2 + n.z * 0.85;
|
|
93
|
+
vec2 w1 = vec2(
|
|
94
|
+
fbm(q * 1.4 + vec2(t * 0.22, t * 0.18)),
|
|
95
|
+
fbm(q * 1.4 + vec2(-t * 0.16, t * 0.24) + 4.1)
|
|
96
|
+
);
|
|
97
|
+
q += (w1 - 0.5) * 0.72;
|
|
98
|
+
float f = fbm(q * 2.1 + vec2(0.0, t * 0.12));
|
|
99
|
+
float g = fbm(q * 4.6 - vec2(t * 0.2, 0.0));
|
|
100
|
+
vec3 col = mix(u_c1, u_c2, smoothstep(0.28, 0.72, f));
|
|
101
|
+
return mix(col, u_c3, pow(smoothstep(0.42, 0.9, g), 1.4));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void main() {
|
|
105
|
+
vec2 uv = (gl_FragCoord.xy / u_resolution.xy) * 2.0 - 1.0;
|
|
106
|
+
float aspect = u_resolution.x / max(u_resolution.y, 1.0);
|
|
107
|
+
uv.x *= aspect;
|
|
108
|
+
|
|
109
|
+
float radius = 0.94;
|
|
110
|
+
vec2 p = uv / radius;
|
|
111
|
+
float r2 = dot(p, p);
|
|
112
|
+
float edge = 1.0 - smoothstep(0.985, 1.012, sqrt(max(r2, 0.0)));
|
|
113
|
+
if (edge <= 0.001) {
|
|
114
|
+
gl_FragColor = vec4(0.0);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
float z = sqrt(max(1.0 - r2, 0.0));
|
|
119
|
+
vec3 n = normalize(vec3(p, z));
|
|
120
|
+
|
|
121
|
+
vec2 look = u_look;
|
|
122
|
+
float lm = length(look);
|
|
123
|
+
if (lm > 1.0) look /= lm;
|
|
124
|
+
|
|
125
|
+
vec3 right = orient(vec3(1.0, 0.0, 0.0), look);
|
|
126
|
+
vec3 up = orient(vec3(0.0, 1.0, 0.0), look);
|
|
127
|
+
vec3 eL = orient(normalize(vec3(-0.32, 0.08, 1.0)), look);
|
|
128
|
+
vec3 eR = orient(normalize(vec3(0.32, 0.08, 1.0)), look);
|
|
129
|
+
|
|
130
|
+
float halfH = mix(0.128, 0.012, u_blink);
|
|
131
|
+
float rad = mix(0.054, 0.062, u_blink);
|
|
132
|
+
float eyes = max(
|
|
133
|
+
eyeMask(n, eL, right, up, halfH, rad),
|
|
134
|
+
eyeMask(n, eR, right, up, halfH, rad)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
vec3 body = u_mode > 0.5 ? wash(n, u_time * u_speed) : u_body;
|
|
138
|
+
vec3 col = mix(body, u_eye, clamp(eyes, 0.0, 1.0));
|
|
139
|
+
|
|
140
|
+
gl_FragColor = vec4(clamp(col, 0.0, 1.0), edge);
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
function isDev() {
|
|
144
|
+
return typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
145
|
+
}
|
|
146
|
+
function hexToRgb(hex) {
|
|
147
|
+
const h = hex.replace("#", "").trim();
|
|
148
|
+
const full = h.length === 3 ? h.split("").map((c)=>c + c).join("") : h.padEnd(6, "0").slice(0, 6);
|
|
149
|
+
const n = Number.parseInt(full, 16);
|
|
150
|
+
if (Number.isNaN(n)) return [
|
|
151
|
+
0.96,
|
|
152
|
+
0.96,
|
|
153
|
+
0.96
|
|
154
|
+
];
|
|
155
|
+
return [
|
|
156
|
+
(n >> 16 & 255) / 255,
|
|
157
|
+
(n >> 8 & 255) / 255,
|
|
158
|
+
(n & 255) / 255
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
function compile(gl, type, source) {
|
|
162
|
+
const shader = gl.createShader(type);
|
|
163
|
+
if (!shader) return null;
|
|
164
|
+
gl.shaderSource(shader, source);
|
|
165
|
+
gl.compileShader(shader);
|
|
166
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
167
|
+
if (isDev()) {
|
|
168
|
+
console.warn("LiveOrb: shader failed to compile\n", gl.getShaderInfoLog(shader));
|
|
169
|
+
}
|
|
170
|
+
gl.deleteShader(shader);
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return shader;
|
|
174
|
+
}
|
|
175
|
+
export function resolveVariant(variant, color, eyeColor, colors) {
|
|
176
|
+
let body = WHITE.color;
|
|
177
|
+
let eye = WHITE.eyeColor;
|
|
178
|
+
let mode = 0;
|
|
179
|
+
let palette = WEBGL_COLORS;
|
|
180
|
+
if (variant === "black") {
|
|
181
|
+
body = BLACK.color;
|
|
182
|
+
eye = BLACK.eyeColor;
|
|
183
|
+
} else if (variant === "webgl") {
|
|
184
|
+
palette = colors && colors.length > 0 ? colors : WEBGL_COLORS;
|
|
185
|
+
body = palette[1] ?? WEBGL_COLORS[1];
|
|
186
|
+
eye = "#0C0C10";
|
|
187
|
+
mode = 1;
|
|
188
|
+
} else if (variant === "custom") {
|
|
189
|
+
body = color ?? CUSTOM_DEFAULT.color;
|
|
190
|
+
eye = eyeColor ?? CUSTOM_DEFAULT.eyeColor;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
body,
|
|
194
|
+
eye,
|
|
195
|
+
mode,
|
|
196
|
+
palette
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export function fallbackFaceStyle(resolved) {
|
|
200
|
+
if (resolved.mode === 1) {
|
|
201
|
+
const a = resolved.palette[0] ?? WEBGL_COLORS[0];
|
|
202
|
+
const b = resolved.palette[1] ?? WEBGL_COLORS[1];
|
|
203
|
+
const c = resolved.palette[2] ?? WEBGL_COLORS[2];
|
|
204
|
+
return {
|
|
205
|
+
backgroundImage: `linear-gradient(135deg, ${a}, ${b}, ${c})`
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
backgroundColor: resolved.body
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Evenly lit sphere with two capsule eyes that follow the pointer.
|
|
214
|
+
* The orb stays put — only the gaze moves.
|
|
215
|
+
*/ export function createLiveOrb(canvas, initial = {}) {
|
|
216
|
+
let options = {
|
|
217
|
+
variant: "white",
|
|
218
|
+
interactive: true,
|
|
219
|
+
blink: true,
|
|
220
|
+
...initial
|
|
221
|
+
};
|
|
222
|
+
const look = {
|
|
223
|
+
x: 0,
|
|
224
|
+
y: 0.08
|
|
225
|
+
};
|
|
226
|
+
const targetLook = {
|
|
227
|
+
x: 0,
|
|
228
|
+
y: 0.08
|
|
229
|
+
};
|
|
230
|
+
let reduce = false;
|
|
231
|
+
const gl = canvas.getContext("webgl", {
|
|
232
|
+
alpha: true,
|
|
233
|
+
antialias: false,
|
|
234
|
+
depth: false,
|
|
235
|
+
stencil: false,
|
|
236
|
+
premultipliedAlpha: false,
|
|
237
|
+
powerPreference: "high-performance"
|
|
238
|
+
});
|
|
239
|
+
if (!gl) return null;
|
|
240
|
+
const vs = compile(gl, gl.VERTEX_SHADER, VERT);
|
|
241
|
+
const fs = compile(gl, gl.FRAGMENT_SHADER, FRAG);
|
|
242
|
+
if (!vs || !fs) return null;
|
|
243
|
+
const program = gl.createProgram();
|
|
244
|
+
if (!program) return null;
|
|
245
|
+
gl.attachShader(program, vs);
|
|
246
|
+
gl.attachShader(program, fs);
|
|
247
|
+
gl.linkProgram(program);
|
|
248
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
249
|
+
if (isDev()) {
|
|
250
|
+
console.warn("LiveOrb: program failed to link\n", gl.getProgramInfoLog(program));
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
gl.useProgram(program);
|
|
255
|
+
options.onHasGl?.(true);
|
|
256
|
+
const buf = gl.createBuffer();
|
|
257
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
|
|
258
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
|
|
259
|
+
-1,
|
|
260
|
+
-1,
|
|
261
|
+
1,
|
|
262
|
+
-1,
|
|
263
|
+
-1,
|
|
264
|
+
1,
|
|
265
|
+
-1,
|
|
266
|
+
1,
|
|
267
|
+
1,
|
|
268
|
+
-1,
|
|
269
|
+
1,
|
|
270
|
+
1
|
|
271
|
+
]), gl.STATIC_DRAW);
|
|
272
|
+
const loc = gl.getAttribLocation(program, "a_position");
|
|
273
|
+
gl.enableVertexAttribArray(loc);
|
|
274
|
+
gl.vertexAttribPointer(loc, 2, gl.FLOAT, false, 0, 0);
|
|
275
|
+
const uResolution = gl.getUniformLocation(program, "u_resolution");
|
|
276
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
277
|
+
const uSpeed = gl.getUniformLocation(program, "u_speed");
|
|
278
|
+
const uLook = gl.getUniformLocation(program, "u_look");
|
|
279
|
+
const uBlink = gl.getUniformLocation(program, "u_blink");
|
|
280
|
+
const uMode = gl.getUniformLocation(program, "u_mode");
|
|
281
|
+
const uBody = gl.getUniformLocation(program, "u_body");
|
|
282
|
+
const uEye = gl.getUniformLocation(program, "u_eye");
|
|
283
|
+
const uC1 = gl.getUniformLocation(program, "u_c1");
|
|
284
|
+
const uC2 = gl.getUniformLocation(program, "u_c2");
|
|
285
|
+
const uC3 = gl.getUniformLocation(program, "u_c3");
|
|
286
|
+
gl.enable(gl.BLEND);
|
|
287
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
288
|
+
let raf = 0;
|
|
289
|
+
let running = true;
|
|
290
|
+
const start = performance.now();
|
|
291
|
+
let nextBlink = start + 1800 + Math.random() * 2400;
|
|
292
|
+
let blinkAt = -10000;
|
|
293
|
+
const resize = ()=>{
|
|
294
|
+
const parent = canvas.parentElement;
|
|
295
|
+
if (!parent) return;
|
|
296
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
297
|
+
const w = parent.clientWidth;
|
|
298
|
+
const h = parent.clientHeight;
|
|
299
|
+
if (w <= 0 || h <= 0) return;
|
|
300
|
+
canvas.width = Math.max(1, Math.floor(w * dpr));
|
|
301
|
+
canvas.height = Math.max(1, Math.floor(h * dpr));
|
|
302
|
+
canvas.style.width = `${w}px`;
|
|
303
|
+
canvas.style.height = `${h}px`;
|
|
304
|
+
gl.viewport(0, 0, canvas.width, canvas.height);
|
|
305
|
+
};
|
|
306
|
+
resize();
|
|
307
|
+
const ro = new ResizeObserver(resize);
|
|
308
|
+
if (canvas.parentElement) ro.observe(canvas.parentElement);
|
|
309
|
+
const mqReduce = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
310
|
+
const onReduce = ()=>{
|
|
311
|
+
reduce = mqReduce.matches;
|
|
312
|
+
};
|
|
313
|
+
onReduce();
|
|
314
|
+
mqReduce.addEventListener("change", onReduce);
|
|
315
|
+
const onMove = (e)=>{
|
|
316
|
+
if (!options.interactive) return;
|
|
317
|
+
const parent = canvas.parentElement;
|
|
318
|
+
if (!parent) return;
|
|
319
|
+
const rect = parent.getBoundingClientRect();
|
|
320
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
321
|
+
const dx = (e.clientX - (rect.left + rect.width / 2)) / (rect.width / 2);
|
|
322
|
+
const dy = (rect.top + rect.height / 2 - e.clientY) / (rect.height / 2);
|
|
323
|
+
targetLook.x = Math.min(1, Math.max(-1, dx));
|
|
324
|
+
targetLook.y = Math.min(1, Math.max(-1, dy));
|
|
325
|
+
};
|
|
326
|
+
window.addEventListener("pointermove", onMove, {
|
|
327
|
+
passive: true
|
|
328
|
+
});
|
|
329
|
+
const tick = (now)=>{
|
|
330
|
+
if (!running) return;
|
|
331
|
+
const resolved = resolveVariant(options.variant, options.color, options.eyeColor, options.colors);
|
|
332
|
+
const time = (now - start) / 1000;
|
|
333
|
+
if (options.interactive) {
|
|
334
|
+
look.x += (targetLook.x - look.x) * 0.16;
|
|
335
|
+
look.y += (targetLook.y - look.y) * 0.16;
|
|
336
|
+
} else {
|
|
337
|
+
look.x += (0 - look.x) * 0.12;
|
|
338
|
+
look.y += (0.08 - look.y) * 0.12;
|
|
339
|
+
}
|
|
340
|
+
if (!reduce && options.blink && now >= nextBlink) {
|
|
341
|
+
blinkAt = now;
|
|
342
|
+
nextBlink = now + 2200 + Math.random() * 3800;
|
|
343
|
+
}
|
|
344
|
+
const bt = (now - blinkAt) / 1000;
|
|
345
|
+
let b = 0;
|
|
346
|
+
if (!reduce && options.blink) {
|
|
347
|
+
if (bt < 0.055) b = bt / 0.055;
|
|
348
|
+
else if (bt < 0.1) b = 1;
|
|
349
|
+
else if (bt < 0.18) b = 1 - (bt - 0.1) / 0.08;
|
|
350
|
+
}
|
|
351
|
+
const body = hexToRgb(resolved.body);
|
|
352
|
+
const eye = hexToRgb(resolved.eye);
|
|
353
|
+
const palette = [
|
|
354
|
+
0,
|
|
355
|
+
1,
|
|
356
|
+
2
|
|
357
|
+
].map((i)=>hexToRgb(resolved.palette[i % resolved.palette.length] ?? WEBGL_COLORS[i]));
|
|
358
|
+
gl.clearColor(0, 0, 0, 0);
|
|
359
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
360
|
+
gl.uniform2f(uResolution, canvas.width, canvas.height);
|
|
361
|
+
gl.uniform1f(uTime, reduce ? 0 : time);
|
|
362
|
+
gl.uniform1f(uSpeed, reduce ? 0 : 0.55);
|
|
363
|
+
gl.uniform2f(uLook, look.x, look.y);
|
|
364
|
+
gl.uniform1f(uBlink, b);
|
|
365
|
+
gl.uniform1f(uMode, resolved.mode);
|
|
366
|
+
gl.uniform3f(uBody, body[0], body[1], body[2]);
|
|
367
|
+
gl.uniform3f(uEye, eye[0], eye[1], eye[2]);
|
|
368
|
+
gl.uniform3f(uC1, palette[0][0], palette[0][1], palette[0][2]);
|
|
369
|
+
gl.uniform3f(uC2, palette[1][0], palette[1][1], palette[1][2]);
|
|
370
|
+
gl.uniform3f(uC3, palette[2][0], palette[2][1], palette[2][2]);
|
|
371
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
372
|
+
raf = requestAnimationFrame(tick);
|
|
373
|
+
};
|
|
374
|
+
raf = requestAnimationFrame(tick);
|
|
375
|
+
return {
|
|
376
|
+
setOptions (next) {
|
|
377
|
+
options = {
|
|
378
|
+
...options,
|
|
379
|
+
...next
|
|
380
|
+
};
|
|
381
|
+
},
|
|
382
|
+
destroy () {
|
|
383
|
+
running = false;
|
|
384
|
+
cancelAnimationFrame(raf);
|
|
385
|
+
ro.disconnect();
|
|
386
|
+
mqReduce.removeEventListener("change", onReduce);
|
|
387
|
+
window.removeEventListener("pointermove", onMove);
|
|
388
|
+
options.onHasGl?.(false);
|
|
389
|
+
gl.deleteProgram(program);
|
|
390
|
+
gl.deleteShader(vs);
|
|
391
|
+
gl.deleteShader(fs);
|
|
392
|
+
gl.deleteBuffer(buf);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Evenly lit sphere with two capsule eyes that follow the pointer.
|
|
398
|
+
* The orb stays put — only the gaze moves.
|
|
399
|
+
*/ export function LiveOrb({ className, size = 280, variant = "white", color, eyeColor, colors, interactive = true, blink = true }) {
|
|
400
|
+
const canvasRef = useRef(null);
|
|
401
|
+
const instanceRef = useRef(null);
|
|
402
|
+
const [hasGl, setHasGl] = useState(false);
|
|
403
|
+
useEffect(()=>{
|
|
404
|
+
const canvas = canvasRef.current;
|
|
405
|
+
if (!canvas) return;
|
|
406
|
+
instanceRef.current = createLiveOrb(canvas, {
|
|
407
|
+
variant,
|
|
408
|
+
color,
|
|
409
|
+
eyeColor,
|
|
410
|
+
colors,
|
|
411
|
+
interactive,
|
|
412
|
+
blink,
|
|
413
|
+
onHasGl: setHasGl
|
|
414
|
+
});
|
|
415
|
+
return ()=>{
|
|
416
|
+
instanceRef.current?.destroy();
|
|
417
|
+
instanceRef.current = null;
|
|
418
|
+
};
|
|
419
|
+
// Engine reads live options via setOptions; mount once.
|
|
420
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
421
|
+
}, []);
|
|
422
|
+
useEffect(()=>{
|
|
423
|
+
instanceRef.current?.setOptions({
|
|
424
|
+
variant,
|
|
425
|
+
color,
|
|
426
|
+
eyeColor,
|
|
427
|
+
colors,
|
|
428
|
+
interactive,
|
|
429
|
+
blink,
|
|
430
|
+
onHasGl: setHasGl
|
|
431
|
+
});
|
|
432
|
+
}, [
|
|
433
|
+
variant,
|
|
434
|
+
color,
|
|
435
|
+
eyeColor,
|
|
436
|
+
colors,
|
|
437
|
+
interactive,
|
|
438
|
+
blink
|
|
439
|
+
]);
|
|
440
|
+
const resolved = resolveVariant(variant, color, eyeColor, colors);
|
|
441
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
442
|
+
"data-slot": "live-orb",
|
|
443
|
+
role: "img",
|
|
444
|
+
"aria-label": "Orb character",
|
|
445
|
+
className: cn("relative shrink-0", className),
|
|
446
|
+
style: {
|
|
447
|
+
width: size,
|
|
448
|
+
height: size
|
|
449
|
+
},
|
|
450
|
+
children: [
|
|
451
|
+
!hasGl ? /*#__PURE__*/ _jsxs("div", {
|
|
452
|
+
"aria-hidden": true,
|
|
453
|
+
className: "absolute inset-[2%] overflow-hidden rounded-full",
|
|
454
|
+
style: fallbackFaceStyle(resolved),
|
|
455
|
+
children: [
|
|
456
|
+
/*#__PURE__*/ _jsx("span", {
|
|
457
|
+
className: "absolute rounded-full",
|
|
458
|
+
style: {
|
|
459
|
+
backgroundColor: resolved.eye,
|
|
460
|
+
width: "13%",
|
|
461
|
+
height: "28%",
|
|
462
|
+
left: "31%",
|
|
463
|
+
top: "34%"
|
|
464
|
+
}
|
|
465
|
+
}),
|
|
466
|
+
/*#__PURE__*/ _jsx("span", {
|
|
467
|
+
className: "absolute rounded-full",
|
|
468
|
+
style: {
|
|
469
|
+
backgroundColor: resolved.eye,
|
|
470
|
+
width: "13%",
|
|
471
|
+
height: "28%",
|
|
472
|
+
left: "56%",
|
|
473
|
+
top: "34%"
|
|
474
|
+
}
|
|
475
|
+
})
|
|
476
|
+
]
|
|
477
|
+
}) : null,
|
|
478
|
+
/*#__PURE__*/ _jsx("canvas", {
|
|
479
|
+
ref: canvasRef,
|
|
480
|
+
className: "absolute inset-0 size-full"
|
|
481
|
+
})
|
|
482
|
+
]
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
export default LiveOrb;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface PromptInputProps {
|
|
3
|
+
onSubmit?: (value: string, meta: {
|
|
4
|
+
model: string;
|
|
5
|
+
effort: string;
|
|
6
|
+
attachments: File[];
|
|
7
|
+
}) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
models?: string[];
|
|
11
|
+
efforts?: string[];
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
maxAttachments?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const PromptInput: React.ForwardRefExoticComponent<PromptInputProps & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export default PromptInput;
|
|
19
|
+
//# sourceMappingURL=prompt-input.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-input.component.d.ts","sourceRoot":"","sources":["../../src/assistant/prompt-input.component.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoS/B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,IAAI,EAAE,CAAA;KAAE,KACzD,IAAI,CAAC;IACV,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,yFA+pBvB,CAAC;AAIF,eAAe,WAAW,CAAC"}
|