customizable-toast-notification 3.20.1 → 4.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 CHANGED
@@ -1,3 +1,32 @@
1
+ # [4.0.0](https://github.com/sammy-cool/customizable-toast-notification/compare/v3.20.2...v4.0.0) (2026-10-27)
2
+
3
+
4
+ * feat!: streamline core engine to ultra-lightweight pure toast library ([8cbcc9a](https://github.com/sammy-cool/customizable-toast-notification/commit/8cbcc9a04bc86c3c6158f4f98b8c1863febd0dfc))
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * **ci:** repair audit workflow yaml syntax, prune dead overrides, and achieve 100% test coverage ([4839726](https://github.com/sammy-cool/customizable-toast-notification/commit/4839726471394701916b63dea39c107b6a49a65b))
10
+ * fortify multi-config interactions, mobile overflow, and focus trap ([eefc61c](https://github.com/sammy-cool/customizable-toast-notification/commit/eefc61c8a2680f1d3393603a8bb52208d06e9cf4))
11
+
12
+
13
+ ### Performance Improvements
14
+
15
+ * migrate rollup pipeline to native esbuild and streamline package manifests ([e3523fd](https://github.com/sammy-cool/customizable-toast-notification/commit/e3523fde7384696cc9d338b6c53c1a59878edad1))
16
+
17
+
18
+ ### BREAKING CHANGES
19
+
20
+ * removed audio synthesizer, ai-scorer, spring solver,
21
+ multi-touch pinch, and DOM pool utilities in favor of web standards.
22
+
23
+ ## [3.20.2](https://github.com/sammy-cool/customizable-toast-notification/compare/v3.20.1...v3.20.2) (2026-10-27)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * guarantee 3-character salt length in generateSalt fallback ([a21d6d6](https://github.com/sammy-cool/customizable-toast-notification/commit/a21d6d68c2c757401db5f71792f032516e5fea17))
29
+
1
30
  ## [3.20.1](https://github.com/sammy-cool/customizable-toast-notification/compare/v3.20.0...v3.20.1) (2026-10-27)
2
31
 
3
32
 
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=sammy-cool_customizable-toast-notification&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=sammy-cool_customizable-toast-notification)
12
12
  [![Open in StackBlitz](https://img.shields.io/badge/StackBlitz-Live%20Sandbox-blue?logo=stackblitz)](https://stackblitz.com/edit/customizable-toast-notification-demo?file=index.html)
13
13
 
14
- **[▶ Try the interactive live playground](https://sammy-cool.github.io/customizable-toast-notification/)** — test damped spring physics, 5 zero-asset Web Audio synthesizer presets, dynamic action undo countdowns, and iOS-style card deck stacking in real time.
14
+ **[▶ Try the interactive live playground](https://sammy-cool.github.io/customizable-toast-notification/)** — test smooth cubic-bezier physics, audio notification hooks, dynamic action undo countdowns, and iOS-style card deck stacking in real time.
15
15
 
16
16
  ```
17
17
  ┌────────────────────────────────────────────────────────────────────────┐
@@ -22,10 +22,10 @@
22
22
  ┌───────────────────┬───────────┴───────────┬───────────────────┐
23
23
  ▼ ▼ ▼ ▼
24
24
  ┌──────────────┐ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
25
- │ Web Audio │ │ Spring Physics│ │ Action Undo │ │ Card Deck │
26
- │ 5 Synth │ │ Damped │ │ Dynamic Live │ │ iOS-Style │
27
- │ Presets + │ │ Harmonic │ │ Countdown │ │ Pinch-to- │
28
- │ Oscilloscope │ │ Oscillator │ │ Badge (Xs) │ │ Expand Stack │
25
+ │ Sound Audio │ │ Natural Curve │ │ Action Undo │ │ Card Deck │
26
+ │ URL / Custom │ │ Cubic-Bezier │ │ Dynamic Live │ │ iOS-Style │
27
+ │ onSound Hook │ │ Spring Ease │ │ Countdown │ │ Expandable │
28
+ │ Playback │ │ Physics │ │ Badge (Xs) │ │ Stacking │
29
29
  └──────────────┘ └───────────────┘ └───────────────┘ └───────────────┘
30
30
  │ │ │ │
31
31
  └───────────────────┴───────────┬───────────┴───────────────────┘
@@ -102,7 +102,7 @@ toast({
102
102
  type: "success",
103
103
  duration: 3000,
104
104
  position: "bottom-right",
105
- spring: "gentle",
105
+ animationType: "spring",
106
106
  sound: true,
107
107
  });
108
108
  ```
@@ -116,7 +116,7 @@ Global Variable Name: `customizableToast`
116
116
  <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification/dist/index.umd.js"></script>
117
117
 
118
118
  <!-- OR pin to a specific version -->
119
- <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@3.20.1/dist/index.umd.js"></script>
119
+ <script src="https://cdn.jsdelivr.net/npm/customizable-toast-notification@4.0.0/dist/index.umd.js"></script>
120
120
 
121
121
  <script>
122
122
  // Access the global UMD export
@@ -203,6 +203,7 @@ auto-dismissed on its own — they no-op gracefully rather than throwing. You ca
203
203
  | `showProgressBar` | `boolean` | `true` | Show countdown progress bar |
204
204
  | `animationDuration` | `string` | `"0.4s"` | CSS animation duration |
205
205
  | `animationEasing` | `string` | `"ease"` | CSS animation easing function |
206
+ | `animationType` | `string` | `"default"` | Entrance & exit animation: `"default"`, `"fade"`, `"slide"`, `"zoom"`, `"bounce"`, `"spring"`, `"flip"` |
206
207
  | `progressColor` | `string` | Falls back to `textColor` | Progress bar color |
207
208
  | `progressHeight` | `string` | `"4px"` | Progress bar height |
208
209
  | `progressPosition` | `string` | `"bottom"` | Progress bar position: `"top"` or `"bottom"` |
@@ -222,19 +223,19 @@ auto-dismissed on its own — they no-op gracefully rather than throwing. You ca
222
223
  | `fontPadding` | `string` | `undefined` | Custom padding for message container (e.g. `"4px 8px"`) |
223
224
  | `className` | `string` | `undefined` | Custom CSS class name(s) for animations / styling |
224
225
  | `stacked` | `boolean` | `false` | Enable iOS-style card deck stacking for multiple toasts |
225
- | `sound` | `boolean \| string`| `false` | Zero-asset audio chime (`true`, `'success'`, `'error'`, `'warning'`, `'pop'`) |
226
- | `soundPreset` | `string` | `"modern"` | Audio synth theme: `"modern"`, `"retro"`, `"futuristic"`, `"subtle"`, `"bell"` |
227
- | `swipeToDismiss` | `boolean` | `true` | Mobile touch swipe-to-dismiss gesture with physics |
226
+ | `sound` | `boolean \| string`| `false` | Sound notification toggle or audio file URL (e.g. `"/chime.mp3"`) |
227
+ | `onSound` | `function` | `undefined` | Sound playback handler callback invoked on mount `(options) => void` |
228
+ | `priority` | `number` | `undefined` | Numeric queue priority (higher score displays ahead of lower priority toasts) |
229
+ | `swipeToDismiss` | `boolean` | `true` | Mobile touch & desktop mouse drag swipe-to-dismiss gesture |
228
230
  | `progressDirection` | `string` | `"decreasing"` | Progress bar fill direction: `"decreasing"`, `"increasing"`, `"reverse"`, `"ltr"` |
229
231
  | `progressBarColor` | `string` | Falls back to `textColor` | Alias for `progressColor` (accepts hex, rgb, hsl, CSS var) |
230
232
  | `progress` | `number \| 'indeterminate'`| `undefined` | Explicit percentage (0 to 100) or `"indeterminate"` moving gradient |
231
- | `usePool` | `boolean` | `false` | Virtual element pooling for DOM recycling in high-frequency rendering |
232
233
  | `tag` / `groupId` | `string` | `undefined` | Thread grouping identifier to replace notification in-place instead of stacking |
233
234
  | `trapFocus` | `boolean` | `false` | Modal keyboard focus trap (`Tab`/`Shift+Tab`) cycling for high-priority toasts |
234
235
  | `shadowDom` | `boolean` | `false` | Render toast container inside isolated Shadow Root to prevent CSS bleed |
235
236
  | `cta` | `object \| array` | `null` | Call-to-action configuration (see [CTA](#call-to-action)) |
236
237
  | `undo` | `function \| object`| `null` | Action Undo button with live dynamic countdown badge (see [Undo](#️-action-undo-with-live-countdown)) |
237
- | `spring` | `boolean \| string \| object`| `null` | Configurable spring physics animations (see [Spring Physics](#-configurable-spring-physics-animation-engine)) |
238
+ | `spring` | `boolean` | `false` | Natural cubic-bezier bounce curve (`cubic-bezier(0.34, 1.56, 0.64, 1)`) |
238
239
 
239
240
  #### Position Options
240
241
 
@@ -360,41 +361,16 @@ createToast({
360
361
  | `showCountdown` | `boolean` | `true` | Decays remaining duration in seconds in real-time |
361
362
  | `onUndo` | `function` | `undefined` | Callback fired on click; supports async promises before auto-closing toast |
362
363
 
363
- ### 🌀 Configurable Spring Physics Animation Engine
364
+ ### 🌀 Natural Spring Easing Physics
364
365
 
365
- Replaces standard transitions with damped harmonic oscillator physics:
366
+ Toasts support smooth cubic-bezier physics curves with natural overshoot and settling:
366
367
 
367
368
  ```js
368
- // Use built-in presets: 'default', 'gentle', 'wobbly', 'stiff', 'bouncy'
369
+ // Enable natural spring overshoot:
369
370
  createToast({
370
371
  message: "Synced to cloud",
371
- spring: "bouncy",
372
+ spring: true, // applies cubic-bezier(0.34, 1.56, 0.64, 1) at 400ms
372
373
  });
373
-
374
- // Or customize exact physical constants:
375
- createToast({
376
- message: "Physics simulated notification",
377
- spring: {
378
- stiffness: 180, // Spring tension (k)
379
- damping: 12, // Friction resistance (c)
380
- mass: 1.2, // Inertial mass (m)
381
- },
382
- });
383
- ```
384
-
385
- | Preset | Stiffness ($k$) | Damping ($c$) | Mass ($m$) | Behavior |
386
- | ------ | --------------- | ------------- | ---------- | -------- |
387
- | `default` | 100 | 10 | 1 | Natural subtle bounce |
388
- | `gentle` | 120 | 14 | 1 | Smooth with minimal overshoot |
389
- | `wobbly` | 180 | 12 | 1 | Playful oscillation |
390
- | `stiff` | 210 | 20 | 1 | Crisp, rapid settling |
391
- | `bouncy` | 300 | 15 | 1.2 | High energy with dynamic bounce |
392
-
393
- Register custom global presets or resolve spring curves directly:
394
- ```js
395
- import { registerSpringPreset, getSpringTransition } from "customizable-toast-notification";
396
-
397
- registerSpringPreset("snappy", { stiffness: 250, damping: 22, mass: 1 });
398
374
  ```
399
375
 
400
376
  ### Loader Options
@@ -434,21 +410,29 @@ createToast({ message: "Deploy finished successfully", type: "success", stacked:
434
410
  - Hovering or keyboard-focusing on the deck automatically expands all notifications with spring animations.
435
411
  - Leaving collapses them back into a clean stack.
436
412
 
437
- ### 🔊 Zero-Asset Web Audio API Chimes
413
+ ### 🔊 Sound Notification Playback & Hooks
438
414
 
439
- Play pleasant micro-feedback audio chimes generated entirely on the fly with the browser's native `AudioContext` and pure math oscillators — **zero external audio files, zero MP3 assets, and 0 network overhead**:
415
+ Trigger sound feedback on notification mount via audio URL or custom sound handler callbacks:
440
416
 
441
417
  ```js
442
- import { createToast, setAudioEnabled, playTone } from "customizable-toast-notification";
418
+ import { createToast } from "customizable-toast-notification";
443
419
 
444
- // Automatically chime based on type or custom tone:
445
- createToast({ message: "Changes saved", type: "success", sound: true }); // pleasant major chord
446
- createToast({ message: "Network error", type: "error", sound: "error" }); // gentle alert buzz
447
- createToast({ message: "Warning threshold", sound: "warning" });
448
- createToast({ message: "New ping", sound: "pop" });
420
+ // 1. Play from audio URL:
421
+ createToast({
422
+ message: "Changes saved",
423
+ type: "success",
424
+ sound: "/assets/sounds/success.mp3",
425
+ });
449
426
 
450
- // Globally toggle sound effects (e.g. user accessibility preferences)
451
- setAudioEnabled(false);
427
+ // 2. Or supply a custom onSound callback:
428
+ createToast({
429
+ message: "Network warning",
430
+ type: "warning",
431
+ sound: true,
432
+ onSound: (options) => {
433
+ mySoundPlayer.play(options.type);
434
+ },
435
+ });
452
436
  ```
453
437
 
454
438
  ### 👆 Mobile Touch Swipe-to-Dismiss
@@ -601,12 +585,10 @@ if (shouldReduceMotion()) {
601
585
  | `theme` | `"light" \| "dark" \| "high-contrast" \| "compact" \| "spacious" \| "glass"` | `"light"` | Built-in CSS theme applied via `data-toast-theme` on document root. |
602
586
  | `stacked` | `boolean` | `false` | Enable iOS-style 3D card deck layout with depth scaling and hover expansion. |
603
587
  | `swipeToDismiss` | `boolean` | `true` | Enable touch / mouse drag swipe gesture to dismiss toasts with spring snap-back physics. |
604
- | `sound` | `boolean` | `true` | Enable pure Web Audio API notification chimes (0KB network, zero audio assets). |
605
- | `soundPreset` | `"modern" \| "retro" \| "futuristic" \| "subtle" \| "bell"` | `"modern"` | Built-in sound synthesis theme for audio notifications. |
588
+ | `sound` | `boolean` | `false` | Enable sound notification support (audio URLs or `onSound` callbacks). |
606
589
  | `pauseOnHover` | `boolean` | `false` | When `true`, automatically pauses countdown timers for all toasts on mouse hover or keyboard focus. |
607
- | `syncTabs` | `boolean` | `false` | Synchronize toast notifications across browser tabs using BroadcastChannel. |
608
- | `aiPrioritization` | `boolean` | `false` | Enable offline content-aware queue priority sorting (critical alerts jump ahead of routine messages). |
609
- | `priorityScorer` | `((context) => number) \| null` | `null` | Custom priority scoring function for custom business logic or external AI models. |
590
+ | `priorityQueue` | `boolean` | `false` | Enable content-aware queue priority sorting (critical alerts jump ahead of routine messages). |
591
+ | `priorityScorer` | `((context) => number) \| null` | `null` | Custom priority scoring function for custom business logic or external classifiers. |
610
592
  | `onMetrics` | `((metrics: ToastMetrics) => void) \| null` | `null` | Real-time telemetry callback emitting `{ activeCount, queueDepth, visibleCount, droppedCount, timestamp }`. |
611
593
  | `disableInlineStyles` | `boolean` | `false` | When `true`, toasts use CSS classes instead of inline `style.*` for stricter CSP compliance. |
612
594
  | `reducedMotion` | `"auto" \| "always" \| "never"` | `"auto"` | Control animation behavior. `"auto"` respects `prefers-reduced-motion`, `"always"` disables, `"never"` enables. |
@@ -683,68 +665,44 @@ setConfig({ zIndex: 50000 });
683
665
 
684
666
  The following enterprise-grade features are available in v3.17.0+ and are opt-in via global config or toast options:
685
667
 
686
- ### 🔄 Cross-Tab Toast Synchronization
668
+ ### ⚡ Priority Queue Routing
687
669
 
688
- Broadcast toasts to other tabs of the same application using the `BroadcastChannel` API. The first tab becomes the leader and mirrors queued / active toasts to follower tabs.
670
+ When the queue fills (more than `maxVisible` toasts), the `priorityQueue` flag and `priority` options reorder the queue by urgency instead of strict FIFO. Priority is derived from `priority` option or `type` (error > warning > info > success), with support for custom priority scorers or consumer classifiers (`examples/ai-triage/`).
689
671
 
690
672
  ```js
691
- import { setConfig, createToast } from "customizable-toast-notification";
673
+ setConfig({ priorityQueue: true });
692
674
 
693
- // Enable cross-tab sync globally
694
- setConfig({ syncTabs: true });
675
+ createToast({ message: "Payment failed", type: "error" }); // Highest priority (score: 80)
676
+ createToast({ message: "Background sync", type: "info" }); // Queued behind the error (score: 40)
695
677
 
696
- createToast({ message: "Shared across all open tabs!", type: "info" });
678
+ // Or specify an explicit priority score:
679
+ createToast({ message: "VIP Customer Alert", priority: 100 });
697
680
  ```
698
681
 
699
- Graceful degradation: if `BroadcastChannel` is unavailable (e.g. Node.js or older browsers), the library simply runs in single-tab mode — no errors.
700
-
701
- ### 🧠 AI-Powered Priority Queue Routing
702
-
703
- When the queue fills (more than `maxVisible` toasts), the `aiPrioritization` flag reorders the queue by urgency instead of strict FIFO. Priority is derived from `type` (error > warning > info > success) plus keyword scoring (`urgent`, `critical`, `failed`, `done`, etc.). Fully offline, zero external calls.
704
-
705
- ```js
706
- setConfig({ aiPrioritization: true });
707
-
708
- createToast({ message: "Payment failed", type: "error" }); // Highest priority
709
- createToast({ message: "Background sync", type: "info" }); // Queued behind the error
710
- ```
682
+ ### 👆 Touch & Pointer Swipe-to-Dismiss
711
683
 
712
- The built-in scorer also exposes `calculateToastPriority(context)` and `categorizeToast(message)` for custom routing integrations.
684
+ Toasts support smooth native pointer and touch swipe-to-dismiss out of the box:
713
685
 
714
- ### 🃏 Virtual Scrolling — DOM Element Pool
715
-
716
- An internal element-pool recycles toast DOM nodes, so burst queues of 100+ toasts no longer create proportional DOM pressure or trigger layout thrashing / GC spikes. The pool size scales automatically with `MAX_VISIBLE`.
717
-
718
- No configuration required — it's transparent to callers. The queue drains in priority order (when enabled above) and reuses the same recycled elements.
719
-
720
- ### 👆 Advanced Gestures: Flick Swipe & Pinch-to-Expand
721
-
722
- Swipe-to-dismiss already exists in Phase 2; Phase 3 refines the physics:
723
-
724
- - **Flick detection**: velocity ≥ 0.65 px/ms over ≥ 50 px triggers instant dismiss; anything shorter snaps back with spring easing.
725
- - **Pinch-to-expand**: two-finger gesture on a toast expands it to full height (useful for long error messages with stack traces); releasing collapses it back.
726
-
727
- The multi-touch math (`calculateVelocity`, `isFlick`, `detectPinch`) is exported for consumer recipes that want custom gesture behavior.
686
+ - Horizontal drag beyond threshold flings the toast off screen with smooth dismissal transition.
687
+ - Dragging below threshold cleanly snaps the notification back into position.
688
+ - Interactive elements (buttons, links, inputs) inside toasts automatically guard against accidental swipe drag.
728
689
 
729
690
  ### 🏗️ How It All Fits Together
730
691
 
731
692
  ```js
732
- import { setConfig } from "customizable-toast-notification";
693
+ import { setConfig, createToast } from "customizable-toast-notification";
733
694
 
734
695
  setConfig({
735
696
  maxVisible: 3,
736
- syncTabs: true, // mirror to other tabs
737
- aiPrioritization: true,// sort the queue by urgency
697
+ priorityQueue: true, // sort the queue by urgency
738
698
  stacked: true, // iOS-style card deck
739
- swipeToDismiss: true, // flick physics (Phase 2)
740
- sound: true, // zero-asset Web Audio chimes (Phase 2)
699
+ swipeToDismiss: true, // touch & pointer gestures
700
+ sound: true, // notification chimes
741
701
  });
742
702
 
743
703
  createToast({ message: "New notification", type: "success" });
744
704
  ```
745
705
 
746
- The library keeps its zero-runtime-dependency guarantee: `BroadcastChannel`, Web Audio, and the gesture math are all native browser APIs with immediate graceful fallbacks when unavailable.
747
-
748
706
  ## 💡 Examples
749
707
 
750
708
  ### Basic Toast Types
@@ -1016,8 +974,8 @@ createToast({ message: "Using external CSS!" });
1016
974
 
1017
975
  ```html
1018
976
  <!-- HTML (CDN) -->
1019
- <link rel="stylesheet" href="https://unpkg.com/customizable-toast-notification@3.20.1/dist/index.css">
1020
- <script src="https://unpkg.com/customizable-toast-notification@3.20.1/dist/index.umd.js"></script>
977
+ <link rel="stylesheet" href="https://unpkg.com/customizable-toast-notification@4.0.0/dist/index.css">
978
+ <script src="https://unpkg.com/customizable-toast-notification@4.0.0/dist/index.umd.js"></script>
1021
979
  <script>
1022
980
  customizableToast.setConfig({ disableInlineStyles: true });
1023
981
  customizableToast.createToast({ message: "Using external CSS!" });
@@ -1263,40 +1221,6 @@ toast.info("Protected from global styles", {
1263
1221
  });
1264
1222
  ```
1265
1223
 
1266
- ## 🌍 Internationalization (i18n) Engine
1267
-
1268
- Built-in multi-locale support with automatic RTL layout switching:
1269
-
1270
- ```javascript
1271
- import { setLocale, registerLocale } from "customizable-toast-notification";
1272
-
1273
- // Built-in support for "en", "hi", "ar"
1274
- setLocale("ar"); // Automatically switches to right-to-left layout
1275
-
1276
- // Register custom translations
1277
- registerLocale("fr", {
1278
- undo: "Annuler",
1279
- close: "Fermer la notification",
1280
- success: "Opération réussie"
1281
- });
1282
- ```
1283
-
1284
- ## 📜 Notification History & Telemetry Ring Buffer
1285
-
1286
- Track and inspect notification delivery, dismissals, and drop telemetry:
1287
-
1288
- ```javascript
1289
- import { getToastHistory, clearToastHistory, setHistoryCapacity } from "customizable-toast-notification";
1290
-
1291
- // Set capacity (default 50)
1292
- setHistoryCapacity(100);
1293
-
1294
- // Get immutable snapshot of recent toasts with timestamps, status, and metadata
1295
- const history = getToastHistory();
1296
- console.log(history);
1297
- // Output: [{ id: "...", message: "...", type: "...", status: "active" | "dismissed" | "dropped", timestamp: ... }]
1298
- ```
1299
-
1300
1224
  ## 🤝 Contributing
1301
1225
 
1302
1226
  Exciting times ahead! Looking for sponsors and eager to explore new collaborations:) . Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) for details.