-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Implement createObjectURL/Blob from File API #16167
Comments
@bcoe Here ^ |
For reference: https://w3c.github.io/FileAPI/ |
@bmeck @TimothyGu I'd be interested in pitching in on this work, along with being one of the early consumers with Istanbul ... designing the Blob and BlobeStore bit sounds interesting. Do you picture we'd be exposing existing structures in V8? |
@bcoe great! Unfortunately v8 does not expose Blobs in the File API terms, their blobs in The important bit to the BlobStore is that it works across workers. If a worker makes a url using If you need any help I can assist when I have a bit more free time or if you schedule something in advance I will make time. |
For reference - What is BlobStore? |
@refack it is the place that It is used such that it can share URLs across workers so you can do multi-threaded processing: https://jsfiddle.net/ctyvm1tr/1/ |
@bmeck I intend to make some time this weekend to read through the spec and play with the existing APIs in the browser. Once I know more than basically nothing, I would definitely be interested in arranging a quick screen share. Is there any prior art in the codebase that shares state across workers that we could build on? |
@bcoe nothing in this realm that is sane to read that I know of. I know game engines use it, but that isn't helpful since I don't know their internals. |
I'm not really certain what the point of this is given we have an existing file system api and various types of buffers. Could this please be elaborated on before implementation? Thanks. |
So I've been working on this but I've been behind due to other pressing matters. It's very much something that I would like to see. To be specific: I already have an implementation underway, I just haven't had the time to finish it. My goal is to have an initial implementation by mid to late November. In terms of the what the implementation would provide:
While this all may seem complicated, the interfaces here are rather simple. A For There is certainly a cost, and there are aspects of the implementation that are non-trivial, but the benefits are quite real. FWIW, I'm not entirely sold on the idea of implementing the |
@jasnell my personal interest in this API surface is a follow on from: The goal being to facilitate test-coverage and other transpilation steps in I'm picturing that one could instrument code for coverage using pseudo code that looks something like this: export async function resolve(specifier, parentModuleURL, defaultResolver) {
const resolved = new url.URL(specifier, parentModuleURL)
const ext = path.extname(resolved.pathname)
if (ext === 'mjs') {
const source = fs.readFileSync(resolved.pathname)
const instrumented = istanbul.instrument(source)
const blob = new Blob([instrumentedSource], {type : 'application/mjs'})
return {
url: createObjectURL(blob),
format: 'esm'
}
} else {
return defaultResolver(specifier, parentModuleURL)
}
} Does it seem like I'm on the same page as to how this API could potentially be used? ...an aside: I keep coming back to the argument that @guybedford's work on #15445 should be exposed through an API hook rather than just a flag. In the world of developer tools, it's often the case that a few transformations need to be performed in sequence, e.g.,
I don't hate the idea of using In the land of |
with the new worker api i'd like to get this all working primarily to support @bmeck that should be enough reasoning to land mimes yea? |
This work would be great to see. @bcoe it's best not to try and see this as the final picture on the matter I think, but rather allow it to inform the discussions. The use case you describe is one very much understood by the modules group, that will be polished in due course. Would also be interested to hear your thoughts on #18914 as it is a goal of mine to get that going again, just not sure how much to prioritise it right now. |
Don't really need the FileReader now when there exist new reading methods on blob's
|
So folks know, I've already started work on the async blobs piece. And that is a prereq for the filesystem blobs. Expect a pr soonish. |
|
...And blob#streams and some other minor stuff! Cool! what's next? The File class? I suppose a async blob source is supported now (from #39693) ...or? I'm not entirely sure how the underlying data structor looks like anymore (how it's handled in the backend)... if it still behaves like a large ArrayBuffer bucket like before, or like a blobParts array that holds all chunks with a offset+size. What happens under the hood if you slice a large blob? dose it takes up more memory or is it just a references point now? what would eg happen if i did: const blob = new Blob([new Uint8Array(2gb)])
const concat = new Blob([blob, blob]) // 4gb
concat.slice(0, 2gb) |
Reading blobs text larger than 500 MiB is a problem. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
This was done |
Tracking Issue to allow Loaders to create in-memory URLs that can be imported for things like code coverage:
--loader
to use MIMEsThe text was updated successfully, but these errors were encountered: