@neo-ui-kit/react 1.3.14 → 1.3.16

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 CHANGED
@@ -4,6 +4,10 @@ Migration: replace `@ad-voice/ui` with `@neo-ui-kit/react` in dependencies and i
4
4
 
5
5
  NEO UI — React + TypeScript UI kit: glass/ruby surfaces, animated neon borders, fields, tabs, dialogs, audio controls and a melody editor.
6
6
 
7
+ ## 1.3.15
8
+
9
+ Animated borders use a shared WebGPU pipeline when available, combining the existing masks and glow textures in one pass. Rendering is limited to the moving lights. Canvas 2D and SVG remain fallback paths; speeds, colors and effects are retained. See the performance report for laptop measurements and pixel-comparison limits.
10
+
7
11
  ## 1.3.14
8
12
 
9
13
  Animated borders composite their moving lights in bounded buffers instead of repainting full-size intermediate surfaces. The same masks, glow textures, speeds and overlapping-light composition are preserved.
@@ -61,7 +65,7 @@ import "@neo-ui-kit/react/styles.css";
61
65
  To test repository changes before publishing, run `npm run package` from the repository root and install the resulting archive in a separate application:
62
66
 
63
67
  ```bash
64
- npm install /path/to/adui/release/neo-ui-kit-react-1.3.14.tgz
68
+ npm install /path/to/adui/release/neo-ui-kit-react-1.3.16.tgz
65
69
  ```
66
70
 
67
71
  Maintainers publish new versions from `Pro100Dimka/adui` using the `release.yml` GitHub Actions workflow, a matching `v<version>` tag, and the `npm-publication` environment. npm trusts its OIDC identity; no `NPM_TOKEN` is required. The workflow checks the project and packed consumer before publishing the tested archive. Published `1.0.0` cannot be overwritten: code and README changes in npm require a new package version. See the [repository release instructions](https://github.com/Pro100Dimka/adui#npm-пакет).
@@ -11,15 +11,158 @@ import {
11
11
 
12
12
  // src/core/border-worker.js
13
13
  function renderBorders() {
14
+ async function createGpuPainter() {
15
+ if (!navigator.gpu) return null;
16
+ const adapter = await navigator.gpu.requestAdapter();
17
+ if (!adapter) return null;
18
+ const device = await adapter.requestDevice();
19
+ const format = navigator.gpu.getPreferredCanvasFormat();
20
+ const shader = device.createShaderModule({ code: `
21
+ struct Uniforms { size: vec4f, canvas: vec4f, lights: vec4f, padding: vec4f };
22
+ @group(0) @binding(0) var<uniform> u: Uniforms;
23
+ @group(0) @binding(1) var linearSampler: sampler;
24
+ @group(0) @binding(2) var mask0: texture_2d<f32>;
25
+ @group(0) @binding(3) var glow0: texture_2d<f32>;
26
+ @group(0) @binding(4) var mask1: texture_2d<f32>;
27
+ @group(0) @binding(5) var glow1: texture_2d<f32>;
28
+ @vertex fn vertex(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
29
+ let positions = array<vec2f, 3>(vec2f(-1,-1), vec2f(3,-1), vec2f(-1,3));
30
+ return vec4f(positions[i], 0, 1);
31
+ }
32
+ fn spot(p: vec2f, origin: vec2f, texture: texture_2d<f32>) -> vec4f {
33
+ let uv = (p - origin) / (u.size.w * 2);
34
+ if (any(uv < vec2f(0)) || any(uv > vec2f(1))) { return vec4f(0); }
35
+ return textureSampleLevel(texture, linearSampler, uv, 0);
36
+ }
37
+ fn layer(p: vec2f, mask: texture_2d<f32>, glow: texture_2d<f32>) -> vec4f {
38
+ let alpha = textureSampleLevel(mask, linearSampler, p / u.size.xy, 0).a;
39
+ if (alpha == 0) { return vec4f(0); }
40
+ let first = spot(p, u.lights.xy, glow);
41
+ let second = spot(p, u.lights.zw, glow);
42
+ return (second + first * (1 - second.a)) * alpha;
43
+ }
44
+ fn filtered(q: vec2f, mask: texture_2d<f32>, glow: texture_2d<f32>) -> vec4f {
45
+ let base = floor(q - vec2f(.5)) + vec2f(.5);
46
+ let f = fract(q - vec2f(.5));
47
+ let a = layer(base / u.size.z, mask, glow);
48
+ let b = layer((base + vec2f(1,0)) / u.size.z, mask, glow);
49
+ let c = layer((base + vec2f(0,1)) / u.size.z, mask, glow);
50
+ let d = layer((base + vec2f(1,1)) / u.size.z, mask, glow);
51
+ return mix(mix(a,b,f.x),mix(c,d,f.x),f.y);
52
+ }
53
+ @fragment fn fragment(@builtin(position) p: vec4f) -> @location(0) vec4f {
54
+ let q = p.xy * u.canvas.xy / (u.size.xy * u.size.z);
55
+ let aura = filtered(q, mask0, glow0) * u.canvas.z;
56
+ let core = filtered(q, mask1, glow1) * u.canvas.w;
57
+ return core + aura * (1-core.a);
58
+ }
59
+ ` });
60
+ let pipeline;
61
+ try {
62
+ pipeline = await device.createRenderPipelineAsync({
63
+ layout: "auto",
64
+ vertex: { module: shader, entryPoint: "vertex" },
65
+ fragment: { module: shader, entryPoint: "fragment", targets: [{ format }] },
66
+ primitive: { topology: "triangle-list" }
67
+ });
68
+ } catch (error) {
69
+ device.destroy();
70
+ throw error;
71
+ }
72
+ const sampler = device.createSampler({ magFilter: "linear", minFilter: "linear" });
73
+ device.addEventListener("uncapturederror", (event) => {
74
+ throw event.error;
75
+ });
76
+ device.lost.then((info) => {
77
+ setTimeout(() => {
78
+ throw new Error(info.message || "Border GPU device lost");
79
+ });
80
+ });
81
+ return (scene) => {
82
+ const context = scene.canvas.getContext("webgpu");
83
+ context.configure({ device, format, alphaMode: "premultiplied" });
84
+ const textures = scene.layers.flatMap((layer) => [layer.mask, layer.texture]).map((image) => {
85
+ const texture = device.createTexture({
86
+ size: [image.width, image.height],
87
+ format: "rgba8unorm",
88
+ usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
89
+ });
90
+ device.queue.copyExternalImageToTexture({ source: image }, { texture, premultipliedAlpha: true }, [image.width, image.height]);
91
+ return texture;
92
+ });
93
+ const buffer = device.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
94
+ const values = new Float32Array(16);
95
+ values.set([
96
+ scene.width,
97
+ scene.height,
98
+ scene.dpr,
99
+ scene.radius,
100
+ scene.canvas.width,
101
+ scene.canvas.height,
102
+ scene.layers[0].opacity,
103
+ scene.layers[1].opacity
104
+ ]);
105
+ const bindGroup = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0), entries: [
106
+ { binding: 0, resource: { buffer } },
107
+ { binding: 1, resource: sampler },
108
+ ...textures.map((texture, index) => ({ binding: index + 2, resource: texture.createView() }))
109
+ ] });
110
+ return {
111
+ draw(current) {
112
+ current.lights.forEach((light, index) => {
113
+ const at = (light.phase + current.elapsed * light.speed / current.length) % 1 * 1024;
114
+ const lo = Math.floor(at), hi = (lo + 1) % 1024, weight = at - lo;
115
+ for (let axis = 0; axis < 2; axis++) values[8 + index * 2 + axis] = current.points[lo * 2 + axis] * (1 - weight) + current.points[hi * 2 + axis] * weight - current.radius + 16;
116
+ });
117
+ device.queue.writeBuffer(buffer, 0, values);
118
+ const encoder = device.createCommandEncoder();
119
+ const pass = encoder.beginRenderPass({ colorAttachments: [{
120
+ view: context.getCurrentTexture().createView(),
121
+ loadOp: "clear",
122
+ storeOp: "store",
123
+ clearValue: [0, 0, 0, 0]
124
+ }] });
125
+ pass.setPipeline(pipeline);
126
+ pass.setBindGroup(0, bindGroup);
127
+ for (let i = 0; i < 2; i++) {
128
+ const sx = current.width * current.dpr / current.canvas.width, sy = current.height * current.dpr / current.canvas.height;
129
+ const x = Math.max(0, Math.floor((values[8 + i * 2] * current.dpr - 2) * sx));
130
+ const y = Math.max(0, Math.floor((values[9 + i * 2] * current.dpr - 2) * sy));
131
+ const r = Math.min(current.canvas.width, Math.ceil(((values[8 + i * 2] + current.radius * 2) * current.dpr + 2) * sx));
132
+ const b = Math.min(current.canvas.height, Math.ceil(((values[9 + i * 2] + current.radius * 2) * current.dpr + 2) * sy));
133
+ if (r > x && b > y) {
134
+ pass.setScissorRect(x, y, r - x, b - y);
135
+ pass.draw(3);
136
+ }
137
+ }
138
+ pass.end();
139
+ device.queue.submit([encoder.finish()]);
140
+ },
141
+ dispose() {
142
+ context.unconfigure();
143
+ buffer.destroy();
144
+ textures.forEach((texture) => texture.destroy());
145
+ }
146
+ };
147
+ };
148
+ }
149
+ let gpu;
150
+ const pending = [];
151
+ onmessage = (event) => pending.push(event);
14
152
  const scenes = /* @__PURE__ */ new Map();
15
153
  let frame = null, fps = 60, last2 = -Infinity;
16
154
  const release = (scene) => {
155
+ scene.gpu?.dispose();
17
156
  for (const layer of scene.layers) {
18
157
  layer.mask.close();
19
158
  layer.texture.close();
20
159
  }
21
160
  };
22
161
  const draw = (scene) => {
162
+ if (scene.gpu) {
163
+ scene.gpu.draw(scene);
164
+ return;
165
+ }
23
166
  const { ctx, width, height, points, length, radius, dpr } = scene;
24
167
  const lights = scene.lights.map((light) => {
25
168
  const index = (light.phase + scene.elapsed * light.speed / length) % 1 * 1024;
@@ -89,7 +232,7 @@ function renderBorders() {
89
232
  }
90
233
  schedule2();
91
234
  }
92
- onmessage = ({ data }) => {
235
+ const receive = ({ data }) => {
93
236
  const scene = scenes.get(data.id);
94
237
  if (data.type === "rate") fps = data.fps;
95
238
  else if (data.type === "remove") {
@@ -105,15 +248,18 @@ function renderBorders() {
105
248
  const next = { ...data, canvas: scene?.canvas ?? data.canvas, elapsed: scene?.elapsed ?? data.elapsed, previous: null };
106
249
  next.canvas.width = Math.ceil(data.width * data.dpr);
107
250
  next.canvas.height = Math.ceil(data.height * data.dpr);
108
- next.ctx = next.canvas.getContext("2d");
109
- next.ctx.setTransform(data.dpr, 0, 0, data.dpr, 0, 0);
110
- for (const layer of next.layers) {
111
- layer.buffer = new OffscreenCanvas(
112
- Math.min(next.canvas.width, Math.ceil(next.radius * 4 * data.dpr) + 4),
113
- Math.min(next.canvas.height, Math.ceil(next.radius * 4 * data.dpr) + 4)
114
- );
115
- layer.ctx = layer.buffer.getContext("2d");
116
- layer.ctx.setTransform(data.dpr, 0, 0, data.dpr, 0, 0);
251
+ if (gpu) next.gpu = gpu(next);
252
+ else {
253
+ next.ctx = next.canvas.getContext("2d");
254
+ next.ctx.setTransform(data.dpr, 0, 0, data.dpr, 0, 0);
255
+ for (const layer of next.layers) {
256
+ layer.buffer = new OffscreenCanvas(
257
+ Math.min(next.canvas.width, Math.ceil(next.radius * 4 * data.dpr) + 4),
258
+ Math.min(next.canvas.height, Math.ceil(next.radius * 4 * data.dpr) + 4)
259
+ );
260
+ layer.ctx = layer.buffer.getContext("2d");
261
+ layer.ctx.setTransform(data.dpr, 0, 0, data.dpr, 0, 0);
262
+ }
117
263
  }
118
264
  scenes.set(data.id, next);
119
265
  draw(next);
@@ -121,6 +267,18 @@ function renderBorders() {
121
267
  }
122
268
  schedule2();
123
269
  };
270
+ createGpuPainter().catch((error) => {
271
+ console.warn("Border GPU initialization failed; using Canvas 2D", error);
272
+ return null;
273
+ }).then((value) => {
274
+ gpu = value;
275
+ onmessage = receive;
276
+ pending.splice(0).forEach(receive);
277
+ }).catch((error) => {
278
+ setTimeout(() => {
279
+ throw error;
280
+ });
281
+ });
124
282
  }
125
283
  var worker = null;
126
284
  var workerUrl = null;
@@ -2,7 +2,7 @@ import {
2
2
  themes,
3
3
  useBorder,
4
4
  usePauseOffscreen
5
- } from "./chunk-BHX5MDJL.js";
5
+ } from "./chunk-6VPAU3TV.js";
6
6
  import {
7
7
  assignRef,
8
8
  clamp,
@@ -19,9 +19,18 @@ html:has(.ad-dialog[open]) {
19
19
  }
20
20
  /* Pointer light: a soft glow under the cursor, painted over the window's own surface. */
21
21
  .ad.ad-dialog[data-ad-material] {
22
- background:
23
- radial-gradient(26rem circle at var(--ad-spot-x, -40rem) var(--ad-spot-y, -40rem), rgb(from var(--ad-primary) r g b / 0.11), transparent 60%),
24
- var(--ad-surface-dialog);
22
+ background: var(--ad-surface-dialog);
23
+ }
24
+ .ad-dialog-spotlight {
25
+ position: absolute;
26
+ left: -26rem;
27
+ top: -26rem;
28
+ width: 52rem;
29
+ height: 52rem;
30
+ z-index: -2;
31
+ pointer-events: none;
32
+ background: radial-gradient(26rem circle, rgb(from var(--ad-primary) r g b / 0.11), transparent 60%);
33
+ transform: translate3d(var(--ad-spot-x, -40rem), var(--ad-spot-y, -40rem), 0);
25
34
  }
26
35
  .ad-dialog > .ad-header {
27
36
  flex-wrap: nowrap;
@@ -18,23 +18,31 @@
18
18
  margin-bottom: var(--ad-space-3);
19
19
  }
20
20
  /* Pointer spotlight: a soft ruby light under the cursor, faded in on hover. */
21
- .ad-card::after {
22
- /* The pointer position is not inherited by default: the light reads it from its own card. */
21
+ .ad-card-light {
22
+ position: absolute;
23
+ inset: 0;
24
+ border-radius: inherit;
25
+ overflow: hidden;
26
+ opacity: 0;
27
+ transition: opacity 0.35s;
28
+ pointer-events: none;
29
+ }
30
+ .ad-card-light::before {
23
31
  --ad-spot-x: inherit;
24
32
  --ad-spot-y: inherit;
25
33
  content: "";
26
34
  position: absolute;
27
- inset: 0;
28
- border-radius: inherit;
35
+ width: 44rem;
36
+ height: 44rem;
37
+ left: var(--ad-spot-x, 50%);
38
+ top: var(--ad-spot-y, 0%);
39
+ transform: translate3d(-50%, -50%, 0);
29
40
  background: radial-gradient(
30
- 22rem circle at var(--ad-spot-x, 50%) var(--ad-spot-y, 0%),
41
+ 22rem circle,
31
42
  rgb(from var(--ad-primary) r g b / 0.08),
32
43
  transparent 60%
33
44
  );
34
- opacity: 0;
35
- transition: opacity 0.35s;
36
- pointer-events: none;
37
45
  }
38
- .ad-card:hover::after {
46
+ .ad-card:hover > .ad-card-light {
39
47
  opacity: 1;
40
48
  }
package/dist/core.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  useSmoothWheel,
12
12
  useTabShape,
13
13
  useTick
14
- } from "./chunks/chunk-BHX5MDJL.js";
14
+ } from "./chunks/chunk-6VPAU3TV.js";
15
15
  import {
16
16
  LocaleProvider,
17
17
  addMessages,
package/dist/forms.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  defaultFieldRegistry,
5
5
  useForm,
6
6
  useFormContext
7
- } from "./chunks/chunk-VEAA27XZ.js";
8
- import "./chunks/chunk-BHX5MDJL.js";
7
+ } from "./chunks/chunk-TMCWA446.js";
8
+ import "./chunks/chunk-6VPAU3TV.js";
9
9
  import "./chunks/chunk-BJSFN52W.js";
10
10
  import "./chunks/chunk-FCOU3ODR.js";
11
11
  export {
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ import {
62
62
  useSvgId,
63
63
  variantMaterial,
64
64
  vectorElement
65
- } from "./chunks/chunk-VEAA27XZ.js";
65
+ } from "./chunks/chunk-TMCWA446.js";
66
66
  import {
67
67
  ThemeProvider,
68
68
  createNeonRenderer,
@@ -79,7 +79,7 @@ import {
79
79
  useTabShape,
80
80
  useThemePalette,
81
81
  useTick
82
- } from "./chunks/chunk-BHX5MDJL.js";
82
+ } from "./chunks/chunk-6VPAU3TV.js";
83
83
  import {
84
84
  LocaleProvider,
85
85
  addMessages,
@@ -315,6 +315,7 @@ var Card = ({
315
315
  ...p
316
316
  }) => {
317
317
  const ref = useRef(null);
318
+ const spotlight = useRef(null);
318
319
  useBorder(ref, border, shell);
319
320
  usePauseOffscreen(ref);
320
321
  return createElement3(
@@ -330,12 +331,14 @@ var Card = ({
330
331
  "data-ad-padding": padding,
331
332
  // A soft light follows the pointer across the surface.
332
333
  onPointerMove: (event) => {
334
+ const style = spotlight.current?.style;
335
+ if (!style) return;
333
336
  const box = event.currentTarget.getBoundingClientRect();
334
- event.currentTarget.style.setProperty(
337
+ style.setProperty(
335
338
  "--ad-spot-x",
336
339
  `${event.clientX - box.left}px`
337
340
  );
338
- event.currentTarget.style.setProperty(
341
+ style.setProperty(
339
342
  "--ad-spot-y",
340
343
  `${event.clientY - box.top}px`
341
344
  );
@@ -353,7 +356,8 @@ var Card = ({
353
356
  compact: level > 2
354
357
  }
355
358
  ),
356
- children
359
+ children,
360
+ createElement3("span", { ref: spotlight, className: "ad-card-light", "aria-hidden": true })
357
361
  );
358
362
  };
359
363
 
@@ -2865,7 +2869,7 @@ var Dialog = (p) => {
2865
2869
  p.defaultOpen ?? false,
2866
2870
  p.onOpenChange
2867
2871
  ), [pending, setPending] = useState5(false), [error, setError] = useState5();
2868
- const ref = useRef10(null), confirmation = useRef10(0), confirming = useRef10(false), pressedOutside = useRef10(false), titleId = useId(), descId = useId();
2872
+ const ref = useRef10(null), spotlight = useRef10(null), confirmation = useRef10(0), confirming = useRef10(false), pressedOutside = useRef10(false), titleId = useId(), descId = useId();
2869
2873
  useLayoutEffect2(() => {
2870
2874
  confirming.current = false;
2871
2875
  setPending(false);
@@ -2911,13 +2915,15 @@ var Dialog = (p) => {
2911
2915
  pressedOutside.current = false;
2912
2916
  },
2913
2917
  onPointerMove: (e) => {
2918
+ const style = spotlight.current?.style;
2919
+ if (!style) return;
2914
2920
  const box = e.currentTarget.getBoundingClientRect();
2915
- e.currentTarget.style.setProperty("--ad-spot-x", `${e.clientX - box.left}px`);
2916
- e.currentTarget.style.setProperty("--ad-spot-y", `${e.clientY - box.top}px`);
2921
+ style.setProperty("--ad-spot-x", `${e.clientX - box.left}px`);
2922
+ style.setProperty("--ad-spot-y", `${e.clientY - box.top}px`);
2917
2923
  },
2918
- onPointerLeave: (e) => {
2919
- e.currentTarget.style.removeProperty("--ad-spot-x");
2920
- e.currentTarget.style.removeProperty("--ad-spot-y");
2924
+ onPointerLeave: () => {
2925
+ spotlight.current?.style.removeProperty("--ad-spot-x");
2926
+ spotlight.current?.style.removeProperty("--ad-spot-y");
2921
2927
  },
2922
2928
  "aria-describedby": p.description ? descId : void 0,
2923
2929
  onCancel: (e) => {
@@ -2925,6 +2931,7 @@ var Dialog = (p) => {
2925
2931
  if (!pending) setOpen(false);
2926
2932
  },
2927
2933
  children: [
2934
+ /* @__PURE__ */ jsx23("span", { ref: spotlight, className: "ad-dialog-spotlight", "aria-hidden": "true" }),
2928
2935
  p.art && /* @__PURE__ */ jsx23("div", { className: "ad-dialog-art", "aria-hidden": "true", children: p.art }),
2929
2936
  /* @__PURE__ */ jsx23(
2930
2937
  Header,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo-ui-kit/react",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
4
4
  "description": "NEO UI — React component library",
5
5
  "type": "module",
6
6
  "license": "MIT",