Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

chore: update ipfs #43

Merged
merged 12 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- browser-ipns-publish
- browser-lit
- browser-mfs
- browser-nextjs
#- browser-nextjs
- browser-parceljs
- browser-readablestream
- browser-script-tag
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [Structure](#structure)
- [IPFS Tutorials at ProtoSchool](#ipfs-tutorials-at-protoschool)
- [Documentation](#documentation)
- [ipfs or ipfs-core?](#ipfs-or-ipfs-core)
- [Contributing](#contributing)
- [Guidelines](#guidelines)
- [Steps to follow after adding a new example](#steps-to-follow-after-adding-a-new-example)
Expand Down Expand Up @@ -88,6 +89,16 @@ Explore [ProtoSchool's IPFS tutorials](https://proto.school/#/tutorials?course=i
- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)
- [Tutorials](https://proto.school)

## ipfs or ipfs-core?

The JavaScript implementation of IPFS is available as two packages, `ipfs-core` and `ipfs`.

`ipfs-core` contains the [core api](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) and is intended to be used to run an IPFS node as part of your application without the need to start external processes or manage API ports and servers.

`ipfs` is built on `ipfs-core` but also includes the CLI, an HTTP RPC API server and other tools to run `ipfs` as a background process so is a larger install with more dependencies.

If you are writing an application that needs to access the IPFS network, use `ipfs-core`. If you wish to use js-IPFS in a terminal window or run it as a server for use by multiple otherwise unrelated processes, use `ipfs`.

## Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-add-readable-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1"
"ipfs-core": "^0.11.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-add-readable-stream/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import Ipfs from 'ipfs'
import { create } from 'ipfs-core'

const main = async () => {
let ipfs;
Expand Down Expand Up @@ -123,7 +123,7 @@ const main = async () => {
showStatus(`Creating IPFS node...`, COLORS.active)

const repoPath = `ipfs-${Math.random()}`
ipfs = await Ipfs.create({ repo: repoPath })
ipfs = await create({ repo: repoPath })
}

const id = await ipfs.id();
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@angular/platform-browser-dynamic": "~12.2.0",
"@angular/router": "~12.2.0",
"global": "^4.4.0",
"ipfs": "^0.58.1",
"ipfs-core-types": "^0.7.1",
"ipfs-core": "^0.11.0",
"ipfs-core-types": "^0.8.0",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
Expand Down
11 changes: 5 additions & 6 deletions examples/browser-angular/src/app/ipfs.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Injectable } from '@angular/core';

import * as IPFS from 'ipfs';
import { IPFS, create } from 'ipfs-core';
import * as IPFS_ROOT_TYPES from 'ipfs-core-types/src/root';
import * as IPFS_UTILS_TYPES from 'ipfs-core-types/src/utils';
import { BehaviorSubject, } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class IpfsService {
private _ipfsSource = new BehaviorSubject<null | IPFS.IPFS>(null);
private _createIPFSNodePromise: Promise<IPFS.IPFS>;
private _ipfsSource = new BehaviorSubject<null | IPFS>(null);
private _createIPFSNodePromise: Promise<IPFS>;

private get ipfs() {
const getter = async () => {
Expand All @@ -18,7 +17,7 @@ export class IpfsService {
if (node == null) {
console.log("Waiting node creation...")

node = await this._createIPFSNodePromise as IPFS.IPFS
node = await this._createIPFSNodePromise as IPFS
this._ipfsSource.next(node);
}

Expand All @@ -31,7 +30,7 @@ export class IpfsService {
constructor() {
console.log("Starting new node...")

this._createIPFSNodePromise = IPFS.create()
this._createIPFSNodePromise = create()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "npm run build && playwright test tests"
},
"dependencies": {
"ipfs": "^0.58.1"
"ipfs-core": "^0.11.0"
},
"devDependencies": {
"@playwright/test": "^1.12.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-browserify/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const IPFS = require('ipfs')
const IPFS = require('ipfs-core')

const App = () => {
let ipfs
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"dot-prop": "^6.0.1",
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"ipfs-css": "^1.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ipfs from 'ipfs'
import { create } from 'ipfs-core'
import { useEffect, useState } from 'react'

let ipfs = null
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function useIpfsFactory () {
} else {
try {
console.time('IPFS Started')
ipfs = await Ipfs.create()
ipfs = await create()
console.timeEnd('IPFS Started')
} catch (error) {
console.error('IPFS init error:', error)
Expand Down
6 changes: 4 additions & 2 deletions examples/browser-exchange-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"it-all": "^1.0.4",
"libp2p-websockets": "^0.16.1",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
"ipfs-http-client": "^52.0.1",
"ipfs": "^0.59.0",
"ipfs-core-types": "^0.8.0",
"ipfs-http-client": "^53.0.0",
"libp2p-webrtc-star": "^0.23.0",
"parcel": "latest",
"playwright": "^1.12.3",
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-exchange-files/src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global location */
'use strict'

const IPFS = require('ipfs')
const IPFS = require('ipfs-core')
const WS = require('libp2p-websockets')
const filters = require('libp2p-websockets/src/filters')
const transportKey = WS.prototype[Symbol.toStringTag]
Expand Down Expand Up @@ -41,7 +41,7 @@ let workspace = (location.hash || 'default-workspace').replace(/^#/, '')

let fileSize = 0

/** @type {import('ipfs').IPFS} */
/** @type {import('ipfs-core-types').IPFS} */
let node
let info

Expand Down
2 changes: 1 addition & 1 deletion examples/browser-exchange-files/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const play = test.extend({
ipfsHttpModule: require('ipfs-http-client')
}, {
js: {
ipfsBin: require.resolve('ipfs/src/cli.js')
ipfsBin: require('ipfs').path()
}
},
[
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-ipns-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"browserslist": "last 1 Chrome version",
"dependencies": {
"human-crypto-keys": "^0.1.4",
"ipfs": "^0.58.1",
"ipfs-http-client": "^52.0.1",
"ipfs-core": "^0.11.0",
"ipfs-http-client": "^53.0.0",
"ipfs-utils": "^8.1.4",
"ipns": "^0.13.3",
"it-last": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-ipns-publish/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const IpfsHttpClient = require("ipfs-http-client");
const ipns = require("ipns");
const IPFS = require("ipfs");
const IPFS = require("ipfs-core");
const pRetry = require("p-retry");
const last = require("it-last");
const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed }
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"ipfs-css": "^1.3.0",
"lit": "^2.0.0-rc.2",
"tachyons": "^4.12.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-lit/src/ipfs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

import {html, LitElement} from 'lit';
import IPFS from 'ipfs'
import { create } from 'ipfs-core'

export class IPFSInfo extends LitElement {
static get properties() {
Expand Down Expand Up @@ -29,7 +29,7 @@ export class IPFSInfo extends LitElement {
}

async initIPFS() {
const ipfs = await IPFS.create();
const ipfs = await create();
const id = await ipfs.id();
const version = await ipfs.version();

Expand Down
2 changes: 1 addition & 1 deletion examples/browser-mfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"mime-sniffer": "~0.0.3"
},
"devDependencies": {
Expand Down
6 changes: 2 additions & 4 deletions examples/browser-mfs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import {
hideForms
} from './forms'
import mime from 'mime-sniffer'

/** @type {import('ipfs-core-types/src/index').IPFS} IPFS */
import IPFS from 'ipfs'
import { create } from 'ipfs-core'

document.addEventListener('DOMContentLoaded', async () => {
const ipfs = await IPFS.create({
const ipfs = await create({
repo: `ipfs-${Math.random()}`
})

Expand Down
4 changes: 2 additions & 2 deletions examples/browser-nextjs/components/ipfs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'
import Ipfs from 'ipfs'
import { create } from 'ipfs-core'

const IpfsComponent = () => {
const [id, setId] = useState(null);
Expand All @@ -11,7 +11,7 @@ const IpfsComponent = () => {
const init = async () => {
if (ipfs) return

const node = await Ipfs.create();
const node = await create();

const nodeId = await node.id();
const nodeVersion = await node.version();
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "npm run build && playwright test tests"
},
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"next": "11.0.0",
"react": "17.0.2",
"react-dom": "17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-parceljs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1"
"ipfs-core": "^0.11.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-parceljs/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import IPFS from 'ipfs'
import { create } from 'ipfs-core'

const App = () => {
let ipfs
Expand Down Expand Up @@ -62,7 +62,7 @@ const App = () => {
if (!ipfs) {
showStatus('Creating IPFS node...', COLORS.active)

ipfs = await IPFS.create({
ipfs = await create({
repo: String(Math.random() + Date.now()),
init: { alogorithm: 'ed25519' }
})
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-readablestream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"browserslist": "last 1 Chrome version",
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-core": "^0.11.0",
"it-to-stream": "^1.0.0",
"videostream": "^3.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/browser-readablestream/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Ipfs from 'ipfs'
import { create } from 'ipfs-core'
import VideoStream from 'videostream'
import toStream from 'it-to-stream'
import {
Expand All @@ -18,7 +18,7 @@ const App = async () => {

log('IPFS: Initializing')
const videoElement = createVideoElement()
const ipfs = await Ipfs.create({ repo: 'ipfs-' + Math.random() })
const ipfs = await create({ repo: 'ipfs-' + Math.random() })

// Allow adding files to IPFS via drag and drop
dragDrop(ipfs, log)
Expand Down
8 changes: 4 additions & 4 deletions examples/browser-service-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"last 1 Chrome version"
],
"dependencies": {
"ipfs": "^0.58.1",
"ipfs-message-port-client": "^0.8.3",
"ipfs-message-port-protocol": "^0.9.0",
"ipfs-message-port-server": "^0.9.0",
"ipfs-core": "^0.11.0",
"ipfs-message-port-client": "^0.9.0",
"ipfs-message-port-protocol": "^0.10.0",
"ipfs-message-port-server": "^0.10.0",
"process": "0.11.10"
},
"devDependencies": {
Expand Down
Loading