-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(api): add SERIALIZE_TO_IPC_FN
const and implement it for dpi types, add more constructors
#11191
base: dev
Are you sure you want to change the base?
Conversation
Package Changes Through 258fe72There are 5 changes which include @tauri-apps/api with minor, tauri with minor, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
toIpc
method on dpi types, add more constructorstoIpc
and toJSON
method on dpi types, add more constructors
this one can wait to be merged after the v2 stable release right? |
Co-authored-by: Tony <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should use toTauriIpc
instead of just toIPC
?
Co-authored-by: Tony <[email protected]>
Co-authored-by: Tony <[email protected]>
yes, i am not to keen on |
Made a |
Sounds good to me, but shouldn't the symbol be a |
Normally it should be, but we access this value in multiple places and we can't keep re-defining it because it will not be the same value (that's how Symbol works, it is always unique). We can define it on the global const ToIPCSymbol = window.ToIPCSymbol because it will break usage with next.js and SSR framworks and I don't want to deal with their issues again. |
Never mind, we can't use import here |
What about |
That works I guess but is it really that different? the main problem here IMO is that we can't share the value by using imports |
Right, that doesn't really make a difference, let's just go with a string then, in that case maybe changing the name to |
renamed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test it, but the code looks good to me
* | ||
* @since 2.0.0 | ||
*/ | ||
[SERIALIZE_TO_IPC_FN]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the whole toIPC approach (makes the __CHANNEL__
thingy available to anyone) but this is actually a breaking change - existing commands relying on PhysicalPosition / PhysicalSize / LogicalPosition / LogicalSize cannot deserialize this new format, so we should revert these - if you explictly want a generic Position or Size type we need to create a wrapper type just like Rust has one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense, I have added Position
and Size
classes and reverted breaking changes.
@@ -26,8 +76,6 @@ function transformCallback<T = unknown>( | |||
|
|||
class Channel<T = unknown> { | |||
id: number | |||
// @ts-expect-error field used by the IPC serializer | |||
private readonly __TAURI_CHANNEL_MARKER__ = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucasfernog isn't this a breaking change? removing the field will make new @tauri-apps/api
packages not work with [email protected]
val instanceof Object && | ||
'__TAURI_CHANNEL_MARKER__' in val && | ||
typeof val.id === 'number' | ||
) { | ||
return `__CHANNEL__:${val.id}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
toIpc
and toJSON
method on dpi types, add more constructorsSERIALIZE_TO_IPC_FN
const and implement it for dpi types, add more constructors
No description provided.