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

[Svelte] Improve typescript types + minor fixes #1881

Closed
wants to merge 9 commits into from

Conversation

jamesst20
Copy link
Contributor

@jamesst20 jamesst20 commented May 28, 2024

@reinink

I have rebased all my commits in my repo (https://github.com/jamesst20/inertia) to include the latest changes and afterwards I have taken all my packages/svelte files there to overwrite the ones in the current repo. I have stripped down all unnecessary changes and all new features as well.

This PR only improve the types and fix some possible regression that I will comment in a few seconds in the diff

Edit: @reinink it's ready. i'm done adding comments :)

@@ -2,17 +2,15 @@
import Render, { h } from './Render.svelte'
import store from '../store'

$$props
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does nothing

$: {
if (prevComponent !== component) {
key = Date.now()
prevComponent = component
}
}
Copy link
Contributor Author

@jamesst20 jamesst20 May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to the typescript merge we had

$: {
  if (prevComponent !== component) {
    key = Date.now()
    prevComponent = component
  }
}

and with the typescript merge we are now having

function updateKey(component: InertiaComponentType) {
  if (prev !== component) {
    prev = component
    key = new Date().getTime()
  }
}


$: updateKey(component)

While it looks like to be the same, it ain't. Everything between ${...} is reactive and is able to trigger state update unlike when it's wrapped into a method. Maybe it doesn't matter, however I don't see any justification for that change

import type { Page } from '@inertiajs/core'
export type SSRProps = { id: string; initialPage: Page }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here. Exporting the types to use in createInertiaApp for the SSR instead of casting to any for better typing.

@@ -184,8 +174,8 @@ export default function useForm<TForm extends Record<string, unknown>>(
return options.onStart(visit)
}
},
onProgress: (event: AxiosProgressEvent) => {
this.setStore('progress', event)
onProgress: (event?: AxiosProgressEvent) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the real inertia@core signature

Copy link
Contributor

@joetannenbaum joetannenbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jamesst20, thanks for this PR! @reinink asked me to give it a review, I have just a couple of items that need clarification whenever you have a moment.

packages/svelte/tsconfig.json Outdated Show resolved Hide resolved
packages/svelte/src/lib/useForm.ts Outdated Show resolved Hide resolved
packages/svelte/src/lib/createInertiaApp.ts Show resolved Hide resolved
packages/svelte/src/lib/types.ts Outdated Show resolved Hide resolved
packages/svelte/src/lib/types.ts Outdated Show resolved Hide resolved
packages/svelte/src/lib/types.ts Outdated Show resolved Hide resolved
@jamesst20
Copy link
Contributor Author

@joetannenbaum @reinink

What would be the next step?

@jamesst20
Copy link
Contributor Author

@joetannenbaum @reinink

What would be the next step?

Hey guys @joetannenbaum @reinink it's me again bothering you 😆 let me know if I can be of any help

@joetannenbaum
Copy link
Contributor

Hey @jamesst20! Sorry for the delay here. This is on my list to review again tomorrow, I'll update you then.

@joetannenbaum
Copy link
Contributor

This is looking good! Thanks @jamesst20. Just one final nit, let me know what you think.

@kevin82222
Copy link

@joetannenbaum @reinink @jamesst20 Have anything to do more about this?
I looking forward to using inertia@svelte with TypeScript in my project~
Thanks everyone for this pr works!

@jamesst20
Copy link
Contributor Author

@joetannenbaum I applied the styling suggestion and rebased on the latest commit too

@joetannenbaum @reinink @jamesst20 Have anything to do more about this? I looking forward to using inertia@svelte with TypeScript in my project~ Thanks everyone for this pr works!

Not really, I have been running my own typescript fork for few months without troubles

@jamesst20
Copy link
Contributor Author

@reinink Could you please merge? :)

Copy link
Collaborator

@pedroborges pedroborges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great work @jamesst20, thank you! Please see my comments.

After installing @types/lodash I got different type errors. I worked on a fix to those error and have opened a PR to your branch. Please review it when you get a chance.

packages/svelte/src/lib/components/Render.svelte Outdated Show resolved Hide resolved
packages/svelte/src/lib/useForm.ts Show resolved Hide resolved
@jamesst20
Copy link
Contributor Author

@pedroborges All done! Nice addition to remove all the duplicated calls and checks for the data type being function or object :)

Ready to merge?

@jamesst20 jamesst20 requested a review from pedroborges August 10, 2024 16:18
@pedroborges
Copy link
Collaborator

pedroborges commented Aug 10, 2024

Ready to merge?

@jamesst20 please install @types/lodash. I didn't include that in my PR but only fixed the type errors, sorry for the confusion.

After that, I'd like to see if @joetannenbaum wants to review this once again. Then it will be good to merge.

Thanks again @jamesst20!

@jamesst20
Copy link
Contributor Author

Ready to merge?

@jamesst20 please install @types/lodash. I didn't include that in my PR but only fixed the type errors, sorry for the confusion.

After that, I'd like to see if @joetannenbaum wants to review this once again. Then we will be good to merge.

Thanks again @jamesst20!

Done!

Screenshot 2024-08-11 at 12 44 13 AM

@joetannenbaum @pedroborges @reinink Let me know if this can be merged

Copy link
Collaborator

@pedroborges pedroborges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jamesst20! Just tested locally and it looks good 👏

Let's just wait for @joetannenbaum and @reinink before we merge it 😉

@jamesst20
Copy link
Contributor Author

Thanks @jamesst20! Just tested locally and it looks good 👏

Let's just wait for @joetannenbaum and @reinink before we merge it 😉

Could we proceed? It doesn't look like anyone is looking into it?

@joekrump
Copy link

If others are required for review before this can be merged I suggest adding them as reviewers on the PR so they will be more likely to be aware that they are blocking if that is the case.

@jamesst20
Copy link
Contributor Author

It appears to me the project Inertia is dead and there are no more reasons for me to keep my work open and maintain it.

I am closing all my opened PRs which includes #1864 #1872 #1873 #1874 #1875 #1881

I will be maintaining unofficially my own fork of this library so my projects using Svelte 5 can still live until I find or create an appropriate replacement for this library.

Thanks to everyone who spent time looking at my PRs.

@jamesst20 jamesst20 closed this Aug 31, 2024
jamesst20 added a commit to jamesst20/inertia that referenced this pull request Aug 31, 2024
[Svelte] Improve typescript types + minor fixes inertiajs#1881
jamesst20 added a commit to jamesst20/inertia that referenced this pull request Aug 31, 2024
[Svelte] Improve typescript types + minor fixes inertiajs#1881
@jamesst20 jamesst20 deleted the ts-fixes branch August 31, 2024 19:38
jamesst20 added a commit to jamesst20/inertia that referenced this pull request Aug 31, 2024
jamesst20 added a commit to jamesst20/inertia that referenced this pull request Aug 31, 2024
jamesst20 added a commit to jamesst20/inertia that referenced this pull request Aug 31, 2024
@kevin82222
Copy link

@jamesst20 It's really unfortunate to hear that the Inertia project might no longer be actively maintained. I understand why you decided to close your PRs, but it's still a pity, given all the valuable contributions you've made.
I'm particularly interested in the unofficial version of the library that you'll be maintaining, especially since I am using Svelte 5 in my projects. Could you please let me know how I can access your fork? It would be a huge help in keeping my projects running smoothly.
Thank you again for all your efforts and for continuing to support the community with your unofficial fork.

@jamesst20
Copy link
Contributor Author

@jamesst20 It's really unfortunate to hear that the Inertia project might no longer be actively maintained. I understand why you decided to close your PRs, but it's still a pity, given all the valuable contributions you've made. I'm particularly interested in the unofficial version of the library that you'll be maintaining, especially since I am using Svelte 5 in my projects. Could you please let me know how I can access your fork? It would be a huge help in keeping my projects running smoothly. Thank you again for all your efforts and for continuing to support the community with your unofficial fork.

With pleasure :) I'm glad I am not the only one interested into it :)

My fork is here https://github.com/jamesst20/inertia/

The main branch is for Svelte 5 and there is also a backup branch that has a Svelte 5 separate adapter. I would recommend you use the main branch since it will be the one I keep up to date but I only completed yesterday. The old branch have months of testing but it's mostly the same but forked from the current typescript implementation instead :)

Backup branch : https://www.npmjs.com/package/@jamesst20/inertia-svelte5

Main branch : https://www.npmjs.com/package/@jamesst20/inertia-svelte

Also use https://www.npmjs.com/package/@jamesst20/inertia-core

@reinink
Copy link
Member

reinink commented Sep 2, 2024

maintain

It appears to me the project Inertia is dead and there are no more reasons for me to keep my work open and maintain it.

I am closing all my opened PRs which includes #1864 #1872 #1873 #1874 #1875 #1881

I will be maintaining unofficially my own fork of this library so my projects using Svelte 5 can still live until I find or create an appropriate replacement for this library.

Thanks to everyone who spent time looking at my PRs.

Bummer dude 😕

We've been working really hard on Inertia.js v2.0 (as you can see in Taylor's Laracon keynote), so the project is far from dead — we're just in a bit of an awkward position between major versions.

I apologize that your work has not received more attention, that's partly my fault for not having enough time to review PRs recently. I don't work on Inertia.js full time like other open source maintainers (ie. Laravel, Livewire), so for me it actually requires time out of my personal life. Because of that things just take longer, as much as I wish it didn't.

Thanks for your contributions either way.

@pedroborges
Copy link
Collaborator

@jamesst20, I totally get where you're coming from, and I'm really sorry for the frustration you've been feeling. We can definitely do better here. I haven't been as involved as I wished. I was away from the project for the last two years, but I'm back now and really grateful for everyone who's kept contributing in the meantime 🙇

The team has been heads down working on Inertia.js v2, especially leading up to the Laracon announcement last week. There are a lot of cool new features coming, and I'm excited to be more involved again!

Just last Friday I mentioned internally that getting #1881 and #1872 reviewed and approved was my top priority this week since I'm blocked by them too. I'd really appreciate it if you could reopen these two PRs. After that, I'll be focusing on fixing #1670 and adding all the new v2 stuff to the Svelte adapter so we can launch it with the other adapters next month.

Thanks again for all your hard work and contributions. It really means a lot!

@kevin82222
Copy link

I appreciate the clarification, and I apologize for my earlier comment — it seems I misunderstood the situation. I had been following this PR because I need the functionality it provides, and I mistakenly thought the project might not be actively maintained.
It's great to hear that Inertia.js is actively being worked on and that v2.0 is in progress. I can imagine how challenging it must be to balance open-source work with personal life, so I completely understand the delays.
I'm excited to see the new features in the upcoming version, and I'll continue to follow the project closely. Thanks to the entire team for your hard work and dedication to this project!

@pedroborges
Copy link
Collaborator

#1963 has been merged and will be tagged in the next release 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants