Avoid repetitive checks via isViewAttached() using null object pattern

Hey!
I've been experimenting with mosby a little bit this afternoon. Great framework, thanks!
This really makes creating a clean architecture on Android a lot simpler.
One thing I found slightly annoying are the repetitive checks using isViewAttached() that are required to ensure the MvpView is still attached to the MvpPresenter every time you want to update the view. Obviously these checks are necessary since it's the view's responsibility to attach to and detach from the presenter and any asynchronous callback might only return after the view has already been detached. However, I think this can be simplified.
So a common solution to avoid these null-checks before notifying listeners/callbacks is to use the null object pattern, i.e. providing a no-op implementation of the respective interface. Now this gets a bit tricky if generics are involved like in your MvpPresenter<V extends MvpView>. However, I think I've come up with a reasonable solution by creating dynamic no-op implementations of those interfaces at runtime using Java's dynamic proxies feature and using a default invocation handler.
I've created a MvpBasePresenter2 which makes use of this and also removes the now redundant isViewAttached() method.
Here's the relevant commit in my fork.
I know that this solution is based on reflection. And reflection is baaaaaaaaad. Some people are allergic to it. However, in my opinion, in this case the cleaner code far outweighs the negligible performance penalty.
Please let me know your thoughts.

In general I agree, it's painful to add all those isViewAttached() checked.
First let me explain why MvpBasePresenter uses a WeakReference. Usually there is no need to wrap the MvpView in a WeakReference because:

Any async call should be canceled in detachView(), so that no callback should be invoked afterwards. For instance with RxJava and unsubscribe() this works like a charm.

However, there might be scenarios where you don't want to cancel running async background tasks, like using retaining Fragments. But also in that case the Fragment gets detached and reattached temporarily during orientation changes. However, Mosby assumes that every interaction with the view takes place on the main UI Thread. So every interaction with the view from a callback / presenter must run on the main UI Thread. Hence it's not possible that a callback accesses the view during a screen orientation change, since screen orientation changes run on the main ui thread as well. Therefore, either screen orientation changes run before callback or vice versa, but never in parallel.

So why does Mosby's default implementation uses a WeakReference?
The only reason why Mosby's default implementation uses a WeakReference is that I wanted to avoid memory leaks if other developers misuse Mosby by writing a custom delegate that i.e. forget to call  presenter.detachView().
Thus at a first glance you might come to the conclusion that View can never be null. Unfortunately, it can be in case that View is detached (i.e. user has closed the activity by pressing back button) but an async running background thread has not been canceled in detachView(). i.e. as far as I know Retrofit 1.x has no API to cancel running requests. Therefore, we have to check if view != null anyway.
Alright, so back to your suggestion to use the null object pattern. Your implementation looks good  (there is a little issue with WeakReference, I have added a comment in your commit to point out the problem) and I think in that case it reasonable to use reflections.
But I have in general a problem with the null object pattern in general. I don't like it because usually it only tries to hide other problems (might be an implementation detail like libraries that don't support canceling async threads or a lack of java programming language syntax / expressiveness).
On one hand you are right and those view != null checks are pretty annoying. I have to think  about it again, but I think we could try to find a compromise by adding those kind of base presenter, but I see it more as an addition and not as a replacement of MvpBasePresenter. However, having a second  null object based MvpNullObjectBasePresenter implementation may result in having also a bunch of other presenter implemetation like RxNullObjectPresenter, RetrofitNullObjectPresenter and so on.
On the other hand that kind of problem could be solved by a Kotlin, where you could replace
 if (isViewAttached()){
    getView.showContent();
}

with
getView()?showContent()

What do you think?

So Kotlin solves this problem by internally looking for null Views?  I
didn't know that. Perhaps I should give Kotlin a more serious look.
Igor
On Jun 14, 2015 9:11 PM, "Hannes Dorfmann"<EMAIL_ADDRESS>wrote:

In general I agree, it's painful to add all those isViewAttached()
checked.
First let me explain why MvpBasePresenter uses a WeakReference. Usually
there is no need to wrap the MvpView in a WeakReference because:

Any async call should be canceled in detachView(), so that no callback
should be invoked afterwards. For instance with RxJava and
unsubscribe() this works like a charm.
2.
However, there might be scenarios where you don't want to cancel
running async background tasks, like using retaining Fragments. But also in
that case the Fragment gets detached and reattached temporarily during
orientation changes. However, Mosby assumes that every interaction with the
view takes place on the main UI Thread. So every interaction with the view
from a callback / presenter must run on the main UI Thread. Hence
it's not possible that a callback accesses the view during a screen
orientation change, since screen orientation changes run on the main ui
thread as well. Therefore, either screen orientation changes run before
callback or vice versa, but never in parallel.
So why does Mosby's default implementation uses a WeakReference?
The only reason why Mosby's default implementation uses a WeakReference
is that I wanted to avoid memory leaks if other developers misuse Mosby by
writing a custom delegate that i.e. forget to call presenter.detachView().
Thus at a first glance you might come to the conclusion that View can
never be null. Unfortunately, it can be in case that View is detached
(i.e. user has closed the activity by pressing back button) but an async
running background thread has not been canceled in detachView(). i.e. as
far as I know Retrofit 1.x has no API to cancel running requests.
Therefore, we have to check if view != null anyway.
Alright, so back to your suggestion to use the null object pattern. Your
implementation looks good (there is a little issue with WeakReference, I
have added a comment in your commit to point out the problem) and I think
in that case it reasonable to use reflections.
But I have in general a problem with the null object pattern in general. I
don't like it because usually it only tries to hide other problems (might
be an implementation detail like libraries that don't support canceling
async threads or a lack of java programming language syntax /
expressiveness).
On one hand you are right and those view != null checks are pretty
annoying. I have to think about it again, but I think we could try to find
a compromise by adding those kind of base presenter, but I see it more as
an addition and not as a replacement of MvpBasePresenter. However, having
a second null object based MvpNullObjectBasePresenter implementation may
result in having also a bunch of other presenter implemetation like
RxNullObjectPresenter, RetrofitNullObjectPresenter and so on.
On the other hand that kind of problem could be solved by a Kotlin, where
you could replace
if (isViewAttached()){
getView.showContent();
}
with
getView()?showContent()
What do you think?
—
Reply to this email directly or view it on GitHub
https://github.com/sockeqwe/mosby/issues/56#issuecomment-111894936.

http://kotlinlang.org/docs/reference/null-safety.html

Hi @jenzz  I was wondering if you would allow me to integrate your  dynamic no-op  view code into the next major release?

Sure. That's how open-source works, right?
I'm happy to send over a PR that you can tweak as you see fit.
I think the use of WeakReference in the presenter needs to be revised though. I suggest dropping them altogether.
I see the point of being defensive to avoid potential misuse of your library. However, devs should know that for every call to register(), attach(), subscribe() there is most probably a corresponding unregister(), detach() or unsubscribe(). I usually add documentation (Javadoc) to the respective public methods and mention the importance of deregistering to avoid memory leaks.

Yes, there is no need for WeakReference.
Could you please also rename the class to  NullObjectPresenter (any better naming idea is very welcome) since it will not be a replacement for MvpBasePresenter but rather an additional presenter.

Done.
I've also moved the new presenter into the mvp-common module since it's an Android-agnostic implementation and there is no need for it to reside in the mvp module which is in fact Android-specific.

Merged, thanks!

Hi, I know this issue is a bit old, but seeing as it merged, thought it would still be valid to ask the question.
I wasn't using Mosby in a project, but came up with the exact same solution independently and I tried it out for a while. However, I discovered a large problem with it not handling methods with return types.
I did start going down a similar path to how Mosby accepted it (having the ability to return "default" ints booleans strings etc... but I couldn't solve the problem of having a method on the view which returned a class I defined in my project. In those scenarios, the call to view.getUser() or whatever would still inevitably return null and subsequently null pointer.
Did you ever run into this problem, or find a nice solution to it?
My solution for reference<EMAIL_ADDRESS>Thanks

No, this is not solvable.
You simply should never call view getter methods from presenter (view should not offer getter methods at all).  Pass all data needed for the presenter as constructor parameter or as method parameter like presenter.doSomething(user)

I have the similar experience as @sockeqwe. I used to go down this path of having view with getters, even simple ones like view.getEditTextContent() and this makes unit-testing rather hard (you have to constantly mock and stub view) and in this case state slowly starts moving to the view and presenter turns out to be tightly coupled with view and presenter logic also tends to start moving to view bit by bit...
Instead what I've found working "right" is to hold all this state in presenter, even if it will result in copying. I.e. initial reasoning is like this "why should I have a copy of userName string in presenter if it is already held in EditText and I can just call view.getUserName() which would get it out of there, and so I wouldn't need an extra variable in presenter..."
But I found that this doesn't work so well. Holding all state in presenter does work though.

Thanks @sockeqwe @dimsuz; makes a lot of sense.


Add --spwn-token

This works with SNS logins, as long as you can intercept the token request from the streaming page.

Thanks!


Devel/mavros integration

That was supposed to go into my fork, sorry

HI potatio, I would like to take a look at the changes and see if we can main-line into this repo as well so that it will be easy to keep it in sync.  I will review these changes and let you know.
Thanks
Rama.

I am all in favour of that, so let me if I can be of help. This pull request here of course should not be merged as I replaced components in the VISLAM example instead of adding the ROS parts on top.
There are a few issues / things to be taken care of:

The CPU load is twice as high as with the original VISLAM example (on average two cores at 50% instead of just one). I can't believe it's all because of mavros.
It might make sense to not only fuse the pose estimate from VISLAM, but also the velocity to the PX4. This should provide a smoother estimate on the PX4 side. I tried adding a twist publisher for mavros, but could not verify that it's actually being fused by the LPE.
Since I set the mavros timesync mode to PASSTHROUGH, the IMU, Camera and VISLAM odometry messages have a timestamp relative to the boot time rather than the actual wall time (i.e. ros::Time::now().

@potaito thanks for willing to help.  After reviewing the code, I think there may be some changes to the framework that will help wtih cleaner integration.  In terms of the plan, this is what I am thinking of:

Update the VISLAM Manager to add an API to get the IMU data.  Also remove the dependency of IMU manager on VISLAM Manager.  By doing this, for px4 integration, one use mavRos to get the IMU an call the new API to inject the IMU data.
Update the make file/cmake file to create an new target for px4 integration.

Question regarding one of the change you make to package.xml, does it need to change or can we make it generic but use a different launch file when integrating with px4.
Comment regarding the load increase, I am wondering if that is comming from px4 running on apps processor.  Can you run a test without VISLAM and see if the load is increased.

@rkintada

Update the VISLAM Manager to add an API to get the IMU data. Also remove the dependency of IMU manager on VISLAM Manager.

That sounds good. The IMU manager dependency was actually a bit confusing.

Question regarding one of the change you make to package.xml, does it need to change or can we make it generic but use a different launch file when integrating with px4.

No I do not think the change is crucial. Without mavros compiled or installed, the mavros-specific launch file would fail anyway.

Comment regarding the load increase, I am wondering if that is comming from px4 running on apps processor. Can you run a test without VISLAM and see if the load is increased.

That's a very good point.

Running the original px4 stack with EKF2 results in one core being under approx. 15% load.
Running the px4 stack modified for LPE requires 30% of one core.
Running the original (EKF2) px4 stack with mavros and vislam: 2 cores at 50%
Running PX4 with LPE, together with mavros and vislam: 2 - 3 cores at 50%

What I get from this is that there are two problems: One related to the modified px4.config and `mainapp.conf. Another one related to a change in the VISLAM package.


BehaviorSubject implements IBehaviorObservable

What is the nature of your contribution?
Enhancement
IBehaviorObservable is used to expose the subject's Value property as readonly, in order to restrict public write access.

@dotnet-policy-service agree

Please describe why you want to add this change.

Please describe why you want to add this change.

Sorry, done.

Please describe the why, not the what. What's the reason you want to add that misspelled interface? Also where is this IReadOnlyBehavior? In addition, there are style requirements, such as the license header missing.

Please describe the why, not the what. What's the reason you want to add that misspelled interface? Also where is this IReadOnlyBehavior? In addition, there are style requirements, such as the license header that is missing.

Sorry about the misspelling, I want to contribute, do whatever you want.

Your contribution makes no sense. The problem with fluent APIs such as Rx is that any specific type/interface is pretty much lost immediately after an operator.
var bs = new BehaviorSubject<int>();

var cs = bs.Select(v => v * v);

Here cs is no longer a BehaviorSubject but only an IObservable so IBehaviorObservable is not accessible. The only place IBehaviorObservable would be usable is right at bs, which is already a BehaviorSubject thus Value is accessible anyway.
There is currently one Behavior-Subject implementation, an implementation that makes most sense. The question is, what other Behavior you want to implement that would be significantly different yet you want to mix it with the standard BehaviorSubject through the IBehaviorSubject interface?

Your contribution makes no sense. The problem with fluent APIs such as Rx is that any specific type/interface is pretty much lost immediately after an operator.
var bs = new BehaviorSubject<int>();

var cs = bs.Select(v => v * v);

Here cs is no longer a BehaviorSubject but only an IObservable so IBehaviorObservable is not accessible. The only place IBehaviorObservable would be usable is right at bs, which is already a BehaviorSubject thus Value is accessible anyway.
There is currently one Behavior-Subject implementation, an implementation that makes most sense. The question is, what other Behavior you want to implement that would be significantly different yet you want to mix it with the standard BehaviorSubject through the IBehaviorSubject interface?

But it's still useful to expose a BehaviorSubject to create a reactive property.
for example:
public class UserData
{
    public BehaviorSubject<string> UserName;
}

is useful to allow both access the user's current username, but also listen to changes without allowing for outside change, but it forces you to give public write access.
The current alternative for such use case if you want a read-only reactive property is:
public class UserData
{
    private BehaviorSubject<string> _userName;

    public string UserName => _userName;
    public IObservable<string> OnUserNameChange => _userName;
}

Also I like to subscribe the behavior subject to other observables in order to "cache" the last value, like:
OnUserNameChangeComplete.Subscribe(_userName);
So of course, when someone will use the username subject like an event he will lose the option to access the Value property and that obviously makes sense, but I don't think it makes the interface useless or makes no sense.

Yes, use composition or educate the users of your code to not call the OnXXX methods.

"Educate users of your code"?
That makes no sense.

Do you have other developers who would use the raw BehaviorSubject in a way you don't want them to do? If yes, just tell them not to call no matter how much urge they feel. If it's just you, then remember not to call them (other than the places where you want to update the subject of course).

@akarnokd Coming from a big corporate with a lot of users on a codebase - it is not possible to educate developers to not use certain utilities that are practically available. Clean code means safe code. Protecting the user from themselves.
It's like saying "why use private functions/properties? just educate your user not to use them.".

If education is not viable, then use composition as the OP already recognized as the straightforward solution. No Rx library change needed, the users will know little difference and no one has to run back later to Rx to ask yet another interface for whatever method combination to restrict the Rx types to.

Well, I see your point - the change is not "a must" since there is a way to achieve a readonly approach today (like OP described).
But then again - what are the cons of adding this interface?
This approach is harmless, optional, eliminates boilerplate for users that do want a readonly BehaviorObservable and IMO encourages users to practice a cleaner design.

Sounds like the underlying convenience issue would be best solved on the language level. There is a proposal for C#, Roles & Extensions, of which the section Adaptation to Interfaces does look like what the OP would like.


Select dependencies not installed with CLI

Please provide the environment you discovered this bug in.
Use npx nx g @spartan-ng/cli:ui select to add Select component to your NX project.
It should install all required dependencies. #320 added dependencies for @spartan-ng/ui-forms-brain and @spartan-ng/ui-form-field-brain.
Which area/package is the issue in?
select
Description
When adding Select component with the CLI (NX/Angular) the dependencies to @spartan-ng/ui-forms-brain and @spartan-ng/ui-form-field-brain should be installed. Maybe they should also be mentioned on the component page.
Currently the deps must be installed manually
npm install @spartan-ng/ui-forms-brain @spartan-ng/ui-form-field-brain

Please provide the exception or error you saw
No response
Other information
No response
I would be willing to submit a PR to fix this issue

[X] Yes
[ ] No

@goetzrobin where should I add those dependencies? I think here https://github.com/goetzrobin/spartan/blob/main/libs/cli/src/generators/ui/generator.ts the deps for Icon and button is added. Should it be added here or in another place? Is there a place to describe each deps for one component?
Like
export const primitiveDeps: Record<string, string[]> = {
     ...
     select: ['icon', 'forms', 'form-field'],
};


Null Propagation Operator: Stage 1

TC39 Proposals: https://github.com/tc39/proposals
Stage: 1, Gabriel Isenberg
Proposed at TC39 Meeting: https://github.com/tc39/agendas/blob/master/2017/01.md#agenda-items
Spec Repo: https://github.com/claudepache/es-optional-chaining
Slides: https://docs.google.com/presentation/d/11O_wIBBbZgE1bMVRJI8kGnmC6dWCBOwutbN9SWOK0fU/edit#slide=id.p
ESTree Issue to discuss AST Spec: https://github.com/estree/estree/issues/146
cc @gisenberg if you can implement or work with someone to do so. (Please join our slack if you haven't http://slack.babeljs.io/)

Thanks for looping me in! I wanted to let everyone know that I'm over in the BabelJS Slack if there are others that would like to discuss this feature further. I'm currently working with @bmeck on the Babel side of things.

I'm currently werking on An PR for this

Any news? @kristofdegrave

As discussed in the babel slack, I'm also interested in contributing to this once the spec is a bit more settled.
I previously implemented a ?. feature for LightScript (a fork/superset of JS built on babylon/babel). In case it helps anyone, here is:

The babel transform which implements short-circuiting.
The associated tests
The commit adding the feature to the lightscript parser (a fork of babylon). It uses poor naming ("elvis operator" isn't accurate) and isn't backwards-compatible; a different approach would be necessary.

My version doesn't currently support assignments or delete, though I may add those soon.

Can't wait to see this on ES. Inspite of it being yet at stage-1, it is the only thing that I've always wanted to be part of EcmaScript since I stopped using CoffeeScript. I wish I had spare time to implement it.

@gisenberg @kristofdegrave is this still something you are working on? Do you need help?

Based on @kristofdegrave's work, I can make a PR with this https://github.com/babel/babylon/compare/master...xtuc:feat-optional-chaining
I have the Babel part as well https://github.com/babel/babel/compare/7.0...xtuc:feat-optionnal-chaining
I currently only support the basic syntax:
a?.b = 42
delete a?.b
foo?.bar()

@thomaschaaf This is still underway. If you're interested in helping, https://github.com/gisenberg/proposal-optional-chaining is tracking the remaining work. I'm also in the BabelJS Slack if you want to reach out directly.

@xtuc, @kristofdegrave  Let's start the PR so we can make a review by us + Gabe?

The babylon PR is merged (https://github.com/babel/babylon/issues/545)
Please help review/test https://github.com/babel/babel/pull/5786

For context, at the TC39 meeting where this proposal was presented, there were a couple concerns raised about the scope of the proposal, one syntactic and one semantic. I've filed two issues to discuss these issues. This is a Stage 1 feature and subject to change!

https://github.com/babel/babel/tree/7.0/packages/babel-plugin-transform-optional-chaining


ENH: update theoretical description of classif with RAPS

Description
Add theoretical description and examples of the RAPS method
Fixes #221

Codecov Report
Base: 99.71% // Head: 99.91% // Increases project coverage by +0.20% :tada:

Coverage data is based on head (66e6d8c) compared to base (0aa9ee5).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #222      +/-   ##
==========================================
+ Coverage   99.71%   99.91%   +0.20%
==========================================
  Files          24       24
  Lines        2445     2445
  Branches      266      266
==========================================
+ Hits         2438     2443       +5
+ Misses          5        1       -4
+ Partials        2        1       -1

Impacted Files
Coverage Δ

mapie/_compatibility.py
100.00% <0.00%> (+27.77%)
:arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.


Ad error: AdError 303: No Ads VAST response after one or more Wrappers

I think there was a problem when I implemented VAST on my Ad Manager.
When I test, a message returns that:

Ad error: AdError 303: No Ads VAST response after one or more Wrappers

https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/vastinspector?tag=https%253A%252F%252Fpubads.g.doubleclick.net%252Fgampad%252Fads%253Fiu%253D%252F21899927763%252Fvast_test-video%2526description_url%253Dhttps%25253A%25252F%25252F24hexpress.net%2526tfcd%253D0%2526npa%253D0%2526sz%253D400x300%25257C640x480%2526ciu_szs%253Dfluid%2526gdfp_req%253D1%2526output%253Dvast%2526unviewed_position_start%253D1%2526env%253Dvp%2526impl%253Ds%2526correlator%253D
How can I fix them?
Thank   you so much

Hello @JulianNguyen1992 ,
This seems to be an issue with you VAST tag, and not the videoJS-IMA plugin. As you have shown, the VSI player, which does not use the plugin shows the error as well.
I would recommend checking your Ad Manager settings for the ad unit to ensure everything is set up correctly, and reaching out to Ad Manager support if the problem persists.
Thank you,
Jackson
IMA SDK team


Update Step15-..Binding..Factory Fn- Missing xmlns

In the staring <mvc:View tag of XML view App.view.xml, namespace 'core' needs to be added which will be used for fragments:
xmlns:core="sap.ui.core"

The source code of this step seems to be outdated and needs to be adjusted. If templating is used the namspace core needs to be declared in the view


Auto dispatch of undispatched events

Eval to auto dispatch of undispatched events after checking if there are undispatched event before writing new events. But eval to use some kind of delay to "ensure" that other active instances are not working on it.
Also think about exceptions in case of error....

In the first version the client has to implement the retry logic (it could use a little delay to "ensure" that other active instances are not working on it).

Before writing a new event NEStore tries to redispatch last undispatched commit (set AutoDispatchUndispatchedOnWrite to false to disable it).


Fix data check on GVRMesh.setVecXVector(), also put check on all setX().

Add this exception mechanism to make sure it won't crash at native level without any useful information or call stack.
GearVRf-DCO-1.0-Signed-off-by: Chao Chen
<EMAIL_ADDRESS>

Hi, Jon.
I modified the setVecXVector based on the Mihail's comment on my previous one.
You can see that in mesh_jni.cpp, the logic of setVec2Vector is as the following:
std::vectorglm::vec2 native_vec2_vector;
for (int i = 0; i < vec2_vector_length; ++i) {
native_vec2_vector.push_back(vec2_vector_pointer[i]);
}
It is similar in other setVecXVector, so that this is why I check the input like that.

Yes. So your test will keep that code from breaking. But what happens if you pass an array 4 floats (two vec2-s) to a mesh with 64 vertices?
From: chenchao1407<EMAIL_ADDRESS>Sent: Monday, April 13, 2015 5:30 PM
To: Samsung/GearVRf
Subject: Re: [GearVRf] Fix data check on GVRMesh.setVecXVector(), also put check on all setX(). (#12)
Hi, Jon.
I modified the setVecXVector based on the Mihail's comment on my previous one.
You can see that in mesh_jni.cpp, the logic of setVec2Vector is as the following:
std::vectorglm::vec2 native_vec2_vector;
for (int i = 0; i < vec2_vector_length; ++i) {
native_vec2_vector.push_back(vec2_vector_pointer[i]);
}
It is similar in other setVecXVector, so that this is why I check the input like that.
—
Reply to this email directly or view it on GitHubhttps://github.com/Samsung/GearVRf/pull/12#issuecomment-92546096.

And also, the reason why I use switch-case is mostly for null pointer check. Otherwise we need to do another null pointer check as you point out.
I can use the mechanism you indicate. But I think the logic of this patch should be fine.

OK. I got your point. I am going to modify the codes and update this pull request.

Pull request updated.

Hi Jon
This is updated based on your comments. Can you help check again?
Thanks in advance.

This looks pretty good. The error check is not 100% accurate but I'm not sure that's 100% necessary ...

Yes, thanks - I missed the way setValidData() has already done the modulus check.


Error when pointing more than 20 A record aliases to the same A record

When pointing the 21st A record alias to an A record I get 'Failed to save record set 'xxxxx'. Error: The request was invalid.' This limitation isn't explained nor does it make sense from a use-case perspective. We are running a wordpress multi-site with 30+ sites hosted at the same IP. It appears I will have to create a second A record pointer to consolidate the A records. Please fix this. I know AWS doesn't have this limitation.

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: d55c6a33-a21f-e8b6-da9b-f071d0db1df9
Version Independent ID: 87388983-e525-89a7-2048-585c6bd0927d
Content: Azure DNS alias records overview
Content Source: articles/dns/dns-alias.md
Service: dns
GitHub Login: @vhorne
Microsoft Alias: victorh

@jecooper There is a limit of 20 records per record set in Azure DNS. If you need more than 20 records, you will need to create a new record set.
This limit is a common one, and I will pass along this feedback to see if we can increase this limit.

@TravisCragg-MSFT this is not happening within a single record set. These are separate A records that are configured as alias and just happen to be pointed to the same multi-site A record.

@TravisCragg-MSFT: any word on your end?
Repro steps:

Create an A record set for abc.example.com, mark it as not an alias, point to a single IP address
Create a new A record set, set it as an alias pointed to a  Zone record set, select abc.example.com record set created in step 1.
Repeat Step 2 20 times.
Expected outcome: 21st A record set pointed to abc.example.com is created successfully
Actual outcome: 21st A record set fails to create with error "Failed to save record set 'xxxxx'. Error: The request was invalid."

@jecooper your timing is excellent, I am working on this now. Thanks for the repro steps, I will try this out, double check known limitations, and follow up as needed.

@jecooper I was able to reproduce this issue, and I am following up now to get more information. I cannot find a limit that this is hitting.
This seems to be limited to Alias records tied to a single zone record set. You can add other alias records to different zone records, but it seems that the error occurs when more than 20 Alias records are added to a single zone record.

@jecooper There is a limit of 20 records pointing to a single Azure resource. Unfortunately this limit is not currently documented, and the error message upon hitting this limit is not clear. We will be adding this limit to the docs, and making a more suitable error message for reaching this limit.
Unfortunately there is not a way to increase this limit at this time, but we will be revisiting the limit in the future.
I have assigned the issue to the content author to evaluate and update as appropriate.
@vhorne This is for adding a limit of 20 records pointing to a single Azure resource.

Article updated for 20 limit.
#please-close

In my DNS configuration I ran into this limit right away. I use traffic manager to dynamically send web requests to whatever server is up at the moment. So it is important to be able to "alias" the Apex domain in addition to the canonical domain name to the Traffic Manger URL. To buy time until this limit is fixed, I use the alias only on the naked or Apex DNS A records and use CNAME for the canonical DNS A records. Even with this, I am stymied with the 20 host name limit. Please fix this or provide a meaningful work around.

To overcome this limitation, I thought maybe I can just generate A records with reference to the IP address. But azure does convert these entries to be resource-reference entries and therefore the limit applies as well. Kinda crazy that I have a DNS service which does limit me to have 20 A records to the same "ip address" no?


[SPARK-49887] Update cluster-with-template.yaml example with pod annotation

What changes were proposed in this pull request?
This PR aims to update cluster-with-template.yaml example with pod annotation.
Why are the changes needed?
For SparkCluster CRD, safe-to-evict is frequently used. We had better provide it as an example.
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"

Does this PR introduce any user-facing change?
No. This is only an example update.
How was this patch tested?
Manual review.
Was this patch authored or co-authored using generative AI tooling?
No.

Could you review this PR, @viirya ?

Thank you, @viirya . Merged to master.


[win,fs]: Give DELETE writes with the w permission

Windows has a default permissions inheritance scheme setup whereby
files/folders created in the user's home directory are (by default)
deletable by that same user.  Creating folders in the root C: do not
inherit those same permissions, and as such may inadvertently have their
delete permissions stripped by a chmod().
@musm confirms that this fixes the recently-observed windows permissions issues.

Seems to make sense


SBT 012x migration guide incomplete, need to mention task

Hi all. This migration guide: http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html  is probably a bit incomplete.
It turns out it's not possible to really migrate the config with only using the migration guide, if you had code that relied on Task[T]. Consider, for example, this code:
resourceGenerators in Compile <+= (resourceManaged, baseDirectory) map { (managedBase, base) =>
	val webappBase = base / "src" / "main" / "webapp"
 	for {
 		(from, to) <- webappBase ** "*" pair rebase(webappBase, managedBase / "main" / "webapp")
 	} yield {
 		Sync.copy(from, to)
 		to
 	}
}

You can't really change it to += and .value invocations because it was previously a Task[Seq[File]], and now you'll get Seq[File]. What you actually should do is wrap the code with task {}. So this is the solution I've come to for my code:
resourceGenerators in Compile += task {
	val webappBase = sourceDirectory.value / "main" / "webapp"
	val managedBase = resourceManaged.value
 	for {
 		(from, to) <- webappBase ** "*" pair rebase(webappBase, managedBase / "main" / "webapp")
 	} yield {
 		Sync.copy(from, to)
 		to
 	}
}

What I am suggesting is to enrich the migration guide with info about Task.
Telling that if you previously had a Task[T] and now getting the T itself, consider wrapping the code with task {} to get the previous behavior back.
I think that would be helpful especially when migrating to sbt-1.0.0 (which removes the method <+=).
Thanks.

"Moved" the issue to the website tracker here: https://github.com/sbt/website/issues/351


Computed Var example doesn't work if @pc.computed handler doesn't specify return type

Describe the bug
The computed vars example no longer works if the return type annotation is removed. It shows an error as follows:
Traceback (most recent call last):
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
    target(sockets=sockets)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/uvicorn/server.py", line 67, in serve
    config.load()
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/uvicorn/config.py", line 458, in load
    self.loaded_app = import_from_string(self.app)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/kabir/Repos/translator/./translator/translator.py", line 51, in <module>
    app.add_page(index, title=title)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/pynecone/app.py", line 169, in add_page
    component = component if isinstance(component, Component) else component()
  File "/Users/kabir/Repos/translator/./translator/translator.py", line 41, in index
    pc.input(value=State.translation),
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/pynecone/components/component.py", line 202, in create
    return cls(children=children, **attrs)
  File "/Users/kabir/.pyenv/versions/3.10.2/lib/python3.10/site-packages/pynecone/components/component.py", line 132, in __init__
    assert expected_type == Any or issubclass(
TypeError: issubclass() arg 1 must be a class

To Reproduce

Use this code but remove the -> str.
Expected behavior
I expected this to work, or provide a descriptive error message saying that a return type is required. In general, I expected the entire API surface to work with or without type annotations.

Resolved with the new release.


Library does not work with 32-bit integers

A more general issue than #37

F.F.FF..EFFEEFFFE..E....FFF.FFFF.........EFEFFFF.FF.SFF.....FS.  63 / 121 ( 52%)
.S.F.FFF.SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS      121 / 121 (100%)

Time: 27.48 seconds, Memory: 27.00MB

[snip]

ERRORS!
Tests: 121, Assertions: 674, Errors: 7, Failures: 30, Skipped: 52.

Here's the full output for the curious.
output.txt

This is going to require a significant rewrite of a lot of the code, and may not be worth it.
Most systems support 64-bit integers (i.e. PHP_INT_SIZE === 8). Windows on PHP 5 is the notable exception here.
For the moment, I'm going to document this behavior and make it fail hard if PHP_INT_SIZE === 4. Adding 32-bit implementations for Windows users can come in a future release.

At least PHP 5.6 on ARM (like Raspberry Pi) are also effected. (PHP_INT_SIZE is 4)

Thanks for the update. I'll try to prioritize getting 32-bit working, but I've got a lot on my plate.

No hurry. I think i found the bug for my PHP 7.x problem and will be able to use native support in 7.2.


WIP title component - testing and playing

this is a mess, ignore for now. just need to get it up so i can stop working on it for today

EEK I'm SO HAPPY! It works! Check it out!!
What this Title component does:

Can have custom content with the text property
Can have a custom class with the className prop
The type prop determines whether it's a h1, h2, etc

LS to do:

[ ] LS: style properly - want to set up CSS Modules in a separate branch
[ ] LS: add in defaults for h1-h5 once we know what we need

Questions for SB:

[ ] SB: check how this is looking and let me know if you would do anything differently. Please note the commented out part in Title.js about ChatGPT
[ ] SB: is this branch naming convention right? Was influenced by your Notion but not sure if it's right.

Woohoo looks great!!
SB: check how this component is setup/built and let me know if you would do anything differently. Please note the commented out part in Title.js about ChatGPT

I think chat GPT has just suggested a refactor that removes a  bit of markup in favour of templating code. I think the way you've done it is fine, perhaps we'll define some of these conventions as we go?
In general I prefer fat arrow syntax for writing functional components, it's a bit more of a modern convention and generally considered more readable
( so instead of

export function Title({ className, text, type, ...props }) {
//code
}

do
const Title = ({className, text, type, ...props}) => {
//code
}

)
SB: is this branch naming convention right? Was influenced by your Notion but not sure if it's right. I think it's meant to be feature-branch-Title-component, right?

Again I think we can decide this as we go, but yeah either using the feature-branch- kinda naming convention, or using Jira ticket IDs. As long as we can understand what it is and perhaps trace it to some documentation


Fix serialization of api key auth location

Description
Fix serialization of location in api key auth configuration.
Closes #260
Type of change

[x] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?
Published locally and tested.
Checklist:

[x] My code follows the style guidelines of this project
[x] I have performed a self-review of my own code
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
[x] I have updated the CHANGELOG in the Unreleased section
[x] My changes generate no new warnings
[ ] I have added tests that prove my fix is effective or that my feature works
[x] New and existing unit tests pass locally with my changes
[x] Any dependent changes have been merged and published in downstream modules

hmmm this will solve it for kotlinx serialization but not for other frameworks correct?  This may just need to be a string value.

Thanks for the PR btw 🙏 very much appreciated

hmmm this will solve it for kotlinx serialization but not for other frameworks correct? This may just need to be a string value.

I changed it to use a string type


Block Versions Based on Some Filter

Is your feature request related to a problem? Please describe.
Recent issues with community published libraries either malicious or not are generally caught by the community quickly. I'd like to come up with a defense against these types of issues.
Describe the solution you'd like
The ability to create a plugin that allows for fine grained, rule based control of if a package appears to exist to npm clients.
For example, I could create a rule that says a package must have been published at least X days ago before the registry proxy claims it exists to clients. This would take us off bleeding edge, but lower the risk of major issues. I would also be able to do things like feed it a blacklist of libraries that no one should be able to download (e.g. in the days before npm grabbed this, we would block it). A good design would allow for easy admin and escape hatches to let new versions flow through. It may also consider allowing clients the ability to override this depending on the design and trust model we want to build.
There is clear risk here and moving away from a simple proxy and increasing the complexity and management of a proxy, but given the seriousness of recent issues, I believe would add a good line of defense.
What do you think?

It relates with https://github.com/verdaccio/verdaccio/issues/810

I like the idea, but we would need to elaborate a bit more what are the boundaries and whether is possible with the current design + being optional

Hi @juanpicado, any more thoughts on this?

@mlucool I haven't had time yet, sorry.

I spent some time on this. I would I was able to remove packages by adding in a function in storage.getPackage that pruned the result by deleting both the time and versions key for that specific version.
e.g.
delete result.versions[badVersion];
delete result.time[badVersion];

The only major issue with this approach is if you delete something that is a also a dist-tag you have to do some sort of repair. I also don't know if this is all that is necessary, but testing showed this is sufficient for the npm i case.
Therefore, I propose we add in a plugin with an API of one function, filter. This will be called on every call to getPackage. A noop implementation of this is the identity function.
What do you think? Worth pursuing?

@juanpicado I created an WIP in https://github.com/verdaccio/verdaccio/pull/1161 for what I think could create a plugin based approach to solve this. What do you think of this concept? If you like it, what do you think are the next steps to get this ready for merging? I know I need to refactor this so external plugins can be created and add unit testing.

Closing as this was completed via https://github.com/verdaccio/verdaccio/pull/1161

@mlucool Was this documented anywhere? I see all the PRs merged, but I can't see anything about filters on the docs site

@robcresswell not extensively https://verdaccio.org/docs/en/dev-plugins#filter-plugin but yes, also the PR contains some information.


[LIBCLOUD-873] Updated ProfitBricks Compute Driver (REST api v3)

Updating the ProfitBricks compute driver to work with the REST api (v3)
Description
This PR includes changes to the ProfitBricks compute driver to drop support for the old SOAP api (now end of life) and provide support for v3 of the REST api.
All public operations provided by the new REST api are supported in this driver.
New test fixtures have been added and all tests have been amended.
A change has been added to the libcloud/common/base.py file to ensure that a request that returns with a HTTP status of 202 is not flagged as a failed request. Before this, only 200 and 201 were flagged as successful requests.
Status

done, ready for review

Checklist (tick everything that applies)

Code linting for the compute driver implementation and the accompanying test file has been completed using the flake8 tool.

Documentation has been updated consisting of examples of using all core and extended functionality specific to ProfitBricks. A demo file with instructions on creating two servers has been put together and these will be published on the ProfitBricks community website.

All test fixtures for api calls have been added in JSON format, replacing the older XML fixtures. All tests are passing.

Summary of changes
Refactoring the compute  driver to remove support for the EOL SOAP api and modifying api calls to use the REST api (v3).
Removing XML test fixtures and replacing them with JSON fixtures.
Providing wrappers for all new functionality provided in v3 of the Cloud API.
Addressing an issue in libcloud/common/base.py where a http status code of 202 would not be flagged as a successful request.

thanks @matfin for the detailed PR, the changes look good to me. Has this been tested against an active endpoint using a real account as well?

Hi @tonybaloney - It has. It was also developed against a test account I was using.

then 👍


CWD is not the root of the zip action

Problem when your action wants to reference another file in your zip, locally this is easy because the node process usually get's started from the root of the project where the package.json is located.
For example the following code works fine in my local computer.
Since I'm running the node process locally
const fs = require('fs')
exports.main = () => {
    const cwd = process.cwd()
    const dirname = __dirname
    //in openwhisk need to find the root of the zip
    console.log(`dirname= ${dirname}`)
    console.log(`cwd= ${cwd}`)
    const file = fs.readFileSync('secondfile.txt',{encoding:'utf8'})
    console.log(file)
    return {file, cwd, dirname}
}

I run this code in openwhisk I get an error about not found
In openwhisk currently the current working directory (cwd) is set to where the nodejs process started /nodejsAction
This is different from using for example dockerskeleton or python action, where the cwd is changed to the tmp directory where the the zip action get's unzip.
For now the workaround is to use __dirname like ${dirname}/secondfile.txt instead of secondfile.txt
const fs = require('fs')
exports.main = () => {
    const cwd = process.cwd()
    const dirname = __dirname
    //in openwhisk need to find the root of the zip
    console.log(`dirname= ${dirname}`)
    console.log(`cwd= ${cwd}`)
    const file = fs.readFileSync(`${dirname}/secondfile.txt`,{encoding:'utf8'})
    console.log(file)
    return {file, cwd, dirname}
}

The fix is in runner.js to change the process directory process.chdir() to the directory where the zip get's extracted
https://github.com/apache/incubator-openwhisk-runtime-nodejs/blob/master/core/nodejsActionBase/runner.js#L59
process.chdir(moduleDir)
 thisRunner.userScriptMain = eval('require("' + moduleDir + '").' + message.main);

cc @rabbah

@csantanapr I believe this can be closed now


✨ add performance test

Summary
Adds a simple performance test that we can integrate into the cicd testing.  The purpose is to identify early major regressions resulting in 10x elapsed time.
The setup is a single bindingpolicy and a single deployment.  The test adds the deployment to the WDS and measures the amount of time it takes to create the WDS object, the Binding object, the ManifestWork object, and the deployment object on the WEC.  The starting time is just prior to adding the WDS object and the end time is just after the deployment object is observed on the WEC.  The other timing are obtained from the object creation timestamp.  The test intentionally looks at seconds rather than milliseconds since we expect this test to run on VMs and local systems and anything below seconds is likely just noise.
This is what the results look like:
  Run 0: wds deployment=0, binding=1, manifestwork=1, wec deployment=1, total=2
  Run 1: wds deployment=0, binding=0, manifestwork=0, wec deployment=5, total=6
  Run 2: wds deployment=0, binding=1, manifestwork=1, wec deployment=7, total=7
  Run 3: wds deployment=0, binding=0, manifestwork=0, wec deployment=5, total=5
  Run 4: wds deployment=0, binding=0, manifestwork=0, wec deployment=4, total=5
  Run 5: wds deployment=0, binding=0, manifestwork=0, wec deployment=4, total=5
  Run 6: wds deployment=0, binding=0, manifestwork=0, wec deployment=4, total=5
  Run 7: wds deployment=0, binding=1, manifestwork=1, wec deployment=6, total=7
  Run 8: wds deployment=0, binding=0, manifestwork=0, wec deployment=4, total=5
  Run 9: wds deployment=0, binding=0, manifestwork=0, wec deployment=5, total=5
  ----------------------------------------------------------------------------------
  Avg:   wds deployment=0, binding=0, manifestwork=0, wec deployment=4, total=5

Related issue(s)
Fixes #

@effi-ofer After looking at the code, I'm not sure ginkgo is a good choice for the performance test.  I'm quite sure that for such very simple base line tests, we could have used a very simple shell script with couple of kubectl commands.

@effi-ofer After looking at the code, I'm not sure ginkgo is a good choice for the performance test. I'm quite sure that for such very simple base line tests, we could have used a very simple shell script with couple of kubectl commands.

I like the go and ginkgo approach because:

It allows for code reuse of all the utility functions that we already wrote and that speeds up development.
Using golang for accessing kube structures is simpler than in shell but that's a personal preference.
It provides an existing implementation of busy waiting for something to happen.

I find it easy and convenient, but I agree that it's an issue of personal preference.  If you feel strongly about it.  Put the PR on hold and I'll switch it to shell.  It's not a big deal either way.

The purpose is to identify early major regressions resulting in 10x elapsed time.

That may be an eventual goal, or maybe an expectation for some future higher level thing, but that is not what this PR does. This PR only introduces a test that logs elapsed times; there is no comparison with expected elapsed times. The PR and README should be clear about this.

(A) The explanation in the PR and in the README does not make the exact sequencing clear. What is not clearly said is that first the BindingPolicy is created, and then the timer is started, without waiting for anything but the existence of the BindingPolicy. This matters (see next point).
(B) The timestamp collection here is not fully cognizant of the generality of the asynchronous processing involved (or possible --- I think that we do not want our tests to rely too intimately on implementation details that may change). The mere creation of a BindingPolicy is (or logically could be) enough to trigger creation of the corresponding Binding object --- before the existence of any workload objects that match the BindingPolicy. Similarly, the existence of a Binding is, or could be, enough to trigger the creation of the corresponding ManifestWork object. It is possible to get accurate timing of when the Deployment was put in the Binding and when the Deployment was put in the ManifestWork by looking at the ObjectMeta.ManagedFields.

The purpose is to identify early major regressions resulting in 10x elapsed time.

That may be an eventual goal, or maybe an expectation for some future higher level thing, but that is not what this PR does. This PR only introduces a test that logs elapsed times; there is no comparison with expected elapsed times. The PR and README should be clear about this.

Long term, it would be good to either automatically fail when a predetermined threshold is surpassed, or parse the output and use it as part of the data displayed on the project status.  But I agree that it's a follow up.

Regarding ObjectMeta.ManagedFields, note that kubectl get normally omits that but will show it if asked. For example:
kubectl --context wds1 get bindings.control nginx -o yaml --show-managed-fields


Add SHELL Scripting resources

Description
As DevOps is all about automation & to avoid the repetitive task, SHELL Scripting knowledge is mandatory for the folks.

Add some beginner-friendly to advanced-level resources for this -

Screenshots
No response
Additional information
No response

Great idea @Saha-7. Would you like to add resources links in the issue discription so someone (or you) can go ahead and create pr for same.

Sure, I will. Please assign it to me.

@Saha-7 sure, can you please add the resouces in the issue discription so we can review it maybe?

PR has been merged so closing the issue


Enable eslint blockBindings so const can be used.

LGTM, waiting on this PR so I can implement consts

LGTM, waiting on this PR so I can implement consts

I'm going to go ahead and merge so this doesn't block you and since it's a straightforward configuration change.


⌘T no longer mapped to "Add to Sidebar"

In Yosemite (not sure about Mavericks), Command+T is mapped to "New Tab". Karabiner has it as "Add to Sidebar".

Thank you for feedback!
I've fixed this issue at v10.5.8.
How to upgrade to the latest beta version:
https://pqrs.org/osx/karabiner/document.html#check-for-updates
Diff:
https://github.com/tekezo/Karabiner/commit/fb7e2f65c8e2480f2107437036c18821319a9ce4


Impossible to use type inference while redefining an inherited class field while reusing the inherited value.

Bug Report

🔎 Search Terms

redefine class fields inference implicit any circular this
🕗 Version & Regression Information
This is the behavior in every version I tried including nightly and I assume it is a consequence of how Typescript currently handle class fields, which is different from the actual implementation of public class fields in current browser engines.
I assume this bug will disappear when Typescript handle class fields as is without transforming them into assignment on this.
⏯ Playground Link

Playground link with relevant code
💻 Code

class Base {
    prop = { a: 42 };
}

class SubWithCircularThis extends Base {
    // This throws: 'prop' implicitly has type 'any' because it does not have a type
    // annotation and is referenced directly or indirectly in its own initializer.(7022)
    // The error would be correct in a standard assignment scenario, but it seems abusive
    // here considering the type of `this.prop` at the moment of the spread operator is
    // actually the type (wrongly) inferred for `super.prop`, see below, thus not circular.
    prop = {
        ...this.prop,
        b: 48,
    }
}

class SubWithoutCircularThisButWithBogusSuperType extends Base {
    // Here `prop` has the correct inferred typing but it is in fact wrong as super
    // references the prototype of Base at this point, which does not have `prop` at
    // all. See the console.log output below.
    prop = {
        ...super.prop,
        b: 48,
    }
}

var bogus = new SubWithoutCircularThisButWithBogusSuperType();
console.log(bogus.prop.a); // output: undefined instead of 42.

🙁 Actual behavior

It is not possible to use type inference when redefining a class field in a sub class using the same name as the super class and reuse the value of the super class field without explicitely typing the proeprty.
It throws: 'prop' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.(7022).
The error would be correct in a standard assignment scenario, but it seems abusive in class fields considering the type of this.prop at the moment of the spread operator is actually the type (wrongly) inferred for super.prop, thus not circular.
However, the type of super.prop, while being the one I would have expected to get for this.prop in the context of class fields definition, is wrong for super in itself as super is the prototype of the Base class, not the instance itself.
So there are two bugs here but they are somewhat linked together because this.prop in the context of class field definition should be the type of super.prop and super.prop should not exist per se.
🙂 Expected behavior

this.prop in the context of class field definition should be the type currently used for super.prop and super.prop should not exist per se as this would more correctly match the behavior of public class fields.
As I mentionned earlier, I assume this would change when Typescript outputs actual public class fields, which is not the case for now, but the behavior seems wrong anyway. Especially the typing of super.prop. Anyway, the compiler should be able to distinguish between the "normal" context, where this.prop indeed means this.prop and the typing would indeed be circular, and the class field context, where this.prop means the prop previously defined in the super class, thus no circularity.
For anyone who would be facing the same issue as I was and who really wants to use type inference rather than manually type the property, I have found a rather hacky workaround to make super.prop return the value of this.prop:
Playground link with hacky workaround
Please do not fix the type of super.prop without fixing the circular type inference of this.prop in the context of class fields, as this would break the workaround. Ideally, these two bugs should be fixed together.
I don't expect this to be fixed before Typescript actually starts outputing javascript code with public class fields but I thought you would like to know nonetheless.

Related to #10570

Related to #10570

Looks like a duplicate of #33899.

Looks like a duplicate of #33899.

Respectfully, I do not think this issue is a duplicate of those two. The first one does not seem to reuse the previous value of the property, thus only encompassing the "redefinition" part of this issue, while the second one uses Object.assign which does not "merge" the types (result of Object.assign(A, B) is A & B) like the spread operator does.
I am not that much into Typescript so I might be wrong and my issue might indeed be a duplicate of those but I don't think any of them include the typing issue of super.prop. This is quite confusing in my opinion because you can only spot the error at runtime when the object is not initialized with the correct value since super.prop is actually undefined in reality.

Respectfully, I do not think this issue is a duplicate of those two. The first one does not seem to reuse the previous value of the property, thus only encompassing the "redefinition" part of this issue, while the second one uses Object.assign which does not "merge" the types (result of Object.assign(A, B) is A & B) like the spread operator does.
I am not that much into Typescript so I might be wrong and my issue might indeed be a duplicate of those but I don't think any of them include the typing issue of super.prop. This is quite confusing in my opinion because you can only spot the error at runtime when the object is not initialized with the correct value since super.prop is actually undefined in reality.

The issue of super.prop is a bug.

The issue of super.prop is a bug.

Respectfully, I do not think this issue is a duplicate of those two. [...] while the second one uses Object.assign which does not "merge" the types (result of Object.assign(A, B) is A & B) like the spread operator does.

The behavior is the same when you use object spread: Playground link
But in the end it's in the discretion of the TypeScript team, of course.

EDIT: Woops, sorry jcalz I did not realize you said "related to" and not "duplicate". Indeed the two issues are definitely related.

jcalz said related, I said duplicate. :-)

Respectfully, I do not think this issue is a duplicate of those two. [...] while the second one uses Object.assign which does not "merge" the types (result of Object.assign(A, B) is A & B) like the spread operator does.

The behavior is the same when you use object spread: Playground link
But in the end it's in the discretion of the TypeScript team, of course.

EDIT: Woops, sorry jcalz I did not realize you said "related to" and not "duplicate". Indeed the two issues are definitely related.

jcalz said related, I said duplicate. :-)

I don't think there's anything here not covered by the existing linked issues.

I don't think there's anything here not covered by the existing linked issues.


✨ feat: improve sample size handling in Validator class

Fixed an issue where a warning is now logged if the requested sample size exceeds available records in the QA data.
Sampling for QA data is now limited by the number of available records, ensuring safe sampling practices.


archiver.add() is callback required?

Docs show archiver.add(key, [opts], [callback]) but add errors without callback.

ah, no thats a bug then

should be fixed in latest


npm run dev suddenly not working anymore. VueLoaderPlugin issue

Laravel Mix Version: 6.0.19 (npm list --depth=0)
Node Version (node -v): 15.2.1
NPM Version (npm -v): 7.13.0
OS: Mac BigSur 11.2.1
VueLoaderPlugin: 7.13.0

Description:
When running npm run dev I can't get behind this error.
Going crazy because already searching for 1 day to solve this error, but don't know how.
Somebody issuing the same error after npm install a component?

[webpack-cli] TypeError: VueLoaderPlugin is not a constructor
at Vue.webpackPlugins (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/components/Vue.js:116:17)
at ComponentRegistrar.applyPlugins (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/components/ComponentRegistrar.js:203:23)
at /Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/components/ComponentRegistrar.js:102:50
at /Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/Dispatcher.js:37:62
at Array.map ()
at Dispatcher.fire (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/Dispatcher.js:37:47)
at Mix.dispatch (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/Mix.js:244:32)
at WebpackConfig.buildPlugins (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/builder/WebpackConfig.js:176:24)
at WebpackConfig.build (/Users/maarenlermytte/Documents/crm/node_modules/laravel-mix/src/builder/WebpackConfig.js:31:20)
at async /Users/maarenlermytte/Documents/crm/node_modules/webpack-cli/lib/webpack-cli.js:1391:37

Steps To Reproduce:

I'm also facing the same issue too.

Fixed it by running the following commands:
npm install<EMAIL_ADDRESS>--save-dev --legacy-peer-dep
npm install laravel-mix@latest
npm cache clean --force
npm install && npm run dev

Closing as you fixed the issue. The npm cache is a bit weird sometimes.


Change where Prowler integration check for AWS Security Hub is called

New feature motivation
When a customer is importing findings into AWS Security Hub a call is made to confirm that the prowler integration is enabled in Security Hub.    The current implementation of the security hub integration is making this confirmation call every time a finding is sent to Security Hub.   This means that if during one prowler report run a customer has 1000 findings, this call to confirm the integration is enabled is also called 1000 times when only needs to be called once before sending the first finding as part of a report run.
Solution Proposed
The current check to see if the integration is enabled is called in this library: https://github.com/prowler-cloud/prowler/blob/bc11537350e1e919eff4a02d4d3fcd3e109c6d11/prowler/providers/aws/lib/security_hub/security_hub.py#L32C1-L33C1.    I think that the right place to put this check is right before the call to send a finding to security hub: https://github.com/prowler-cloud/prowler/blob/bc11537350e1e919eff4a02d4d3fcd3e109c6d11/prowler/lib/outputs/outputs.py#L111.  Logic here should have a variable to track that the integration is confirmed as enabled and then use the state of that variable to only check that the integration is enabled for the first finding and then skip the check for all additional findings.
Describe alternatives you've considered
No alternatives considered.
Additional context
No response

Thanks for reporting it @scottbward, I'll take a look this week. Thanks!

Hi @scottbward, the above PR improves the behaviour of the Security Hub integration, checking just one time per region audited if the service is enabled and the integration configured.
Thanks for using Prowler 🚀


Create new action to recreate / regenerate Xcode project schemes.

This solves an issue when no scheme is commited into the SCM or the Xcode project is generated (in Apache Cordova for example). This could be fixed for example with this recreate_schemes action within  the before_all block.
TL;DR: After generating (add) a Apache Cordova Xcode project with cordova platform add ios for example the project contains no scheme by default. Also other project maybe exclude the user schemes in the .gitignore. After open the project with Xcode everything works as expected. But for me I had strange issues with gym & co. to build the project automatically without Xcode (local and on a CI/CD server).
The main issue was that xcodebuild -list -project path/to/MyApp.xcodeproj doesn't exit when it doesn't find a scheme. m( The command hangs after this:
    Information about project "MyApp":
        Targets:
            MyApp

        Build Configurations:
            Debug
            Release

        If no build configuration is specified and -scheme is not passed then "Release" is used.
[XCODEBUILD NEVER STOPS...]

Would be happy to see this in the upstream. Feedback is welcome if there is an easy way to implement this in a way which also supports workspaces. I didn't understand ruby nor fastlane good enough. :smirk:
Code was inspired from http://stackoverflow.com/a/20941812

I tested this now with a second project which uses cocoapods. I need this also there and it works fine when specify the project, too.

Sorry for the delay on reviewing this. Looks okay to me, let's wait for @AliSoftware before we merge this :+1:

LGTM :+1:

:tada: :smirk:

Oh yeah, thanks @jerolimov :rocket:


Fix some spell mistakes

// Describe your PR here; eg. Fixes #issueNo

Make sure that:

[ ] You have read the contribution guidelines.
[ ] You submit test cases (unit or integration tests) that back your changes.
[ ] Your local test passed mvn clean install -Dmaven.javadoc.skip=true.

Codecov Report

Merging #911 (372afa4) into master (ef91a67) will increase coverage by 0.34%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master     #911      +/-   ##
============================================
+ Coverage     76.41%   76.75%   +0.34%
- Complexity     1866     1868       +2
============================================
  Files           309      309
  Lines          6987     6987
  Branches        792      792
============================================
+ Hits           5339     5363      +24
+ Misses         1244     1219      -25
- Partials        404      405       +1

Impacted Files
Coverage Δ
Complexity Δ

...ul/admin/listener/AbstractDataChangedListener.java
4.10% <ø> (ø)
2.00 <0.00> (ø)

...tener/http/HttpLongPollingDataChangedListener.java
6.72% <ø> (ø)
2.00 <0.00> (ø)

...omara/soul/admin/service/impl/RuleServiceImpl.java
100.00% <ø> (ø)
19.00 <0.00> (ø)

.../soul/admin/service/impl/UpstreamCheckService.java
73.21% <0.00%> (-1.79%)
13.00% <0.00%> (-1.00%)

...soul/client/sofa/SofaServiceBeanPostProcessor.java
64.51% <0.00%> (+40.32%)
8.00% <0.00%> (+3.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef91a67...32e96c2. Read the comment docs.


generic tagged union

Initial Checks

[X] I confirm that I'm using Pydantic V2

Description
Hi,
I'm trying to work with a generic tagged union. It seems to work well with TypedDict, for instance:
from typing import TypedDict
from typing import Generic, Literal, TypeAlias, TypeVar

T = TypeVar("T")

class TriangleDict(TypedDict, Generic[T]):
    tag: Literal["triangle"]

class SquareDict(TypedDict, Generic[T]):
    tag: Literal["square"]

ShapeDict: TypeAlias = TriangleDict[T] | SquareDict[T]

def foo_dict(shape: ShapeDict[int]) -> None:
    if shape["tag"] == "triangle":
        reveal_type(shape)  # Revealed type is "TypedDict('shapes_dict.TriangleDict', {'tag': Literal['triangle']})"

But with the example code bellow using BaseModel instead, mypy is still ok, but Python fails with:
Traceback (most recent call last):
  File "(...)", line 18, in <module>
    def foo(shape: Shape[int]) -> None:
                   ~~~~~^^^^^
TypeError: __main__.Triangle | __main__.Square is not a generic class

Thanks!
Example Code
from pydantic import BaseModel
from typing import Generic, Literal, TypeAlias, TypeVar

T = TypeVar("T")

class Triangle(BaseModel, Generic[T]):
    tag: Literal["triangle"]

class Square(BaseModel, Generic[T]):
    tag: Literal["square"]

Shape: TypeAlias = Triangle[T] | Square[T]

def foo(shape: Shape[int]) -> None:
    if shape.tag == "triangle":
        reveal_type(shape)  # mypy: Revealed type is "shapes.Triangle[builtins.int]"

Python, Pydantic & OS Version
pydantic version: 2.5.2
        pydantic-core version: 2.14.5
          pydantic-core build: profile=release pgo=true
                 install path: /home/dfroger/.pyenv/versions/3.11.4/lib/python3.11/site-packages/pydantic
               python version: 3.11.4 (main, Aug 18 2023, 15:33:08) [GCC 9.4.0]
                     platform: Linux-5.14.0-1058-oem-x86_64-with-glibc2.31
             related packages: typing_extensions-4.8.0 fastapi-0.104.0 mypy-1.7.0

Can you try with the following?
from typing_extensions import TypeAliasType

Shape = TypeAliasType("Shape", Triangle[T] | Square[T], type_params=(T,))

Thanks, Indeed it work! Didn't know about TypeAliasType!
Now mypy complains:
shapes.py:17: error: Type variable "shapes.T" is unbound  [valid-type]
shapes.py:17: note: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class)
shapes.py:17: note: (Hint: Use "T" in function signature to bind "T" inside a function)
shapes.py:17: error: Argument "type_params" to "TypeAliasType" has incompatible type "tuple[object]"; expected "tuple[typing_extensions.TypeVar | ParamSpec | TypeVarTuple, ...]"  [arg-type]
shapes.py:20: error: Variable "shapes.Shape" is not valid as a type  [valid-type]
shapes.py:20: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
shapes.py:21: error: "Shape?[builtins.int]" has no attribute "tag"  [attr-defined]
shapes.py:22: note: Revealed type is "Shape?[builtins.int]"

But like this it's ok for both python and mypy::
if TYPE_CHECKING:
    Shape: TypeAlias = Triangle[T] | Square[T]
else:
    Shape = TypeAliasType("Shape", Triangle[T] | Square[T], type_params=(T,))

will try to improve, and test on my real code.

So it's not so bad:
from pydantic import BaseModel
from typing import Generic, Literal, TypeAlias, TypeVar, TYPE_CHECKING
from typing_extensions import TypeAliasType

T = TypeVar("T")

class Triangle(BaseModel, Generic[T]):
    tag: Literal["triangle"]

class Square(BaseModel, Generic[T]):
    tag: Literal["square"]

Shape: TypeAlias = Triangle[T] | Square[T]

if not TYPE_CHECKING:
    Shape = TypeAliasType("Shape", Shape, type_params=(T,))

def foo(shape: Shape[int]) -> None:
    if shape.tag == "triangle":
        reveal_type(shape)  # mypy: Revealed type is "shapes.Triangle[builtins.int]"

@Viicos,
Great suggestion with TypeAliasType. Using said type is currently our recommendation for your use case @dfroger. Closing this for now, happy to consider more discussion if this is a high demand request 😄.

@Viicos,
Great suggestion with TypeAliasType. Using said type is currently our recommendation for your use case @dfroger. Closing this for now, happy to consider more discussion if this is a high demand request 😄.

Agree, thanks @sydney-runkle !


Different storage content by using EFS in more than 1 ECS task

When I start more than 1 ECS task I get different storage content for example regarding Atlantis Terraform locks. For example existing task shows me lock in UI but new one doesn't. Is it intentionally or I am missing something regarding parameters? I don't use ephemeral storage.

Atlantis is not designed to run more than one task - see the upstream project for more info. Parallel execution is supported but only with named workspaces


Remove redundant parameter when generating thumbnail

The FFmpeg documentation makes it sound like -vframes and -t are mutually exclusive:

If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time.

...and I had one video where no output file was produced (and no error reported) when both -vframes and -t were specified.

Thanks for this, sorry about the later merge, also I'll be changing line number 130 on ConvertTest.cs so that Assert.IsTrue becomes Assert.That, this is to have all assertions using the same testing library NUnit


cant log in

im trying to log in but I cant. what's the raspberrypi login and the password?

Will this be via SSH or TTY?  Default Debian UserID/Password
pi:raspberry

If you are trying to connect via WiFi, Select your SSID (mine was SUBZero, likely default) with the WPA password/phrase of
raspberry


[WIP] Prepared Queries

Add a new provider for prepared queries API

Please remove the WIP that I added in the title and squash/rebase when you are ready for review.

LGTM? I've not personally used (or even heard tbh) of this feature of consul before now.
Writing providers can be tricky, it looks pretty sane and you have a few tests :)
Shipping!


json/ js to xml conversion looses empty arrays information

json/ js to xml conversion looses empty arrays information
An empty string is converted to an empty tag.
An empty array is Not converted to an empty tag.
However, we needed for our functionality so that clients don't break, for example, when card numbers are not given, an empty tag exists
example:
let jsonObj = {
	key1: 'val2',
	arrayKey1: [456],
	emptyKey1: '',
	emptyArrayKey1: []
};

var builder = new xml2js.Builder();
var xml = builder.buildObject(jsonObj);
console.log(xml);

actual output (NOTE: emptyArrayKey1 tag is missing):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
  <key1>val2</key1>
  <arrayKey1>456</arrayKey1>
  <emptyKey1/>
</root>

expected output (NOTE: emptyArrayKey1 tag is now back):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
  <key1>val2</key1>
  <arrayKey1>456</arrayKey1>
  <emptyKey1/>
  <emptyArrayKey1/>
</root>

I have fixed it using below code, using JavaScript, writing fix details below, because I don't know Coffee Script to create pull-request, if fix is good in general too, then please help others via a pull request:

Fix details
in the file:
.\xml2js\lib\builder.js
OR
https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/lib/builder.js
below code:
	} else if (Array.isArray(child)) {
		for (index in child) {

should be changed to:
	} else if (Array.isArray(child)) {

		// NOTE: FIX - begin
		if (child.length === 0) {
			element = render(element.ele(key), '').up();
		}
		// NOTE: FIX - end

		for (index in child) {

Good point. Please send this as pull request.

Oh, I didn't see your message. Well, I can only apply it when I have some spare time.

I'm not sure this needs a fix in xml2js. If you want an empty element in your XML, just add an empty string to your array:
let jsonObj = {
	key1: 'val2',
	arrayKey1: [456],
	emptyKey1: '',
	emptyArrayKey1: ['']
};

var builder = new xml2js.Builder();
var xml = builder.buildObject(jsonObj);
console.log(xml);

Output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
  <key1>val2</key1>
  <arrayKey1>456</arrayKey1>
  <emptyKey1/>
  <emptyArrayKey1/>
</root>


feat: add secret rotation schemas

Current dependencies on/for this PR:

11-29-feat_add_s3_batch_schemas

PR #15   👈

This comment was auto-generated by Graphite.


Second starts when call connects but it should when call is received

When call connects or ringing twilio shows second. Even when ends the call after receiving twilio sends duration in callback from when call connects. But it should when call is received.

Hi @hbrawnak
For app to only receive the "connected" callback when the call has been answered by the callee, please use the answerOnBridge flag in your  verb.
Please note that this only applies when there is no  or  verb before  in the TwiML response, otherwise the client will receive the "connected" callback once the connection is established between the caller and Twilio.
Hope this helps.
-bobie

Thank you


MQTT support

This library and command line works fine with my SunGrow SG15RT and SG5.0RT (with some oddity, see separate issue), thanks a lot for your work!
Are you aware of anyone who has used this library to poll and to publish it via MQTT? I don't want to reinvent the wheel.
Would that be acceptable as a feature for sungrow-websocket  itself?

I would love it. I don't need it myself, but every addition is highly appreciated!

https://github.com/bohdan-s/SunGather also worked for me and already has MQTT support - I'll probably just use that.


Spinbox part of the gui expands with larger window instead of graphs

When displaying multiple charts it would be nice to be able to make the window size larger so we can see the data in more detail. When the window is made larger the left section (spin boxes and controls) of the gui expands to fill the space instead of the right side (charts). It would be nice to have the controls stay a constant width and the charts take up the rest of the available space in the window

This can be (and is being) addressed in branch task/lock-user-control-size by "fixing" the user control width so that the contained controls won't stretch (remain the same size) when the user drags the app window to a larger size. Similarly the controls won't shrink in size if the app window is reduced in size.


backward compatibility with old metadata versions

How do we want to handle old metadata versions? Ideally this won't involve re-implementing common codecs for each version. However, this is quite important for interacting with archival nodes, as well as ensuring we have a consistent framework for adapting to future changes.

#paritytech/scale-ts#134


Update the grant selection page in submission details with new style and layout

[x] (1) number of grants is too big and should align left or right since nothing on the site is aligned center
[x] (2) number of grants shouldn't be displayed anyway if less than 10.
[x] (3) bottom table is indented top is not
[x] (4) funder really needs a min width, it forces the table to be more spaced out than necessary and splits words like "aeronautics"
[x] (5) the grey highlight color on rows is too dark and little obnoxious, i would go for a lighter grey
[x] (6) I'm wondering if the back/next buttons should be duplicated under grants added to submission (edited)
[x] (7) The table at the top should include the date like this ANALYSIS OF BLAH BLAH (12/12/2016-12/12/2018)
[x] (8) Add date range to project name on bottom to help with spacing?
[x] (9) reword top to say "Please select grant(s)/award(s) that funded this work." take out the second "Please select grants that should be associated with this submission.", reword "If you could not find your grant in the below dropdown list" -> "If your grant is not listed, please contact us"
[x] (10) make subheadings smaller
[x] (11) link grants in bottom table same as top table

Closed by PR #832


Fix warning with incomplete umbrella header

Removes the header giving the warning

@flovilmart hello!
How did you enable -Wincomplete-umbrella warning?
I have a project with a lot of public headers. (Framework project)
Several of them are missing in umbrella header.
Modulemap file only includes framework umbrella header.
So, as I suppose, Xcode should warn me about missing headers.
It doesn't :(

Probably adding it to the WARN_CFLAGS. Not sure

@flovilmart thanks for help!


Add iframe approach

As we have in Click2vox.com, add the iFrame option (this is currently hidden since it is not fully merged)

The approach to making this work is different from what is already implemented in click2vox. This task is more complex than it seemed.

I think we should close this one since we're not encouraging the users to use the iFrame approach


allow keepalive to be cloud specific and infinite

On clouds where resources can be dedicated doesn't make sense to shutdown VMs when queue idle unless the resources are needed for something else.
Alter keepalive to have a cloud based default pulled from cloud_resources.conf if specified and allow it have a special value (-1) to be kept up indefinitely

still race condition occurring for keepalive, machines may not get their idle time set in time for the clean_unneeded_vms check that destroys them.


Need fallback for conic to cubic conversion

This could be done with skia.Path.ConvertConicToQuads() but that's currently not working for me: https://github.com/kyamagu/skia-python/issues/115

Context: we need to convert to non-conics for path.drawToPen(pen), and Skia outputs conic segments for ovals and arcs.

Not sure if you want to depend on two skia bindings at the same time, but https://github.com/fonttools/skia-pathops exposes that method to convert conic to quads (plus the pathops operations which I think the other bindings does not)

Oh that sounds great, I'll check it out, thanks!
Yeah, skia-python misses that main pathops entry point, so I was already considering using skia-pathops as a workaround.
There probably is no currently way to use a skia-python Path object directly in skia-pathops? It's a bit of a waste if I have to convert a SkPath instance to a SkPath instance via fonttools pens...

I don't know, the two projects use different binding techniques and embed different copies of the skia library.

If skia-python exposed all the API that we need in skia-pathops, i'd be happy to use that as the low level wrapper in skia-pathops and keep the latter only as a booleanOperations-like python-only interface.

On the other hand, skia-pathops is lean and mean(-ish...), and skia-python is rather bulky.

Further reference: https://github.com/kyamagu/skia-python/issues/116


Implement logging

Overview
Currently, it's hard to trace errors because CLI catches all of them and not showing stacktrace

Merged into https://github.com/frictionlessdata/livemark/issues/35


Fix a timeline into desired time and not 24 hours.

Hi,
Am trying to make the timeline be shown from 10 am to 22 pm.
Eventually, I did manage to do it using visibleTimeStart/End .
The problem is the timeline, below the dates arent being fixed. Its scrollable like left/right scroll.
I want that to be fixed with respect to the time.
I would be really happy if anyone could help with this.
Thank you

same probleme here searching for solution pleaz


Add support of keyboard and mouse

WIP
This PR adds mouse and keyboard controls for aplicable Libretro cores.
As simple as it may sound, the main idea is to capture browser Keyboard and Mouse API events and then feed them in a digestible form to the Libretro frontend. Unfortunately, there are several problems related to the original design choices of cloud-game.
Initially, it was assumed that each player would have just one controller device occupying a single controller port in terms of the underlying Libretro API. This way, it would be pretty easy to distinguish controller events of each player, knowing that you can safely forward player control events to their dedicated port without the fear of interfering with other players. However, that was quite a wrong assumption, thinking that one player occupies just one device port. In reality, many cores allow the use of several different controller devices, in theory mapped to an unlimited number of ports (in practice, only up to 9 ports can be used), or even multiplex multiple devices (merge controller events) on a single port, as in the case of the DOSBox Pure core.
Keyboard in Libretro
To use a keyboard with Libretro, two callback functions from the core are required:

Keyboard Callback Function: RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK

Set when the core pushes out the environment variable with the same name.
This callback should be called once a user presses or releases a keyboard key.
It's important to note that the keyboard controls in Libretro do not have a distinct port argument in the callback function. This limitation makes it impossible to separate player keyboards in cores like DosBox, even though DosBox polls the state of pressed keys for each port separately in the polling callback.
The callback function has the following parameters:

bool down: Indicates if the key is pressed.
unsigned keycode: Internal Libretro representation of the pressed key.
uint32_t character: Ignored.
uint16_t key_modifiers: Special key modifiers such as shift, alt, ctrl, meta, num/caps/scroll-locks.

Device Callback Function: RETRO_DEVICE_KEYBOARD

It is polled after each emulation tick in the core_input_state polling function.
Each key that was previously pressed by the keyboard callback function must be left in the pressed state or released (by setting the device callback function result to 1 or 0).

Mouse in Libretro
Mouse controls in Libretro are polled similarly to the keyboard, using the core_input_state function with the device name RETRO_DEVICE_MOUSE. The behavior of the callback depends on the id parameter:

Button States:

When the id parameter corresponds to a mouse button, the callback returns the state of that button (pressed or released).
In this PR, only the states of the Left, Right, and Middle buttons are implemented.

Cursor Position:

When the id parameter corresponds to the cursor position, the callback returns the position of the mouse cursor.
It should be noted that in the case of DOSBox, the X and Y positions of the mouse are not absolute, but rather the relative deltas of X and Y coordinates between two emulation ticks.

Scale cursor speed to native resolution
Since raw pointer movement is not supported in all browsers or platforms, when you stream a display which size is different from a display on which you use mouse, the mouse movement (DPI) should be approximated accordingly.
Used algorithm takes coordinates (movement delta) from the virtual display (cursor over the browser video element) and scales them to the default DosBox VGA display size of 640x480.
Because the scale ratio value is a floating point number and we can't use subpixel coordinates on the server side, we need to take into account accumulated floating point errors when rounding coordinates to the destination screen (Libretro framebuffer). See an example.

WIP This PR adds mouse and keyboard controls for aplicable Libretro cores. As simple as it may sound, the main idea is to capture browser Keyboard and Mouse API events and then feed them in a digestible form to the Libretro frontend. Unfortunately, there are several problems related to the original design choices of cloud-game. Initially, it was assumed that each player would have just one controller device occupying a single controller port in terms of the underlying Libretro API. This way, it would be pretty easy to distinguish controller events of each player, knowing that you can safely forward player control events to their dedicated port without the fear of interfering with other players. However, that was quite a wrong assumption, thinking that one player occupies just one device port. In reality, many cores allow the use of several different controller devices, in theory mapped to an unlimited number of ports (in practice, only up to 9 ports can be used), or even multiplex multiple devices (merge controller events) on a single port, as in the case of the DOSBox Pure core.
Keyboard in Libretro
To use a keyboard with Libretro, two callback functions from the core are required:

Keyboard Callback Function: RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK

Set when the core pushes out the environment variable with the same name.

This callback should be called once a user presses or releases a keyboard key.

It's important to note that the keyboard controls in Libretro do not have a distinct port argument in the callback function. This limitation makes it impossible to separate player keyboards in cores like DosBox, even though DosBox polls the state of pressed keys for each port separately in the polling callback.

The callback function has the following parameters:

bool down: Indicates if the key is pressed.
unsigned keycode: Internal Libretro representation of the pressed key.
uint32_t character: Ignored.
uint16_t key_modifiers: Special key modifiers such as shift, alt, ctrl, meta, num/caps/scroll-locks.

Device Callback Function: RETRO_DEVICE_KEYBOARD

It is polled after each emulation tick in the core_input_state polling function.
Each key that was previously pressed by the keyboard callback function must be left in the pressed state or released (by setting the device callback function result to 1 or 0).

Mouse in Libretro
Mouse controls in Libretro are polled similarly to the keyboard, using the core_input_state function with the device name RETRO_DEVICE_MOUSE. The behavior of the callback depends on the id parameter:

Button States:

When the id parameter corresponds to a mouse button, the callback returns the state of that button (pressed or released).
In this PR, only the states of the Left, Right, and Middle buttons are implemented.

Cursor Position:

When the id parameter corresponds to the cursor position, the callback returns the position of the mouse cursor.
It should be noted that in the case of DOSBox, the X and Y positions of the mouse are not absolute, but rather the relative deltas of X and Y coordinates between two emulation ticks.

Scale cursor speed to native resolution
Since raw pointer movement is not supported in all browsers or platforms, when you stream a display which size is different from a display on which you use mouse, the mouse movement (DPI) should be approximated accordingly. Used algorithm takes coordinates (movement delta) from the virtual display (cursor over the browser video element) and scales them to the default DosBox VGA display size of 640x480. Because the scale ratio value is a floating point number and we can't use subpixel coordinates on the server side, we need to take into account accumulated floating point errors when rounding coordinates to the destination screen (Libretro framebuffer). See an example.

Could it support virtual keyboard and virtual mouse features which support by retro on mobile? and If run on PC platform, could it supports native mouse and keyboard events?

@guozanhua, could you explain how this touchpad mode works and what do you expect from it?
Right now, you can press toggle-button under the options not in the fullscreen mode and with that you can touch control mouse movement (virtual cursor) by touching left joystick on the screen.

@guozanhua, could you explain how this touchpad mode works and what do you expect from it? Right now, you can press toggle-button under the options not in the fullscreen mode and with that you can touch control mouse movement (virtual cursor) by touching left joystick on the screen.

I want to cloud-retro work on mobile device or some touch screen device ,can only operator with touch screen like we operate on mobile phone without joystick,The touch screen method is more intuitive, allowing tapping, moving, right clicking, and double clicking at the focal position on the touch screen. The virtual mouse method is a bit cumbersome to operate, but by moving the mouse and then combining it with the joystick to confirm and cancel, it simulates the left and right mouse buttons. The entire operation process has a longer rhythm

@guozanhua, could you explain how this touchpad mode works and what do you expect from it? Right now, you can press toggle-button under the options not in the fullscreen mode and with that you can touch control mouse movement (virtual cursor) by touching left joystick on the screen.

I want to cloud-retro work on mobile device or some touch screen device ,can only operator with touch screen like we operate on mobile phone without joystick,The touch screen method is more intuitive, allowing tapping, moving, right clicking, and double clicking at the focal position on the touch screen. The virtual mouse method is a bit cumbersome to operate, but by moving the mouse and then combining it with the joystick to confirm and cancel, it simulates the left and right mouse buttons. The entire operation process has a longer rhythm

reference this video
and in dosbox_pure_mouse_input setting,there is below information
"dosbox_pure_mouse_input",
"Mouse Input Mode", NULL,
"You can disable input handling from a mouse or a touchscreen (emulated mouse through joypad will still work)." "\n"
"In touchpad mode use drag to move, tap to click, two finger tap to right-click and press-and-hold to drag", NULL,
"Input",
{
{ "true", "Virtual mouse (default)" },
{ "direct", "Direct controlled mouse (not supported by all games)" },
{ "pad", "Touchpad mode (see description, best for touch screens)" },
{ "false", "Off (ignore mouse inputs)" },
},
"true"
For your reference

@guozanhua, thanks for the example. I think, on the browser side, touchscreen and mouse should share the same pointer API (which I use for mouse). On the side of nanoarch, it's missing Libretro pointer device API handlers. So, it would need some coding for new pointer controller device in addition to Retropad, keyboard, and mouse. (you can, actually, convert touch events into mouse events on the server for existing API, but that's ugly)
OK, maybe I'll add this thing later.

@guozanhua, thanks for the example. I think, on the browser side, touchscreen and mouse should share the same pointer API (which I use for mouse). On the side of nanoarch, it's missing Libretro pointer device API handlers. So, it would need some coding for new pointer controller device in addition to Retropad, keyboard, and mouse. (you can, actually, convert touch events into mouse events on the server for existing API, but that's ugly) OK, maybe I'll add this thing later.
there is a different between mouse and pointer device, Mouse is for moving position, pointer is for absolute position，reference below code from dosbox_pure_libretro.cpp

@guozanhua, thanks for the example. I think, on the browser side, touchscreen and mouse should share the same pointer API (which I use for mouse). On the side of nanoarch, it's missing Libretro pointer device API handlers. So, it would need some coding for new pointer controller device in addition to Retropad, keyboard, and mouse. (you can, actually, convert touch events into mouse events on the server for existing API, but that's ugly) OK, maybe I'll add this thing later.
there is a different between mouse and pointer device, Mouse is for moving position, pointer is for absolute position，reference below code from dosbox_pure_libretro.cpp

Right. I think, it wouldn't matter in case if I'd use normalized coordinates. Initially, I tried to normalize relative coordinates of the mouse, but it didn't work for some reason, and I ditched it because hadn't much time for debugging. But in general, that might work as one API for absolute and relative coordinates.
In the Discord channel I wrote:

I think, I'll also switch to normalized coordinates [0; 1] (dx / width, dy / height) for deltas in the server API, this way it will be independent from the screen resolutions and more universal if the code will be merged with morph (libretro uses int16 for x,y positions and the current API as well, but Windows API -- 32bit long, so I'll make them normalized in float32, after that everything may be recalculated on the servers. I haven't tested float precision for int-float-int mapping yet, hopefully it is OK and it should be).
(aaaand it didn't work out, lol)