Releases: ipfs/js-ipfs
[email protected]
2.0.0 (2020-03-31)
Bug Fixes
Code Refactoring
Features
- Allows for byte offsets when using ipfs.files.cat and friends to request slices of files (a93971a)
BREAKING CHANGES
ipfs.util.isIPFS
andipfs.util.crypto
have moved to static exports and should be accessed viaconst { isIPFS, crypto } = require('ipfs')
.
The modules available under ipfs.types.*
have also become static exports.
License: MIT
Signed-off-by: Alan Shaw [email protected]
[email protected]
1.0.1 (2020-03-31)
Note: Version bump only for package example-browser-parceljs
[email protected]
[email protected]
0.1.1 (2020-03-31)
Note: Version bump only for package example-browser-create-react-app
[email protected]
[email protected]
2.0.0 (2020-03-31)
Bug Fixes
Code Refactoring
BREAKING CHANGES
ipfs.util.isIPFS
andipfs.util.crypto
have moved to static exports and should be accessed viaconst { isIPFS, crypto } = require('ipfs')
.
The modules available under ipfs.types.*
have also become static exports.
License: MIT
Signed-off-by: Alan Shaw [email protected]
v0.41.2
chore: release version v0.41.2
v0.41.1
v0.41.0
π¦ Highlights
One giant leap forward
π¦ Async Await and Async Iterables
πΆ In the jungle, the mighty jungle the lion sleeps tonight!
πΆ async await, async await, async await, async await...
We've completed a HUGE refactor to js-ipfs internals π₯³, switching to using Promises and async
/await
over Callbacks and using async iterables instead of Node.js Streams and Pull Streams. Ok, I tell a lie, it's actually not just js-ipfs internals, it's the whole stack, including libp2p, IPLD and multiformats, you might call it a ground up re-write, but, you know, we don't like to brag.
π¨ Oh, wait, serious note - this release brings big breaking changes to the core API so please consult the "API Changes" section below for all the information.
It's been a long and emotional voyage but this refactor brings a plethora of incredible immediate and future benefits to consumers, contributors and core developers that make all the work and effort worthwhile. To summarise, we've:
- Switched to streaming APIs by default to reduce memory pressure
- Reduced API surface area by removing buffering, Node.js and Pull Stream APIs
- Reduced the amount of code in the code base and number of dependencies we depend on (for smaller browser bundles and faster install times)
- Switched to using async iterables to stream data to help make streaming more approachable
- Switched to using
async
/await
so weβll get better error stack traces and improved readability and maintainability
Using async
/await
in JavaScript is gaining a lot of traction in the ecosystem and is rapidly becoming the de facto way of writing idiomatic JS. We want js-ipfs to move with the times and continue to be attractive to contributors by using modern JS features, techniques and practices. The big idea with these changes is for the code to be easier to contribute to, easier to understand, easier to maintain, and be faster and smaller than ever.
This change is so big, and so significant, we wrote a whole blog post about it to explain the motivations behind the changes...in excruciating delightful depth π€£!
We've also compiled some stats on this refactor for your viewing pleasure:
- 27 direct dependencies were removed from our
package.json
- 214 fewer modules end up in our browser bundle
- 155 kB lighter browser bundle (unpkg.com/[email protected] vs unpkg.com/[email protected]) - that's 18% smaller!
- 124 kB lighter
ipfs-http-client
browser bundle (unpkg.com/[email protected] vs unpkg.com/[email protected]) - that's 60% smaller! - ~2,600 lines of code removed (net)
- ~360 lines of code removed from
ipfs-http-client
(net) - ~10 minutes shorter CI run times
...and a lot of those stats are just for js-ipfs and js-ipfs-http-client - the tip of the iceberg! We saw changes similar to this for between 60-70 dependencies across IPFS, libp2p, IPLD and multiformats.
π UnixFS v1.5
Turns out, it's really important for package managers to retain file metadata, particularly last modified time (mtime
). File mtime
allows them to selectively sync only data that has changed. Up until now if you wanted to host a large data set on IPFS, like a package manager's repository, it would be difficult to update.
"What about the permanent web?" I hear you cry. Well, this absolutely doesn't prevent a particular snapshot of a package manager's repository from being permanently available. Metadata just enables diffs to be imported, instead of the whole thing. So, when I say "difficult to update", like I did up there, I mean slow and/or impossible. When you have Terabytes (or more) of package data and someone publishes a new package, it's kinda inconvenient to import everything again, when only a little part changed. File mtime
is a really good indicator of which things have changed, so you can use it in IPFS now! π₯³
For example, there's two new options to jsipfs add
that allow mode
and mtime
to be preserved as the file is added to IPFS:
$ jsipfs add -r --preserve-mtime --preserve-mode ~/Desktop/gif
added QmT6WX9McZyx5ZoisRgpsjYKDBWnYpMnBLpfAgjW5kavBA gif/yesthisisdog.jpg
added QmXMrFfZ9zHLZKN7xP2dX76YFFhvBJsQkd4fLnTDkyR31Q gif
Ok, no big changes there aside from the new options, buuut, now when you list directory contents you get Mode
and Mtime
info:
$ jsipfs ls QmXMrFfZ9zHLZKN7xP2dX76YFFhvBJsQkd4fLnTDkyR31Q -v
Mode Mtime Hash Size Name
-rw-r--r-- Apr 16, 2018, 12:20:33 PM GMT+1 QmT6WX9McZyx5ZoisRgpsjYKDBWnYpMnBLpfAgjW5kavBA 87779 yesthisisdog.jpg
Rad right!?
Persisting the file mode
is also super rad, because it opens up NFS type use cases that weren't possible before. Imagine your node_modules
directory is backed by IPFS and mounted on your file system - the file mode
will allow everything in node_modules/.bin
to be executable as you'd expect.
The coolest thing about all of this is that it's completely backwards compatible. The CID for a given file/directory only changes if you opt in to metadata, otherwise the CIDs remain the same. Hooray!
There's a bunch of changes that add metadata capability to the CLI, HTTP and core API both for inputs and outputs. There's also a couple of new MFS commands touch
and chmod
which allow you to change the metadata whenever you like! Magic π§ββοΈ.
See the API Changes sections below for details of all the new UnixFS v1.5 stuffs.
π API Changes
Core API
There are significant and breaking core API changes in this release. Please see the migration guide.
- IPFS is not a class that can be instantiated - use
IPFS.create
. An IPFS node instance is not an event emitter. - The
init
option passed toIPFS.create
will now not take any initialization steps if it is set tofalse
. Previously, the repo would be initialized if it already existed. This is no longer the case. If you wish to initialize a node but only if the repo exists, passinit: { allowNew: false }
to the constructor. - Instance
.ready
property has been removed. Please useIPFS.create
instead. IPFS.createNode
has been removed, please useIPFS.create
instead.- Callbacks are no longer supported on any API methods. Please use a utility such as
callbackify
on API methods that return Promises to emulate previous behaviour. See the migration guide for more info. - Delegated peer and content routing modules are no longer included as part of core (but are still available if starting a js-ipfs daemon from the command line). If you wish to use delegated routing and are creating your node programmatically in Node.js or the browser you must
npm install libp2p-delegated-content-routing
and/ornpm install libp2p-delegated-peer-routing
and provide configured instances of them inoptions.libp2p
. See the module repos for further instructions: add
now returns an async iterable.add
now acceptsmode
andmtime
options on inputs to allow setting mode and mtime metadata for added files. See the core interface docs for more info.add
results now contain acid
property (a CID instance) instead of a stringhash
property.- π
add
results now includemode
andmtime
properties if they were set. addReadableStream
,addPullStream
have been removed. Please see the migration guide for more info.addFromStream
has been removed. Useadd
instead.addFromFs
has been removed. Please use the exportedglobSource
utility and pass the result toadd
. See the glob source documentation for more details and an example.addFromURL
has been removed. Please use the exportedurlSource
utility and pass the result toadd
. See the URL source documentation for more details and an example.bitswap.stat
result has changed -wantlist
and values are now an array of CID instances andpeers
is now astring[]
of peer IDs.bitswap.wantlist
now returns an array of CID instances.block.rm
now returns an async iterable.block.rm
now yields objects of{ cid: CID, error: Error }
.block.stat
result now contains acid
property (whose value is a CID instance) instead of akey
property.dht.findProvs
,dht.provide
,dht.put
anddht.query
now all return an async iterable.dht.findPeer
,dht.findProvs
,dht.provide
,dht.put
anddht.query
now yield/return an object{ id: string, addrs: Multiaddr[] }
ins...
v0.41.0-rc.2
chore: release version v0.41.0-rc.2