Commit Graph

1897 Commits

Author SHA1 Message Date
Younes ENNAJI 50ffa722a5 Add tests for OctaneListener and WorkerListener 2026-03-02 03:04:35 +00:00
Younes ENNAJI 93fc3c00e8 Add worker listeners for Octane and Symfony, update FallbackSession 2026-03-02 02:55:50 +00:00
Younes ENNAJI e783943933 Fix notification cleanup for Turbo and Livewire navigation 2026-03-02 02:42:38 +00:00
Younes ENNAJI f3d72c88c9 Fix array_merge error and update exception handling 2026-03-02 02:35:27 +00:00
Younes ENNAJI 63b9083782 Update README and documentation pages 2026-03-02 02:34:48 +00:00
Younes ENNAJI 1f7d884c4d Update README and JavaScript documentation 2026-03-02 02:01:00 +00:00
Younes ENNAJI 88f7546b50 Update documentation for installation and libraries 2026-03-02 01:29:04 +00:00
Younes ENNAJI cbd753371b Upgrade Symfony demo to v8.0, update dependencies 2026-03-02 00:40:18 +00:00
Younes ENNAJI 04d1e42fa3 Refine code block rendering and features 2026-03-01 23:27:02 +00:00
Younes ENNAJI 67b24f24bb Refactor demo notification display and asset loading 2026-03-01 23:21:50 +00:00
Younes ENNAJI b136cfcf6e Revamp Flasher demo application 2026-03-01 22:47:28 +00:00
Younes ENNAJI fd65254d63 docs: move Try All Themes section to top of themes page 2026-03-01 22:17:40 +00:00
Younes ENNAJI 33ac9013d5 build assets 2026-03-01 22:16:54 +00:00
Younes ENNAJI 1cc6a7c537 docs: remove hero sections from playground and themes pages 2026-03-01 22:15:18 +00:00
Younes ENNAJI dfe9a12fe1 docs: remove old themes.md (replaced by themes/index.html) 2026-03-01 22:11:08 +00:00
Younes ENNAJI 8074bb1f90 docs: add themes gallery page at /themes/
Features:
- Hero section with animated gradient background
- Themes organized by category (Brand-Inspired, Gemstone, Minimal)
- Visual cards with gradient previews for each theme
- Interactive "Try All Themes" section with demo buttons
- Usage code examples for setting default or per-notification themes
- CTA linking to playground
- Added "All Themes" link to navigation menu
2026-03-01 22:11:00 +00:00
Younes ENNAJI 03942aa634 build assets 2026-03-01 22:04:32 +00:00
Younes ENNAJI 6abae0bdde docs: add interactive playground page
Features:
- Hero section with animated background elements
- Embedded flasher-studio interactive component
- Quick theme preview buttons (12 popular themes)
- Pro tips section for better user experience
- CTA section linking to Laravel/Symfony guides
- Added playground to navigation menu
2026-03-01 22:02:13 +00:00
Younes ENNAJI 05c15399ac docs: restore Palestine support banner 2026-03-01 21:57:14 +00:00
Younes ENNAJI 1bd85021d9 docs: redesign root README for better first impression
Key improvements:
- Strong tagline: "One line of PHP. Beautiful notifications. Zero JavaScript"
- Quick Start at the top (installation in 1 command)
- "Why PHPFlasher?" comparison table showing advantages
- Livewire integration section (previously missing)
- Collapsible themes list for better scannability
- Cleaner visual hierarchy with horizontal rules
- Prominent links to docs, playground, and bug reports
- Simplified contributors section using contrib.rocks
- Clear calls to action for starring and sharing
2026-03-01 21:54:51 +00:00
Younes ENNAJI 359e6de361 docs: expand adapter READMEs with comprehensive examples
Each adapter README now includes:
- Features section highlighting key capabilities
- Installation instructions for Laravel and Symfony
- Multiple Quick Start code examples
- Configuration options table
- Livewire integration with events
- Global configuration examples
2026-03-01 21:50:11 +00:00
Younes ENNAJI e417105f7a refactor(themes): create shared utilities and design tokens
This refactoring improves code quality and reduces duplication:

## New Files
- `themes/shared/icons.ts` - Centralized SVG icons (getIcon, getCloseIcon)
- `themes/shared/accessibility.ts` - A11y helpers (getA11yString, getCloseButtonA11y)
- `themes/shared/constants.ts` - Standard class names and default titles

## Design Tokens Added (index.scss)
- Spacing scale: --fl-spacing-xs through --fl-spacing-2xl
- Typography scale: --fl-font-size-xs through --fl-font-size-xl
- Close button sizes: --fl-close-sm, --fl-close-md, --fl-close-lg
- Border radius: --fl-radius-sm through --fl-radius-full
- Shadow tokens: --fl-shadow-sm through --fl-shadow-lg
- Animation: --fl-duration-*, --fl-easing-*, --fl-slide-*

## Mixins Updated
- Added `close-button-sized($size)` with sm/md/lg support
- Added `close-button-circular($size)` variant
- Added `close-button-text` for text-style buttons
- Updated existing mixins to use design tokens

## All 17 Themes Refactored
Each theme now uses shared utilities instead of duplicating code:
- Icon code: 20+ lines → 1 function call
- Accessibility: 3 lines → 1 function call
- Class names: via CLASS_NAMES constants

Backwards compatible - no breaking changes.
2026-03-01 21:34:50 +00:00
Younes ENNAJI abd70c1d4b Update main JavaScript bundle 2026-03-01 21:13:14 +00:00
Younes ENNAJI 9acddbda52 docs: update CHANGELOG and Livewire docs with event system
Add documentation for the event dispatching system:
- Update CHANGELOG.md with unreleased features
- Add Toastr events section (click, close, show, hidden)
- Add Noty events section (click, close, show, hover)
- Add Notyf events section (click, dismiss)
- Add Theme events section (generic and theme-specific click)
- Include code examples for Livewire event listeners
2026-03-01 21:11:13 +00:00
Younes ENNAJI 7d6e9b46b8 add event dispatching system for Livewire integration
Implement consistent event dispatching across Noty, Notyf, Toastr adapters and
themes, following the existing SweetAlert pattern. This enables Livewire
integration for all notification types.

JavaScript Events:
- Noty: flasher:noty:show, flasher:noty:click, flasher:noty:close, flasher:noty:hover
- Notyf: flasher:notyf:click, flasher:notyf:dismiss
- Toastr: flasher:toastr:show, flasher:toastr:click, flasher:toastr:close, flasher:toastr:hidden
- Themes: flasher:theme:click (generic), flasher:theme:{name}:click (specific)

PHP Livewire Listeners:
- LivewireListener for each adapter (Noty, Notyf, Toastr)
- ThemeLivewireListener for theme click events
- Registered in service providers when Livewire is bound

This allows Livewire users to listen for notification events and react
accordingly (e.g., noty:click, theme:flasher:click).
2026-03-01 21:05:10 +00:00
Younes ENNAJI f1051e1d7f fix: resolve PHPStan errors and add Vitest to lint script
- Remove unnecessary null coalescing in HtmlPresenter (mainScript is never null)
- Add comprehensive ignore rules for test-related PHPStan warnings
- Add Vitest test runner to bin/lint script

All quality checks now pass:
- Rector
- PHP-CS-Fixer
- PHPStan (level max)
- Composer validation
- PHPLint
- PHPUnit (1281 tests)
- Vitest (219 tests)
2026-03-01 20:24:33 +00:00
Younes ENNAJI 87da42fdea Refine code style and tests 2026-03-01 20:16:44 +00:00
Younes ENNAJI 4d9cda22cf build assets 2026-03-01 20:16:00 +00:00
Younes ENNAJI c58f3c7b40 upgrade dependencies 2026-03-01 20:15:46 +00:00
Younes ENNAJI 47eb66e874 fix: update tests for new validation requirements
Update tests that were using invalid values for HopsStamp (0 is now
invalid, must be >= 1) and update expected output format for
mainScript (now uses json_encode which produces double quotes).
2026-03-01 20:13:57 +00:00
Younes ENNAJI 30de24f054 fix: add null checks and error handling to docs JS controllers
clipboard_controller.js:
- Check if clipboard API is available before using
- Handle clipboard write promise rejection
- Show error icon on failure

prev-next_controller.js:
- Guard against missing navigation element
- Guard against missing span element in links

anchor_controller.js:
- Guard against missing ul element
2026-03-01 20:11:07 +00:00
Younes ENNAJI 162ea87330 fix: prevent memory leaks and handle errors in FlasherPlugin
- Remove DOMContentLoaded listener after it fires to prevent memory leak
- Clean up timer interval and event listeners when notification is removed
- Add null check in stringToHTML to throw clear error for invalid templates
- Store cleanup function on notification element for proper disposal

Added tests for memory leak prevention and error handling.
2026-03-01 20:10:06 +00:00
Younes ENNAJI 8cda9d1eb1 fix: rename shadowed variable in Request::getType()
The parameter \$type was being reassigned to the session value, which
shadows the original parameter and causes confusion for static analysis
tools and maintainers.

Renamed the session value variable to \$value for clarity.
2026-03-01 20:08:28 +00:00
Younes ENNAJI 6d314dbc07 fix: add validation to HopsStamp and DelayStamp
HopsStamp:
- Validate hops amount must be >= 1 (positive integer)
- Negative or zero hops don't make logical sense

DelayStamp:
- Validate delay must be >= 0 (non-negative integer)
- Negative delays don't make logical sense

Both now throw InvalidArgumentException for invalid values, making
configuration errors fail fast with clear messages.
2026-03-01 20:07:54 +00:00
Younes ENNAJI ad5c0f56dd fix: validate limit criteria must be positive integer
Previously, negative limits caused array_slice() to return unexpected
results (all except last N elements) and zero returned an empty array
without clear intent.

Now throws InvalidArgumentException for values < 1, making invalid
configurations fail fast with a clear error message.
2026-03-01 20:06:53 +00:00
Younes ENNAJI fd36c2ec0c fix: validate alias attribute in PresenterCompilerPass
Add validation to ensure services tagged with 'flasher.presenter' have
the required 'alias' attribute. Previously, accessing $attributes['alias']
without checking would throw an "Undefined array key" error.

Now throws a clear InvalidArgumentException with a helpful message.
2026-03-01 20:01:12 +00:00
Younes ENNAJI 5202c86107 fix: handle invalid JSON gracefully in FlasherComponent
The json_decode() with JSON_THROW_ON_ERROR throws an exception before
the ?: operator can provide a fallback value. This caused page crashes
when invalid JSON was passed to the Blade component attributes.

Now using a helper method with try-catch to safely decode JSON and
return an empty array on failure, preventing page crashes.
2026-03-01 20:00:16 +00:00
Younes ENNAJI 9e7bb17faa fix: make OctaneListener invokable for Laravel event dispatcher
Laravel's event dispatcher expects listener classes to be invokable
(have __invoke method) when registered as a class name string.

The OctaneListener was using a handle() method which caused the
listener to never be invoked, resulting in notification state leaking
between Octane requests.

Renamed handle() to __invoke() to fix the issue.
2026-03-01 19:59:25 +00:00
Younes ENNAJI 83dc9e49dc fix: handle null public directory gracefully in InstallCommand
The getPublicDir() method can return null, but the code was directly
concatenating it with a string, which could cause unexpected behavior.

Now the command properly checks for null and returns a failure with
a clear error message instead of proceeding with an invalid path.
2026-03-01 19:57:50 +00:00
Younes ENNAJI 1d81de581b fix: escape nonce and mainScript to prevent XSS vulnerabilities
The HtmlPresenter was interpolating user-controlled values directly into
HTML attributes and JavaScript code without proper escaping, creating
XSS vulnerabilities.

Changes:
- Escape nonce with htmlspecialchars() for HTML attribute context
- Escape nonce with json_encode() for JavaScript string context
- Escape mainScript with json_encode() for JavaScript string context

Added tests to verify XSS payloads are properly escaped.
2026-03-01 19:55:49 +00:00
Younes ENNAJI 2ebdbecda6 fix: correct inverted Livewire registration condition
The condition in registerLivewire() was inverted, causing the Livewire
listener to never be registered when Livewire was actually available.

Before: returned early when Livewire class exists AND is NOT bound
After: returns early when Livewire class does NOT exist OR is NOT bound

This fixes Livewire notifications not being displayed in Livewire components.
2026-03-01 19:53:39 +00:00
Younes ENNAJI 851e0a00ed improve Translator test coverage to 100% 2026-02-26 06:13:13 +00:00
Younes ENNAJI d9b0b6998e add tests for FlasherDataCollector 2026-02-26 06:04:11 +00:00
Younes ENNAJI ed992d78f6 add tests for FlasherAssert and Constraint classes 2026-02-25 20:45:32 +00:00
Younes ENNAJI 0612a3bb61 exclude .phpstorm.meta.php from coverage 2026-02-25 20:35:27 +00:00
Younes ENNAJI c9a61ba69c add tests for helper functions 2026-02-25 20:29:51 +00:00
Younes ENNAJI f9746f607b add Laravel Facade tests 2026-02-25 20:22:38 +00:00
Younes ENNAJI 18c2233baa add tests for remaining Criteria classes 2026-02-25 20:01:29 +00:00
Younes ENNAJI 08c242b45a fix test to properly suppress expected console error 2026-02-25 19:50:01 +00:00
Younes ENNAJI cd53ceb139 improve test coverage for edge cases 2026-02-25 19:31:21 +00:00