108 Commits

Author SHA1 Message Date
Younes ENNAJI f372dcf70e Fix Laravel 13 JSON session serialization compatibility 2026-03-28 01:52:00 +01:00
Younes ENNAJI e0766c1198 Add v2.5.0 release preparation tests and update CHANGELOG 2026-03-07 18:31:05 +00:00
Younes ENNAJI e4337b0b63 Fix SweetAlertBuilder::question() bug and improve code quality 2026-03-07 17:50:43 +00:00
Younes ENNAJI bd8169619e Refactor code and update tests for improved DX 2026-03-02 05:19:34 +00:00
Younes ENNAJI 0d25c72743 Add IDE autocompletion support and Type helper methods 2026-03-02 05:13:28 +00:00
Younes ENNAJI d4abef58eb Standardize exception message format and add exception tests 2026-03-02 04:06:51 +00:00
Younes ENNAJI e126813835 Fix FlasherPlugin::normalizeAlias() return type and add tests 2026-03-02 04:02:08 +00:00
Younes ENNAJI 5612d4d705 Fix ResponseManager filter criteria handling and update tests 2026-03-02 03:49:35 +00:00
Younes ENNAJI d39159cf90 Fix FilterEvent type consistency and remove redundant callable check 2026-03-02 03:42:27 +00:00
Younes ENNAJI 76d63c03ce Reset CSP handler in worker listeners and add related tests 2026-03-02 03:33:16 +00:00
Younes ENNAJI f399bc912d Update NotificationFactoryLocator and CHANGELOG 2026-03-02 03:23:45 +00:00
Younes ENNAJI 98336b98bf Update filter criteria and CHANGELOG 2026-03-02 03:20:33 +00:00
Younes ENNAJI 50ffa722a5 Add tests for OctaneListener and WorkerListener 2026-03-02 03:04:35 +00:00
Younes ENNAJI e783943933 Fix notification cleanup for Turbo and Livewire navigation 2026-03-02 02:42:38 +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 87da42fdea Refine code style and tests 2026-03-01 20:16:44 +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 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 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 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
Younes ENNAJI 549c36eeee improve test coverage for PHPUnit and Vitest 2026-02-25 19:16:53 +00:00
Younes ENNAJI d33de77835 add vitest for JS/TS testing with comprehensive test coverage 2026-02-25 15:52:21 +00:00
Younes ENNAJI c5059adac7 fix PHPStan errors in ThemeTemplatesTest 2026-02-25 11:34:09 +00:00
Younes ENNAJI 4145b870dd fix PHPStan errors in SessionBag 2026-02-25 11:34:01 +00:00
Younes ENNAJI f20bdebda0 add bootstrap and tailwindcss theme templates for Laravel 2026-02-25 11:20:29 +00:00
Younes ENNAJI f9807e91e2 add FallbackSession for stateless requests in Laravel 2026-02-25 11:15:34 +00:00
Younes ENNAJI 670e40dc97 fix StampsCriteria comparing values instead of keys 2026-02-25 10:43:44 +00:00
Younes ENNAJI 2b0e736d28 fix multi-field sorting in OrderByCriteria 2026-02-25 10:43:36 +00:00
Younes ENNAJI d65300a0e9 Fix PHPStan errors and test failures, improve PHPDoc documentation ordering 2026-01-10 04:36:16 +01:00
Younes ENNAJI 93ca18a67b add themes to symfony configuration 2025-03-27 21:23:53 +00:00
Younes ENNAJI 08b96bdd39 chore: enhance type safety with detailed PHPDoc annotations and stricter PHPStan validations 2024-10-13 21:39:22 +01:00
Younes ENNAJI 43affdc543 chore: add Symfony Profiler integration for PHPFlasher 2024-10-05 15:34:57 +01:00
Younes ENNAJI 58ca234a37 chore: upgrade dependencies 2024-09-21 18:33:59 +01:00
Younes ENNAJI d59e37812d chore: run php-cs-fixer 2024-09-19 06:42:10 +01:00
Younes ENNAJI b28525d718 chore: add and run phpstan phpunit 2024-05-27 00:34:47 +01:00
Younes ENNAJI 6de67f7fb3 chore: Refactor middleware to use Symfony's base response class
This commit updates the FlasherMiddleware and SessionMiddleware to utilize Symfony's base response class instead of Laravel's. This change ensures broader compatibility and addresses the issue with flash message rendering after page refreshes as identified by the community. Preparing for release in v2.0.2.
2024-05-26 13:20:48 +01:00