diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 485e083..d83c2e3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,9 +34,6 @@ jobs: - name: Install Node Dependencies run: npm ci - - name: Build Assets - run: npm run build - - name: Install Dependencies run: composer install --no-interaction --prefer-dist --optimize-autoloader @@ -46,5 +43,8 @@ jobs: - name: Generate Application Key run: php artisan key:generate + - name: Build Assets + run: npm run build + - name: Tests run: ./vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 3847c0d..c625a11 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ /public/build /public/hot /public/storage +/resources/js/actions +/resources/js/routes +/resources/js/wayfinder /storage/*.key /storage/pail /vendor diff --git a/.prettierignore b/.prettierignore index df954ec..6b929ae 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,2 @@ resources/js/components/ui/* -resources/js/ziggy.js resources/views/mail/* diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 5226e82..c987856 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -5,7 +5,6 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Http\Request; use Inertia\Middleware; -use Tighten\Ziggy\Ziggy; class HandleInertiaRequests extends Middleware { @@ -46,10 +45,6 @@ public function share(Request $request): array 'auth' => [ 'user' => $request->user(), ], - 'ziggy' => fn (): array => [ - ...(new Ziggy)->toArray(), - 'location' => $request->url(), - ], ]; } } diff --git a/composer.json b/composer.json index 06272d4..6adb38f 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "inertiajs/inertia-laravel": "^2.0", "laravel/framework": "^12.0", "laravel/tinker": "^2.10.1", - "tightenco/ziggy": "^2.4" + "laravel/wayfinder": "^0.1.11" }, "require-dev": { "fakerphp/faker": "^1.23", diff --git a/composer.lock b/composer.lock index 15d0794..b300a24 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6d580901de64f9d577d8c139cea61306", + "content-hash": "571ef328e142a00b03493cd8656d5d2e", "packages": [ { "name": "brick/math", @@ -1524,6 +1524,68 @@ }, "time": "2025-01-27T14:24:01+00:00" }, + { + "name": "laravel/wayfinder", + "version": "v0.1.11", + "source": { + "type": "git", + "url": "https://github.com/laravel/wayfinder.git", + "reference": "240f984fd8f48144e51dbe9efd2ec29d0b2aa075" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/wayfinder/zipball/240f984fd8f48144e51dbe9efd2ec29d0b2aa075", + "reference": "240f984fd8f48144e51dbe9efd2ec29d0b2aa075", + "shasum": "" + }, + "require": { + "illuminate/console": "^11.0|^12.0", + "illuminate/filesystem": "^11.0|^12.0", + "illuminate/routing": "^11.0|^12.0", + "illuminate/support": "^11.0|^12.0", + "php": "^8.2" + }, + "require-dev": { + "laravel/pint": "^1.21", + "orchestra/testbench": "^10.1 | ^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Wayfinder\\WayfinderServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Wayfinder\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Generate TypeScript representations of your Laravel actions and routes.", + "homepage": "https://github.com/laravel/wayfinder", + "keywords": [ + "laravel", + "php", + "routes", + "typescript" + ], + "support": { + "issues": "https://github.com/laravel/wayfinder/issues", + "source": "https://github.com/laravel/wayfinder" + }, + "time": "2025-09-02T16:25:15+00:00" + }, { "name": "league/commonmark", "version": "2.7.1", @@ -5617,76 +5679,6 @@ ], "time": "2025-07-29T20:02:46+00:00" }, - { - "name": "tightenco/ziggy", - "version": "v2.5.3", - "source": { - "type": "git", - "url": "https://github.com/tighten/ziggy.git", - "reference": "0b3b521d2c55fbdb04b6721532f7f5f49d32f52b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tighten/ziggy/zipball/0b3b521d2c55fbdb04b6721532f7f5f49d32f52b", - "reference": "0b3b521d2c55fbdb04b6721532f7f5f49d32f52b", - "shasum": "" - }, - "require": { - "ext-json": "*", - "laravel/framework": ">=9.0", - "php": ">=8.1" - }, - "require-dev": { - "laravel/folio": "^1.1", - "orchestra/testbench": "^7.0 || ^8.0 || ^9.0 || ^10.0", - "pestphp/pest": "^2.26|^3.0", - "pestphp/pest-plugin-laravel": "^2.4|^3.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Tighten\\Ziggy\\ZiggyServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Tighten\\Ziggy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel Coulbourne", - "email": "daniel@tighten.co" - }, - { - "name": "Jake Bathman", - "email": "jake@tighten.co" - }, - { - "name": "Jacob Baker-Kretzmar", - "email": "jacob@tighten.co" - } - ], - "description": "Use your Laravel named routes in JavaScript.", - "homepage": "https://github.com/tighten/ziggy", - "keywords": [ - "Ziggy", - "javascript", - "laravel", - "routes" - ], - "support": { - "issues": "https://github.com/tighten/ziggy/issues", - "source": "https://github.com/tighten/ziggy/tree/v2.5.3" - }, - "time": "2025-05-17T18:15:19+00:00" - }, { "name": "tijsverkoyen/css-to-inline-styles", "version": "v2.3.0", diff --git a/package-lock.json b/package-lock.json index b549256..d2e0db6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ }, "devDependencies": { "@eslint/js": "^9.19.0", + "@laravel/vite-plugin-wayfinder": "^0.1.3", "@types/node": "^22.13.5", "eslint": "^9.17.0", "eslint-config-prettier": "^10.0.1", @@ -1023,6 +1024,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@laravel/vite-plugin-wayfinder": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@laravel/vite-plugin-wayfinder/-/vite-plugin-wayfinder-0.1.3.tgz", + "integrity": "sha512-S/21Lzl7lci7LrRo/VsN5AXT02AMf7rs+OPTyt3VPgffBB1wTrzwsPr28sCU0gcR/APhfC1eVIUwpLbAvBmyKw==", + "dev": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/package.json b/package.json index beff1b6..812a1c3 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "@eslint/js": "^9.19.0", + "@laravel/vite-plugin-wayfinder": "^0.1.3", "@types/node": "^22.13.5", "eslint": "^9.17.0", "eslint-config-prettier": "^10.0.1", diff --git a/resources/js/ssr.tsx b/resources/js/ssr.tsx index c9fa482..123cd80 100644 --- a/resources/js/ssr.tsx +++ b/resources/js/ssr.tsx @@ -2,7 +2,6 @@ import { createInertiaApp } from '@inertiajs/react'; import createServer from '@inertiajs/react/server'; import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; import ReactDOMServer from 'react-dom/server'; -import { type RouteName, route } from 'ziggy-js'; const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; @@ -12,19 +11,6 @@ createServer((page) => render: ReactDOMServer.renderToString, title: (title) => title ? `${title} - ${appName}` : appName, resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')), - setup: ({ App, props }) => { - /* eslint-disable */ - // @ts-expect-error - global.route = (name, params, absolute) => - route(name, params as any, absolute, { - // @ts-expect-error - ...page.props.ziggy, - // @ts-expect-error - location: new URL(page.props.ziggy.location), - }); - /* eslint-enable */ - - return ; - }, + setup: ({ App, props }) => , }), ); diff --git a/resources/js/types/global.d.ts b/resources/js/types/global.d.ts deleted file mode 100644 index b3c9b78..0000000 --- a/resources/js/types/global.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { route as routeFn } from 'ziggy-js'; - -declare global { - const route: typeof routeFn; -} diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 2c932c8..5160156 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -1,5 +1,3 @@ -import type { Config } from 'ziggy-js'; - export interface Auth { user: User; } @@ -8,7 +6,6 @@ export interface SharedData { name: string; quote: { message: string; author: string }; auth: Auth; - ziggy: Config & { location: string }; [key: string]: unknown; } diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index d1145fd..e777743 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -13,7 +13,6 @@ - @routes @viteReactRefresh @vite(['resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"]) @inertiaHead diff --git a/tsconfig.json b/tsconfig.json index f905a3e..86c608a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -109,8 +109,7 @@ "skipLibCheck": true /* Skip type checking all .d.ts files. */, "baseUrl": ".", "paths": { - "@/*": ["./resources/js/*"], - "ziggy-js": ["./vendor/tightenco/ziggy"] + "@/*": ["./resources/js/*"] }, "jsx": "react-jsx" }, diff --git a/vite.config.ts b/vite.config.ts index 290d90e..2183575 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,7 @@ +import { wayfinder } from '@laravel/vite-plugin-wayfinder'; import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; import laravel from 'laravel-vite-plugin'; -import { resolve } from 'node:path'; import { defineConfig } from 'vite'; export default defineConfig({ @@ -13,13 +13,11 @@ export default defineConfig({ }), react(), tailwindcss(), + wayfinder({ + formVariants: true, + }), ], esbuild: { jsx: 'automatic', }, - resolve: { - alias: { - 'ziggy-js': resolve(__dirname, 'vendor/tightenco/ziggy'), - }, - }, });