Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inertia.js v2.0 compatibility #671

Draft
wants to merge 50 commits into
base: 1.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a720de1
Install and run Pint
reinink May 25, 2024
c8f9b44
Make changelog consistent with previous entries
reinink May 25, 2024
e68596e
Drop support for Laravel 8 and 9 (#629)
reinink May 27, 2024
971d42d
Update changelog
reinink May 27, 2024
2db5eb2
Update CHANGELOG.md
driesvints May 28, 2024
7ad2ffb
deferred props
joetannenbaum Jul 9, 2024
369faff
lazy -> optional
joetannenbaum Jul 9, 2024
8edbd02
new meta key, nested version -> assetVersion under meta key
joetannenbaum Jul 12, 2024
4be6289
introduce the concept of ignore first load
joetannenbaum Jul 18, 2024
88b00ba
simplify app call detection logic
joetannenbaum Jul 18, 2024
336809f
clear history from the server
joetannenbaum Jul 23, 2024
95434d6
mergeable props
joetannenbaum Jul 29, 2024
fa70b17
eager prefetch via config
joetannenbaum Aug 1, 2024
0c99750
wip
joetannenbaum Aug 8, 2024
f6ad746
encrypt history
joetannenbaum Sep 27, 2024
b198c78
fixing tests
joetannenbaum Oct 3, 2024
e00319c
fixed spelling error
joetannenbaum Oct 3, 2024
7b473f4
removed eager loading as it landed in vite main
joetannenbaum Oct 3, 2024
da906d5
added history related props to tests
joetannenbaum Oct 3, 2024
141e693
Update DeferPropTest.php
joetannenbaum Oct 3, 2024
931130e
test for defer + merge
joetannenbaum Oct 3, 2024
289222e
encrypt/clear history
joetannenbaum Oct 3, 2024
735d20f
merge props test
joetannenbaum Oct 3, 2024
1a99ec8
history middleware tests
joetannenbaum Oct 3, 2024
935be8d
Update Response.php
joetannenbaum Oct 3, 2024
4905907
Update DeferPropTest.php
joetannenbaum Oct 3, 2024
c639445
Update ResponseFactoryTest.php
joetannenbaum Oct 3, 2024
22b22cd
merge and defer prop tests
joetannenbaum Oct 3, 2024
9b26d03
assertions for defer + merge tests
joetannenbaum Oct 3, 2024
7d702c6
Formatting
reinink Oct 10, 2024
31fed76
Delete ViteEagerPrefetch.php
joetannenbaum Oct 10, 2024
141256b
fixed dot config merging
joetannenbaum Oct 10, 2024
402a52e
store history clearing in session so it also works with redirects
joetannenbaum Oct 18, 2024
a836013
Merge pull request #677 from inertiajs/encryption-redirect-test
joetannenbaum Oct 18, 2024
4901e35
[2.x] Update dependencies
crynobone Nov 20, 2024
1558bac
[2.x] Supports PHP 8.4
crynobone Nov 20, 2024
91935b0
wip
crynobone Nov 20, 2024
7ee78a9
wip
crynobone Nov 20, 2024
a071794
upgrade github action dependencies
joetannenbaum Nov 20, 2024
4aa876b
Update tests.yml
joetannenbaum Nov 20, 2024
49f9305
Update tests.yml
joetannenbaum Nov 20, 2024
111d38b
Merge pull request #689 from inertiajs/upgrade-github-actions
joetannenbaum Nov 20, 2024
fad74bc
Merge branch '2.x' into patch-2
joetannenbaum Nov 20, 2024
166f25a
Merge pull request #687 from crynobone/patch-2
joetannenbaum Nov 20, 2024
1f84639
fixed situation where lazy functions were always being evaluated
joetannenbaum Nov 20, 2024
75410d7
resolve closures via app
joetannenbaum Nov 20, 2024
af3d0f3
public -> protected
joetannenbaum Nov 20, 2024
f557ed3
Merge pull request #688 from inertiajs/lazy-properties-fix
joetannenbaum Dec 3, 2024
d5e1d51
Merge pull request #686 from crynobone/patch-1
joetannenbaum Dec 5, 2024
0259e37
Update changelog
reinink Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/facade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: facades
on:
push:
branches:
- 'master'
- "master"

jobs:
update:
Expand All @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
49 changes: 10 additions & 39 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,19 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, "8.0", 8.1, 8.2, 8.3]
laravel: [8, 9, 10, 11]
php: [8.1, 8.2, 8.3, 8.4]
laravel: [10, 11]
stability: ["prefer-lowest", "prefer-stable"]
exclude:
- php: 7.3
laravel: 9
- php: 7.3
- php: 8.4
laravel: 10
- php: 7.3
laravel: 11
- php: 7.4
laravel: 9
- php: 7.4
laravel: 10
- php: 7.4
laravel: 11
- php: '8.0'
laravel: 10
- php: '8.0'
laravel: 11
- php: 8.1
laravel: 6
- php: 8.1
laravel: 7
- php: 8.1
laravel: 11
- php: 8.2
laravel: 6
- php: 8.2
laravel: 7
- php: 8.2
laravel: 8
- php: 8.3
laravel: 6
- php: 8.3
laravel: 7
- php: 8.3
laravel: 8

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (w/ ${{ matrix.stability }})
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -66,7 +36,7 @@ jobs:
coverage: none

- name: Set Minimum PHP 8.1 Versions
uses: nick-invision/retry@v1
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
Expand All @@ -76,7 +46,7 @@ jobs:
if: matrix.php >= 8.1 && matrix.stability == 'prefer-lowest'

- name: Set Minimum PHP 8.2 Versions
uses: nick-invision/retry@v1
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
Expand All @@ -85,23 +55,24 @@ jobs:
if: matrix.php >= 8.2 && matrix.stability == 'prefer-lowest'

- name: Set Minimum PHP 8.2 Versions and Laravel > 11
uses: nick-invision/retry@v1
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: |
composer require orchestra/testbench:^9.2 --dev --${{ matrix.stability }} --no-update --no-interaction
composer require phpunit/phpunit:^10.4 --dev --${{ matrix.stability }} --no-update --no-interaction
if: matrix.php >= 8.2 && matrix.stability == 'prefer-lowest' && matrix.laravel >= 11

- name: Set Laravel version
uses: nick-invision/retry@v1
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework=^${{ matrix.laravel }}" --no-interaction --no-update

- name: Install dependencies
uses: nick-invision/retry@v1
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
Expand Down
28 changes: 0 additions & 28 deletions .php-cs-fixer.dist.php

This file was deleted.

24 changes: 17 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
# Release Notes

## [Unreleased](https://github.com/inertiajs/inertia-laravel/compare/v1.2.0...1.x)
## [Unreleased](https://github.com/inertiajs/inertia-laravel/compare/v2.0.0...2.x)

- Add "always" props using new `Inertia::always()` wrapper ([#627](https://github.com/inertiajs/inertia-laravel/pull/627))
- Nothing!

## [v2.0.0](https://github.com/inertiajs/inertia-laravel/compare/v1.2.0...2.0.0)

- Add support for Inertia.js v2.0.0
- Add `Inertia::defer()` to support deferred props
- Add `Inertia::merge()` to support merging props on client
- Add `Inertia::always()` for props that should always be included ([#627](https://github.com/inertiajs/inertia-laravel/pull/627))
- Add `Inertia::clearHistory()` and `Inertia::encryptHistory()` methods, encryption config, and encryption middleware
- Deprecated `Inertia::lazy()` in favor of `Inertia::optional()`
- Drop support for Laravel 8 and 9 ([#629](https://github.com/inertiajs/inertia-laravel/pull/629))

## [v1.2.0](https://github.com/inertiajs/inertia-laravel/compare/v1.1.0...v1.2.0) - 2024-05-17

* [1.x] Make commands lazy by [@timacdonald](https://github.com/timacdonald) in https://github.com/inertiajs/inertia-laravel/pull/601
* [1.x] Persistent properties by [@lepikhinb](https://github.com/lepikhinb) in https://github.com/inertiajs/inertia-laravel/pull/621
* [1.x] Exclude properties from partial responses by [@lepikhinb](https://github.com/lepikhinb) in https://github.com/inertiajs/inertia-laravel/pull/622
- Make commands lazy ([#601](https://github.com/inertiajs/inertia-laravel/pull/601))
- Add persistent properties ([#621](https://github.com/inertiajs/inertia-laravel/pull/621))
- Exclude `except` props from partial reloads ([#622](https://github.com/inertiajs/inertia-laravel/pull/622))

## [v1.1.0](https://github.com/inertiajs/inertia-laravel/compare/v1.0.0...v1.1.0) - 2024-05-16

* Support dot notation in partial requests by [@lepikhinb](https://github.com/lepikhinb) in https://github.com/inertiajs/inertia-laravel/pull/620
* [1.x] Add `$request->inertia()` IDE helper by [@ycs77](https://github.com/ycs77) in https://github.com/inertiajs/inertia-laravel/pull/625
- Support dot notation in partial requests ([#620](https://github.com/inertiajs/inertia-laravel/pull/620))
- Add `$request->inertia()` IDE helper ([#625](https://github.com/inertiajs/inertia-laravel/pull/625))

## [v1.0.0](https://github.com/inertiajs/inertia-laravel/compare/v0.6.11...v1.0.0) - 2024-03-08

Expand Down
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "inertiajs/inertia-laravel",
"type": "library",
"description": "The Laravel adapter for Inertia.js.",
"keywords": ["laravel", "inertia"],
"keywords": [
"laravel",
"inertia"
],
"license": "MIT",
"authors": [
{
Expand All @@ -25,16 +28,17 @@
}
},
"require": {
"php": "^7.3|~8.0.0|~8.1.0|~8.2.0|~8.3.0",
"php": "^8.1.0",
"ext-json": "*",
"laravel/framework": "^8.74|^9.0|^10.0|^11.0",
"symfony/console": "^5.3|^6.0|^7.0"
"laravel/framework": "^10.0|^11.0",
"symfony/console": "^6.2|^7.0"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"orchestra/testbench": "^6.4|^7.0|^8.0|^9.0",
"orchestra/testbench": "^8.0|^9.2",
"mockery/mockery": "^1.3.3",
"phpunit/phpunit": "^8.0|^9.5.8|^10.4"
"phpunit/phpunit": "^10.4|^11.0",
"laravel/pint": "^1.16"
},
"suggest": {
"ext-pcntl": "Recommended when running the Inertia SSR server via the `inertia:start-ssr` artisan command."
Expand All @@ -44,9 +48,6 @@
"providers": [
"Inertia\\ServiceProvider"
]
},
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"minimum-stability": "dev",
Expand Down
6 changes: 6 additions & 0 deletions config/inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@

],

'history' => [

'encrypt' => false,

],

];
2 changes: 1 addition & 1 deletion src/AlwaysProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AlwaysProp
protected $value;

/**
* @param mixed $value
* @param mixed $value
*/
public function __construct($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/CreateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function getStub(): string
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @param string $rootNamespace
*/
protected function getDefaultNamespace($rootNamespace): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/StartSsr.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Inertia\Commands;

use Inertia\Ssr\SsrException;
use Illuminate\Console\Command;
use Inertia\Ssr\BundleDetector;
use Inertia\Ssr\SsrException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -36,7 +36,7 @@ public function handle(): int
return self::FAILURE;
}

$bundle = (new BundleDetector())->detect();
$bundle = (new BundleDetector)->detect();
$configuredBundle = config('inertia.ssr.bundle');

if ($bundle === null) {
Expand Down
30 changes: 30 additions & 0 deletions src/DeferProp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Inertia;

use Illuminate\Support\Facades\App;

class DeferProp implements IgnoreFirstLoad, Mergeable
{
use MergesProps;

protected $callback;

protected $group;

public function __construct(callable $callback, ?string $group = null)
{
$this->callback = $callback;
$this->group = $group;
}

public function group()
{
return $this->group;
}

public function __invoke()
{
return App::call($this->callback);
}
}
4 changes: 2 additions & 2 deletions src/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Directive
/**
* Compiles the "@inertia" directive.
*
* @param string $expression
* @param string $expression
*/
public static function compile($expression = ''): string
{
Expand All @@ -32,7 +32,7 @@ public static function compile($expression = ''): string
/**
* Compiles the "@inertiaHead" directive.
*
* @param string $expression
* @param string $expression
*/
public static function compileHead($expression = ''): string
{
Expand Down
22 changes: 22 additions & 0 deletions src/EncryptHistoryMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Inertia;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class EncryptHistoryMiddleware
{
/**
* Handle the incoming request.
*
* @return Response
*/
public function handle(Request $request, Closure $next)
{
Inertia::encryptHistory();

return $next($request);
}
}
8 changes: 8 additions & 0 deletions src/IgnoreFirstLoad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Inertia;

interface IgnoreFirstLoad
{
//
}
5 changes: 5 additions & 0 deletions src/Inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
* @method static void setRootView(string $name)
* @method static void share(string|array|\Illuminate\Contracts\Support\Arrayable $key, mixed $value = null)
* @method static mixed getShared(string|null $key = null, mixed $default = null)
* @method static void clearHistory()
* @method static void encryptHistory($encrypt = true)
* @method static void flushShared()
* @method static void version(\Closure|string|null $version)
* @method static string getVersion()
* @method static \Inertia\OptionalProp optional(callable $callback)
* @method static \Inertia\LazyProp lazy(callable $callback)
* @method static \Inertia\DeferProp defer(callable $callback, string $group = 'default')
* @method static \Inertia\AlwaysProp always(mixed $value)
* @method static \Inertia\MergeProp merge(mixed $value)
* @method static \Inertia\Response render(string $component, array|\Illuminate\Contracts\Support\Arrayable $props = [])
* @method static \Symfony\Component\HttpFoundation\Response location(string|\Symfony\Component\HttpFoundation\RedirectResponse $url)
* @method static void macro(string $name, object|callable $macro)
Expand Down
2 changes: 1 addition & 1 deletion src/LazyProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Support\Facades\App;

class LazyProp
class LazyProp implements IgnoreFirstLoad
{
protected $callback;

Expand Down
Loading
Loading