-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow embedding of CORS proxy in fetch relay_url #1189
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
690c46b
Allow embedding of CORS proxy in fetch relay_url
chschnell f66e39c
moved fetch URL decoding from starter.js into main.js
chschnell 32f0cb2
fixed eslint error
chschnell 27fc39d
pass options.net_device to NetworkAdapter constructors
chschnell fdc2f1f
Update src/browser/main.js
copy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this again, I think this code belongs in
browser/main.js
. TheV86
constructor is supposed to be the high-level api, whilebrowser/main.js
implements the more stringly-typed frontend.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgive me if I'm wrong, but isn't main.js the entry point for your web page and V86 embedding? In my own embedding I call the V86 constructor directly without using anything from main.js (to my knowledge), so I wouldn't gain anything from my own PR, or would I? :)
How about this: We currently have this in starter.js:
Note that
relay_url
is passed as the first argument to the constructors ofWispNetworkAdapter
andNetworkAdapter
.Why not do the same with
FetchNetworkAdapter
and do away with itsfetch_options
alltogether (EDIT: remove it only here, keep it as the 3rd, optional constructor argument as inFetchNetworkAdapter(fetch_url, bus, config)
).The rule would then be that it is the NetworkAdapter's responsibility to decode its
relay_url
according to its internal rules, this knowledge doesn't need to leak outside the respective NetworkAdapter classes.And the code from above would simplify to (nice and clean):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your second example looks worse to me than the current version in this PR, because it splits the parsing over multiple files.
You're making a valid point though, which is that the the existing implementation already does parsing to a certain degree.
I'm mostly worried that we end up with:
When, in my opinion, a nicer JavaScript API would look like this:
The V86 constructor should provide an option to specify the cors proxy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean now.
So I moved the fetch URL decoding out into main.js (and also into my own embedding).
I am not entirely sure where to put
cors_proxy
though, I've put it undernet_device
:In starter.js, I decided to pass
options.net_device
as theoptions
argument to theFetchNetworkAdapter
constructor, meaning this constructor expects an object like (all members optional):I am pointing this out because this is not how it is implemented for
WispNetworkAdapter
, the wholeoptions
object and not just its memberoptions.net_device
is passed to its constructor in starter.js.I'd suggest to also pass
options.net_device
instead ofoptions
to theWispNetworkAdapter
constructor.Here's the combined set of all possible members for
options.net_device
that we would have then (for both constructors):