lensfx 0.1.1 → 0.1.3

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 CHANGED
@@ -1,53 +1,69 @@
1
- # Changelog
2
-
3
- All notable changes to `lensfx` will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.1.1] - 2026-10-17
9
-
10
- ### Added
11
-
12
- #### Engine Layer (`lensfx`)
13
- - Pure mathematical optics engine:
14
- - Error function (`erf`) calculation for Gaussian surface profiles.
15
- - Optical dome constant calculation (`computeDomeConstants`).
16
- - Radial gradient generation for spherical dome profiles (`domeGradient`).
17
- - SVG `feColorMatrix` calculation for aspect ratio corrections (`colorMatrixValues`).
18
- - SVG mask URI generation for rounded-rectangle lens clipping (`getSvgMaskDataUri`).
19
- - Real-time and asynchronous displacement map generator (`createDisplacementMapGeneratorSync`, `generateDisplacementMapAsync`).
20
- - Pre-calibrated lens optical constants (`SWITCH_GLASS_DEFAULTS`, `SLIDER_GLASS_DEFAULTS`, dark/light theme overrides).
21
-
22
- #### Primitives Layer
23
- - `<Lens>` unstyled behavioral glass component:
24
- - SVG `feDisplacementMap` real-time DOM refraction (preserves text selection, pointer events, form inputs).
25
- - Chromatic aberration separation (red, green, blue optical channels).
26
- - Multi-lens context support (`Lens.General` / `Lens.Group`) for sharing one background across multiple moving lenses.
27
- - Offscreen generation pausing (`pauseOffscreen`) via `IntersectionObserver`.
28
- - Motion value interpolation for 60fps gesture and scroll-driven physics via Framer Motion.
29
-
30
- #### Components Layer
31
- - `<LensSwitch>` accessible glass toggle switch with spring physics, keyboard support (Space / Enter), and full controlled/uncontrolled state.
32
- - `<LensSlider>` accessible optical glass range slider with tick quantization, track fill refraction, and thumb dome physics.
33
- - `<LensToggleGroup>` segmented radio control with real-time sliding optical lens and glowing active indicator.
34
-
35
- #### WebGL Layer
36
- - `VideoRefractionRenderer` WebGL 1 shader fallback for live HTML5 `<video>` elements on WebKit / Safari.
37
- - `QRRefractionRenderer` WebGL 2 (#version 300 es) interactive QR code refraction engine with O(1) uniform texture lookup.
38
-
39
- #### Design Tokens
40
- - Design token stylesheet `lensfx/styles` (`dist/lensfx.css`) providing namespaced CSS custom properties (`--lensfx-*`) for colors, radii, shadows, animations, auto dark-mode (`prefers-color-scheme`), and accessibility (`prefers-reduced-motion`, `:focus-visible`).
41
-
42
- #### Developer Experience & Tooling
43
- - Dual ESM and CJS bundle output with TypeScript declarations (`tsup`).
44
- - `"use client"` directive injection for Next.js App Router (RSC) compatibility.
45
- - Tree-shaking enabled with `sideEffects: ["*.css"]`.
46
- - Comprehensive Vitest unit & integration test suite (50 tests covering pure math, switch, slider, and toggle group).
47
- - Size-limit bundle gate (core engine < 10 kB, full library < 80 kB).
48
- - GitHub Actions CI workflow for type checking, testing, building, and bundle size tracking.
49
-
50
- ## [0.1.0] - 2026-10-16
51
-
52
- ### Added
53
- - Initial experimental release of reverse-engineered glass simulation engine.
1
+ # Changelog
2
+
3
+ All notable changes to `lensfx` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.3] - 2026-10-17
9
+
10
+ ### Added
11
+ - Zero-dependency vanilla DOM engine: `createLens(target, options)` with real-time SVG displacement, chromatic aberration, pointer tracking (`interactive: true`), responsive auto-resizing via `ResizeObserver`, and dynamic lifecycle controls (`setPosition`, `update`, `destroy`).
12
+ - Standalone CDN IIFE builds (`dist/cdn/lensfx.min.js` and `dist/cdn/lensfx.js`) attaching to `window.lensfx` for direct `<script>` tag usage without bundlers or React.
13
+ - Subpath exports `"lensfx/vanilla"` and `"lensfx/cdn"` in `package.json`.
14
+ - Standard CDN distribution fields (`unpkg`, `jsdelivr`) pointing to `dist/cdn/lensfx.min.js`.
15
+ - Made peer dependencies (`react`, `react-dom`, `framer-motion`) optional for vanilla JS consumers.
16
+ - Live standalone CDN showcase demo (`examples/cdn-demo.html`).
17
+
18
+ ## [0.1.2] - 2026-10-17
19
+
20
+ ### Changed
21
+ - Refined package description and registry metadata to emphasize clean optical physics, real DOM refraction, and SVG filter mechanics.
22
+ - Cleaned up internal documentation and comments across engine and primitive layers.
23
+
24
+ ## [0.1.1] - 2026-10-17
25
+
26
+ ### Added
27
+
28
+ #### Engine Layer (`lensfx`)
29
+ - Pure mathematical optics engine:
30
+ - Error function (`erf`) calculation for Gaussian surface profiles.
31
+ - Optical dome constant calculation (`computeDomeConstants`).
32
+ - Radial gradient generation for spherical dome profiles (`domeGradient`).
33
+ - SVG `feColorMatrix` calculation for aspect ratio corrections (`colorMatrixValues`).
34
+ - SVG mask URI generation for rounded-rectangle lens clipping (`getSvgMaskDataUri`).
35
+ - Real-time and asynchronous displacement map generator (`createDisplacementMapGeneratorSync`, `generateDisplacementMapAsync`).
36
+ - Pre-calibrated lens optical constants (`SWITCH_GLASS_DEFAULTS`, `SLIDER_GLASS_DEFAULTS`, dark/light theme overrides).
37
+
38
+ #### Primitives Layer
39
+ - `<Lens>` unstyled behavioral glass component:
40
+ - SVG `feDisplacementMap` real-time DOM refraction (preserves text selection, pointer events, form inputs).
41
+ - Chromatic aberration separation (red, green, blue optical channels).
42
+ - Multi-lens context support (`Lens.General` / `Lens.Group`) for sharing one background across multiple moving lenses.
43
+ - Offscreen generation pausing (`pauseOffscreen`) via `IntersectionObserver`.
44
+ - Motion value interpolation for 60fps gesture and scroll-driven physics via Framer Motion.
45
+
46
+ #### Components Layer
47
+ - `<LensSwitch>` accessible glass toggle switch with spring physics, keyboard support (Space / Enter), and full controlled/uncontrolled state.
48
+ - `<LensSlider>` accessible optical glass range slider with tick quantization, track fill refraction, and thumb dome physics.
49
+ - `<LensToggleGroup>` segmented radio control with real-time sliding optical lens and glowing active indicator.
50
+
51
+ #### WebGL Layer
52
+ - `VideoRefractionRenderer` WebGL 1 shader fallback for live HTML5 `<video>` elements on WebKit / Safari.
53
+ - `QRRefractionRenderer` WebGL 2 (#version 300 es) interactive QR code refraction engine with O(1) uniform texture lookup.
54
+
55
+ #### Design Tokens
56
+ - Design token stylesheet `lensfx/styles` (`dist/lensfx.css`) providing namespaced CSS custom properties (`--lensfx-*`) for colors, radii, shadows, animations, auto dark-mode (`prefers-color-scheme`), and accessibility (`prefers-reduced-motion`, `:focus-visible`).
57
+
58
+ #### Developer Experience & Tooling
59
+ - Dual ESM and CJS bundle output with TypeScript declarations (`tsup`).
60
+ - `"use client"` directive injection for Next.js App Router (RSC) compatibility.
61
+ - Tree-shaking enabled with `sideEffects: ["*.css"]`.
62
+ - Comprehensive Vitest unit & integration test suite (50 tests covering pure math, switch, slider, and toggle group).
63
+ - Size-limit bundle gate (core engine < 10 kB, full library < 80 kB).
64
+ - GitHub Actions CI workflow for type checking, testing, building, and bundle size tracking.
65
+
66
+ ## [0.1.0] - 2026-10-16
67
+
68
+ ### Added
69
+ - Initial experimental release of optical glass refraction engine.
package/README.md CHANGED
@@ -67,6 +67,45 @@ That's it. Zero configuration for a working lens.
67
67
 
68
68
  ---
69
69
 
70
+ ### Vanilla JS / Static HTML (via CDN — No React, No Bundler)
71
+
72
+ You don't need npm, React, or a bundler. Drop a `<script>` tag into any static `.html` file:
73
+
74
+ ```html
75
+ <!-- jsDelivr (always latest) -->
76
+ <script src="https://cdn.jsdelivr.net/npm/lensfx/dist/cdn/lensfx.min.js"></script>
77
+
78
+ <!-- or unpkg -->
79
+ <!-- <script src="https://unpkg.com/lensfx/dist/cdn/lensfx.min.js"></script> -->
80
+
81
+ <div id="card" style="width: 400px; height: 300px; position: relative;">
82
+ <h2>Refracted content</h2>
83
+ </div>
84
+
85
+ <script>
86
+ const lens = lensfx.createLens("#card", {
87
+ width: 200,
88
+ height: 120,
89
+ radius: 28,
90
+ depth: 2.5,
91
+ chroma: 0.7,
92
+ interactive: true, // tracks cursor automatically
93
+ });
94
+
95
+ // Dynamic API
96
+ // lens.setPosition(x, y);
97
+ // lens.update({ depth: 3 });
98
+ // lens.destroy();
99
+ </script>
100
+ ```
101
+
102
+ Or import the zero-dependency vanilla engine via npm:
103
+ ```ts
104
+ import { createLens } from "lensfx/vanilla";
105
+ ```
106
+
107
+ ---
108
+
70
109
  ## Components
71
110
 
72
111
  ### `<Lens>` — primitive (unstyled)