diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b5a62a4bf..18e18d9d9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: true matrix: - stack: [blade, livewire, livewire-functional, react, vue, api] + stack: [blade, livewire, livewire-functional, react, svelte, vue, api] laravel: [11] args: ["", --pest] include: @@ -26,6 +26,9 @@ jobs: - stack: react args: --ssr --typescript laravel: 11 + - stack: svelte + args: --ssr --typescript + laravel: 11 name: Test Stubs - Laravel ${{ matrix.laravel }} - ${{ matrix.stack }} ${{ matrix.args }} diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 17be8c5fb..f5d8469e9 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -29,7 +29,7 @@ class InstallCommand extends Command implements PromptsForMissingInput * * @var string */ - protected $signature = 'breeze:install {stack : The development stack that should be installed (blade,livewire,livewire-functional,react,vue,api)} + protected $signature = 'breeze:install {stack : The development stack that should be installed (blade,livewire,livewire-functional,react,svelte,vue,api)} {--dark : Indicate that dark mode support should be installed} {--pest : Indicate that Pest should be installed} {--ssr : Indicates if Inertia SSR support should be installed} @@ -55,6 +55,8 @@ public function handle() return $this->installInertiaVueStack(); } elseif ($this->argument('stack') === 'react') { return $this->installInertiaReactStack(); + } elseif ($this->argument('stack') === 'svelte') { + return $this->installInertiaSvelteStack(); } elseif ($this->argument('stack') === 'api') { return $this->installApiStack(); } elseif ($this->argument('stack') === 'blade') { @@ -380,6 +382,7 @@ protected function promptForMissingArgumentsUsing() 'livewire' => 'Livewire (Volt Class API) with Alpine', 'livewire-functional' => 'Livewire (Volt Functional API) with Alpine', 'react' => 'React with Inertia', + 'svelte' => 'Svelte with Inertia', 'vue' => 'Vue with Inertia', 'api' => 'API only', ], @@ -397,7 +400,7 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp { $stack = $input->getArgument('stack'); - if (in_array($stack, ['react', 'vue'])) { + if (in_array($stack, ['react', 'svelte', 'vue'])) { collect(multiselect( label: 'Would you like any optional features?', options: [ diff --git a/src/Console/InstallsInertiaStacks.php b/src/Console/InstallsInertiaStacks.php index 3ba5268c1..46fd90a0b 100644 --- a/src/Console/InstallsInertiaStacks.php +++ b/src/Console/InstallsInertiaStacks.php @@ -472,6 +472,218 @@ protected function configureReactHydrateRootForSsr($path) ); } + /** + * Install the Inertia Svelte stack. + * + * @return int|null + */ + protected function installInertiaSvelteStack() + { + // Install Inertia... + if (! $this->requireComposerPackages(['inertiajs/inertia-laravel:^1.0', 'laravel/sanctum:^4.0', 'tightenco/ziggy:^2.0'])) { + return 1; + } + + // NPM Packages... + $this->updateNodePackages(function ($packages) { + return [ + '@inertiajs/svelte' => '^2.0.0-beta.2', + '@tailwindcss/forms' => '^0.5.7', + '@sveltejs/vite-plugin-svelte' => '^4.0.0', + 'autoprefixer' => '^10.4.20', + 'postcss' => '^8.4.33', + 'tailwindcss' => '^3.4.10', + 'svelte' => '^5.0', + 'svelte-check' => '^4.0.0', + ] + $packages; + }); + + if ($this->option('typescript')) { + $this->updateNodePackages(function ($packages) { + return [ + 'typescript' => '^5.5', + '@tsconfig/svelte' => '^5.0.2', + ] + $packages; + }); + } + + if ($this->option('eslint')) { + $this->updateNodePackages(function ($packages) { + return [ + 'eslint' => '^9.7.0', + 'eslint-plugin-svelte' => '^2.36.0', + 'eslint-config-prettier' => '^9.1.0', + 'prettier' => '^3.3.3', + 'prettier-plugin-organize-imports' => '^4.0.0', + 'prettier-plugin-tailwindcss' => '^0.6.5', + 'prettier-plugin-svelte' => '^3.2.7', + ] + $packages; + }); + + if ($this->option('typescript')) { + $this->updateNodePackages(function ($packages) { + return [ + '@types/eslint' => '^9.6.0', + 'typescript-eslint' => '^8.0.0', + ] + $packages; + }); + + + $this->updateNodeScripts(function ($scripts) { + return $scripts + [ + 'check' => 'svelte-check --tsconfig ./tsconfig.json', + 'check:watch' => 'svelte-check --tsconfig ./tsconfig.json --watch', + 'format' => 'prettier --write resources/js', + 'lint' => 'eslint resources/js --fix', + ]; + }); + + copy(__DIR__.'/../../stubs/inertia-svelte-ts/eslint.config.js', base_path('eslint.config.js')); + } else { + $this->updateNodeScripts(function ($scripts) { + return $scripts + [ + 'check' => 'svelte-check --tsconfig ./jsconfig.json', + 'check:watch' => 'svelte-check --tsconfig ./jsconfig.json --watch', + 'format' => 'prettier --write resources/js', + 'lint' => 'eslint resources/js --fix', + ]; + }); + + copy(__DIR__.'/../../stubs/inertia-svelte/eslint.config.js', base_path('eslint.config.js')); + } + + copy(__DIR__.'/../../stubs/inertia-svelte/.prettierrc', base_path('.prettierrc')); + } + + // Providers... + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/app/Providers', app_path('Providers')); + + // Controllers... + (new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/app/Http/Controllers', app_path('Http/Controllers')); + + // Requests... + (new Filesystem)->ensureDirectoryExists(app_path('Http/Requests')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Requests', app_path('Http/Requests')); + + // Middleware... + $this->installMiddleware([ + '\App\Http\Middleware\HandleInertiaRequests::class', + '\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class', + ]); + + (new Filesystem)->ensureDirectoryExists(app_path('Http/Middleware')); + copy(__DIR__.'/../../stubs/inertia-common/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php')); + + // Views... + copy(__DIR__.'/../../stubs/inertia-svelte/resources/views/app.blade.php', resource_path('views/app.blade.php')); + + @unlink(resource_path('views/welcome.blade.php')); + + // Components + Pages... + (new Filesystem)->ensureDirectoryExists(resource_path('js/Components')); + (new Filesystem)->ensureDirectoryExists(resource_path('js/Layouts')); + (new Filesystem)->ensureDirectoryExists(resource_path('js/Pages')); + + if ($this->option('typescript')) { + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/Components', resource_path('js/Components')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/Layouts', resource_path('js/Layouts')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/Pages', resource_path('js/Pages')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/types', resource_path('js/types')); + } else { + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte/resources/js/Components', resource_path('js/Components')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte/resources/js/Layouts', resource_path('js/Layouts')); + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-svelte/resources/js/Pages', resource_path('js/Pages')); + } + + if (! $this->option('dark')) { + $this->removeDarkClasses((new Finder) + ->in(resource_path('js')) + ->name(['*.svelte', '*.svelte']) + ->notName(['Welcome.svelte']) + ); + } + + // Tests... + if (! $this->installTests()) { + return 1; + } + + if ($this->option('pest')) { + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/pest-tests/Feature', base_path('tests/Feature')); + } else { + (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/inertia-common/tests/Feature', base_path('tests/Feature')); + } + + // Routes... + copy(__DIR__.'/../../stubs/inertia-common/routes/web.php', base_path('routes/web.php')); + copy(__DIR__.'/../../stubs/inertia-common/routes/auth.php', base_path('routes/auth.php')); + + // Tailwind / Vite... + copy(__DIR__.'/../../stubs/default/resources/css/app.css', resource_path('css/app.css')); + copy(__DIR__.'/../../stubs/default/postcss.config.js', base_path('postcss.config.js')); + copy(__DIR__.'/../../stubs/inertia-common/tailwind.config.js', base_path('tailwind.config.js')); + copy(__DIR__.'/../../stubs/inertia-svelte/vite.config.js', base_path('vite.config.js')); + + if ($this->option('typescript')) { + copy(__DIR__.'/../../stubs/inertia-svelte-ts/tsconfig.json', base_path('tsconfig.json')); + copy(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/app.ts', resource_path('js/app.ts')); + + if (file_exists(resource_path('js/app.js'))) { + unlink(resource_path('js/app.js')); + } + + if (file_exists(resource_path('js/bootstrap.js'))) { + rename(resource_path('js/bootstrap.js'), resource_path('js/bootstrap.ts')); + } + + $this->replaceInFile('.js', '.ts', base_path('vite.config.js')); + $this->replaceInFile('.js', '.ts', resource_path('views/app.blade.php')); + $this->replaceInFile('.vue', '.svelte', base_path('tailwind.config.js')); + $this->replaceInFile('"vite build', '"tsc && vite build', base_path('package.json')); + } else { + copy(__DIR__.'/../../stubs/inertia-svelte/jsconfig.json', base_path('jsconfig.json')); + copy(__DIR__.'/../../stubs/inertia-svelte/resources/js/app.js', resource_path('js/app.js')); + + $this->replaceInFile('.vue', '.svelte', base_path('tailwind.config.js')); + } + + if ($this->option('ssr')) { + $this->installInertiaSvelteSsrStack(); + } + + $this->components->info('Installing and building Node dependencies.'); + + if (file_exists(base_path('pnpm-lock.yaml'))) { + $this->runCommands(['pnpm install', 'pnpm run build']); + } elseif (file_exists(base_path('yarn.lock'))) { + $this->runCommands(['yarn install', 'yarn run build']); + } elseif (file_exists(base_path('bun.lockb'))) { + $this->runCommands(['bun install', 'bun run build']); + } else { + $this->runCommands(['npm install', 'npm run build']); + } + + $this->line(''); + $this->components->info('Breeze scaffolding installed successfully.'); + } + + protected function installInertiaSvelteSsrStack() + { + if ($this->option('typescript')) { + copy(__DIR__.'/../../stubs/inertia-svelte-ts/resources/js/ssr.ts', resource_path('js/ssr.ts')); + $this->replaceInFile("input: 'resources/js/app.ts',", "input: 'resources/js/app.ts',".PHP_EOL." ssr: 'resources/js/ssr.ts',", base_path('vite.config.js')); + } else { + copy(__DIR__.'/../../stubs/inertia-svelte/resources/js/ssr.js', resource_path('js/ssr.js')); + $this->replaceInFile("input: 'resources/js/app.js',", "input: 'resources/js/app.js',".PHP_EOL." ssr: 'resources/js/ssr.js',", base_path('vite.config.js')); + } + + $this->configureZiggyForSsr(); + + $this->replaceInFile('vite build', 'vite build && vite build --ssr', base_path('package.json')); + $this->replaceInFile('/node_modules', '/bootstrap/ssr'.PHP_EOL.'/node_modules', base_path('.gitignore')); + } + /** * Configure Ziggy for SSR. * diff --git a/stubs/inertia-svelte-ts/eslint.config.js b/stubs/inertia-svelte-ts/eslint.config.js new file mode 100644 index 000000000..04d0acd70 --- /dev/null +++ b/stubs/inertia-svelte-ts/eslint.config.js @@ -0,0 +1,39 @@ +import prettier from 'eslint-config-prettier'; +import js from '@eslint/js'; +import svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; +import ts from 'typescript-eslint'; + +export default ts.config( + js.configs.recommended, + ...ts.configs.recommended, + ...svelte.configs['flat/recommended'], + prettier, + ...svelte.configs['flat/prettier'], + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + files: ['**/*.svelte'], + + languageOptions: { + parserOptions: { + parser: ts.parser + } + } + }, + { + ignores: ['bootstrap', 'public', 'vendor'] + }, + { + rules: { + 'no-undef': 'off', + '@typescript-eslint/no-unused-expressions': 'off', + } + } +); diff --git a/stubs/inertia-svelte-ts/resources/js/Components/ApplicationLogo.svelte b/stubs/inertia-svelte-ts/resources/js/Components/ApplicationLogo.svelte new file mode 100644 index 000000000..78d5bd7d7 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/ApplicationLogo.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/Checkbox.svelte b/stubs/inertia-svelte-ts/resources/js/Components/Checkbox.svelte new file mode 100644 index 000000000..9f8a293df --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/Checkbox.svelte @@ -0,0 +1,18 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/DangerButton.svelte b/stubs/inertia-svelte-ts/resources/js/Components/DangerButton.svelte new file mode 100644 index 000000000..1e44a0045 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/DangerButton.svelte @@ -0,0 +1,19 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/Dropdown.svelte b/stubs/inertia-svelte-ts/resources/js/Components/Dropdown.svelte new file mode 100644 index 000000000..cd60612cd --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/Dropdown.svelte @@ -0,0 +1,96 @@ + + + + + + +
+
(open = !open)}> + {@render trigger()} +
+ + + {#if open} +
(open = false)}>
+
+
(open = false)} + > +
+ {@render content()} +
+
+
+ {/if} +
diff --git a/stubs/inertia-svelte-ts/resources/js/Components/DropdownLink.svelte b/stubs/inertia-svelte-ts/resources/js/Components/DropdownLink.svelte new file mode 100644 index 000000000..04a2a0def --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/DropdownLink.svelte @@ -0,0 +1,26 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/InputError.svelte b/stubs/inertia-svelte-ts/resources/js/Components/InputError.svelte new file mode 100644 index 000000000..661fcdfa1 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/InputError.svelte @@ -0,0 +1,18 @@ + + +{#if message} +
+

+ {message} +

+
+{/if} diff --git a/stubs/inertia-svelte-ts/resources/js/Components/InputLabel.svelte b/stubs/inertia-svelte-ts/resources/js/Components/InputLabel.svelte new file mode 100644 index 000000000..f9f8eed33 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/InputLabel.svelte @@ -0,0 +1,22 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/Modal.svelte b/stubs/inertia-svelte-ts/resources/js/Components/Modal.svelte new file mode 100644 index 000000000..1b99bbca2 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/Modal.svelte @@ -0,0 +1,84 @@ + + + + +{#if show} +
+
+
+ + +
+ +
+
+ {@render children()} +
+
+
+
+{/if} diff --git a/stubs/inertia-svelte-ts/resources/js/Components/NavLink.svelte b/stubs/inertia-svelte-ts/resources/js/Components/NavLink.svelte new file mode 100644 index 000000000..dff8a804d --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/NavLink.svelte @@ -0,0 +1,30 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/PrimaryButton.svelte b/stubs/inertia-svelte-ts/resources/js/Components/PrimaryButton.svelte new file mode 100644 index 000000000..28b0babce --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/PrimaryButton.svelte @@ -0,0 +1,19 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/ResponsiveNavLink.svelte b/stubs/inertia-svelte-ts/resources/js/Components/ResponsiveNavLink.svelte new file mode 100644 index 000000000..1576ee422 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/ResponsiveNavLink.svelte @@ -0,0 +1,35 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/SecondaryButton.svelte b/stubs/inertia-svelte-ts/resources/js/Components/SecondaryButton.svelte new file mode 100644 index 000000000..90da9d74d --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/SecondaryButton.svelte @@ -0,0 +1,22 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Components/TextInput.svelte b/stubs/inertia-svelte-ts/resources/js/Components/TextInput.svelte new file mode 100644 index 000000000..9b3b766d0 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Components/TextInput.svelte @@ -0,0 +1,31 @@ + + + diff --git a/stubs/inertia-svelte-ts/resources/js/Layouts/AuthenticatedLayout.svelte b/stubs/inertia-svelte-ts/resources/js/Layouts/AuthenticatedLayout.svelte new file mode 100644 index 000000000..77e46ae66 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Layouts/AuthenticatedLayout.svelte @@ -0,0 +1,149 @@ + + +
+ + + + {#if header} +
+
+ {@render header()} +
+
+ {/if} + + +
+ {@render children()} +
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Layouts/GuestLayout.svelte b/stubs/inertia-svelte-ts/resources/js/Layouts/GuestLayout.svelte new file mode 100644 index 000000000..9cf9d7143 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Layouts/GuestLayout.svelte @@ -0,0 +1,23 @@ + + +
+
+ + + +
+ +
+ {@render children()} +
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ConfirmPassword.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ConfirmPassword.svelte new file mode 100644 index 000000000..2e543a5c4 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ConfirmPassword.svelte @@ -0,0 +1,54 @@ + + + + Confirm Password + + + +
+ This is a secure area of the application. Please confirm your password before continuing. +
+ +
+
+ + + +
+ +
+ Confirm +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ForgotPassword.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ForgotPassword.svelte new file mode 100644 index 000000000..e55306f99 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ForgotPassword.svelte @@ -0,0 +1,62 @@ + + + + Forgot Password + + + +
+ Forgot your password? No problem. Just let us know your email address and we will email you + a password reset link that will allow you to choose a new one. +
+ + {#if status} +
+ {status} +
+ {/if} + +
+
+ + + + + +
+ +
+ + Email Password Reset Link + +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Login.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Login.svelte new file mode 100644 index 000000000..eedecdcc7 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Login.svelte @@ -0,0 +1,100 @@ + + + + Log in + + + + {#if status} +
+ {status} +
+ {/if} + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ +
+ +
+ {#if canResetPassword} + + Forgot your password? + + {/if} + + Log in +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Register.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Register.svelte new file mode 100644 index 000000000..bfb686f0e --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/Register.svelte @@ -0,0 +1,109 @@ + + + + Register + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ + Already registered? + + + + Register + +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ResetPassword.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ResetPassword.svelte new file mode 100644 index 000000000..e930428e5 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/ResetPassword.svelte @@ -0,0 +1,86 @@ + + + + Reset Password + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ Reset Password +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Auth/VerifyEmail.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/VerifyEmail.svelte new file mode 100644 index 000000000..a2f64c556 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Auth/VerifyEmail.svelte @@ -0,0 +1,49 @@ + + + + Email Verification + + + +
+ Thanks for signing up! Before getting started, could you verify your email address by + clicking on the link we just emailed to you? If you didn't receive the email, we will gladly + send you another. +
+ + {#if verificationLinkSent} +
+ A new verification link has been sent to the email address you provided during + registration. +
+ {/if} + +
+
+ + Resend Verification Email + + + +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Dashboard.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Dashboard.svelte new file mode 100644 index 000000000..dab886378 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Dashboard.svelte @@ -0,0 +1,23 @@ + + + + Dashboard + + + + {#snippet header()} +

+ Dashboard +

+ {/snippet} + +
+
+
+
You're logged in!
+
+
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Edit.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Edit.svelte new file mode 100644 index 000000000..6f1795712 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Edit.svelte @@ -0,0 +1,40 @@ + + + + Profile + + + + {#snippet header()} +

+ Profile +

+ {/snippet} + +
+
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte new file mode 100644 index 000000000..b8a5b5932 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte @@ -0,0 +1,94 @@ + + +
+
+

Delete Account

+ +

+ Once your account is deleted, all of its resources and data will be permanently deleted. + Before deleting your account, please download any data or information that you wish to + retain. +

+
+ + Delete Account + + +
+

+ Are you sure you want to delete your account? +

+ +

+ Once your account is deleted, all of its resources and data will be permanently + deleted. Please enter your password to confirm you would like to permanently delete + your account. +

+ +
+ + + e.key === 'Enter' && deleteUser()} + /> + + +
+ +
+ Cancel + + + Delete Account + +
+
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte new file mode 100644 index 000000000..a864424a9 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte @@ -0,0 +1,106 @@ + + +
+
+

Update Password

+ +

+ Ensure your account is using a long, random password to stay secure. +

+
+ +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ Save + + {#if $form.recentlySuccessful} +
+

+ Saved. +

+
+ {/if} +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte new file mode 100644 index 000000000..cbbe3fd52 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte @@ -0,0 +1,103 @@ + + +
+
+

Profile Information

+ +

+ Update your account's profile information and email address. +

+
+ +
+
+ + + + + +
+ +
+ + + + + +
+ + {#if mustVerifyEmail && user.email_verified_at === null} +

+ Your email address is unverified. + +

+ + {#if status === 'verification-link-sent'} +
+ A new verification link has been sent to your email address. +
+ {/if} + {/if} + +
+ Save + + {#if $form.recentlySuccessful} +
+

+ Saved. +

+
+ {/if} +
+
+
diff --git a/stubs/inertia-svelte-ts/resources/js/Pages/Welcome.svelte b/stubs/inertia-svelte-ts/resources/js/Pages/Welcome.svelte new file mode 100644 index 000000000..769f63780 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/Pages/Welcome.svelte @@ -0,0 +1,360 @@ + + + + Welcome + + + diff --git a/stubs/inertia-svelte-ts/resources/js/app.ts b/stubs/inertia-svelte-ts/resources/js/app.ts new file mode 100644 index 000000000..a9ad83d3b --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/app.ts @@ -0,0 +1,26 @@ +import '../css/app.css'; +import './bootstrap'; + +import type { ResolvedComponent } from '@inertiajs/svelte'; +import { createInertiaApp } from '@inertiajs/svelte'; +import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; +import { hydrate, mount } from 'svelte'; + +createInertiaApp({ + resolve: (name) => + resolvePageComponent( + `./Pages/${name}.svelte`, + import.meta.glob('./Pages/**/*.svelte') + ), + setup({ el, App, props }) { + if (!el) { + console.error('Target element not found'); + return; + } + if (el.dataset.serverRendered === 'true') { + hydrate(App, { target: el, props }); + } else { + mount(App, { target: el, props }); + } + } +}); diff --git a/stubs/inertia-svelte-ts/resources/js/bootstrap.ts b/stubs/inertia-svelte-ts/resources/js/bootstrap.ts new file mode 100644 index 000000000..da50fcb4b --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/bootstrap.ts @@ -0,0 +1,4 @@ +import axios from 'axios'; +window.axios = axios + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' diff --git a/stubs/inertia-svelte-ts/resources/js/ssr.ts b/stubs/inertia-svelte-ts/resources/js/ssr.ts new file mode 100644 index 000000000..d3bb5e0e4 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/ssr.ts @@ -0,0 +1,28 @@ +import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'; +import createServer from '@inertiajs/svelte/server'; +import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; +import { render } from 'svelte/server'; +import { route } from '../../vendor/tightenco/ziggy'; + +createServer((page) => + createInertiaApp({ + page, + resolve: (name) => + resolvePageComponent( + `./Pages/${name}.svelte`, + import.meta.glob('./Pages/**/*.svelte') + ), + setup({ App, props }) { + /* eslint-disable */ + // @ts-expect-error + globalThis.route = (name, params, absolute) => + route(name, params as any, absolute, { + ...page.props.ziggy, + location: page.props.ziggy.location + }); + /* eslint-enable */ + + return render(App, { props }); + } + }) +); diff --git a/stubs/inertia-svelte-ts/resources/js/types/global.d.ts b/stubs/inertia-svelte-ts/resources/js/types/global.d.ts new file mode 100644 index 000000000..8db57b9d3 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/types/global.d.ts @@ -0,0 +1,23 @@ +import { PageProps as InertiaPageProps } from '@inertiajs/core'; +import { AxiosInstance } from 'axios'; +import type { route as ziggyRoute } from 'ziggy-js'; +import { PageProps as AppPageProps } from './'; + +declare global { + interface Window { + axios: AxiosInstance; + } + + /* eslint-disable no-var */ + var route: typeof ziggyRoute; +} + +declare module '@inertiajs/core' { + interface PageProps extends InertiaPageProps, AppPageProps {} +} + +declare module 'svelte/elements' { + interface HTMLAttributes { + 'scroll-region'?: boolean; + } +} diff --git a/stubs/inertia-svelte-ts/resources/js/types/index.d.ts b/stubs/inertia-svelte-ts/resources/js/types/index.d.ts new file mode 100644 index 000000000..22c74aa44 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/types/index.d.ts @@ -0,0 +1,15 @@ +import { Config } from 'ziggy-js'; + +export interface User { + id: number; + name: string; + email: string; + email_verified_at?: string; +} + +export type PageProps = Record> = T & { + auth: { + user: User; + }; + ziggy: Config & { location: string }; +}; diff --git a/stubs/inertia-svelte-ts/resources/js/types/vite-env.d.ts b/stubs/inertia-svelte-ts/resources/js/types/vite-env.d.ts new file mode 100644 index 000000000..4078e7476 --- /dev/null +++ b/stubs/inertia-svelte-ts/resources/js/types/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/stubs/inertia-svelte-ts/tsconfig.json b/stubs/inertia-svelte-ts/tsconfig.json new file mode 100644 index 000000000..f2bd63a1f --- /dev/null +++ b/stubs/inertia-svelte-ts/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler", + "paths": { + "@/*": ["./resources/js/*"], + "ziggy-js": ["./vendor/tightenco/ziggy"] + } + }, + "include": ["resources/js/**/*.ts", "resources/js/**/*.d.ts", "resources/js/**/*.svelte"] +} diff --git a/stubs/inertia-svelte/.prettierrc b/stubs/inertia-svelte/.prettierrc new file mode 100644 index 000000000..9d941a678 --- /dev/null +++ b/stubs/inertia-svelte/.prettierrc @@ -0,0 +1,18 @@ +{ + "singleQuote": true, + "trailingComma": "none", + "printWidth": 100, + "plugins": [ + "prettier-plugin-organize-imports", + "prettier-plugin-tailwindcss", + "prettier-plugin-svelte" + ], + "overrides": [ + { + "files": "*.svelte", + "options": { + "parser": "svelte" + } + } + ] +} \ No newline at end of file diff --git a/stubs/inertia-svelte/eslint.config.js b/stubs/inertia-svelte/eslint.config.js new file mode 100644 index 000000000..d559a1853 --- /dev/null +++ b/stubs/inertia-svelte/eslint.config.js @@ -0,0 +1,28 @@ +import prettier from 'eslint-config-prettier'; +import js from '@eslint/js'; +import svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + js.configs.recommended, + ...svelte.configs['flat/recommended'], + prettier, + ...svelte.configs['flat/prettier'], + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + ignores: ['bootstrap', 'public', 'vendor'] + }, + { + rules: { + 'no-undef': 'off' + } + } +]; \ No newline at end of file diff --git a/stubs/inertia-svelte/jsconfig.json b/stubs/inertia-svelte/jsconfig.json new file mode 100644 index 000000000..0a94b1f3c --- /dev/null +++ b/stubs/inertia-svelte/jsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["resources/js/*"], + "ziggy-js": ["./vendor/tightenco/ziggy"] + } + }, + "include": ["resources/js/**/*.js", "resources/js/**/*.svelte"], + "exclude": ["node_modules", "public", "vendor"] +} \ No newline at end of file diff --git a/stubs/inertia-svelte/resources/js/Components/ApplicationLogo.svelte b/stubs/inertia-svelte/resources/js/Components/ApplicationLogo.svelte new file mode 100644 index 000000000..16d8e6371 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/ApplicationLogo.svelte @@ -0,0 +1,7 @@ + + + + + diff --git a/stubs/inertia-svelte/resources/js/Components/Checkbox.svelte b/stubs/inertia-svelte/resources/js/Components/Checkbox.svelte new file mode 100644 index 000000000..4d598f631 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/Checkbox.svelte @@ -0,0 +1,5 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Components/DangerButton.svelte b/stubs/inertia-svelte/resources/js/Components/DangerButton.svelte new file mode 100644 index 000000000..2a8d9efb3 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/DangerButton.svelte @@ -0,0 +1,9 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Components/Dropdown.svelte b/stubs/inertia-svelte/resources/js/Components/Dropdown.svelte new file mode 100644 index 000000000..68b2551fa --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/Dropdown.svelte @@ -0,0 +1,82 @@ + + + + + + +
+
(open = !open)}> + {@render trigger()} +
+ + + {#if open} +
(open = false)}>
+
+
(open = false)}> +
+ {@render content()} +
+
+
+ {/if} +
diff --git a/stubs/inertia-svelte/resources/js/Components/DropdownLink.svelte b/stubs/inertia-svelte/resources/js/Components/DropdownLink.svelte new file mode 100644 index 000000000..9d39359b3 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/DropdownLink.svelte @@ -0,0 +1,13 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte/resources/js/Components/InputError.svelte b/stubs/inertia-svelte/resources/js/Components/InputError.svelte new file mode 100644 index 000000000..02a54a2fe --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/InputError.svelte @@ -0,0 +1,9 @@ + + +{#if message} +
+

{ message }

+
+{/if} diff --git a/stubs/inertia-svelte/resources/js/Components/InputLabel.svelte b/stubs/inertia-svelte/resources/js/Components/InputLabel.svelte new file mode 100644 index 000000000..89723eb42 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/InputLabel.svelte @@ -0,0 +1,11 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Components/Modal.svelte b/stubs/inertia-svelte/resources/js/Components/Modal.svelte new file mode 100644 index 000000000..3762bc8bb --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/Modal.svelte @@ -0,0 +1,60 @@ + + + + +{#if show} +
+
+
+ + +
+ +
+
+ {@render children()} +
+
+
+
+{/if} \ No newline at end of file diff --git a/stubs/inertia-svelte/resources/js/Components/NavLink.svelte b/stubs/inertia-svelte/resources/js/Components/NavLink.svelte new file mode 100644 index 000000000..e0b943b78 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/NavLink.svelte @@ -0,0 +1,11 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte/resources/js/Components/PrimaryButton.svelte b/stubs/inertia-svelte/resources/js/Components/PrimaryButton.svelte new file mode 100644 index 000000000..24760c334 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/PrimaryButton.svelte @@ -0,0 +1,7 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Components/ResponsiveNavLink.svelte b/stubs/inertia-svelte/resources/js/Components/ResponsiveNavLink.svelte new file mode 100644 index 000000000..d8d094642 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/ResponsiveNavLink.svelte @@ -0,0 +1,10 @@ + + + + {@render children()} + diff --git a/stubs/inertia-svelte/resources/js/Components/SecondaryButton.svelte b/stubs/inertia-svelte/resources/js/Components/SecondaryButton.svelte new file mode 100644 index 000000000..743f522e8 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/SecondaryButton.svelte @@ -0,0 +1,7 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Components/TextInput.svelte b/stubs/inertia-svelte/resources/js/Components/TextInput.svelte new file mode 100644 index 000000000..237b7d94a --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Components/TextInput.svelte @@ -0,0 +1,23 @@ + + + diff --git a/stubs/inertia-svelte/resources/js/Layouts/AuthenticatedLayout.svelte b/stubs/inertia-svelte/resources/js/Layouts/AuthenticatedLayout.svelte new file mode 100644 index 000000000..cdbdc6a09 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Layouts/AuthenticatedLayout.svelte @@ -0,0 +1,140 @@ + + +
+ + + + {#if header} +
+
+ {@render header()} +
+
+ {/if} + + +
+ {@render children()} +
+
diff --git a/stubs/inertia-svelte/resources/js/Layouts/GuestLayout.svelte b/stubs/inertia-svelte/resources/js/Layouts/GuestLayout.svelte new file mode 100644 index 000000000..873fc92ae --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Layouts/GuestLayout.svelte @@ -0,0 +1,18 @@ + + +
+
+ + + +
+ +
+ {@render children()} +
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/ConfirmPassword.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/ConfirmPassword.svelte new file mode 100644 index 000000000..f487b7d9a --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/ConfirmPassword.svelte @@ -0,0 +1,53 @@ + + + + Confirm Password + + + +
+ This is a secure area of the application. Please confirm your password before continuing. +
+ +
+
+ + + +
+ +
+ Confirm +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/ForgotPassword.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/ForgotPassword.svelte new file mode 100644 index 000000000..753cf9eee --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/ForgotPassword.svelte @@ -0,0 +1,49 @@ + + + + Forgot Password + + + +
+ Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one. +
+ + + {#if status} +
+ {status} +
+ {/if} + +
+ +
+ + + +
+ +
+ Email Password Reset Link +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/Login.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/Login.svelte new file mode 100644 index 000000000..8012bce4b --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/Login.svelte @@ -0,0 +1,79 @@ + + + + Log in + + + + + {#if status} +
+ {status} +
+ {/if} + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ +
+ +
+ {#if canResetPassword} + + Forgot your password? + + {/if} + + Log in +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/Register.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/Register.svelte new file mode 100644 index 000000000..d23477f03 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/Register.svelte @@ -0,0 +1,72 @@ + + + + Register + + + +
+ +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ +
+ + Already Registered? + + + Register +
+
+
+ diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/ResetPassword.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/ResetPassword.svelte new file mode 100644 index 000000000..9f3ae777d --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/ResetPassword.svelte @@ -0,0 +1,85 @@ + + + + Reset Password + + + +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ Reset Password +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Auth/VerifyEmail.svelte b/stubs/inertia-svelte/resources/js/Pages/Auth/VerifyEmail.svelte new file mode 100644 index 000000000..8b2bb2210 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Auth/VerifyEmail.svelte @@ -0,0 +1,47 @@ + + + + Email Verification + + + +
+ Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we + just emailed to you? If you didn't receive the email, we will gladly send you another. +
+ + {#if verificationLinkSent} +
+ A new verification link has been sent to the email address you provided during registration. +
+ {/if} + +
+
+ + Resend Verification Email + + + +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Dashboard.svelte b/stubs/inertia-svelte/resources/js/Pages/Dashboard.svelte new file mode 100644 index 000000000..e12610cfc --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Dashboard.svelte @@ -0,0 +1,21 @@ + + + + Dashboard + + + + {#snippet header()} +

Dashboard

+ {/snippet} + +
+
+
+
You're logged in!
+
+
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Profile/Edit.svelte b/stubs/inertia-svelte/resources/js/Pages/Profile/Edit.svelte new file mode 100644 index 000000000..a1e1c93d3 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Profile/Edit.svelte @@ -0,0 +1,32 @@ + + + + Profile + + + + {#snippet header()} +

Profile

+ {/snippet} + +
+
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte new file mode 100644 index 000000000..1edeafd16 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/DeleteUserForm.svelte @@ -0,0 +1,105 @@ + + +
+
+

+ Delete Account +

+

+ Once your account is deleted, all of its resources and data will be + permanently deleted. Before deleting your account, please download + any data or information that you wish to retain. +

+
+ + Delete Account + + +
+

+ Are you sure you want to delete your account? +

+ +

+ Once your account is deleted, all of its resources and data + will be permanently deleted. Please enter your password to + confirm you would like to permanently delete your account. +

+ +
+ + + { + if (event.key === "Enter") deleteUser(); + }} + /> + + +
+ +
+ + Cancel + + + + Delete Account + +
+
+
+
\ No newline at end of file diff --git a/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte new file mode 100644 index 000000000..5f486300a --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdatePasswordForm.svelte @@ -0,0 +1,104 @@ + + +
+
+

Update Password

+ +

+ Ensure your account is using a long, random password to stay secure. +

+
+ +
+
+ + + + + +
+ +
+ + + + + +
+ +
+ + + + + +
+ +
+ Save + + {#if $form.recentlySuccessful} +
+

Saved.

+
+ {/if} +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte new file mode 100644 index 000000000..7d90784f4 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.svelte @@ -0,0 +1,97 @@ + + +
+
+

Profile Information

+ +

+ Update your account's profile information and email address. +

+
+ +
+
+ + + + + +
+ +
+ + + + + +
+ + {#if mustVerifyEmail && user.email_verified_at === null} +

+ Your email address is unverified. + +

+ + {#if status === 'verification-link-sent'} +
+ A new verification link has been sent to your email address. +
+ {/if} + {/if} + +
+ Save + + {#if $form.recentlySuccessful} +
+

Saved.

+
+ {/if} +
+
+
diff --git a/stubs/inertia-svelte/resources/js/Pages/Welcome.svelte b/stubs/inertia-svelte/resources/js/Pages/Welcome.svelte new file mode 100644 index 000000000..f69e5cc91 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/Pages/Welcome.svelte @@ -0,0 +1,165 @@ + + + + Welcome + + + + +
+ Background +
+
+
+
+ +
+ {#if canLogin} + + {/if} +
+ +
+ +
+ +
+ Laravel v{ laravelVersion } (PHP v{ phpVersion }) +
+
+
+
diff --git a/stubs/inertia-svelte/resources/js/app.js b/stubs/inertia-svelte/resources/js/app.js new file mode 100644 index 000000000..ddc77ff89 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/app.js @@ -0,0 +1,22 @@ +import './bootstrap.js'; +import '../css/app.css'; + +import { createInertiaApp } from '@inertiajs/svelte'; +import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; +import { hydrate, mount } from 'svelte'; + +createInertiaApp({ + resolve: (name) => + resolvePageComponent(`./Pages/${name}.svelte`, import.meta.glob('./Pages/**/*.svelte')), + setup({ el, App, props }) { + if (!el) { + console.error('Target element not found'); + return; + } + if (el.dataset.serverRendered === 'true') { + hydrate(App, { target: el, props }); + } else { + mount(App, { target: el, props }); + } + } +}); diff --git a/stubs/inertia-svelte/resources/js/bootstrap.js b/stubs/inertia-svelte/resources/js/bootstrap.js new file mode 100644 index 000000000..5f1390b01 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/bootstrap.js @@ -0,0 +1,4 @@ +import axios from 'axios'; +window.axios = axios; + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; diff --git a/stubs/inertia-svelte/resources/js/ssr.js b/stubs/inertia-svelte/resources/js/ssr.js new file mode 100644 index 000000000..85eaa5382 --- /dev/null +++ b/stubs/inertia-svelte/resources/js/ssr.js @@ -0,0 +1,22 @@ +import { createInertiaApp } from '@inertiajs/svelte'; +import createServer from '@inertiajs/svelte/server'; +import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; +import { render } from 'svelte/server'; +import { route } from '../../vendor/tightenco/ziggy'; + +createServer((page) => + createInertiaApp({ + page, + resolve: (name) => + resolvePageComponent(`./Pages/${name}.svelte`, import.meta.glob('./Pages/**/*.svelte')), + setup({ App, props }) { + global.route = (name, params, absolute) => + route(name, params, absolute, { + ...page.props.ziggy, + location: new URL(page.props.ziggy.location) + }); + + return render(App, { props }) + }, + }), +); \ No newline at end of file diff --git a/stubs/inertia-svelte/resources/views/app.blade.php b/stubs/inertia-svelte/resources/views/app.blade.php new file mode 100644 index 000000000..498d7157a --- /dev/null +++ b/stubs/inertia-svelte/resources/views/app.blade.php @@ -0,0 +1,21 @@ + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + @routes + @vite(['resources/js/app.js', "resources/js/Pages/{$page['component']}.svelte"]) + @inertiaHead + + + @inertia + + diff --git a/stubs/inertia-svelte/vite.config.js b/stubs/inertia-svelte/vite.config.js new file mode 100644 index 000000000..2f81cb2f0 --- /dev/null +++ b/stubs/inertia-svelte/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; + +export default defineConfig({ + plugins: [ + laravel({ + input: 'resources/js/app.js', + refresh: true, + }), + svelte() + ] +}); \ No newline at end of file