Comments (8)
Quick update: I've confirmed that webbundle crate produces a broken bundle if it contains a primary-url. I'm afraid this bug has been there since we supported b2 version format, where a primary-url became optional.
Let me fix that.
from webbundle.
Sorry for the late reply; the newest version works, thanks!
from webbundle.
Thanks for filing an issue. Ack.
Let me take a look closely this week and try to provide working examples.
(Or fix a bug and release a new version).
from webbundle.
I guess you are trying "Navigate-to-Bundle" feature (e.g. Drag and drop a created wbn to a browser's window), which is explained in https://web.dev/web-bundles/.
This feature, "Navigate-to-Bundle", requires an absolute URL for each resource in Web Bundle.
Unfortunately, it seems I dropped "absolute URL" support from webbundle::Builder::exchange_from_dir()
in version 0.32 or later. Now that only supports a "relative URL".
- https://docs.rs/webbundle/0.3.2/webbundle/struct.Builder.html
- exchanges_from_dir() can take only
dir
.
- exchanges_from_dir() can take only
- https://docs.rs/webbundle/0.2.0/webbundle/index.html
- exchanges_from_dir() can take
base_url
+dir
.
- exchanges_from_dir() can take
That's a reason Chrome complains because "Navigate-to-Support" requires an absolute URL.
As a workaround, to create a web bundle where each resource has an absolute URL:
-
webbundle crate: Use webbundle::Builder::exchange()
This is a most flexible, low-level API. You can pass any string as URL. -
CLI: Since you already use
gen-bundle
tools (Written in Go), I think you can pass a base-URL option, as follows:gen-bundle -dir static -baseURL https://example.com/ -o foo.wbn -primaryURL https://example.com/
(https://github.com/WICG/webpackage/blob/main/go/bundle/README.md)
from webbundle.
Hi @hayatoito, thanks for your reply. I'm only really interested in creating the .wbn
file from the webbundle
crate using the remove urls and the exchange()
I have tried using exchange()
, but I still get the error I describe above in the second section.
Here's the snippet I'm using:
let primary_url = "https://www.google.com/".parse::<Uri>().unwrap();
let ex_req = Request::from("https://www.google.com/".to_string());
let ex_res = reqwest::get("https://www.google.com/").await?.bytes().await?.to_vec();
let write = BufWriter::new(File::create("./google.wbn")?);
Bundle::builder()
.version(Version::VersionB2)
.primary_url(primary_url)
.exchange((ex_req, ex_res, ContentType::html()).into())
.build()?
.write_to(write)?;
Maybe I'm passing something wrong to the exchange
function?
from webbundle.
Thanks for trying it. My expectation is "That should work". But I'm afraid something is wrong.
Let me add some examples to webbundle/webbundle/examples directory and confirm the created bundle is surely loaded in Chrome. That's my TODO. Noted!
from webbundle.
Fixed the issue: 631f6a8
webbundle v0.5.0 shouldn't have an issue, I think.
I've confirmed that a bundle generated by https://github.com/google/webbundle/blob/main/webbundle/examples/create-webbundle.rs is successully loaded in Chrome (by drag & drop).
I appreciate if you can confirm it. Thanks!
from webbundle.
Thanks!
from webbundle.
Related Issues (3)
- Simple suggestion on `list` HOT 5
- Is the repo end-of-life? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webbundle.