- 
                Notifications
    
You must be signed in to change notification settings  - Fork 361
 
playground.wordpress.net: Support mounting local files #548
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
Conversation
e4b1bd7    to
    58b4b4b      
    Compare
  
    When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin.
When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin.
When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin.
When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin.
When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin. Co-authored-by: Adam Zieliński <[email protected]>
When mounting local directories in #548, problems appeared in development builds because the dev environemnt runs a separate server for the website that wraps the iframe and the for the assets inside the iframe, the "remote." In this patch we're adjusting the config for the outer website server so that we can proxy requests for the internal frame through the same origin. This is done by adding a prefix to the URL for the dev assets on the outer frame, which then is used in a proxy rule to decide what to route. This means that OPFS handles can be shared between the two sides of the iframe, which normally happens in production since they both come from the same origin. Co-authored-by: Adam Zieliński <[email protected]>
2ae3869    to
    c97c9d6      
    Compare
  
    
          
 This is somewhat unfair, and even though the  Why? Because we're asking "do you want?" and the only possible choice we give someone is "Yes."  | 
    
b871c70    to
    18b2f35      
    Compare
  
    18b2f35    to
    d48991f      
    Compare
  
    | 
           I've also learned the MEMFS->OPFS sync is so slow because Chrome writes everything to a temp file, scans it, and only then creates the actual file. There is chromium work underway to make it faster in the future.  | 
    


Since #547 adds support for OPFS API, I just realized the same API can be used to read/write local files. This PR adds a local directory picker and a "refresh" button to bring the changes back into Playground's MEMFS.
Testing instructions
Other considerations
wp-nowcould be really handy here. It would have to be refactored to use shared, isomorphic feature that works throughphpmethods likephp.readFileAsBuffer()which means they'll need some enhancements like support for reading the first 8kb.refresh filesbutton as everything would be stored and read directly from OPFS. Persistent Playground: Explore OPFS support #544 started exploring that but it uses the deprecated sync API. We'd need to find a way to use the new async one.