From 17c74016f1b9d267dad840c7ee1c50a7b93dff02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:08 +0100 Subject: [PATCH 1/7] Update external dependencies in tsup.config.ts --- lib/tsup.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tsup.config.ts b/lib/tsup.config.ts index 62d9b7f..850ca0b 100644 --- a/lib/tsup.config.ts +++ b/lib/tsup.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ vite: 'src/vite-plugin.ts', }, format: ['cjs', 'esm'], - external: ['vue', 'vite', '@inertiajs/vue3', 'node:fs/promises', 'node:child_process'], + external: ['vue', 'vite', '@inertiajs/vue3', 'node', 'node:fs', 'node:fs/promises', 'node:child_process'], outDir: 'dist', dts: true, minify: true, From 73fa0db70225a7b25f29a175853dd77378f9c8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:16 +0100 Subject: [PATCH 2/7] Fix language fallback in useDate.ts --- lib/src/composables/useDate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/composables/useDate.ts b/lib/src/composables/useDate.ts index ac6b5a2..d72ed7b 100644 --- a/lib/src/composables/useDate.ts +++ b/lib/src/composables/useDate.ts @@ -4,7 +4,7 @@ export function useDate() { month: '2-digit', year: 'numeric', } - const language = 'en-US' || navigator.language + const language = 'en-US' || navigator?.language function toDate(date?: string | Date): Date { if (!date) return new Date() From 2b1865510203cca0c6649b4ec77a3fe2c81dec39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:21 +0100 Subject: [PATCH 3/7] Add isClient computed property to useInertia composable --- lib/src/composables/useInertia.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/composables/useInertia.ts b/lib/src/composables/useInertia.ts index 91b2a6c..31cd02d 100644 --- a/lib/src/composables/useInertia.ts +++ b/lib/src/composables/useInertia.ts @@ -40,6 +40,10 @@ export function useInertia() { return process.env.NODE_ENV === 'development' }) + const isClient = computed(() => { + return typeof window !== 'undefined' + }) + return { page, component, @@ -49,5 +53,6 @@ export function useInertia() { auth, user, isDev, + isClient, } } From 4ef332f7135cbdb0a71434a92cdd6915a762f570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:29 +0100 Subject: [PATCH 4/7] Add import for fs module --- lib/src/composables/useRouter.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/composables/useRouter.ts b/lib/src/composables/useRouter.ts index 15dfdd0..f2e3548 100644 --- a/lib/src/composables/useRouter.ts +++ b/lib/src/composables/useRouter.ts @@ -1,3 +1,4 @@ +import fs from 'node:fs/promises' import { computed } from 'vue' import { LaravelRouter } from '@/methods' From 917f000b89f1a6e3d80ca3a4242a0543137972fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:46 +0100 Subject: [PATCH 5/7] Remove fs import from useRouter.ts --- lib/src/composables/useRouter.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/composables/useRouter.ts b/lib/src/composables/useRouter.ts index f2e3548..15dfdd0 100644 --- a/lib/src/composables/useRouter.ts +++ b/lib/src/composables/useRouter.ts @@ -1,4 +1,3 @@ -import fs from 'node:fs/promises' import { computed } from 'vue' import { LaravelRouter } from '@/methods' From 80905a12e1f1e8192d5a3fb1b53142677780647b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:53:51 +0100 Subject: [PATCH 6/7] Fix search shortcut for Mac users --- lib/src/composables/useSearch.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/composables/useSearch.ts b/lib/src/composables/useSearch.ts index da07559..5590115 100644 --- a/lib/src/composables/useSearch.ts +++ b/lib/src/composables/useSearch.ts @@ -12,7 +12,12 @@ export function useSearch(limit: number | false = 20, routeName = 'api.search.in const { route } = useRouter() function checkSystem() { - const isMac = navigator.userAgent.toUpperCase().includes('MAC') + if (navigator === undefined || navigator?.userAgent === undefined) { + searchText.value = 'Ctrl+K' + return + } + + const isMac = navigator?.userAgent.toUpperCase().includes('MAC') searchText.value = isMac ? '⌘+K' : 'Ctrl+K' } checkSystem() From 855847ea5f8970722472879f62e25269ac5a64dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Sat, 30 Mar 2024 17:59:21 +0100 Subject: [PATCH 7/7] v2.0.02 Fix `window.Routes = Routes` for `routes.ts` --- composer.json | 2 +- src/Typed/Route/TypeRouteListTs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6283f27..2a135b4 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "kiwilan/typescriptable-laravel", "description": "PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript. If you want to use some helpers with Inertia, you can install associated NPM package.", - "version": "2.0.01", + "version": "2.0.02", "keywords": [ "kiwilan", "laravel", diff --git a/src/Typed/Route/TypeRouteListTs.php b/src/Typed/Route/TypeRouteListTs.php index dcf26df..a84fc7c 100644 --- a/src/Typed/Route/TypeRouteListTs.php +++ b/src/Typed/Route/TypeRouteListTs.php @@ -59,7 +59,7 @@ interface Window { if (typeof window !== 'undefined') { if (typeof window !== undefined && typeof window?.Routes !== undefined) - window?.Routes = Routes + window.Routes = Routes } export { Routes, appUrl }