use-scroll-animate 5.8.0 → 6.0.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 +31 -0
- package/README.md +3 -2
- package/README_ja.md +1 -0
- package/README_zh.md +2 -1
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/components/angular.d.cts +5 -3
- package/dist/components/angular.d.ts +5 -3
- package/dist/components/click.cjs +2 -4
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.d.cts +3 -8
- package/dist/components/click.d.ts +3 -8
- package/dist/components/click.js +3 -2
- package/dist/components/click.js.map +1 -1
- package/dist/components/effects.cjs +306 -1
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.d.cts +66 -2
- package/dist/components/effects.d.ts +66 -2
- package/dist/components/effects.js +303 -2
- package/dist/components/effects.js.map +1 -1
- package/dist/components/fx.cjs +2 -2
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.js +2 -2
- package/dist/components/fx.js.map +1 -1
- package/dist/components/lite.cjs +9 -10
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +10 -8
- package/dist/components/lite.js.map +1 -1
- package/dist/components/page.cjs +6 -5
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.css +1 -1
- package/dist/components/page.d.cts +4 -3
- package/dist/components/page.d.ts +4 -3
- package/dist/components/page.js +6 -5
- package/dist/components/page.js.map +1 -1
- package/dist/components/solid.d.cts +5 -3
- package/dist/components/solid.d.ts +5 -3
- package/dist/components/svelte.d.cts +5 -3
- package/dist/components/svelte.d.ts +5 -3
- package/dist/components/vue.d.cts +5 -3
- package/dist/components/vue.d.ts +5 -3
- package/dist/components.cjs +2 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.d.cts +7 -11
- package/dist/components.d.ts +7 -11
- package/dist/components.js +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/ROADMAP.md +12 -12
- package/docs/components.md +29 -3
- package/docs/deprecations.md +4 -0
- package/docs/performance.md +1 -1
- package/docs/upgrading-6.md +32 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [6.0.0] - 2026-10-08
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
- **Removed `burst()`, `confetti()`, `shake()`** from `use-scroll-animate/components`, `/components/click` and the UMD global (deprecated in 5.9). Play the registered effects instead: `playEffect(document.body, 'burst', { x, y, …options })`, `playEffect(el, 'confetti', options)`, `playEffect(el, 'shake', { intensity, duration })` (`use-scroll-animate/components/fx`). `haptic()` stays.
|
|
14
|
+
- **Removed `<usa-cursor mode="trail">`** (deprecated in 5.9): `CURSOR_MODES` is now `dot` · `magnetic` · `glow`, and an unknown mode renders as `dot`. Use the 5.7 `comet-trail` effect: `<usa-fx effect="comet-trail" trigger="load" self>…</usa-fx>`.
|
|
15
|
+
- Every effect now goes through the 5.0 registry (`registerEffect()` / `playEffect()` / `bindEffect()` / `<usa-fx>`); the 5.1–5.9 packs live in `use-scroll-animate/components/effects`.
|
|
16
|
+
|
|
17
|
+
### Migration
|
|
18
|
+
- `npx usa-codemod-6 --write src` rewrites the helper calls and imports (aliases and the `UsaComponents` global included) and lists `<usa-cursor mode="trail">` for a manual edit. Guide: `docs/upgrading-6.md`.
|
|
19
|
+
- CDN URLs move to the `@6` range: `https://unpkg.com/use-scroll-animate@6/dist/components.umd.js`.
|
|
20
|
+
|
|
21
|
+
### Docs
|
|
22
|
+
- README (EN / 中文 / 日本語): new **Effect packs** (`/components/effects`) row.
|
|
23
|
+
- `docs/ROADMAP.md`: post-6.0 roadmap (v6.1 → v7.0).
|
|
24
|
+
|
|
25
|
+
## [5.9.0] - 2026-10-08
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- **`<usa-player>`** (`use-scroll-animate/components/effects`, `definePlayer()`) — plays JSON animations (`format: "use-scroll-animate/animation"`, `version: 1`): tracks with a `target` selector, `start` / `duration`, and a timeline `preset`, your own `keyframes` + `easing`, or any registered `effect` fired at `start`. Source: `src="…json"` or an inline `<script type="application/json">`. `trigger="load | view | scroll | click | manual"` (`scroll` scrubs with the page), `loop`, `rate`, `controls`; methods `play()`, `pause()`, `seek(ms)`, `load(json)`; events `usa-player-ready`, `usa-player-finish`; `data-error` on bad input.
|
|
29
|
+
- `createPlayer(root, animation, { autoplay, loop, rate })` → `{ play, pause, seek, rate, duration, currentTime, playing, finished, destroy }` — keyframe tracks are WAAPI animations driven by one clock; `normalizeAnimation()` validates (and reads Playground presets too).
|
|
30
|
+
- Playground: new **`<usa-player> JSON`** export tab (`tracksToAnimation()`).
|
|
31
|
+
- The registered `burst` effect accepts `x` / `y`.
|
|
32
|
+
- `docs/upgrading-6.md` and **`npx usa-codemod-6 [--write] [paths]`**.
|
|
33
|
+
|
|
34
|
+
### Deprecated (removed in 6.0 — warned once in the console)
|
|
35
|
+
- `burst()`, `confetti()`, `shake()` (components / components/click entries, UMD global) → `playEffect(el, 'burst' | 'confetti' | 'shake', …)` — the codemod rewrites calls and imports.
|
|
36
|
+
- `<usa-cursor mode="trail">` → the 5.7 `comet-trail` effect (`<usa-fx effect="comet-trail" trigger="load" self>`) — reported by the codemod for a manual edit.
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
- Under reduced motion `<usa-player>` jumps to the final state and fires no effects.
|
|
40
|
+
|
|
10
41
|
## [5.8.0] - 2026-10-08
|
|
11
42
|
|
|
12
43
|
### Added
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ defineComponents(); // or per category: import { defineTextComponents } from 'us
|
|
|
39
39
|
|
|
40
40
|
```html
|
|
41
41
|
<!-- or with no build step -->
|
|
42
|
-
<script src="https://unpkg.com/use-scroll-animate@
|
|
42
|
+
<script src="https://unpkg.com/use-scroll-animate@6/dist/components.umd.js"></script>
|
|
43
43
|
<usa-typewriter words="Hello, Windows.|Hello, web."></usa-typewriter>
|
|
44
44
|
<usa-spinner kind="fluent"></usa-spinner>
|
|
45
45
|
```
|
|
@@ -54,7 +54,7 @@ defineComponents(); // or per category: import { defineTextComponents } from 'us
|
|
|
54
54
|
| **Transitions** (`/components/transitions`) | `<usa-dialog>` (modal / drawer / sheet) · `<usa-accordion>` · `<usa-view-switch>` · `viewTransition()` · `flip()` |
|
|
55
55
|
| **Spring & physics** (`/components/physics`) | `<usa-spring>` (bounce-in · pop · drop · jelly · rubber-band) · `<usa-draggable>` (spring-back · inertia · snap) · `<usa-overscroll>` · `spring()` · `createSpring()` · `SPRING_PRESETS` |
|
|
56
56
|
| **Card effects** (`/components/cards`) | `<usa-card>` (flip · holo · glass · border-glow · conic-border · lift · spotlight · sheen · parallax-layers · expand — combinable) · `<usa-card-stack>` (swipe) · `<usa-sticky-stack>` · `<usa-carousel-3d>` |
|
|
57
|
-
| **Click & tap** (`/components/click`) | `<usa-button>` **button click deformation** (squash · wobble · gooey · dent · shape morph · submit→loading→success) · `<usa-icon-morph>` · `<usa-click>` (ripple · burst · confetti · squish · press-spring · shake) · `<usa-like>` · `<usa-hold>` · `<usa-double-tap>` · `<usa-checkbox>` · `
|
|
57
|
+
| **Click & tap** (`/components/click`) | `<usa-button>` **button click deformation** (squash · wobble · gooey · dent · shape morph · submit→loading→success) · `<usa-icon-morph>` · `<usa-click>` (ripple · burst · confetti · squish · press-spring · shake) · `<usa-like>` · `<usa-hold>` · `<usa-double-tap>` · `<usa-checkbox>` · `haptic()` (click effects from code: `playEffect(el, 'confetti')`) |
|
|
58
58
|
| **UI components & variants** (`/components/ui`) | `<usa-tabs>` · `<usa-drawer>` · `<usa-bottom-sheet>` · `<usa-pull-refresh>` · `<usa-fab>` · `<usa-navbar>` · `<usa-slider>` · `<usa-rating>` · `<usa-tooltip>` · `<usa-popover>` · `<usa-badge>` · `<usa-avatar-stack>` · `variant="minimal \| neon \| glass \| brutalist \| fluent \| material"` on every component |
|
|
59
59
|
| **Page & app-wide** (`/components/page`) | `pageTransition()` (fade · slide · circle · blinds · pixel · zoom; SPA + MPA) · `themeTransition()` · `<usa-cursor>` · `smoothScroll()` · `<usa-fullpage>` · `<usa-loading-bar>` · `<usa-back-to-top>` · `<usa-ambient>` (particles · snow · stars · noise · gradient) · `<usa-splash>` · `<usa-auto-skeleton>` · `<usa-motion-switch>` / `setMotionIntensity()` |
|
|
60
60
|
| **Timeline & choreography** (`/components/timeline`) | `timeline()` (chain · overlap · labels · seek · reverse · scrub) · `<usa-timeline>` (`data-tl` steps) |
|
|
@@ -65,6 +65,7 @@ defineComponents(); // or per category: import { defineTextComponents } from 'us
|
|
|
65
65
|
| **Layout animation** (`/components/layout`) | `<usa-auto-animate>` / `autoAnimate()` (list & grid reflow) · `<usa-masonry>` · `sharedTransition()` (shared elements) |
|
|
66
66
|
| **Effect packs** (`/components/packs`) | `<usa-pack>` (`name="ecommerce \| portfolio \| dashboard \| game \| landing"`) · `applyPack()` · `flyToCart()` · `countUp()` |
|
|
67
67
|
| **Effects — plugin API** (`/components/fx`) | `<usa-fx>` (`effect` · `trigger` click / hover / enter / load / loop) · `registerEffect()` · `playEffect()` · `bindEffect()` · built-ins: every timeline entrance, pulse · pop · jelly · wiggle · heartbeat · bounce · flash · tada · shake, burst · confetti · ripple |
|
|
68
|
+
| **Effect packs** (`/components/effects`) | `registerAllEffects()` · card & click 2.0 · physics · page-wide · `<usa-story>` scroll stories · generative backgrounds · sound-reactive (`<usa-audio>`) · cursor trails & gestures (`<usa-gesture-fx>`) · theme packs (`<usa-theme>`) · 23 micro-interactions · `<usa-player>` JSON animations |
|
|
68
69
|
|
|
69
70
|
Whole bundle ≈ 22 kB gzip (JS + CSS); one category 3.5–6.4 kB; a single component ≈ 2 kB. The scroll-animation core below is unaffected.
|
|
70
71
|
|
package/README_ja.md
CHANGED
|
@@ -53,6 +53,7 @@ defineComponents(); // カテゴリ単位: import { defineTextComponents } from
|
|
|
53
53
|
| **レイアウト** (`/components/layout`) | `<usa-auto-animate>` / `autoAnimate()` · `<usa-masonry>` · `sharedTransition()`(共有要素) |
|
|
54
54
|
| **エフェクトパック** (`/components/packs`) | `<usa-pack>` (`name="ecommerce \| portfolio \| dashboard \| game \| landing"`) · `applyPack()` · `flyToCart()` |
|
|
55
55
|
| **エフェクト API** (`/components/fx`) | `<usa-fx>` · `registerEffect()` · `playEffect()` · `bindEffect()` · 内蔵: タイムライン入場、pulse · pop · jelly · wiggle · bounce · tada · shake、burst · confetti · ripple |
|
|
56
|
+
| **エフェクトパック** (`/components/effects`) | `registerAllEffects()` · カード & クリック 2.0 · 物理 · ページ全体 · `<usa-story>` スクロールストーリー · ジェネレーティブ背景 · サウンド連動(`<usa-audio>`)· カーソル & ジェスチャー(`<usa-gesture-fx>`)· テーマパック(`<usa-theme>`)· マイクロインタラクション 23 種 · `<usa-player>` JSON アニメーション |
|
|
56
57
|
|
|
57
58
|
## ドキュメント
|
|
58
59
|
|
package/README_zh.md
CHANGED
|
@@ -36,7 +36,7 @@ defineComponents(); // 或按分类:import { defineTextComponents } from 'use-
|
|
|
36
36
|
|
|
37
37
|
```html
|
|
38
38
|
<!-- 或免构建直接使用 -->
|
|
39
|
-
<script src="https://unpkg.com/use-scroll-animate@
|
|
39
|
+
<script src="https://unpkg.com/use-scroll-animate@6/dist/components.umd.js"></script>
|
|
40
40
|
<usa-typewriter words="你好,Windows。|你好,Web。"></usa-typewriter>
|
|
41
41
|
<usa-spinner kind="fluent"></usa-spinner>
|
|
42
42
|
```
|
|
@@ -62,6 +62,7 @@ defineComponents(); // 或按分类:import { defineTextComponents } from 'use-
|
|
|
62
62
|
| **布局动画** (`/components/layout`) | `<usa-auto-animate>` / `autoAnimate()`(列表与网格重排)· `<usa-masonry>`(瀑布流)· `sharedTransition()`(共享元素) |
|
|
63
63
|
| **效果包** (`/components/packs`) | `<usa-pack>` (`name="ecommerce \| portfolio \| dashboard \| game \| landing"`) · `applyPack()` · `flyToCart()` · `countUp()` |
|
|
64
64
|
| **特效插件 API** (`/components/fx`) | `<usa-fx>`(`effect` · `trigger`)· `registerEffect()` · `playEffect()` · `bindEffect()` · 内置:全部时间线入场、pulse · pop · jelly · wiggle · heartbeat · bounce · flash · tada · shake、burst · confetti · ripple |
|
|
65
|
+
| **特效包** (`/components/effects`) | `registerAllEffects()` · 卡片与点击 2.0 · 物理 · 全页特效 · `<usa-story>` 滚动叙事 · 生成式背景 · 声音响应(`<usa-audio>`)· 光标拖尾与手势(`<usa-gesture-fx>`)· 主题包(`<usa-theme>`)· 23 个微交互 · `<usa-player>` JSON 动画 |
|
|
65
66
|
|
|
66
67
|
完整包约 22 kB gzip(JS + CSS);单个分类 3.5–6.4 kB;单个组件约 2 kB。下方的滚动动画核心不受影响。
|
|
67
68
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// use-scroll-animate 5.x → 6.0 codemod.
|
|
3
|
+
// npx usa-codemod-6 [--write] [paths…] (default: ./src; dry run without --write)
|
|
4
|
+
// Rewrites (5.9 deprecations, removed in 6.0 — every effect goes through the registry):
|
|
5
|
+
// 1. burst(x, y[, opts]) → playEffect(document.body, 'burst', { x: x, y: y[, ...opts] })
|
|
6
|
+
// 2. confetti([opts]) → playEffect(document.body, 'confetti'[, opts])
|
|
7
|
+
// 3. shake(el[, i[, d]]) → playEffect(el, 'shake'[, { intensity: i[, duration: d] }])
|
|
8
|
+
// …and the import of burst / confetti / shake from use-scroll-animate/components[/click]
|
|
9
|
+
// becomes `import { playEffect } from 'use-scroll-animate/components/fx'`.
|
|
10
|
+
// Reported for a manual change (no safe rewrite):
|
|
11
|
+
// 4. <usa-cursor mode="trail"> → <usa-fx effect="comet-trail" trigger="load" self> around the content
|
|
12
|
+
import { readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs';
|
|
13
|
+
import { join, extname } from 'node:path';
|
|
14
|
+
import { pathToFileURL } from 'node:url';
|
|
15
|
+
|
|
16
|
+
const EXT = new Set(['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.mts', '.cts', '.vue', '.svelte', '.html', '.astro']);
|
|
17
|
+
const OLD = ['burst', 'confetti', 'shake'];
|
|
18
|
+
|
|
19
|
+
/** Split a call's argument list at top-level commas (pure). */
|
|
20
|
+
export function splitArgs(s) {
|
|
21
|
+
const out = [];
|
|
22
|
+
let depth = 0;
|
|
23
|
+
let cur = '';
|
|
24
|
+
let q = '';
|
|
25
|
+
for (let i = 0; i < s.length; i++) {
|
|
26
|
+
const c = s[i];
|
|
27
|
+
if (q) {
|
|
28
|
+
cur += c;
|
|
29
|
+
if (c === '\\') cur += s[++i] ?? '';
|
|
30
|
+
else if (c === q) q = '';
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (c === '"' || c === "'" || c === '`') q = c;
|
|
34
|
+
else if ('([{'.includes(c)) depth++;
|
|
35
|
+
else if (')]}'.includes(c)) depth--;
|
|
36
|
+
if (c === ',' && depth === 0) {
|
|
37
|
+
out.push(cur.trim());
|
|
38
|
+
cur = '';
|
|
39
|
+
} else cur += c;
|
|
40
|
+
}
|
|
41
|
+
if (cur.trim()) out.push(cur.trim());
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Find `name(` calls and their balanced argument text. */
|
|
46
|
+
function rewriteCalls(code, name, fn, changes) {
|
|
47
|
+
const re = new RegExp(`(?<![\\w.$])${name}\\(`, 'g');
|
|
48
|
+
let out = '';
|
|
49
|
+
let last = 0;
|
|
50
|
+
let m;
|
|
51
|
+
while ((m = re.exec(code))) {
|
|
52
|
+
const start = m.index;
|
|
53
|
+
let i = re.lastIndex;
|
|
54
|
+
let depth = 1;
|
|
55
|
+
let q = '';
|
|
56
|
+
for (; i < code.length && depth; i++) {
|
|
57
|
+
const c = code[i];
|
|
58
|
+
if (q) {
|
|
59
|
+
if (c === '\\') i++;
|
|
60
|
+
else if (c === q) q = '';
|
|
61
|
+
} else if (c === '"' || c === "'" || c === '`') q = c;
|
|
62
|
+
else if (c === '(') depth++;
|
|
63
|
+
else if (c === ')') depth--;
|
|
64
|
+
}
|
|
65
|
+
if (depth) break;
|
|
66
|
+
const args = splitArgs(code.slice(re.lastIndex, i - 1));
|
|
67
|
+
const rep = fn(args);
|
|
68
|
+
if (rep == null) continue;
|
|
69
|
+
out += code.slice(last, start) + rep;
|
|
70
|
+
last = i;
|
|
71
|
+
re.lastIndex = i;
|
|
72
|
+
changes.push(`${name.replace('\\', '')}() → playEffect(…)`);
|
|
73
|
+
}
|
|
74
|
+
return out + code.slice(last);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const objOf = (pairs, rest) => {
|
|
78
|
+
const lit = rest && /^\{[\s\S]*\}$/.test(rest) ? rest.slice(1, -1).trim() : '';
|
|
79
|
+
const tail = rest ? [lit || `...${rest}`] : [];
|
|
80
|
+
return `{ ${[...pairs.filter(([, v]) => v !== undefined).map(([k, v]) => (k === v ? k : `${k}: ${v}`)), ...tail].filter(Boolean).join(', ')} }`;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** Apply every rewrite to one file's source. Returns { code, changes, manual }. */
|
|
84
|
+
export function transform(source) {
|
|
85
|
+
const changes = [];
|
|
86
|
+
const manual = [];
|
|
87
|
+
let code = source;
|
|
88
|
+
// Only touch files that import the old helpers from the library (or use the UMD global).
|
|
89
|
+
const importRe = /import\s*\{([^}]*)\}\s*from\s*(['"])use-scroll-animate\/components(?:\/click)?\2;?/g;
|
|
90
|
+
const imported = new Map(); // local name → original helper
|
|
91
|
+
code = code.replace(importRe, (m, names, q) => {
|
|
92
|
+
const list = names.split(',').map((n) => n.trim()).filter(Boolean);
|
|
93
|
+
const old = list.filter((n) => OLD.includes(n.split(/\s+as\s+/)[0]));
|
|
94
|
+
if (!old.length) return m;
|
|
95
|
+
old.forEach((n) => imported.set(n.split(/\s+as\s+/).pop(), n.split(/\s+as\s+/)[0]));
|
|
96
|
+
const rest = list.filter((n) => !old.includes(n));
|
|
97
|
+
const src = m.match(/from\s*(['"])(.*?)\1/)[2];
|
|
98
|
+
changes.push(`import { ${old.join(', ')} } → import { playEffect } from 'use-scroll-animate/components/fx'`);
|
|
99
|
+
const keep = rest.length ? `import { ${rest.join(', ')} } from ${q}${src}${q};\n` : '';
|
|
100
|
+
return `${keep}import { playEffect } from ${q}use-scroll-animate/components/fx${q};`;
|
|
101
|
+
});
|
|
102
|
+
const umd = /UsaComponents\.(burst|confetti|shake)\(/.test(code);
|
|
103
|
+
if (umd) code = code.replace(/UsaComponents\.(burst|confetti|shake)\(/g, (_m, n) => (imported.set(`UsaComponents.${n}`, n), `UsaComponents.${n}(`));
|
|
104
|
+
for (const [name, kind] of imported) {
|
|
105
|
+
const pe = name.startsWith('UsaComponents.') ? 'UsaComponents.playEffect' : 'playEffect';
|
|
106
|
+
const esc = name.replace('.', '\\.');
|
|
107
|
+
code = rewriteCalls(code, esc, (a) => {
|
|
108
|
+
if (kind === 'burst') return a.length >= 2 ? `${pe}(document.body, 'burst', ${objOf([['x', a[0]], ['y', a[1]]], a[2])})` : null;
|
|
109
|
+
if (kind === 'confetti') return `${pe}(document.body, 'confetti'${a[0] ? `, ${a[0]}` : ''})`;
|
|
110
|
+
if (kind === 'shake') return a.length ? `${pe}(${a[0]}, 'shake'${a.length > 1 ? `, ${objOf([['intensity', a[1]], ['duration', a[2]]])}` : ''})` : null;
|
|
111
|
+
return null;
|
|
112
|
+
}, changes);
|
|
113
|
+
}
|
|
114
|
+
if (/<usa-cursor\b[^>]*\bmode=(["'])trail\1/.test(code)) manual.push('<usa-cursor mode="trail"> is removed in 6.0 — wrap the content in <usa-fx effect="comet-trail" trigger="load" self> (see docs/upgrading-6.md)');
|
|
115
|
+
return { code, changes, manual };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function* walk(p) {
|
|
119
|
+
const st = statSync(p);
|
|
120
|
+
if (st.isDirectory()) {
|
|
121
|
+
for (const f of readdirSync(p)) if (!['node_modules', 'dist', '.git'].includes(f)) yield* walk(join(p, f));
|
|
122
|
+
} else if (EXT.has(extname(p))) yield p;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function run(args) {
|
|
126
|
+
const write = args.includes('--write');
|
|
127
|
+
const paths = args.filter((a) => !a.startsWith('--'));
|
|
128
|
+
let files = 0;
|
|
129
|
+
let edits = 0;
|
|
130
|
+
let todo = 0;
|
|
131
|
+
for (const root of paths.length ? paths : ['src'])
|
|
132
|
+
for (const f of walk(root)) {
|
|
133
|
+
const src = readFileSync(f, 'utf8');
|
|
134
|
+
const { code, changes, manual } = transform(src);
|
|
135
|
+
if (!changes.length && !manual.length) continue;
|
|
136
|
+
files++;
|
|
137
|
+
edits += changes.length;
|
|
138
|
+
todo += manual.length;
|
|
139
|
+
console.log(`${f}${changes.map((c) => `\n - ${c}`).join('')}${manual.map((c) => `\n ! manual: ${c}`).join('')}`);
|
|
140
|
+
if (write && changes.length) writeFileSync(f, code);
|
|
141
|
+
}
|
|
142
|
+
console.log(`\n${edits} change(s), ${todo} manual item(s) in ${files} file(s)${write ? ' written' : ' (dry run — add --write to apply)'}.`);
|
|
143
|
+
return { files, edits, manual: todo };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (import.meta.url === pathToFileURL(process.argv[1] || '').href) run(process.argv.slice(2));
|
|
@@ -1033,7 +1033,8 @@ interface UsaCheckboxElement extends UsaElement {
|
|
|
1033
1033
|
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
1034
1034
|
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
1035
1035
|
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
1036
|
-
* `
|
|
1036
|
+
* `haptic()`. 6.0: `burst()`, `confetti()` and `shake()` were removed — play
|
|
1037
|
+
* the registered effects instead: `playEffect(el, 'burst' | 'confetti' | 'shake')`.
|
|
1037
1038
|
*/
|
|
1038
1039
|
|
|
1039
1040
|
declare global {
|
|
@@ -1225,10 +1226,11 @@ declare global {
|
|
|
1225
1226
|
}
|
|
1226
1227
|
|
|
1227
1228
|
/**
|
|
1228
|
-
* `<usa-cursor mode="dot |
|
|
1229
|
+
* `<usa-cursor mode="dot | magnetic | glow">` — a custom cursor for
|
|
1229
1230
|
* the page (place it once, e.g. at the end of `<body>`).
|
|
1230
1231
|
* - `dot` — a ring that follows with spring lag around the real pointer;
|
|
1231
|
-
*
|
|
1232
|
+
* (6.0: `mode="trail"` was removed — use the registered `comet-trail` effect;
|
|
1233
|
+
* unknown modes render as `dot`.)
|
|
1232
1234
|
* - `magnetic` — the ring snaps onto and wraps hovered targets (`a`,
|
|
1233
1235
|
* `button`, `[data-cursor]`);
|
|
1234
1236
|
* - `glow` — a large soft light following the pointer (great on dark UIs).
|
|
@@ -1033,7 +1033,8 @@ interface UsaCheckboxElement extends UsaElement {
|
|
|
1033
1033
|
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
1034
1034
|
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
1035
1035
|
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
1036
|
-
* `
|
|
1036
|
+
* `haptic()`. 6.0: `burst()`, `confetti()` and `shake()` were removed — play
|
|
1037
|
+
* the registered effects instead: `playEffect(el, 'burst' | 'confetti' | 'shake')`.
|
|
1037
1038
|
*/
|
|
1038
1039
|
|
|
1039
1040
|
declare global {
|
|
@@ -1225,10 +1226,11 @@ declare global {
|
|
|
1225
1226
|
}
|
|
1226
1227
|
|
|
1227
1228
|
/**
|
|
1228
|
-
* `<usa-cursor mode="dot |
|
|
1229
|
+
* `<usa-cursor mode="dot | magnetic | glow">` — a custom cursor for
|
|
1229
1230
|
* the page (place it once, e.g. at the end of `<body>`).
|
|
1230
1231
|
* - `dot` — a ring that follows with spring lag around the real pointer;
|
|
1231
|
-
*
|
|
1232
|
+
* (6.0: `mode="trail"` was removed — use the registered `comet-trail` effect;
|
|
1233
|
+
* unknown modes render as `dot`.)
|
|
1232
1234
|
* - `magnetic` — the ring snaps onto and wraps hovered targets (`a`,
|
|
1233
1235
|
* `button`, `[data-cursor]`);
|
|
1234
1236
|
* - `glow` — a large soft light following the pointer (great on dark UIs).
|
|
@@ -847,7 +847,8 @@ function defineCheckbox(tag = 'usa-checkbox') {
|
|
|
847
847
|
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
848
848
|
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
849
849
|
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
850
|
-
* `
|
|
850
|
+
* `haptic()`. 6.0: `burst()`, `confetti()` and `shake()` were removed — play
|
|
851
|
+
* the registered effects instead: `playEffect(el, 'burst' | 'confetti' | 'shake')`.
|
|
851
852
|
*/
|
|
852
853
|
/** Register every component of this category under its default tag. */
|
|
853
854
|
function defineClickComponents() {
|
|
@@ -860,10 +861,7 @@ function defineClickComponents() {
|
|
|
860
861
|
defineCheckbox();
|
|
861
862
|
}
|
|
862
863
|
|
|
863
|
-
exports.burst = fx.burst;
|
|
864
|
-
exports.confetti = fx.confetti;
|
|
865
864
|
exports.haptic = fx.haptic;
|
|
866
|
-
exports.shake = fx.shake;
|
|
867
865
|
exports.BUTTON_DEFORMS = BUTTON_DEFORMS;
|
|
868
866
|
exports.CLICK_EFFECTS = CLICK_EFFECTS;
|
|
869
867
|
exports.MORPH_ICONS = MORPH_ICONS;
|