diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6884d04e..78e62be3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,19 +15,18 @@ jobs:
project:
- browser-add-readable-stream
- browser-angular
- - browser-browserify
- browser-create-react-app
- browser-exchange-files
- browser-ipns-publish
- browser-lit
- browser-mfs
- browser-nextjs
- - browser-parceljs
- browser-readablestream
- browser-script-tag
- browser-service-worker
- browser-sharing-node-across-tabs
- browser-video-streaming
+ - browser-vite
- browser-vue
- browser-webpack
- circuit-relaying
@@ -39,7 +38,7 @@ jobs:
- http-client-name-api
- http-client-upload-file
- ipfs-101
- - ipfs-client-add-files
+ #- ipfs-client-add-files
- run-in-electron
- running-multiple-nodes
- traverse-ipld-graphs
diff --git a/examples/browser-add-readable-stream/package.json b/examples/browser-add-readable-stream/package.json
index c233b01e..94696b8f 100644
--- a/examples/browser-add-readable-stream/package.json
+++ b/examples/browser-add-readable-stream/package.json
@@ -2,28 +2,29 @@
"name": "example-browser-add-readable-stream",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "How to add readable streams in the browser",
"keywords": [],
"license": "MIT",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-add-readable-stream/src/index.js b/examples/browser-add-readable-stream/src/index.js
index 46ff72bd..385e53b2 100644
--- a/examples/browser-add-readable-stream/src/index.js
+++ b/examples/browser-add-readable-stream/src/index.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { create } from 'ipfs-core'
const main = async () => {
diff --git a/examples/browser-add-readable-stream/tests/test.js b/examples/browser-add-readable-stream/tests/test.js
index f809ab91..5ff686f0 100644
--- a/examples/browser-add-readable-stream/tests/test.js
+++ b/examples/browser-add-readable-stream/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-add-readable-stream/vite.config.js b/examples/browser-add-readable-stream/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-add-readable-stream/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-angular/angular.json b/examples/browser-angular/angular.json
index 07eb1783..3663c399 100644
--- a/examples/browser-angular/angular.json
+++ b/examples/browser-angular/angular.json
@@ -18,7 +18,7 @@
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
- "path": "./extra-webpack.config.ts"
+ "path": "./extra-webpack.config.js"
},
"outputPath": "dist/",
"index": "src/index.html",
diff --git a/examples/browser-angular/extra-webpack.config.ts b/examples/browser-angular/extra-webpack.config.js
similarity index 72%
rename from examples/browser-angular/extra-webpack.config.ts
rename to examples/browser-angular/extra-webpack.config.js
index 2eccede9..6c05be48 100644
--- a/examples/browser-angular/extra-webpack.config.ts
+++ b/examples/browser-angular/extra-webpack.config.js
@@ -1,5 +1,5 @@
-import { Configuration, ProvidePlugin } from 'webpack';
-import * as NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
+import webpack from 'webpack';
+import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
export default {
plugins: [
@@ -9,8 +9,8 @@ export default {
// dependencies causing runtime errors. This is a workaround to provide
// global `Buffer` until https://github.com/isaacs/core-util-is/issues/29
// is fixed.
- new ProvidePlugin({
+ new webpack.ProvidePlugin({
global: ['global']
})
]
-} as Configuration;
+};
diff --git a/examples/browser-angular/package.json b/examples/browser-angular/package.json
index de6639bd..13cbd347 100644
--- a/examples/browser-angular/package.json
+++ b/examples/browser-angular/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-angular",
"version": "0.0.0",
"private": true,
+ "type": "module",
"scripts": {
"clean": "rimraf ./dist",
"ng": "ng",
@@ -20,9 +21,10 @@
"@angular/platform-browser": "^13.2.0",
"@angular/platform-browser-dynamic": "^13.2.0",
"@angular/router": "^13.2.0",
+ "@libp2p/interface-peer-id": "^1.0.2",
"global": "^4.4.0",
- "ipfs-core": "^0.14.0",
- "ipfs-core-types": "^0.10.0",
+ "ipfs-core": "^0.15.2",
+ "ipfs-core-types": "^0.11.0",
"rxjs": "^7.5.2",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
diff --git a/examples/browser-angular/src/app/app.component.ts b/examples/browser-angular/src/app/app.component.ts
index ee328bf7..00982469 100644
--- a/examples/browser-angular/src/app/app.component.ts
+++ b/examples/browser-angular/src/app/app.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { IpfsService } from './ipfs.service';
+import { PeerId } from '@libp2p/interface-peer-id';
@Component({
selector: 'app-root',
@@ -8,7 +9,7 @@ import { IpfsService } from './ipfs.service';
})
export class AppComponent implements OnInit {
title = 'browser-angular';
- id: string | null = null;
+ id: PeerId | null = null;
version: string | null = null;
status: string | null = null;
diff --git a/examples/browser-angular/tests/test.js b/examples/browser-angular/tests/test.js
index 74dd85cb..6d128974 100644
--- a/examples/browser-angular/tests/test.js
+++ b/examples/browser-angular/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-browserify/.github/workflows/sync.yml b/examples/browser-browserify/.github/workflows/sync.yml
deleted file mode 100644
index 3eb39a90..00000000
--- a/examples/browser-browserify/.github/workflows/sync.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: Sync
-on:
- workflow_dispatch:
- schedule:
- - cron: "0 0 * * *"
-
-jobs:
- sync:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Pull from another repository
- uses: ipfs-examples/actions-pull-directory-from-repo@main
- with:
- source-repo: "ipfs-examples/js-ipfs-examples"
- source-folder-path: "examples/browser-browserify"
- source-branch: "master"
- target-branch: "main"
- git-username: github-actions
- git-email: github-actions@github.com
diff --git a/examples/browser-browserify/README.md b/examples/browser-browserify/README.md
deleted file mode 100644
index 2b8830aa..00000000
--- a/examples/browser-browserify/README.md
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-js-ipfs with browserify
-
-
- Bundle js-ipfs with Browserify!
-
-
-
-
- Explore the docs
- ·
- View Demo
- ·
- Report Bug
- ·
- Request Feature/Example
-
-
-## Table of Contents
-
-- [Table of Contents](#table-of-contents)
-- [About The Project](#about-the-project)
-- [Getting Started](#getting-started)
- - [Prerequisites](#prerequisites)
- - [Installation and Running example](#installation-and-running-example)
-- [Usage](#usage)
-- [References](#references)
-- [Documentation](#documentation)
-- [Contributing](#contributing)
-- [Want to hack on IPFS?](#want-to-hack-on-ipfs)
-
-## About The Project
-
-- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs)
-- Look into other [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser
-- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node
-- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it
-- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs
-- Check out https://docs.ipfs.io for tips, how-tos and more
-- See https://blog.ipfs.io for news and more
-- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
-
-## Getting Started
-
-### Prerequisites
-
-Make sure you have installed all of the following prerequisites on your development machine:
-
-- Git - [Download & Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.
-- Node.js - [Download & Install Node.js](https://nodejs.org/en/download/) and the npm package manager.
-
-### Installation and Running example
-
-```console
-> npm install
-> npm start
-```
-
-Now open your browser at `http://localhost:8888`
-
-## Usage
-
-In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs with [browserify](http://browserify.org/), so that you can use it in your own web app!
-
-You should see the following:
-
-
-
-
-This example demonstrates the `Regular API`, top-level API for add, cat, get and ls Files on IPFS
-
-_For more examples, please refer to the [Documentation](#documentation)_
-
-## References
-
-- Documentation:
- - [IPFS CONFIG](https://github.com/ipfs/js-ipfs/blob/master/docs/CONFIG.md)
- - [MISCELLANEOUS](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/MISCELLANEOUS.md)
- - [FILES](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md)
-- Tutorials:
- - [MFS API](https://proto.school/mutable-file-system)
- - [Regular File API](https://proto.school/regular-files-api)
-
-## Documentation
-
-- [Config](https://docs.ipfs.io/)
-- [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api)
-- [Examples](https://github.com/ipfs-examples/js-ipfs-examples)
-- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)
-- [Tutorials](https://proto.school)
-
-## 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**.
-
-1. Fork the IPFS Project
-2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
-3. Commit your Changes (`git commit -a -m 'feat: add some amazing feature'`)
-4. Push to the Branch (`git push origin feature/amazing-feature`)
-5. Open a Pull Request
-
-## Want to hack on IPFS?
-
-[](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
-
-The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:
-
-Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md).
-
-- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
-- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now
-- **Perform code reviews** More eyes will help
- a. speed the project along
- b. ensure quality, and
- c. reduce possible future bugs.
-- **Add tests**. There can never be enough tests.
-- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next
diff --git a/examples/browser-browserify/img/1.png b/examples/browser-browserify/img/1.png
deleted file mode 100644
index 524b0fc8..00000000
Binary files a/examples/browser-browserify/img/1.png and /dev/null differ
diff --git a/examples/browser-browserify/img/2.png b/examples/browser-browserify/img/2.png
deleted file mode 100644
index 003bf17a..00000000
Binary files a/examples/browser-browserify/img/2.png and /dev/null differ
diff --git a/examples/browser-browserify/package.json b/examples/browser-browserify/package.json
deleted file mode 100644
index 88570621..00000000
--- a/examples/browser-browserify/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "name": "example-browser-browserify",
- "version": "1.0.0",
- "private": true,
- "description": "Bundle js-ipfs with Browserify",
- "keywords": [],
- "license": "MIT",
- "scripts": {
- "clean": "rimraf ./dist",
- "build": "copyfiles -u 1 -a './public/**/*' './dist' && browserify ./src/index.js > ./dist/bundle.js",
- "serve": "http-server dist -a 127.0.0.1 -p 8888",
- "start": "npm run build && npm run serve",
- "test": "npm run build && playwright test tests"
- },
- "dependencies": {
- "ipfs-core": "^0.14.0"
- },
- "devDependencies": {
- "@playwright/test": "^1.12.3",
- "browserify": "^17.0.0",
- "concat-stream": "^2.0.0",
- "copyfiles": "^2.4.1",
- "execa": "^6.0.0",
- "http-server": "^14.0.0",
- "playwright": "^1.12.3",
- "rimraf": "^3.0.2",
- "test-util-ipfs-example": "^1.0.2"
- }
-}
diff --git a/examples/browser-browserify/public/index.html b/examples/browser-browserify/public/index.html
deleted file mode 100644
index 7c0e5217..00000000
--- a/examples/browser-browserify/public/index.html
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
-
-
-
- Bundle js-ipfs with browserify
-
-
-
-
-
-
-
-
-
-
-
-
-
- Add data to IPFS from the browser
-
-
-
- Output
-
-
-
-
-
diff --git a/examples/browser-browserify/src/index.js b/examples/browser-browserify/src/index.js
deleted file mode 100644
index 09aac046..00000000
--- a/examples/browser-browserify/src/index.js
+++ /dev/null
@@ -1,116 +0,0 @@
-'use strict'
-
-const IPFS = require('ipfs-core')
-
-const App = () => {
- let ipfs
-
- const DOM = {
- output: () => document.getElementById('output'),
- fileName: () => document.getElementById('file-name'),
- fileContent: () => document.getElementById('file-content'),
- addBtn: () => document.getElementById('add-submit'),
- terminal: () => document.getElementById('terminal')
- }
-
- const COLORS = {
- active: '#357edd',
- success: '#0cb892',
- error: '#ea5037'
- }
-
- const scrollToBottom = () => {
- const terminal = DOM.terminal()
- terminal.scroll({ top: terminal.scrollHeight, behavior: 'smooth' })
- }
-
- const showStatus = (text, bg, id = null) => {
- let log = DOM.output()
-
- if (!log) {
- const output = document.createElement('div')
- output.id = 'output'
- DOM.terminal().appendChild(output)
-
- log = DOM.output()
- }
-
- const line = document.createElement('p')
- line.innerText = text
- line.style.color = bg
-
- if (id) {
- line.id = id
- }
-
- log.appendChild(line)
-
- scrollToBottom(log)
- }
-
- const cat = async (cid) => {
- const content = []
-
- for await (const chunk of ipfs.cat(cid)) {
- content.push(chunk)
- }
-
- return content
- }
-
- const store = async (name, content) => {
- if (!ipfs) {
- showStatus('Creating IPFS node...', COLORS.active)
-
- ipfs = await IPFS.create({
- repo: String(Math.random() + Date.now()),
- init: { alogorithm: 'ed25519' }
- })
- }
-
- const id = await ipfs.id()
- showStatus(`Connecting to ${id.id}...`, COLORS.active, id.id)
-
- const fileToAdd = {
- path: `${name}`,
- content: content
- }
-
- showStatus(`Adding file ${fileToAdd.path}...`, COLORS.active)
- const file = await ipfs.add(fileToAdd)
-
- showStatus(`Added to ${file.cid}`, COLORS.success, file.cid)
-
- showStatus('Reading file...', COLORS.active)
-
- const text = await cat(file.cid)
-
- showStatus(`\u2514\u2500 ${file.path} ${text.toString()}`)
- showStatus(`Preview: https://ipfs.io/ipfs/${file.cid}`, COLORS.success)
- }
-
- // Event listeners
- DOM.addBtn().onclick = async (e) => {
- e.preventDefault()
- let name = DOM.fileName().value
- let content = DOM.fileContent().value
-
- try {
- if (name == null || name.trim() === '') {
- showStatus('Set default name', COLORS.active)
- name = 'test.txt'
- }
-
- if ((content == null || content.trim() === '')) {
- showStatus('Set default content', COLORS.active)
- content = 'Hello world!'
- }
-
- await store(name, content)
- } catch (err) {
- showStatus(err.message, COLORS.error)
- }
- }
-}
-
-App()
diff --git a/examples/browser-browserify/tests/test.js b/examples/browser-browserify/tests/test.js
deleted file mode 100644
index e3339e90..00000000
--- a/examples/browser-browserify/tests/test.js
+++ /dev/null
@@ -1,39 +0,0 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
-
-// Setup
-const play = test.extend({
- ...playwright.servers(),
-});
-
-play.describe('bundle ipfs with browserify:', () => {
- // DOM
- const nameInput = "#file-name"
- const contentInput = "#file-content"
- const submitBtn = "#add-submit"
- const output = "#output"
-
- play.beforeEach(async ({servers, page}) => {
- await page.goto(`http://localhost:${servers[0].port}/`);
- })
-
- play('should properly initialized a IPFS node and add/get a file', async ({ page }) => {
- const fileName = 'test.txt'
- const stringToUse = 'Hello world!'
-
- await page.fill(nameInput, fileName)
- await page.fill(contentInput, stringToUse)
- await page.click(submitBtn)
-
- await page.waitForSelector(`${output}:has-text("/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY")`)
-
- const outputContent = await page.textContent(output)
-
- expect(outputContent).toContain("QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
- expect(outputContent).toContain("https://ipfs.io/ipfs/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
- expect(outputContent).toContain(fileName);
- expect(outputContent).toContain(stringToUse);
- });
-});
diff --git a/examples/browser-create-react-app/.env b/examples/browser-create-react-app/.env
index 26a83ff0..b23f0db2 100644
--- a/examples/browser-create-react-app/.env
+++ b/examples/browser-create-react-app/.env
@@ -1,3 +1,6 @@
# required because react-scripts scans *up* the tree from this project and finds
# a conflicting version of eslint in the node_modules dir for js-ipfs.
SKIP_PREFLIGHT_CHECK=true
+
+# Turning these on can cause OOM errors
+GENERATE_SOURCEMAP=false
diff --git a/examples/browser-create-react-app/package.json b/examples/browser-create-react-app/package.json
index ead9ffd2..baa1cc9d 100644
--- a/examples/browser-create-react-app/package.json
+++ b/examples/browser-create-react-app/package.json
@@ -37,11 +37,11 @@
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"dot-prop": "^7.1.1",
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"ipfs-css": "^1.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
- "react-scripts": "5.0.0",
+ "react-scripts": "5.0.1",
"tachyons": "^4.12.0",
"web-vitals": "^2.1.2"
},
diff --git a/examples/browser-create-react-app/src/App.js b/examples/browser-create-react-app/src/App.js
index 8bd9df61..34f7909f 100644
--- a/examples/browser-create-react-app/src/App.js
+++ b/examples/browser-create-react-app/src/App.js
@@ -77,7 +77,7 @@ const IpfsId = ({keys, obj}) => {
{keys?.map((key) => (
{key}
-
{obj[key]}
+
{obj[key].toString()}
))}
>
diff --git a/examples/browser-create-react-app/src/index.js b/examples/browser-create-react-app/src/index.js
index 988d87b6..0b00296c 100644
--- a/examples/browser-create-react-app/src/index.js
+++ b/examples/browser-create-react-app/src/index.js
@@ -5,8 +5,8 @@ import 'tachyons'
import "ipfs-css";
import './index.css'
-import App from './App';
-import reportWebVitals from './reportWebVitals';
+import App from './App.js';
+import reportWebVitals from './reportWebVitals.js';
ReactDOM.render(
diff --git a/examples/browser-create-react-app/tests/test.js b/examples/browser-create-react-app/tests/test.mjs
similarity index 88%
rename from examples/browser-create-react-app/tests/test.js
rename to examples/browser-create-react-app/tests/test.mjs
index c999bf6d..02cb1786 100644
--- a/examples/browser-create-react-app/tests/test.js
+++ b/examples/browser-create-react-app/tests/test.mjs
@@ -1,5 +1,5 @@
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-exchange-files/README.md b/examples/browser-exchange-files/README.md
index 70632a95..59643f8c 100644
--- a/examples/browser-exchange-files/README.md
+++ b/examples/browser-exchange-files/README.md
@@ -36,7 +36,7 @@
- [4. Dial to a node using WebSockets (your desktop ones)](#4-dial-to-a-node-using-websockets-your-desktop-ones)
- [5. Transfer files between all of your nodes!](#5-transfer-files-between-all-of-your-nodes)
- [Going to production?](#going-to-production)
- - [Use your own `libp2p-webrtc-star` signalling server](#use-your-own-libp2p-webrtc-star-signalling-server)
+ - [Use your own `@libp2p/webrtc-star` signalling server](#use-your-own-libp2pwebrtc-star-signalling-server)
- [References](#references)
- [Documentation](#documentation)
- [Contributing](#contributing)
@@ -101,7 +101,7 @@ Here's what we are going to be doing:
1. Install a `go-ipfs` or `js-ipfs` node in your machine
2. Make your daemons listen on WebSockets
-3. Start a `libp2p-webrtc-star` signalling server
+3. Start a `@libp2p/webrtc-star` signalling server
4. Start the app
5. Dial to a node using WebSockets (your desktop ones)
6. Transfer files between all of your nodes!
@@ -267,14 +267,14 @@ _For more examples, please refer to the [Documentation](#documentation)_
This example uses public webrtc-star servers. These servers should be used for experimenting and demos, they **MUST** not be used in production as there is no guarantee on availability.
-### Use your own `libp2p-webrtc-star` signalling server
+### Use your own `@libp2p/webrtc-star` signalling server
This server allows the two browser nodes to talk to each other by doing the initial handshake and network introductions.
-First install the `libp2p-webrtc-star-signalling-server` module globally:
+First install the `@libp2p/webrtc-star-signalling-server` module globally:
```sh
-> npm install -g libp2p-webrtc-star-signalling-server
+> npm install -g @libp2p/webrtc-star-signalling-server
```
This will give you the `webrtc-star` command. Use this to start a signalling server:
diff --git a/examples/browser-exchange-files/package.json b/examples/browser-exchange-files/package.json
index d9be4b13..bc3a6642 100644
--- a/examples/browser-exchange-files/package.json
+++ b/examples/browser-exchange-files/package.json
@@ -3,32 +3,33 @@
"version": "1.0.0",
"private": true,
"license": "MIT",
+ "type": "module",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests --retries=3"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "@libp2p/websockets": "^1.0.8",
+ "ipfs-core": "^0.15.2",
"it-all": "^1.0.4",
- "libp2p-websockets": "^0.16.1",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
+ "@libp2p/webrtc-star-signalling-server": "^2.0.1",
"@playwright/test": "^1.12.3",
- "ipfs": "^0.62.0",
- "ipfs-core-types": "^0.10.0",
- "ipfs-http-client": "^56.0.0",
- "libp2p-webrtc-star-signalling-server": "^0.1.0",
- "parcel": "^2.3.2",
+ "ipfs": "^0.63.3",
+ "ipfs-core-types": "^0.11.0",
+ "ipfs-http-client": "^57.0.1",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-exchange-files/src/app.js b/examples/browser-exchange-files/src/app.js
index c274e11f..13428c9c 100644
--- a/examples/browser-exchange-files/src/app.js
+++ b/examples/browser-exchange-files/src/app.js
@@ -1,14 +1,13 @@
/* global location */
-'use strict'
-const IPFS = require('ipfs-core')
-const WS = require('libp2p-websockets')
-const filters = require('libp2p-websockets/src/filters')
-const transportKey = WS.prototype[Symbol.toStringTag]
+import { create } from 'ipfs-core'
+import { WebSockets } from '@libp2p/websockets'
+import * as filters from '@libp2p/websockets/filters'
-const all = require('it-all')
-const { concat: uint8ArrayConcat } = require('uint8arrays/concat')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
+import all from 'it-all'
+import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
// Node
const $nodeId = document.querySelector('.node-id')
@@ -51,7 +50,7 @@ let info
async function start () {
if (!node) {
- node = await IPFS.create({
+ node = await create({
repo: 'ipfs-' + Math.random(),
config: {
Addresses: {
@@ -66,16 +65,14 @@ async function start () {
Bootstrap: []
},
libp2p: {
- config: {
- transport: {
- // This is added for local demo!
- // In a production environment the default filter should be used
- // where only DNS + WSS addresses will be dialed by websockets in the browser.
- [transportKey]: {
- filter: filters.all
- }
- }
- }
+ transports: [
+ // This is added for local demo!
+ // In a production environment the default filter should be used
+ // where only DNS + WSS addresses will be dialed by websockets in the browser.
+ new WebSockets({
+ filter: filters.all
+ })
+ ]
}
})
@@ -147,7 +144,7 @@ async function start () {
const messageHandler = (message) => {
const myNode = info.id.toString()
- const hash = message.data.toString()
+ const hash = uint8ArrayToString(message.data)
const messageSender = message.from
// append new files when someone uploads them
diff --git a/examples/browser-exchange-files/tests/test.js b/examples/browser-exchange-files/tests/test.js
index bb00b434..3c3d07de 100644
--- a/examples/browser-exchange-files/tests/test.js
+++ b/examples/browser-exchange-files/tests/test.js
@@ -1,9 +1,8 @@
-'use strict'
-
-const webRTCStarSigServer = require('libp2p-webrtc-star-signalling-server')
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { sigServer } from '@libp2p/webrtc-star-signalling-server'
+import { test, expect } from '@playwright/test'
+import { playwright } from 'test-util-ipfs-example'
+import * as ipfsModule from 'ipfs'
+import * as ipfsHttpModule from 'ipfs-http-client'
// Setup
const play = test.extend({
@@ -21,11 +20,11 @@ const play = test.extend({
),
...playwright.daemons(
{
- ipfsModule: require('ipfs'),
- ipfsHttpModule: require('ipfs-http-client')
+ ipfsModule,
+ ipfsHttpModule
}, {
js: {
- ipfsBin: require('ipfs').path()
+ ipfsBin: ipfsModule.path()
}
},
[
@@ -81,18 +80,18 @@ play.describe('upload file using http client: ', () => {
await page.click(workspaceBtn)
}
- let sigServer;
+ let sigallingServer;
play.beforeAll(async () => {
- sigServer = await webRTCStarSigServer.start({
+ sigallingServer = await sigServer({
host: '127.0.0.1',
port: 13579
})
})
play.afterAll(async () => {
- if (sigServer) {
- await sigServer.stop()
+ if (sigallingServer) {
+ await sigallingServer.stop()
}
})
@@ -160,5 +159,4 @@ play.describe('upload file using http client: ', () => {
expect(passed).toBeTruthy()
});
-
});
diff --git a/examples/browser-exchange-files/vite.config.js b/examples/browser-exchange-files/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-exchange-files/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-ipns-publish/package.json b/examples/browser-ipns-publish/package.json
index 4a558483..dae2c7d8 100644
--- a/examples/browser-ipns-publish/package.json
+++ b/examples/browser-ipns-publish/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-ipns-publish",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "An example demonstrating publishing to IPNS in the browser",
"keywords": [
"IPNS",
@@ -14,21 +15,21 @@
"license": "MIT",
"author": "Doug Anderson",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests --retries=3 --timeout=120000"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
- "ipfs-http-client": "^56.0.0",
- "ipfs-utils": "^9.0.2",
- "ipns": "^0.16.0",
+ "@libp2p/websockets": "^1.0.8",
+ "ipfs-core": "^0.15.2",
+ "ipfs-http-client": "^57.0.1",
+ "ipfs-utils": "^9.0.6",
+ "ipns": "^1.0.2",
"it-last": "^1.0.4",
- "libp2p-websockets": "^0.16.1",
- "multiformats": "^9.4.7",
+ "multiformats": "^9.6.5",
"p-retry": "^4.2.0",
"uint8arrays": "^3.0.0"
},
@@ -38,12 +39,12 @@
"delay": "^5.0.0",
"execa": "^6.0.0",
"go-ipfs": "^0.11.0",
- "ipfsd-ctl": "^10.0.3",
- "parcel": "^2.3.2",
+ "ipfsd-ctl": "^11.0.1",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-ipns-publish/src/index.js b/examples/browser-ipns-publish/src/index.js
index 7516e09d..965341f2 100644
--- a/examples/browser-ipns-publish/src/index.js
+++ b/examples/browser-ipns-publish/src/index.js
@@ -1,21 +1,16 @@
-"use strict";
-
-const IpfsHttpClient = require("ipfs-http-client");
-const ipns = require("ipns");
-const IPFS = require("ipfs-core");
-const pRetry = require("p-retry");
-const last = require("it-last");
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
-const { base58btc } = require('multiformats/bases/base58')
-const { base36 } = require('multiformats/bases/base36')
-const { CID } = require('multiformats/cid')
-const Digest = require('multiformats/hashes/digest')
-const WS = require('libp2p-websockets')
-const transportKey = WS.prototype[Symbol.toStringTag]
-const filters = require('libp2p-websockets/src/filters')
-
-const { Logger, onEnterPress, catchAndLog } = require("./util");
+import * as IpfsHttpClient from "ipfs-http-client";
+import * as ipns from "ipns";
+import * as IPFS from "ipfs-core";
+import pRetry from "p-retry";
+import last from "it-last";
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
+import { base36 } from 'multiformats/bases/base36'
+import { CID } from 'multiformats/cid'
+import * as Digest from 'multiformats/hashes/digest'
+import { WebSockets } from '@libp2p/websockets'
+import * as filters from '@libp2p/websockets/filters'
+import { Logger, onEnterPress, catchAndLog } from "./util";
async function main() {
const apiUrlInput = document.getElementById("api-url");
@@ -46,16 +41,14 @@ async function main() {
pass: "01234567890123456789",
EXPERIMENTAL: { ipnsPubsub: true },
libp2p: {
- config: {
- transport: {
- // This is added for local demo!
- // In a production environment the default filter should be used
- // where only DNS + WSS addresses will be dialed by websockets in the browser.
- [transportKey]: {
- filter: filters.all
- }
- }
- }
+ transports: [
+ // This is added for local demo!
+ // In a production environment the default filter should be used
+ // where only DNS + WSS addresses will be dialed by websockets in the browser.
+ new WebSockets({
+ filter: filters.all
+ })
+ ]
}
});
const { id } = await ipfsBrowser.id();
@@ -130,7 +123,7 @@ async function main() {
pRetry(async () => {
const res = await daemon.pubsub.peers(topic);
- if (!res || !res.length || !res.includes(peerId)) {
+ if (!res || !res.length || !res.map(p => p.toString()).includes(peerId.toString())) {
throw new Error("Could not find peer subscribing");
}
}, retryOptions);
@@ -141,12 +134,11 @@ async function main() {
topic,
(msg) => {
const from = msg.from;
- const seqno = uint8ArrayToString(msg.seqno, "hex");
tLog(
`${new Date(
Date.now()
- ).toLocaleTimeString()}\n Message ${seqno} from ${from}`
+ ).toLocaleTimeString()}\n Message ${msg.sequenceNumber} from ${from}`
);
let regex = "/record/";
@@ -224,9 +216,8 @@ async function main() {
last(ipfsAPI.name.resolve(keys.id, { stream: false })); // save the pubsub topic to the server to make them listen
// set up the topic from ipns key
- let b58 = base58btc.decode(`z${keys.id}`)
- const ipnsKeys = ipns.getIdKeys(b58);
- const topic = `${namespace}${uint8ArrayToString(ipnsKeys.routingKey.uint8Array(), 'base64url')}`;
+ const routingKey = ipns.peerIdToRoutingKey(browserNode.id);
+ const topic = `${namespace}${uint8ArrayToString(routingKey, 'base64url')}`;
// subscribe and log on both nodes
await subs(ipfsBrowser, topic, log); // browserLog
@@ -271,12 +262,15 @@ async function main() {
log(`Try resolve ${keys.id} on server through API`);
- let name = await last(
- ipfsAPI.name.resolve(keys.id, {
- stream: false,
- })
- );
- log(`Resolved: ${name}`);
+ let name
+
+ for await (const res of ipfsAPI.name.resolve(keys.id, {
+ stream: false,
+ })) {
+ log(`Resolved: ${res}`);
+ name = res;
+ }
+
if (name == content) {
log(`IPNS Publish Success! `);
log(`Look at that! ${keys.id} resolves to ${content} `);
diff --git a/examples/browser-ipns-publish/src/util.js b/examples/browser-ipns-publish/src/util.js
index a7601405..53232461 100644
--- a/examples/browser-ipns-publish/src/util.js
+++ b/examples/browser-ipns-publish/src/util.js
@@ -1,4 +1,4 @@
-exports.Logger = outEl => {
+export const Logger = outEl => {
outEl.innerHTML = ''
return message => {
const container = document.createElement('div')
@@ -8,7 +8,7 @@ exports.Logger = outEl => {
}
}
-exports.onEnterPress = fn => {
+export const onEnterPress = fn => {
return e => {
if (event.which == 13 || event.keyCode == 13) {
e.preventDefault()
@@ -17,7 +17,7 @@ exports.onEnterPress = fn => {
}
}
-exports.catchAndLog = (fn, log) => {
+export const catchAndLog = (fn, log) => {
return async (...args) => {
try {
await fn(...args)
diff --git a/examples/browser-ipns-publish/tests/test.js b/examples/browser-ipns-publish/tests/test.js
index 5f351b7b..381a8107 100644
--- a/examples/browser-ipns-publish/tests/test.js
+++ b/examples/browser-ipns-publish/tests/test.js
@@ -1,15 +1,15 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test'
+import { playwright } from 'test-util-ipfs-example'
+import * as goIpfsModule from 'go-ipfs'
+import * as ipfsHttpModule from 'ipfs-http-client'
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsHttpModule: require("ipfs-http-client"),
- ipfsBin: require("go-ipfs").path(),
+ ipfsHttpModule,
+ ipfsBin: goIpfsModule.path(),
args: [
"--enable-pubsub-experiment",
'--enable-namesys-pubsub'
@@ -54,7 +54,7 @@ play.describe('http ipns publish:', () => {
const publish = "#publish"
play.beforeEach(async ({servers, page, daemons}) => {
- await daemons[0].api.swarm.connect(await daemons[1].api.peerId.addresses[0])
+ await daemons[0].api.swarm.connect(await daemons[1]._peerId.addresses[0])
await page.goto(`http://localhost:${servers[0].port}/`);
})
@@ -66,7 +66,7 @@ play.describe('http ipns publish:', () => {
const { cid } = await goNode.api.add(`Some data ${Date.now()}`)
const topic = `/ipfs/${cid}`;
- const peerAddr = goNode.api.peerId.addresses
+ const peerAddr = goNode._peerId.addresses
.map(addr => addr.toString())
.filter(addr => addr.includes("/ws/p2p/"))
.pop()
diff --git a/examples/browser-ipns-publish/vite.config.js b/examples/browser-ipns-publish/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-ipns-publish/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-lit/package.json b/examples/browser-lit/package.json
index d07d2309..2d4c3438 100644
--- a/examples/browser-lit/package.json
+++ b/examples/browser-lit/package.json
@@ -2,19 +2,20 @@
"name": "example-browser-lit",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "A minimal demonstration of how to use js-ipfs with lit",
"keywords": [],
"license": "MIT",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"ipfs-css": "^1.3.0",
"lit": "^2.0.2",
"tachyons": "^4.12.0"
@@ -22,11 +23,11 @@
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-lit/src/index.js b/examples/browser-lit/src/index.js
index 18f85290..196961a8 100644
--- a/examples/browser-lit/src/index.js
+++ b/examples/browser-lit/src/index.js
@@ -1,5 +1,3 @@
-'use strict'
-
// Global CSS
import "ipfs-css";
import 'tachyons'
diff --git a/examples/browser-lit/src/ipfs.js b/examples/browser-lit/src/ipfs.js
index ae070d88..8a4789ea 100644
--- a/examples/browser-lit/src/ipfs.js
+++ b/examples/browser-lit/src/ipfs.js
@@ -1,5 +1,3 @@
-'use strict'
-
import {html, LitElement} from 'lit';
import { create } from 'ipfs-core'
diff --git a/examples/browser-lit/tests/test.js b/examples/browser-lit/tests/test.js
index 17eec51b..6124f627 100644
--- a/examples/browser-lit/tests/test.js
+++ b/examples/browser-lit/tests/test.js
@@ -1,5 +1,5 @@
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test'
+import { playwright } from 'test-util-ipfs-example'
// Setup
const play = test.extend({
diff --git a/examples/browser-lit/vite.config.js b/examples/browser-lit/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-lit/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-mfs/package.json b/examples/browser-mfs/package.json
index 00fe2100..49ae4f76 100644
--- a/examples/browser-mfs/package.json
+++ b/examples/browser-mfs/package.json
@@ -2,29 +2,30 @@
"name": "example-browser-mfs",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "How to use ipfs MFS in the browser",
"license": "ISC",
"author": "",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"mime-sniffer": "~0.0.3"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-mfs/src/filetree.js b/examples/browser-mfs/src/filetree.js
index 5efb07be..89eff352 100644
--- a/examples/browser-mfs/src/filetree.js
+++ b/examples/browser-mfs/src/filetree.js
@@ -1,8 +1,6 @@
-'use strict'
-
-const {
+import {
createNode
-} = require('./utils')
+} from './utils.js'
const FILE_TYPES = {
FILE: 'file',
@@ -11,7 +9,7 @@ const FILE_TYPES = {
let selected = {}
-const getSelected = () => {
+export const getSelected = () => {
return Object.values(selected)
}
@@ -55,7 +53,7 @@ const listFiles = (parent, files, prefix) => {
})
}
-const updateTree = async (ipfs) => {
+export const updateTree = async (ipfs) => {
const files = await loadFiles(ipfs, '/')
const container = document.querySelector('#files')
@@ -67,8 +65,3 @@ const updateTree = async (ipfs) => {
listFiles(container, files, '')
}
-
-export {
- getSelected,
- updateTree
-}
diff --git a/examples/browser-mfs/src/forms.js b/examples/browser-mfs/src/forms.js
index a35432f3..0f11f7af 100644
--- a/examples/browser-mfs/src/forms.js
+++ b/examples/browser-mfs/src/forms.js
@@ -1,5 +1,3 @@
-'use strict'
-
const modalScreen = document.getElementById('modal-screen')
modalScreen.onclick = (event) => {
@@ -33,7 +31,7 @@ const getValue = (id) => {
return element.value.trim()
}
-const hideForms = () => {
+export const hideForms = () => {
modalScreen.style.display = 'none'
Object.values(forms)
@@ -42,7 +40,7 @@ const hideForms = () => {
})
}
-const showForm = (form) => {
+export const showForm = (form) => {
return (event) => {
event.preventDefault()
@@ -51,7 +49,7 @@ const showForm = (form) => {
}
}
-const mkdirForm = (onMkdir) => {
+export const mkdirForm = (onMkdir) => {
const button = document.getElementById('button-mkdir')
const submit = document.getElementById('button-form-mkdir-submit')
@@ -71,7 +69,7 @@ const mkdirForm = (onMkdir) => {
button.disabled = false
}
-const mvForm = (onMv) => {
+export const mvForm = (onMv) => {
const button = document.getElementById('button-mv')
const submit = document.getElementById('button-form-mv-submit')
@@ -92,7 +90,7 @@ const mvForm = (onMv) => {
button.disabled = false
}
-const cpForm = (onCp) => {
+export const cpForm = (onCp) => {
const button = document.getElementById('button-cp')
const submit = document.getElementById('button-form-cp-submit')
@@ -113,7 +111,7 @@ const cpForm = (onCp) => {
button.disabled = false
}
-const rmForm = (onRm) => {
+export const rmForm = (onRm) => {
const button = document.getElementById('button-rm')
const submit = document.getElementById('button-form-rm-submit')
@@ -130,7 +128,7 @@ const rmForm = (onRm) => {
button.disabled = false
}
-const statForm = (onStat) => {
+export const statForm = (onStat) => {
const button = document.getElementById('button-stat')
const submit = document.getElementById('button-form-stat-submit')
@@ -149,7 +147,7 @@ const statForm = (onStat) => {
button.disabled = false
}
-const readForm = (onRead) => {
+export const readForm = (onRead) => {
const button = document.getElementById('button-read')
const submit = document.getElementById('button-form-read-submit')
@@ -166,13 +164,3 @@ const readForm = (onRead) => {
button.disabled = false
}
-
-export {
- mkdirForm,
- mvForm,
- rmForm,
- cpForm,
- statForm,
- readForm,
- hideForms
-}
diff --git a/examples/browser-mfs/src/index.js b/examples/browser-mfs/src/index.js
index 7a9a7508..330a76ba 100644
--- a/examples/browser-mfs/src/index.js
+++ b/examples/browser-mfs/src/index.js
@@ -1,15 +1,13 @@
-'use strict'
-
/* eslint-env browser */
import {
dragDrop,
log,
bufferToArrayBuffer
-} from './utils'
+} from './utils.js'
import {
updateTree
-} from './filetree'
+} from './filetree.js'
import {
mvForm,
mkdirForm,
@@ -18,7 +16,7 @@ import {
statForm,
readForm,
hideForms
-} from './forms'
+} from './forms.js'
import mime from 'mime-sniffer'
import { create } from 'ipfs-core'
diff --git a/examples/browser-mfs/src/utils.js b/examples/browser-mfs/src/utils.js
index 5cdb66a1..f59c1ae2 100644
--- a/examples/browser-mfs/src/utils.js
+++ b/examples/browser-mfs/src/utils.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const createNode = (type, content, attrbutes) => {
+export const createNode = (type, content, attrbutes) => {
attrbutes = attrbutes || {}
const node = document.createElement(type)
@@ -19,7 +17,7 @@ const createNode = (type, content, attrbutes) => {
return node
}
-const log = (line) => {
+export const log = (line) => {
const output = document.querySelector('#log')
let message
let className = ''
@@ -47,7 +45,7 @@ const log = (line) => {
return node
}
-const dragDrop = (onFiles) => {
+export const dragDrop = (onFiles) => {
const container = document.querySelector('#container')
container.ondragover = (event) => {
@@ -73,7 +71,7 @@ const dragDrop = (onFiles) => {
}
}
-const bufferToArrayBuffer = (buffer) => {
+export const bufferToArrayBuffer = (buffer) => {
const ab = new ArrayBuffer(buffer.length)
const view = new Uint8Array(ab)
@@ -83,10 +81,3 @@ const bufferToArrayBuffer = (buffer) => {
return ab
}
-
-export {
- log,
- dragDrop,
- createNode,
- bufferToArrayBuffer
-}
diff --git a/examples/browser-mfs/tests/test.js b/examples/browser-mfs/tests/test.js
index e2962734..713afc60 100644
--- a/examples/browser-mfs/tests/test.js
+++ b/examples/browser-mfs/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test'
+import { playwright } from 'test-util-ipfs-example'
// Setup
const play = test.extend({
diff --git a/examples/browser-mfs/vite.config.js b/examples/browser-mfs/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-mfs/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-nextjs/components/ipfs.js b/examples/browser-nextjs/components/ipfs.js
index 6e9687d5..30e1d478 100644
--- a/examples/browser-nextjs/components/ipfs.js
+++ b/examples/browser-nextjs/components/ipfs.js
@@ -26,13 +26,13 @@ const IpfsComponent = () => {
init()
}, [ipfs]);
- if (!ipfs) {
+ if (!ipfs || !id) {
return Connecting to IPFS...
}
return (
-
ID: {id}
+ ID: {id.toString()}
Version: {version}
Status: {isOnline ? 'Online' : 'Offline'}
diff --git a/examples/browser-nextjs/next.config.js b/examples/browser-nextjs/next.config.js
index 3f829a07..7901fff1 100644
--- a/examples/browser-nextjs/next.config.js
+++ b/examples/browser-nextjs/next.config.js
@@ -1,9 +1,9 @@
-module.exports = {
+export default {
reactStrictMode: true,
// https://github.com/vercel/next.js/issues/21079
// Remove the workaround the issue is fixed
images: {
loader: "imgix",
path: "https://noop/",
- },
+ }
}
diff --git a/examples/browser-nextjs/package.json b/examples/browser-nextjs/package.json
index ebee3b12..6cb8fe7a 100644
--- a/examples/browser-nextjs/package.json
+++ b/examples/browser-nextjs/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-nextjs",
"version": "1.0.0",
"private": true,
+ "type": "module",
"scripts": {
"clean": "rimraf ./dist ./.next",
"dev": "next dev",
@@ -12,7 +13,7 @@
"test": "npm run build && playwright test tests"
},
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"next": "^12.0.7",
"react": "^17.0.2",
"react-dom": "^17.0.2"
diff --git a/examples/browser-nextjs/tests/test.js b/examples/browser-nextjs/tests/test.js
index 38a7ac4a..f7cdc374 100644
--- a/examples/browser-nextjs/tests/test.js
+++ b/examples/browser-nextjs/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-parceljs/.github/pull_request_template.md b/examples/browser-parceljs/.github/pull_request_template.md
deleted file mode 100644
index e6a8f900..00000000
--- a/examples/browser-parceljs/.github/pull_request_template.md
+++ /dev/null
@@ -1,15 +0,0 @@
-**IMPORTANT: Please do not create a Pull Request for this repository.**
-
-The contents of this repository are automatically synced from the parent [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples) so any changes made to the standalone repository will be lost after the next sync.
-
-Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
-
-## 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**.
-
-1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
-2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
-3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
-4. Push to the Branch (`git push origin feature/amazing-example`)
-5. Open a Pull Request
diff --git a/examples/browser-parceljs/favicon.ico b/examples/browser-parceljs/favicon.ico
deleted file mode 100644
index b2f1f968..00000000
Binary files a/examples/browser-parceljs/favicon.ico and /dev/null differ
diff --git a/examples/browser-parceljs/public/ipfs-logo.svg b/examples/browser-parceljs/public/ipfs-logo.svg
deleted file mode 100644
index f8633f62..00000000
--- a/examples/browser-parceljs/public/ipfs-logo.svg
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/examples/browser-readablestream/package.json b/examples/browser-readablestream/package.json
index 8210e74e..40c67b1a 100644
--- a/examples/browser-readablestream/package.json
+++ b/examples/browser-readablestream/package.json
@@ -2,31 +2,35 @@
"name": "example-browser-readablestream",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "An example of how to play a video in a browser using a readable stream",
"license": "ISC",
"author": "",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "buffer": "^6.0.3",
+ "ipfs-core": "^0.15.2",
"it-to-stream": "^1.0.0",
"videostream": "^3.2.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
+ "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@playwright/test": "^1.12.3",
+ "@rollup/plugin-inject": "^4.0.4",
"events": "^3.3.0",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-readablestream/src/index.js b/examples/browser-readablestream/src/index.js
index de30e3cc..7e88a4a9 100644
--- a/examples/browser-readablestream/src/index.js
+++ b/examples/browser-readablestream/src/index.js
@@ -1,3 +1,6 @@
+import { Buffer } from 'buffer'
+globalThis.Buffer = Buffer
+
import { create } from 'ipfs-core'
import VideoStream from 'videostream'
import toStream from 'it-to-stream'
@@ -6,7 +9,7 @@ import {
statusMessages,
createVideoElement,
log
-} from './utils'
+} from './utils.js'
const App = async () => {
// DOM
diff --git a/examples/browser-readablestream/src/utils.js b/examples/browser-readablestream/src/utils.js
index 4e80b9fe..ac844505 100644
--- a/examples/browser-readablestream/src/utils.js
+++ b/examples/browser-readablestream/src/utils.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const log = (line) => {
+export const log = (line) => {
if (!line) return
const output = document.getElementById('output')
@@ -23,7 +21,7 @@ const log = (line) => {
}
}
-const dragDrop = (ipfs) => {
+export const dragDrop = (ipfs) => {
const container = document.querySelector('#container')
container.ondragover = (event) => {
@@ -65,7 +63,7 @@ const dragDrop = (ipfs) => {
}
}
-const statusMessages = (stream) => {
+export const statusMessages = (stream) => {
let time = 0
const timeouts = [
'Stream: Still loading data from IPFS...',
@@ -95,7 +93,7 @@ const statusMessages = (stream) => {
})
}
-const createVideoElement = () => {
+export const createVideoElement = () => {
const videoElement = document.getElementById('video')
videoElement.addEventListener('loadedmetadata', () => {
videoElement.play()
@@ -133,10 +131,3 @@ const createVideoElement = () => {
return videoElement
}
-
-export {
- log,
- dragDrop,
- createVideoElement,
- statusMessages
-}
diff --git a/examples/browser-readablestream/tests/test.js b/examples/browser-readablestream/tests/test.js
index ea8c1ff4..5d4763e0 100644
--- a/examples/browser-readablestream/tests/test.js
+++ b/examples/browser-readablestream/tests/test.js
@@ -1,8 +1,10 @@
-'use strict'
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
+import fs from 'fs';
+import path from 'path'
+import { fileURLToPath } from 'url'
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
-const fs = require('fs');
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Setup
const play = test.extend({
diff --git a/examples/browser-readablestream/vite.config.js b/examples/browser-readablestream/vite.config.js
new file mode 100644
index 00000000..6d9535e4
--- /dev/null
+++ b/examples/browser-readablestream/vite.config.js
@@ -0,0 +1,32 @@
+import inject from '@rollup/plugin-inject'
+import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
+
+export default {
+ build: {
+ target: 'esnext',
+ minify: false,
+ rollupOptions: {
+ plugins: [inject({ Buffer: ['Buffer', 'Buffer'] })],
+ }
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis',
+ 'process.version': `'${process.version}'`
+ },
+ optimizeDeps: {
+ esbuildOptions: {
+ // Node.js global to browser globalThis
+ define: {
+ global: 'globalThis',
+ },
+ // Enable esbuild polyfill plugins
+ plugins: [
+ NodeGlobalsPolyfillPlugin({
+ process: true,
+ buffer: true
+ })
+ ]
+ }
+ }
+}
diff --git a/examples/browser-script-tag/index.html b/examples/browser-script-tag/index.html
index 2a81b9c2..39b08df4 100644
--- a/examples/browser-script-tag/index.html
+++ b/examples/browser-script-tag/index.html
@@ -12,7 +12,7 @@
src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"
defer
>
-
+
IPFS in the Browser
diff --git a/examples/browser-script-tag/package.json b/examples/browser-script-tag/package.json
index de9c4909..121644d5 100644
--- a/examples/browser-script-tag/package.json
+++ b/examples/browser-script-tag/package.json
@@ -2,13 +2,14 @@
"name": "example-browser-script-tag",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Using IPFS in the browser via a script tag",
"keywords": [],
"license": "MIT",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
@@ -16,11 +17,11 @@
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-script-tag/tests/test.js b/examples/browser-script-tag/tests/test.js
index 11b5616b..d2505131 100644
--- a/examples/browser-script-tag/tests/test.js
+++ b/examples/browser-script-tag/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-script-tag/vite.config.js b/examples/browser-script-tag/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-script-tag/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-service-worker/package.json b/examples/browser-service-worker/package.json
index e0621906..c8ba3826 100644
--- a/examples/browser-service-worker/package.json
+++ b/examples/browser-service-worker/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-service-worker",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "IPFS with service worker",
"keywords": [],
"license": "MIT",
@@ -16,10 +17,10 @@
"last 1 Chrome version"
],
"dependencies": {
- "ipfs-core": "^0.14.0",
- "ipfs-message-port-client": "^0.11.0",
- "ipfs-message-port-protocol": "^0.11.0",
- "ipfs-message-port-server": "^0.11.0"
+ "ipfs-core": "^0.15.2",
+ "ipfs-message-port-client": "^0.12.2",
+ "ipfs-message-port-protocol": "^0.12.0",
+ "ipfs-message-port-server": "^0.12.0"
},
"devDependencies": {
"@babel/core": "^7.13.10",
diff --git a/examples/browser-service-worker/src/service.js b/examples/browser-service-worker/src/service.js
index a16f3992..188994b9 100644
--- a/examples/browser-service-worker/src/service.js
+++ b/examples/browser-service-worker/src/service.js
@@ -1,7 +1,7 @@
// @ts-check
/* eslint-env browser, serviceworker */
import { IPFSClient } from "ipfs-message-port-client"
-import { defer, selectClient, toReadableStream } from "./service/util"
+import { defer, selectClient, toReadableStream } from "./service/util.js"
/**
* @param {LifecycleEvent} event
diff --git a/examples/browser-service-worker/src/worker.js b/examples/browser-service-worker/src/worker.js
index 838e98f6..8c8052df 100644
--- a/examples/browser-service-worker/src/worker.js
+++ b/examples/browser-service-worker/src/worker.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { create } = require('ipfs-core')
-const { Server, IPFSService } = require('ipfs-message-port-server')
+import { create } from 'ipfs-core'
+import { Server, IPFSService } from 'ipfs-message-port-server'
console.info('hello world')
diff --git a/examples/browser-service-worker/tests/test.js b/examples/browser-service-worker/tests/test.js
index 49d81b44..805a865a 100644
--- a/examples/browser-service-worker/tests/test.js
+++ b/examples/browser-service-worker/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-service-worker/webpack.config.js b/examples/browser-service-worker/webpack.config.js
index 97832a8b..e5530785 100644
--- a/examples/browser-service-worker/webpack.config.js
+++ b/examples/browser-service-worker/webpack.config.js
@@ -1,11 +1,12 @@
+import path from 'path'
+import webpack from 'webpack'
+import { merge } from 'webpack-merge'
+import { fileURLToPath } from 'url'
+import CopyWebpackPlugin from 'copy-webpack-plugin'
+import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'
+import HtmlWebpackPlugin from 'html-webpack-plugin'
-const path = require('path')
-const webpack = require('webpack')
-const { merge } = require('webpack-merge')
-
-const CopyWebpackPlugin = require('copy-webpack-plugin')
-const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
/**
* HMR/Live Reloading broken after Webpack 5 rc.0 -> rc.1 update
@@ -151,7 +152,7 @@ const common = {
target: 'web'
}
-module.exports = (cmd) => {
+export default (cmd) => {
const production = cmd.production
const config = production ? prod : dev
diff --git a/examples/browser-sharing-node-across-tabs/package.json b/examples/browser-sharing-node-across-tabs/package.json
index 517caed6..311861d9 100644
--- a/examples/browser-sharing-node-across-tabs/package.json
+++ b/examples/browser-sharing-node-across-tabs/package.json
@@ -2,30 +2,31 @@
"name": "example-browser-sharing-node-across-tabs",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Sharing IPFS node across browsing contexts",
"keywords": [],
"license": "MIT",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0",
- "ipfs-message-port-client": "^0.11.0",
- "ipfs-message-port-server": "^0.11.0"
+ "ipfs-core": "^0.15.2",
+ "ipfs-message-port-client": "^0.12.2",
+ "ipfs-message-port-server": "^0.12.0"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-sharing-node-across-tabs/src/main.js b/examples/browser-sharing-node-across-tabs/src/main.js
index 2784d1ad..6b88d8c0 100644
--- a/examples/browser-sharing-node-across-tabs/src/main.js
+++ b/examples/browser-sharing-node-across-tabs/src/main.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { IPFSClient } from "ipfs-message-port-client"
window.addEventListener('load', (event) => {
diff --git a/examples/browser-sharing-node-across-tabs/src/worker.js b/examples/browser-sharing-node-across-tabs/src/worker.js
index f1526245..aa6e5b44 100644
--- a/examples/browser-sharing-node-across-tabs/src/worker.js
+++ b/examples/browser-sharing-node-across-tabs/src/worker.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { create } from 'ipfs-core'
import { Server, IPFSService } from 'ipfs-message-port-server'
diff --git a/examples/browser-sharing-node-across-tabs/tests/test.js b/examples/browser-sharing-node-across-tabs/tests/test.js
index 9895768e..d2352de4 100644
--- a/examples/browser-sharing-node-across-tabs/tests/test.js
+++ b/examples/browser-sharing-node-across-tabs/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-sharing-node-across-tabs/vite.config.js b/examples/browser-sharing-node-across-tabs/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-sharing-node-across-tabs/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-video-streaming/package.json b/examples/browser-video-streaming/package.json
index 5f8536fc..758f02bb 100644
--- a/examples/browser-video-streaming/package.json
+++ b/examples/browser-video-streaming/package.json
@@ -2,13 +2,14 @@
"name": "example-browser-video-streaming",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "IPFS browser video streaming example",
"keywords": [],
"license": "MIT",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests --browser=firefox --retries=3"
},
@@ -16,16 +17,16 @@
"dependencies": {
"hls.js": "^0.14.17",
"hlsjs-ipfs-loader": "^0.3.0",
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-video-streaming/src/index.js b/examples/browser-video-streaming/src/index.js
index d274736a..c4d36491 100644
--- a/examples/browser-video-streaming/src/index.js
+++ b/examples/browser-video-streaming/src/index.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { create } from 'ipfs-core'
import Hls from 'hls.js'
import HlsjsIpfsLoader from 'hlsjs-ipfs-loader'
diff --git a/examples/browser-video-streaming/tests/test.js b/examples/browser-video-streaming/tests/test.js
index 27fe6fe5..c742e58c 100644
--- a/examples/browser-video-streaming/tests/test.js
+++ b/examples/browser-video-streaming/tests/test.js
@@ -1,9 +1,5 @@
-'use strict'
-
-'use strict'
-
-const { test } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-video-streaming/vite.config.js b/examples/browser-video-streaming/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-video-streaming/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-browserify/.github/pull_request_template.md b/examples/browser-vite/.github/pull_request_template.md
similarity index 100%
rename from examples/browser-browserify/.github/pull_request_template.md
rename to examples/browser-vite/.github/pull_request_template.md
diff --git a/examples/browser-parceljs/.github/workflows/sync.yml b/examples/browser-vite/.github/workflows/sync.yml
similarity index 100%
rename from examples/browser-parceljs/.github/workflows/sync.yml
rename to examples/browser-vite/.github/workflows/sync.yml
diff --git a/examples/browser-parceljs/README.md b/examples/browser-vite/README.md
similarity index 100%
rename from examples/browser-parceljs/README.md
rename to examples/browser-vite/README.md
diff --git a/examples/browser-browserify/public/favicon.ico b/examples/browser-vite/favicon.ico
similarity index 100%
rename from examples/browser-browserify/public/favicon.ico
rename to examples/browser-vite/favicon.ico
diff --git a/examples/browser-parceljs/img/1.png b/examples/browser-vite/img/1.png
similarity index 100%
rename from examples/browser-parceljs/img/1.png
rename to examples/browser-vite/img/1.png
diff --git a/examples/browser-parceljs/img/2.png b/examples/browser-vite/img/2.png
similarity index 100%
rename from examples/browser-parceljs/img/2.png
rename to examples/browser-vite/img/2.png
diff --git a/examples/browser-parceljs/index.html b/examples/browser-vite/index.html
similarity index 100%
rename from examples/browser-parceljs/index.html
rename to examples/browser-vite/index.html
diff --git a/examples/browser-parceljs/package.json b/examples/browser-vite/package.json
similarity index 59%
rename from examples/browser-parceljs/package.json
rename to examples/browser-vite/package.json
index d8b1e76a..86fd8307 100644
--- a/examples/browser-parceljs/package.json
+++ b/examples/browser-vite/package.json
@@ -1,30 +1,31 @@
{
- "name": "example-browser-parceljs",
+ "name": "example-browser-vide",
"version": "1.0.0",
"private": true,
- "description": "Bundle js-ipfs with ParcelJS",
+ "type": "module",
+ "description": "Bundle js-ipfs with vite",
"keywords": [],
"license": "ISC",
"author": "",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/browser-browserify/public/ipfs-logo.svg b/examples/browser-vite/public/ipfs-logo.svg
similarity index 100%
rename from examples/browser-browserify/public/ipfs-logo.svg
rename to examples/browser-vite/public/ipfs-logo.svg
diff --git a/examples/browser-parceljs/src/index.js b/examples/browser-vite/src/index.js
similarity index 99%
rename from examples/browser-parceljs/src/index.js
rename to examples/browser-vite/src/index.js
index 4c7e338f..b72e183b 100644
--- a/examples/browser-parceljs/src/index.js
+++ b/examples/browser-vite/src/index.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { create } from 'ipfs-core'
const App = () => {
diff --git a/examples/browser-parceljs/src/style.css b/examples/browser-vite/src/style.css
similarity index 100%
rename from examples/browser-parceljs/src/style.css
rename to examples/browser-vite/src/style.css
diff --git a/examples/browser-parceljs/tests/test.js b/examples/browser-vite/tests/test.js
similarity index 89%
rename from examples/browser-parceljs/tests/test.js
rename to examples/browser-vite/tests/test.js
index f1c1a615..588eea14 100644
--- a/examples/browser-parceljs/tests/test.js
+++ b/examples/browser-vite/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-vite/vite.config.js b/examples/browser-vite/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/browser-vite/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/browser-vue/babel.config.js b/examples/browser-vue/babel.config.cjs
similarity index 100%
rename from examples/browser-vue/babel.config.js
rename to examples/browser-vue/babel.config.cjs
diff --git a/examples/browser-vue/package.json b/examples/browser-vue/package.json
index 07d5db92..76df2db3 100644
--- a/examples/browser-vue/package.json
+++ b/examples/browser-vue/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-vue-3",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "A minimal demonstration of how to use js-ipfs using vue 3",
"scripts": {
"clean": "rimraf ./dist",
@@ -33,7 +34,7 @@
},
"dependencies": {
"core-js": "^3.8.3",
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"vue": "^3.0.4"
},
"devDependencies": {
diff --git a/examples/browser-vue/src/main.js b/examples/browser-vue/src/main.js
index 08dfc00f..3c16c399 100644
--- a/examples/browser-vue/src/main.js
+++ b/examples/browser-vue/src/main.js
@@ -1,6 +1,6 @@
import { createApp } from 'vue'
import App from './App.vue'
-import VueIpfs from './plugins/vue-ipfs'
+import VueIpfs from './plugins/vue-ipfs.js'
// Load our IPFS plugin.
const app = createApp(App)
diff --git a/examples/browser-vue/tests/test.js b/examples/browser-vue/tests/test.js
index d6f9564f..58518c36 100644
--- a/examples/browser-vue/tests/test.js
+++ b/examples/browser-vue/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-webpack/package.json b/examples/browser-webpack/package.json
index 4b4355c7..07bdd134 100644
--- a/examples/browser-webpack/package.json
+++ b/examples/browser-webpack/package.json
@@ -2,6 +2,7 @@
"name": "example-browser-webpack",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Bundle js-ipfs with Webpack",
"keywords": [],
"license": "MIT",
@@ -16,7 +17,7 @@
"last 1 Chrome version"
],
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
diff --git a/examples/browser-webpack/src/index.js b/examples/browser-webpack/src/index.js
index 6404b51f..d3cf2eaa 100644
--- a/examples/browser-webpack/src/index.js
+++ b/examples/browser-webpack/src/index.js
@@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './app.css';
-import App from './app'
+import App from './app.js'
ReactDOM.render(
diff --git a/examples/browser-webpack/tests/test.js b/examples/browser-webpack/tests/test.js
index 6fe1ad12..c19b22e8 100644
--- a/examples/browser-webpack/tests/test.js
+++ b/examples/browser-webpack/tests/test.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
// Setup
const play = test.extend({
diff --git a/examples/browser-webpack/webpack.config.js b/examples/browser-webpack/webpack.config.js
index fbe567ca..6bfb2282 100644
--- a/examples/browser-webpack/webpack.config.js
+++ b/examples/browser-webpack/webpack.config.js
@@ -1,11 +1,12 @@
+import path from 'path'
+import webpack from 'webpack'
+import { merge } from 'webpack-merge'
+import { fileURLToPath } from 'url'
+import CopyWebpackPlugin from 'copy-webpack-plugin'
+import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'
+import HtmlWebpackPlugin from 'html-webpack-plugin'
-const path = require('path')
-const webpack = require('webpack')
-const { merge } = require('webpack-merge')
-
-const CopyWebpackPlugin = require('copy-webpack-plugin')
-const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
/**
* HMR/Live Reloading broken after Webpack 5 rc.0 -> rc.1 update
@@ -161,7 +162,7 @@ const common = {
target: 'web'
}
-module.exports = (cmd) => {
+export default (cmd) => {
const production = cmd.production
const config = production ? prod : dev
diff --git a/examples/circuit-relaying/package.json b/examples/circuit-relaying/package.json
index 226ca938..2fccc0da 100644
--- a/examples/circuit-relaying/package.json
+++ b/examples/circuit-relaying/package.json
@@ -4,22 +4,23 @@
"private": true,
"description": "IPFS quick msg",
"license": "MIT",
+ "type": "module",
"author": "Dmitriy Ryajov ",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
"deploy": "ipfs add -r --quieter dist",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
+ "@libp2p/websockets": "^1.0.8",
"delay": "^5.0.0",
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"ipfs-css": "^1.3.0",
- "ipfs-pubsub-room": "^2.0.1",
- "libp2p-websockets": "^0.16.1",
+ "ipfs-pubsub-room": "^3.0.0",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
@@ -27,12 +28,12 @@
"@playwright/test": "^1.12.3",
"events": "^3.3.0",
"fs-extra": "^10.0.0",
- "ipfs-http-client": "^56.0.0",
- "parcel": "^2.3.2",
+ "ipfs-http-client": "^57.0.1",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/circuit-relaying/src/app.js b/examples/circuit-relaying/src/app.js
index 9399b9ab..9211fbe8 100644
--- a/examples/circuit-relaying/src/app.js
+++ b/examples/circuit-relaying/src/app.js
@@ -1,11 +1,8 @@
/* eslint-disable no-console */
-'use strict'
-
import { create } from 'ipfs-core'
-import WS from 'libp2p-websockets'
-import filters from 'libp2p-websockets/src/filters'
-import Helpers from './helpers'
-const transportKey = WS.prototype[Symbol.toStringTag]
+import { WebSockets } from '@libp2p/websockets'
+import * as filters from '@libp2p/websockets/filters'
+import Helpers from './helpers.js'
document.addEventListener('DOMContentLoaded', async () => {
const $peerId = document.querySelector('#peer-id')
@@ -43,16 +40,14 @@ document.addEventListener('DOMContentLoaded', async () => {
Bootstrap: []
},
libp2p: {
- config: {
- transport: {
- // This is added for local demo!
- // In a production environment the default filter should be used
- // where only DNS + WSS addresses will be dialed by websockets in the browser.
- [transportKey]: {
- filter: filters.all
- }
- }
- }
+ transports: [
+ // This is added for local demo!
+ // In a production environment the default filter should be used
+ // where only DNS + WSS addresses will be dialed by websockets in the browser.
+ new WebSockets({
+ filter: filters.all
+ })
+ ]
}
})
diff --git a/examples/circuit-relaying/src/helpers.js b/examples/circuit-relaying/src/helpers.js
index 9139f136..d7eadad6 100644
--- a/examples/circuit-relaying/src/helpers.js
+++ b/examples/circuit-relaying/src/helpers.js
@@ -1,9 +1,7 @@
/* eslint-disable no-console */
-'use strict'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import Room from 'ipfs-pubsub-room'
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-
-const Room = require('ipfs-pubsub-room')
const $message = document.querySelector('#message')
const $msgs = document.querySelector('#msgs')
const $addrs = document.querySelector('#addrs')
@@ -16,9 +14,9 @@ const mkRoomName = (name) => {
return `${NAMESPACE}-${name}`
}
-module.exports = (ipfs, peersSet) => {
+export default (ipfs, peersSet) => {
const createRoom = (name) => {
- const room = new Room(ipfs, mkRoomName(name))
+ const room = new Room(ipfs.libp2p, mkRoomName(name))
room.on('peer joined', (peer) => {
console.log('peer ' + peer + ' joined')
@@ -34,9 +32,9 @@ module.exports = (ipfs, peersSet) => {
// send and receive messages
room.on('message', (message) => {
- console.log('got message from ' + message.from + ': ' + uint8ArrayToString(message.data))
+ console.log('got message from ' + message.from.toString() + ': ' + uint8ArrayToString(message.data))
const node = document.createElement('li')
- node.innerText = `${message.from.substr(-4)}: ${uint8ArrayToString(message.data)}`
+ node.innerText = `${message.from.toString().substr(-4)}: ${uint8ArrayToString(message.data)}`
$msgs.appendChild(node)
})
@@ -70,7 +68,6 @@ module.exports = (ipfs, peersSet) => {
// see which peers support the circuit relay protocol
const relayAddrs = []
- const connections = ipfs.libp2p.connections
const peers = await ipfs.swarm.peers()
for (let i = 0; i < peers.length; i++) {
@@ -78,7 +75,7 @@ module.exports = (ipfs, peersSet) => {
peer: peerId
} = peers[i]
- const cons = connections.get(peerId)
+ const cons = ipfs.libp2p.getConnections(peerId)
for (let j = 0; j < cons.length; j++) {
const con = cons[j]
diff --git a/examples/circuit-relaying/tests/test.js b/examples/circuit-relaying/tests/test.js
index 44bc1169..a67ca083 100644
--- a/examples/circuit-relaying/tests/test.js
+++ b/examples/circuit-relaying/tests/test.js
@@ -1,10 +1,7 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
-const path = require('path')
-const os = require('os')
-const fs = require('fs-extra')
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
+import * as ipfsHttpModule from 'ipfs-http-client'
+import * as ipfsCoreModule from 'ipfs-core'
// Setup
const play = test.extend({
@@ -22,8 +19,8 @@ const play = test.extend({
),
...playwright.daemons(
{
- ipfsModule: require('ipfs-core'),
- ipfsHttpModule: require('ipfs-http-client')
+ ipfsModule: ipfsCoreModule,
+ ipfsHttpModule
},
{},
[
diff --git a/examples/circuit-relaying/vite.config.js b/examples/circuit-relaying/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/circuit-relaying/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/custom-ipfs-repo/README.md b/examples/custom-ipfs-repo/README.md
index e8ee320a..cc9db347 100644
--- a/examples/custom-ipfs-repo/README.md
+++ b/examples/custom-ipfs-repo/README.md
@@ -81,7 +81,7 @@ This example leverages [datastore-fs](https://github.com/ipfs/js-datastore-fs) t
This example uses one of the locks that comes with IPFS Repo. If you would like to control how locking happens, such as with a centralized S3 IPFS Repo, you can pass in your own custom lock. See [custom-lock.js](./custom-lock.js) for an example of a custom lock that can be used for [datastore-s3](https://github.com/ipfs/js-datastore-s3). This is also being used in the [full S3 example](https://github.com/ipfs/js-datastore-s3/tree/master/examples/full-s3-repo).
```js
-const S3Lock = require('./custom-lock')
+import S3Lock from './custom-lock.js'
const repo = new Repo('/tmp/.ipfs', {
...
diff --git a/examples/custom-ipfs-repo/custom-lock.js b/examples/custom-ipfs-repo/custom-lock.js
index d02f7f21..8f70742b 100644
--- a/examples/custom-ipfs-repo/custom-lock.js
+++ b/examples/custom-ipfs-repo/custom-lock.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const PATH = require('path')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
+import path from 'path'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
/**
* Uses an object in an S3 bucket as a lock to signal that an IPFS repo is in use.
diff --git a/examples/custom-ipfs-repo/index.js b/examples/custom-ipfs-repo/index.js
index 0b884f15..8f6cef0b 100644
--- a/examples/custom-ipfs-repo/index.js
+++ b/examples/custom-ipfs-repo/index.js
@@ -1,19 +1,22 @@
-'use strict'
+import log from 'why-is-node-running'
-const { create } = require('ipfs-core')
-const { createRepo } = require('ipfs-repo')
-const FSLock = require('ipfs-repo/locks/fs')
-const all = require('it-all')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
-const { concat: uint8ArrayConcat } = require('uint8arrays/concat')
-const { FsDatastore } = require('datastore-fs')
-const { BlockstoreDatastoreAdapter } = require('blockstore-datastore-adapter')
+import { create } from 'ipfs-core'
+import { createRepo } from 'ipfs-repo'
+import { FSLock } from 'ipfs-repo/locks/fs'
+import all from 'it-all'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
+import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
+import { FsDatastore } from 'datastore-fs'
+import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter'
+import * as dagPb from '@ipld/dag-pb'
+import * as dagCbor from '@ipld/dag-cbor'
+import * as raw from 'multiformats/codecs/raw'
// multiformat codecs to support
const codecs = [
- require('@ipld/dag-pb'),
- require('@ipld/dag-cbor'),
- require('multiformats/codecs/raw')
+ dagPb,
+ dagCbor,
+ raw
].reduce((acc, curr) => {
acc[curr.name] = curr
acc[curr.code] = curr
@@ -83,6 +86,12 @@ async function main () {
// to demonstrate custom repos
config: {
Bootstrap: []
+ },
+
+ libp2p: {
+ nat: {
+ enabled: false
+ }
}
})
diff --git a/examples/custom-ipfs-repo/package.json b/examples/custom-ipfs-repo/package.json
index 39eac633..b2895b21 100644
--- a/examples/custom-ipfs-repo/package.json
+++ b/examples/custom-ipfs-repo/package.json
@@ -2,6 +2,7 @@
"name": "example-custom-ipfs-repo",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Customizing your ipfs repo",
"license": "MIT",
"main": "index.js",
@@ -16,11 +17,12 @@
"@ipld/dag-pb": "^2.1.3",
"blockstore-datastore-adapter": "^2.0.3",
"datastore-fs": "^7.0.0",
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"ipfs-repo": "^14.0.1",
"it-all": "^1.0.4",
- "multiformats": "^9.4.1",
- "uint8arrays": "^3.0.0"
+ "multiformats": "^9.6.5",
+ "uint8arrays": "^3.0.0",
+ "why-is-node-running": "^2.2.2"
},
"devDependencies": {
"test-util-ipfs-example": "^1.0.2"
diff --git a/examples/custom-ipfs-repo/tests/test.js b/examples/custom-ipfs-repo/tests/test.js
index 188d0651..c9efb05e 100644
--- a/examples/custom-ipfs-repo/tests/test.js
+++ b/examples/custom-ipfs-repo/tests/test.js
@@ -1,8 +1,9 @@
-'use strict'
+import { node } from 'test-util-ipfs-example'
+import path from 'path'
+import fs from 'fs'
+import { fileURLToPath } from 'url'
-const { node } = require('test-util-ipfs-example');
-const path = require('path')
-const fs = require('fs')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function test () {
await node.execa('node', [path.join(__dirname, '../index.js')], {
diff --git a/examples/custom-ipld-formats/daemon-node.js b/examples/custom-ipld-formats/daemon-node.js
index 3894a791..dcb2bbed 100755
--- a/examples/custom-ipld-formats/daemon-node.js
+++ b/examples/custom-ipld-formats/daemon-node.js
@@ -1,7 +1,7 @@
-const { Daemon } = require('ipfs-daemon')
-const ipfsHttpClient = require('ipfs-http-client')
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
+import { Daemon } from 'ipfs-daemon'
+import * as ipfsHttpClient from 'ipfs-http-client'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
async function main () {
// see https://github.com/multiformats/js-multiformats#multicodec-encoders--decoders--codecs for the interface definition
diff --git a/examples/custom-ipld-formats/in-process-node.js b/examples/custom-ipld-formats/in-process-node.js
index 8241bf75..637cf420 100755
--- a/examples/custom-ipld-formats/in-process-node.js
+++ b/examples/custom-ipld-formats/in-process-node.js
@@ -1,8 +1,6 @@
-'use strict'
-
-const IPFS = require('ipfs-core')
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
+import * as IPFS from 'ipfs-core'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
async function main () {
// see https://github.com/multiformats/js-multiformats#multicodec-encoders--decoders--codecs for the interface definition
diff --git a/examples/custom-ipld-formats/package.json b/examples/custom-ipld-formats/package.json
index e4aee2bd..998e5c1d 100644
--- a/examples/custom-ipld-formats/package.json
+++ b/examples/custom-ipld-formats/package.json
@@ -3,6 +3,7 @@
"version": "1.0.0",
"private": true,
"license": "MIT",
+ "type": "module",
"scripts": {
"clean": "echo 'Nothing to clean...'",
"start": "node in-process-node.js & node daemon-node.js",
@@ -11,10 +12,10 @@
},
"dependencies": {
"dag-jose": "^1.0.0",
- "ipfs-core": "^0.14.0",
- "ipfs-daemon": "^0.12.0",
- "ipfs-http-client": "^56.0.0",
- "multiformats": "^9.4.1",
+ "ipfs-core": "^0.15.2",
+ "ipfs-daemon": "^0.13.3",
+ "ipfs-http-client": "^57.0.1",
+ "multiformats": "^9.6.5",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
diff --git a/examples/custom-ipld-formats/tests/test.js b/examples/custom-ipld-formats/tests/test.js
index 2ed3ddcb..d44d0c7a 100644
--- a/examples/custom-ipld-formats/tests/test.js
+++ b/examples/custom-ipld-formats/tests/test.js
@@ -1,7 +1,8 @@
-'use strict'
+import path from 'path'
+import { node } from 'test-util-ipfs-example'
+import { fileURLToPath } from 'url'
-const path = require('path')
-const { node } = require('test-util-ipfs-example');
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
const testInProcessNode = async () => {
await node.waitForOutput(
diff --git a/examples/custom-libp2p/index.js b/examples/custom-libp2p/index.js
index f94d4656..9965e78f 100644
--- a/examples/custom-libp2p/index.js
+++ b/examples/custom-libp2p/index.js
@@ -1,13 +1,11 @@
-'use strict'
-
-const Libp2p = require('libp2p')
-const IPFS = require('ipfs-core')
-const TCP = require('libp2p-tcp')
-const MulticastDNS = require('libp2p-mdns')
-const Bootstrap = require('libp2p-bootstrap')
-const KadDHT = require('libp2p-kad-dht')
-const MPLEX = require('libp2p-mplex')
-const { NOISE } = require('@chainsafe/libp2p-noise')
+import { createLibp2p } from 'libp2p'
+import * as IPFS from 'ipfs-core'
+import { TCP } from '@libp2p/tcp'
+import { MulticastDNS } from '@libp2p/mdns'
+import { Bootstrap } from '@libp2p/bootstrap'
+import { KadDHT } from '@libp2p/kad-dht'
+import { Mplex } from '@libp2p/mplex'
+import { Noise } from '@chainsafe/libp2p-noise'
/**
* Options for the libp2p bundle
@@ -30,7 +28,7 @@ const libp2pBundle = (opts) => {
// Build and return our libp2p node
// n.b. for full configuration options, see https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md
- return Libp2p.create({
+ return createLibp2p({
peerId,
addresses: {
listen: ['/ip4/127.0.0.1/tcp/0']
@@ -39,56 +37,34 @@ const libp2pBundle = (opts) => {
connectionManager: {
minPeers: 25,
maxPeers: 100,
- pollInterval: 5000
- },
- modules: {
- transport: [
- TCP
- ],
- streamMuxer: [
- MPLEX
- ],
- connEncryption: [
- NOISE
- ],
- peerDiscovery: [
- MulticastDNS,
- Bootstrap
- ],
- dht: KadDHT
+ pollInterval: 5000,
+ autoDial: true, // auto dial to peers we find when we have less peers than `connectionManager.minPeers`
},
- config: {
- peerDiscovery: {
- autoDial: true, // auto dial to peers we find when we have less peers than `connectionManager.minPeers`
- mdns: {
- interval: 10000,
- enabled: true
- },
- bootstrap: {
- interval: 30e3,
- enabled: true,
- list: bootstrapList
- }
- },
- // Turn on relay with hop active so we can connect to more peers
- relay: {
- enabled: true,
- hop: {
- enabled: true,
- active: true
- }
- },
- dht: {
+ transports: [
+ new TCP()
+ ],
+ streamMuxers: [
+ new Mplex()
+ ],
+ connectionEncryption: [
+ new Noise()
+ ],
+ peerDiscovery: [
+ new MulticastDNS({
+ interval: 10000
+ }),
+ new Bootstrap({
+ interval: 30e3,
+ list: bootstrapList
+ })
+ ],
+ dht: new KadDHT(),
+ // Turn on relay with hop active so we can connect to more peers
+ relay: {
+ enabled: true,
+ hop: {
enabled: true,
- kBucketSize: 20,
- randomWalk: {
- enabled: true,
- interval: 10e3, // This is set low intentionally, so more peers are discovered quickly. Higher intervals are recommended
- timeout: 2e3 // End the query quickly since we're running so frequently
- }
- },
- pubsub: {
- enabled: true
+ active: true
}
},
metrics: {
diff --git a/examples/custom-libp2p/package.json b/examples/custom-libp2p/package.json
index bec01595..3a8436fd 100644
--- a/examples/custom-libp2p/package.json
+++ b/examples/custom-libp2p/package.json
@@ -2,6 +2,7 @@
"name": "example-custom-libp2p",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Customizing your libp2p node",
"license": "MIT",
"main": "index.js",
@@ -12,14 +13,14 @@
"test": "node tests/test.js"
},
"dependencies": {
- "@chainsafe/libp2p-noise": "^5.0.0",
- "ipfs-core": "^0.14.0",
- "libp2p": "^0.36.2",
- "libp2p-bootstrap": "^0.14.0",
- "libp2p-kad-dht": "^0.28.6",
- "libp2p-mdns": "^0.18.0",
- "libp2p-mplex": "^0.10.2",
- "libp2p-tcp": "^0.17.1",
+ "@chainsafe/libp2p-noise": "^7.0.0",
+ "@libp2p/bootstrap": "^2.0.0",
+ "@libp2p/kad-dht": "^3.0.0",
+ "@libp2p/mdns": "^2.0.0",
+ "@libp2p/mplex": "^3.0.0",
+ "@libp2p/tcp": "^3.0.0",
+ "ipfs-core": "^0.15.2",
+ "libp2p": "^0.37.3",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
diff --git a/examples/custom-libp2p/tests/test.js b/examples/custom-libp2p/tests/test.js
index 6feee62c..569f34ed 100644
--- a/examples/custom-libp2p/tests/test.js
+++ b/examples/custom-libp2p/tests/test.js
@@ -1,13 +1,14 @@
-'use strict'
+import path from 'path'
+import { node } from 'test-util-ipfs-example'
+import { createLibp2p } from 'libp2p'
+import { TCP } from '@libp2p/tcp'
+import { Mplex } from '@libp2p/mplex'
+import { Noise } from '@chainsafe/libp2p-noise'
+import { createEd25519PeerId } from '@libp2p/peer-id-factory'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { fileURLToPath } from 'url'
-const path = require('path')
-const { node } = require('test-util-ipfs-example');
-const Libp2p = require('libp2p')
-const TCP = require('libp2p-tcp')
-const MPLEX = require('libp2p-mplex')
-const { NOISE } = require('@chainsafe/libp2p-noise')
-const PeerId = require('peer-id')
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function test () {
let output = ''
@@ -27,23 +28,21 @@ async function test () {
console.info('Dialling', address)
- const peerId = await PeerId.create()
- const libp2p = await Libp2p.create({
+ const peerId = await createEd25519PeerId()
+ const libp2p = await createLibp2p({
peerId,
addresses: {
listen: ['/ip4/127.0.0.1/tcp/0']
},
- modules: {
- transport: [
- TCP
- ],
- streamMuxer: [
- MPLEX
- ],
- connEncryption: [
- NOISE
- ]
- }
+ transports: [
+ new TCP()
+ ],
+ streamMuxers: [
+ new Mplex()
+ ],
+ connectionEncryption: [
+ new Noise()
+ ]
})
await libp2p.start()
await libp2p.dial(address)
diff --git a/examples/http-client-browser-pubsub/images/ipfs-logo.svg b/examples/http-client-browser-pubsub/images/ipfs-logo.svg
new file mode 100644
index 00000000..5d24074b
--- /dev/null
+++ b/examples/http-client-browser-pubsub/images/ipfs-logo.svg
@@ -0,0 +1 @@
+IPFS logo (new)
\ No newline at end of file
diff --git a/examples/http-client-browser-pubsub/index.html b/examples/http-client-browser-pubsub/index.html
index c7f7dc00..1009cece 100644
--- a/examples/http-client-browser-pubsub/index.html
+++ b/examples/http-client-browser-pubsub/index.html
@@ -24,7 +24,7 @@
diff --git a/examples/http-client-browser-pubsub/package.json b/examples/http-client-browser-pubsub/package.json
index 55283563..5a610466 100644
--- a/examples/http-client-browser-pubsub/package.json
+++ b/examples/http-client-browser-pubsub/package.json
@@ -2,30 +2,31 @@
"name": "example-http-client-browser-pubsub-example",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "An example demonstrating pubsub in the browser",
"license": "MIT",
"author": "Alan Shaw",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests --retries=3"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-http-client": "^56.0.0"
+ "ipfs-http-client": "^57.0.1"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
"go-ipfs": "^0.11.0",
- "ipfs": "^0.62.0",
- "parcel": "^2.3.2",
+ "ipfs": "^0.63.3",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/http-client-browser-pubsub/src/index.js b/examples/http-client-browser-pubsub/src/index.js
index 2871ddb8..3405fa7f 100644
--- a/examples/http-client-browser-pubsub/src/index.js
+++ b/examples/http-client-browser-pubsub/src/index.js
@@ -1,5 +1,3 @@
-'use strict'
-
import { create as IpfsHttpClient } from 'ipfs-http-client'
import { sleep, Logger, onEnterPress, catchAndLog } from './util'
import { toString as uint8ArrayToString } from "uint8arrays/to-string";
@@ -76,10 +74,15 @@ async function main () {
log(`Subscribing to ${nextTopic}...`)
await ipfs.pubsub.subscribe(nextTopic, msg => {
+ console.info('got message', msg)
const from = msg.from
- const seqno = uint8ArrayToString(msg.seqno, 'base16')
- if (from === peerId) return log(`Ignoring message ${seqno} from self`)
- log(`Message ${seqno} from ${from}:`)
+
+ if (peerId.equals(from)) {
+ return log(`Ignoring message ${msg.sequenceNumber} from self`)
+ }
+
+ log(`Message ${msg.sequenceNumber} from ${from}:`)
+
try {
log(JSON.stringify(uint8ArrayToString(msg.data), null, 2))
} catch (_) {
diff --git a/examples/http-client-browser-pubsub/src/util.js b/examples/http-client-browser-pubsub/src/util.js
index c9f6ecbf..8061188d 100644
--- a/examples/http-client-browser-pubsub/src/util.js
+++ b/examples/http-client-browser-pubsub/src/util.js
@@ -1,6 +1,6 @@
-const sleep = (ms = 1000) => new Promise(resolve => setTimeout(resolve, ms))
+export const sleep = (ms = 1000) => new Promise(resolve => setTimeout(resolve, ms))
-const Logger = outEl => {
+export const Logger = outEl => {
outEl.innerHTML = ''
return message => {
const container = document.createElement('div')
@@ -10,7 +10,7 @@ const Logger = outEl => {
}
}
-const onEnterPress = fn => {
+export const onEnterPress = fn => {
return e => {
if (event.which == 13 || event.keyCode == 13) {
e.preventDefault()
@@ -19,7 +19,7 @@ const onEnterPress = fn => {
}
}
-const catchAndLog = (fn, log) => {
+export const catchAndLog = (fn, log) => {
return async (...args) => {
try {
await fn(...args)
@@ -30,9 +30,3 @@ const catchAndLog = (fn, log) => {
}
}
-export {
- sleep,
- Logger,
- onEnterPress,
- catchAndLog
-}
diff --git a/examples/http-client-browser-pubsub/tests/test.js b/examples/http-client-browser-pubsub/tests/test.js
index 664a1a5f..2e18b413 100644
--- a/examples/http-client-browser-pubsub/tests/test.js
+++ b/examples/http-client-browser-pubsub/tests/test.js
@@ -1,21 +1,22 @@
-'use strict'
-
-const { test } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example'
+import * as ipfsModule from 'ipfs'
+import * as ipfsHttpModule from 'ipfs-http-client'
+import * as goIpfsModule from 'go-ipfs'
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsHttpModule: require('ipfs-http-client'),
+ ipfsHttpModule,
},
{
js: {
- ipfsBin: require('ipfs').path()
+ ipfsBin: ipfsModule.path()
},
go: {
- ipfsBin: require('go-ipfs').path(),
+ ipfsBin: goIpfsModule.path(),
args: ['--enable-pubsub-experiment']
}
},
@@ -89,14 +90,17 @@ play.describe('http client pubsub:', () => {
const pageOne = pages[0];
const pageTwo = pages[1];
- const jsDaemon = daemons.find(m => m.api.peerId.agentVersion.includes("js-ipfs"))
- const goDaemon = daemons.find(m => m.api.peerId.agentVersion.includes("go-ipfs"))
+ const jsDaemon = daemons.find(m => {
+ console.info(m._peerId.agentVersion)
+ return m._peerId.agentVersion.includes("js-ipfs")
+ })
+ const goDaemon = daemons.find(m => m._peerId.agentVersion.includes("go-ipfs"))
const goAddress = goDaemon.apiAddr.toString();
const jsAddress = jsDaemon.apiAddr.toString()
- const goPeerIdAddress = goDaemon.api.peerId.addresses[0].toString()
- const jsPeerIdAddress = jsDaemon.api.peerId.addresses[0].toString()
+ const goPeerIdAddress = goDaemon._peerId.addresses[0].toString()
+ const jsPeerIdAddress = jsDaemon._peerId.addresses[0].toString()
await pageOne.fill(apiInput, jsAddress);
await pageOne.click(connectBtn);
@@ -107,7 +111,6 @@ play.describe('http client pubsub:', () => {
await pageTwo.waitForSelector(`${output}:has-text('Connecting to ${goAddress}')`);
// Connect to Peer
-
await pageOne.fill(peerAddressInput, goPeerIdAddress);
await pageOne.click(peerAddressBtn);
await pageOne.waitForSelector(`${output}:has-text('Connecting to peer ${goPeerIdAddress}')`);
diff --git a/examples/http-client-browser-pubsub/vite.config.js b/examples/http-client-browser-pubsub/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/http-client-browser-pubsub/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/http-client-bundle-webpack/package.json b/examples/http-client-bundle-webpack/package.json
index 14ec489c..e25b2296 100644
--- a/examples/http-client-bundle-webpack/package.json
+++ b/examples/http-client-bundle-webpack/package.json
@@ -2,6 +2,7 @@
"name": "example-http-client-bundle-webpack",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Bundle js-ipfs-http-client with Webpack",
"keywords": [],
"license": "MIT",
@@ -17,7 +18,7 @@
"last 1 Chrome version"
],
"dependencies": {
- "ipfs-http-client": "^56.0.0",
+ "ipfs-http-client": "^57.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
@@ -30,7 +31,7 @@
"copy-webpack-plugin": "^10.0.0",
"css-loader": "^6.2.0",
"html-webpack-plugin": "^5.3.1",
- "ipfs": "^0.62.0",
+ "ipfs": "^0.63.3",
"node-polyfill-webpack-plugin": "^1.0.3",
"playwright": "^1.12.3",
"react-hot-loader": "^4.12.21",
diff --git a/examples/http-client-bundle-webpack/src/App.js b/examples/http-client-bundle-webpack/src/App.js
index d2173ea7..4ebdb0e9 100644
--- a/examples/http-client-bundle-webpack/src/App.js
+++ b/examples/http-client-bundle-webpack/src/App.js
@@ -62,7 +62,7 @@ const App = () => {
contents += decoder.decode()
- setId(id.id)
+ setId(id.id.toString())
setVersion(id.agentVersion)
setProtocolVersion(id.protocolVersion)
setAddedFileHash(hash.toString())
diff --git a/examples/http-client-bundle-webpack/src/index.js b/examples/http-client-bundle-webpack/src/index.js
index b2555a80..8168422c 100644
--- a/examples/http-client-bundle-webpack/src/index.js
+++ b/examples/http-client-bundle-webpack/src/index.js
@@ -1,6 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom'
-import App from './App'
+import App from './App.js'
ReactDOM.render( , document.getElementById('root'))
diff --git a/examples/http-client-bundle-webpack/tests/test.js b/examples/http-client-bundle-webpack/tests/test.js
index c552f681..910f281b 100644
--- a/examples/http-client-bundle-webpack/tests/test.js
+++ b/examples/http-client-bundle-webpack/tests/test.js
@@ -1,15 +1,15 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
+import * as ipfsModule from 'ipfs'
+import * as ipfsHttpModule from 'ipfs-http-client'
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsHttpModule: require('ipfs-http-client'),
- ipfsBin: require('ipfs').path()
+ ipfsHttpModule,
+ ipfsBin: ipfsModule.path()
},
{},
[
@@ -52,12 +52,12 @@ play.describe('bundle http client with webpack:', () => {
})
play('should upload a file without file name and display a valid link to preview', async ({ page, daemons}) => {
- const jsDaemon = daemons.find(m => m.api.peerId.agentVersion.includes("js-ipfs"))
+ const jsDaemon = daemons.find(m => m._peerId.agentVersion.includes("js-ipfs"))
let jsAddress = jsDaemon.apiAddr.toString().split('/');
jsAddress.pop();
jsAddress = jsAddress.join('/')
- const jsPeerId = jsDaemon.api.peerId.id.toString();
+ const jsPeerId = jsDaemon.peer.id.toString();
const text = "hello world from webpack IPFS"
await page.fill(textInput, text);
diff --git a/examples/http-client-bundle-webpack/webpack.config.js b/examples/http-client-bundle-webpack/webpack.config.js
index 4ec6270d..cd115a5b 100644
--- a/examples/http-client-bundle-webpack/webpack.config.js
+++ b/examples/http-client-bundle-webpack/webpack.config.js
@@ -1,11 +1,12 @@
+import path from 'path'
+import webpack from 'webpack'
+import { merge } from 'webpack-merge'
+import { fileURLToPath } from 'url'
+import CopyWebpackPlugin from 'copy-webpack-plugin'
+import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'
+import HtmlWebpackPlugin from 'html-webpack-plugin'
-const path = require('path')
-const webpack = require('webpack')
-const { merge } = require('webpack-merge')
-
-const CopyWebpackPlugin = require('copy-webpack-plugin')
-const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
-const HtmlWebpackPlugin = require('html-webpack-plugin')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
/**
* HMR/Live Reloading broken after Webpack 5 rc.0 -> rc.1 update
@@ -161,7 +162,7 @@ const common = {
target: 'web'
}
-module.exports = (cmd) => {
+export default (cmd) => {
const production = cmd.production
const config = production ? prod : dev
diff --git a/examples/http-client-name-api/package.json b/examples/http-client-name-api/package.json
index be867e1f..1a0bbd31 100644
--- a/examples/http-client-name-api/package.json
+++ b/examples/http-client-name-api/package.json
@@ -2,29 +2,30 @@
"name": "example-http-client-name-api",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "",
"license": "MIT",
"author": "Tara Vancil ",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-http-client": "^56.0.0"
+ "ipfs-http-client": "^57.0.1"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
"go-ipfs": "^0.11.0",
- "parcel": "^2.3.2",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/http-client-name-api/src/index.js b/examples/http-client-name-api/src/index.js
index 2e488495..56d47cb0 100644
--- a/examples/http-client-name-api/src/index.js
+++ b/examples/http-client-name-api/src/index.js
@@ -1,6 +1,4 @@
/* eslint-disable no-console */
-'use strict'
-
import { create as ipfsHttp } from 'ipfs-http-client'
const App = () => {
diff --git a/examples/http-client-name-api/tests/test.js b/examples/http-client-name-api/tests/test.js
index b9e0a526..4f6e3d73 100644
--- a/examples/http-client-name-api/tests/test.js
+++ b/examples/http-client-name-api/tests/test.js
@@ -1,15 +1,15 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
+import * as ipfsHttpModule from 'ipfs-http-client'
+import * as goIpfsModule from 'go-ipfs'
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsHttpModule: require('ipfs-http-client'),
- ipfsBin: require('go-ipfs').path(),
+ ipfsHttpModule,
+ ipfsBin: goIpfsModule.path(),
args: ['--enable-pubsub-experiment']
},
{},
@@ -60,7 +60,7 @@ play.describe('bundle http client with webpack: ', () => {
const resolveResult = '#resolve-result'
play.beforeEach(async ({servers, page, daemons}) => {
- await daemons[0].api.swarm.connect(await daemons[1].api.peerId.addresses[0])
+ await daemons[0].api.swarm.connect(await daemons[1]._peerId.addresses[0])
await page.goto(`http://localhost:${servers[0].port}/`);
})
diff --git a/examples/http-client-name-api/vite.config.js b/examples/http-client-name-api/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/http-client-name-api/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/http-client-upload-file/index.html b/examples/http-client-upload-file/index.html
index c545501f..e12d9520 100644
--- a/examples/http-client-upload-file/index.html
+++ b/examples/http-client-upload-file/index.html
@@ -18,7 +18,7 @@
/>
-
+
diff --git a/examples/http-client-upload-file/package.json b/examples/http-client-upload-file/package.json
index 83176032..1ad337ad 100644
--- a/examples/http-client-upload-file/package.json
+++ b/examples/http-client-upload-file/package.json
@@ -2,6 +2,7 @@
"name": "example-http-client-upload-file",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "Upload file to IPFS via browser using js-ipfs-http-client",
"license": "MIT",
"author": "Harlan T Wood ",
@@ -9,27 +10,27 @@
"Victor Bjelkholm "
],
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-http-client": "^56.0.0",
+ "ipfs-http-client": "^57.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "ipfs": "^0.62.0",
- "parcel": "^2.3.2",
+ "ipfs": "^0.63.3",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/http-client-upload-file/src/app.js b/examples/http-client-upload-file/src/app.jsx
similarity index 97%
rename from examples/http-client-upload-file/src/app.js
rename to examples/http-client-upload-file/src/app.jsx
index cff6a4ae..a4d5db91 100644
--- a/examples/http-client-upload-file/src/app.js
+++ b/examples/http-client-upload-file/src/app.jsx
@@ -1,9 +1,7 @@
/* eslint-disable no-console */
-'use strict'
-
import { create } from 'ipfs-http-client'
import React, { useState, useEffect } from 'react'
-import logo from "url:./../public/ipfs-logo.svg";
+import logo from '../public/ipfs-logo.svg'
const Connect = ({ setIpfs }) => {
const [multiaddr, setMultiaddr] = useState('/ip4/127.0.0.1/tcp/5001')
@@ -153,7 +151,7 @@ const Details = ({keys, obj}) => {
{keys?.map((key) => (
{key}
-
{obj[key]}
+
{obj[key].toString()}
))}
>
@@ -221,4 +219,4 @@ const App = () => {
)
}
-module.exports = App
+export default App
diff --git a/examples/http-client-upload-file/src/index.js b/examples/http-client-upload-file/src/index.jsx
similarity index 52%
rename from examples/http-client-upload-file/src/index.js
rename to examples/http-client-upload-file/src/index.jsx
index b575942d..49dcdb0e 100644
--- a/examples/http-client-upload-file/src/index.js
+++ b/examples/http-client-upload-file/src/index.jsx
@@ -1,7 +1,7 @@
/* eslint-disable no-unused-vars */
'use strict'
-const React = require('react')
-const ReactDOM = require('react-dom')
-const App = require('./app')
+import React from 'react'
+import ReactDOM from 'react-dom'
+import App from './app.jsx'
ReactDOM.render( , document.getElementById('root'))
diff --git a/examples/http-client-upload-file/tests/test.js b/examples/http-client-upload-file/tests/test.js
index fed56d52..a67283b5 100644
--- a/examples/http-client-upload-file/tests/test.js
+++ b/examples/http-client-upload-file/tests/test.js
@@ -1,16 +1,19 @@
-'use strict'
+import { test, expect } from '@playwright/test';
+import path from 'path'
+import { playwright } from 'test-util-ipfs-example';
+import { fileURLToPath } from 'url'
+import * as ipfsModule from 'ipfs'
+import * as ipfsHttpModule from 'ipfs-http-client'
-const { test, expect } = require('@playwright/test');
-const path = require('path')
-const { playwright } = require('test-util-ipfs-example');
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsHttpModule: require('ipfs-http-client'),
- ipfsBin: require('ipfs').path()
+ ipfsHttpModule,
+ ipfsBin: ipfsModule.path()
},
{},
[
diff --git a/examples/http-client-upload-file/vite.config.js b/examples/http-client-upload-file/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/http-client-upload-file/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/ipfs-101/README.md b/examples/ipfs-101/README.md
index 22a3d16b..f01d66d9 100644
--- a/examples/ipfs-101/README.md
+++ b/examples/ipfs-101/README.md
@@ -75,7 +75,7 @@ You can find a complete version of this tutorial in [1.js](./1.js). For this tut
Creating an IPFS instance can be done in one line, after requiring the module, you simply have to:
```js
-const IPFS = require("ipfs");
+import * as IPFS from 'ipfs-core';
async function main() {
const node = await IPFS.create();
@@ -88,7 +88,7 @@ main();
As a test, we are going to check the version of the node.
```js
-const IPFS = require("ipfs");
+import * as IPFS from 'ipfs-core';
async function main() {
const node = await IPFS.create();
@@ -115,7 +115,7 @@ Now let's make it more interesting and add a file to IPFS using `node.add`. A fi
You can learn about the IPFS File API at [interface-ipfs-core](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md).
```js
-const IPFS = require("ipfs");
+import * as IPFS from 'ipfs-core';
async function main() {
const node = await IPFS.create();
@@ -149,7 +149,7 @@ Added file: hello.txt QmXgZAUWd8yo4tvjBETqzUy3wLx5YRzuDwUQnBwRGrAmAo
The last step of this tutorial is retrieving the file back using the `cat` 😺 call.
```js
-const IPFS = require("ipfs");
+import * as IPFS from 'ipfs-core';
async function main() {
const node = await IPFS.create();
diff --git a/examples/ipfs-101/index.js b/examples/ipfs-101/index.js
index bf3af728..09ab8680 100755
--- a/examples/ipfs-101/index.js
+++ b/examples/ipfs-101/index.js
@@ -1,10 +1,8 @@
-'use strict'
-
-const IPFS = require('ipfs-core')
-const all = require('it-all')
-const { concat: uint8ArrayConcat } = require('uint8arrays/concat')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
+import * as IPFS from 'ipfs-core'
+import all from 'it-all'
+import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
async function main () {
const node = await IPFS.create()
diff --git a/examples/ipfs-101/package.json b/examples/ipfs-101/package.json
index 882dfb56..84cc9c25 100644
--- a/examples/ipfs-101/package.json
+++ b/examples/ipfs-101/package.json
@@ -2,6 +2,7 @@
"name": "example-ipfs-101",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "this package.json needs to exist because of new npm config https://github.com/ipfs/js-ipfs/issues/977#issuecomment-326741092",
"license": "MIT",
"author": "David Dias ",
@@ -13,7 +14,7 @@
"test": "node tests/test.js"
},
"dependencies": {
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"it-all": "^1.0.4",
"uint8arrays": "^3.0.0"
},
diff --git a/examples/ipfs-101/tests/test.js b/examples/ipfs-101/tests/test.js
index cab0f46a..9a559d6b 100644
--- a/examples/ipfs-101/tests/test.js
+++ b/examples/ipfs-101/tests/test.js
@@ -1,7 +1,8 @@
-'use strict'
+import { node } from 'test-util-ipfs-example'
+import path from 'path'
+import { fileURLToPath } from 'url'
-const { node } = require('test-util-ipfs-example');
-const path = require('path')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function test () {
await node.waitForOutput('Added file contents: Hello World 101', 'node', [path.resolve(__dirname, '../index.js')])
diff --git a/examples/ipfs-client-add-files/package.json b/examples/ipfs-client-add-files/package.json
index a3c964c8..21406910 100644
--- a/examples/ipfs-client-add-files/package.json
+++ b/examples/ipfs-client-add-files/package.json
@@ -2,27 +2,28 @@
"name": "example-ipfs-client-add-files",
"version": "1.0.0",
"private": true,
+ "type": "module",
"description": "",
"scripts": {
- "clean": "rimraf ./dist ./.cache ./.parcel-cache",
- "build": "parcel build index.html --no-scope-hoist",
- "serve": "parcel serve index.html --open -p 8888",
+ "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
+ "build": "vite build",
+ "serve": "vite dev --port 8888",
"start": "npm run serve",
"test": "npm run build && playwright test tests"
},
"browserslist": "last 1 Chrome version",
"dependencies": {
- "ipfs-client": "^0.7.6"
+ "ipfs-client": "^0.8.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@playwright/test": "^1.12.3",
- "ipfs": "^0.62.0",
- "parcel": "^2.3.2",
+ "ipfs": "^0.63.3",
"playwright": "^1.12.3",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"test-util-ipfs-example": "^1.0.2",
- "util": "^0.12.4"
+ "util": "^0.12.4",
+ "vite": "^3.0.0-beta.1"
}
}
diff --git a/examples/ipfs-client-add-files/src/app.js b/examples/ipfs-client-add-files/src/app.js
index e8135c9e..73824a7c 100644
--- a/examples/ipfs-client-add-files/src/app.js
+++ b/examples/ipfs-client-add-files/src/app.js
@@ -1,6 +1,4 @@
/* eslint-disable no-console */
-'use strict'
-
import { create as ipfsClient } from 'ipfs-client'
const App = () => {
diff --git a/examples/ipfs-client-add-files/tests/test.js b/examples/ipfs-client-add-files/tests/test.js
index f20769bf..6da08095 100644
--- a/examples/ipfs-client-add-files/tests/test.js
+++ b/examples/ipfs-client-add-files/tests/test.js
@@ -1,15 +1,15 @@
-'use strict'
-
-const { test, expect } = require('@playwright/test');
-const { playwright } = require('test-util-ipfs-example');
+import { test, expect } from '@playwright/test';
+import { playwright } from 'test-util-ipfs-example';
+import * as ipfsModule from 'ipfs'
+import * as ipfsClientModule from 'ipfs-client'
// Setup
const play = test.extend({
...playwright.servers(),
...playwright.daemons(
{
- ipfsClientModule: require('ipfs-client'),
- ipfsBin: require('ipfs').path()
+ ipfsClientModule,
+ ipfsBin: ipfsModule.path()
},
{},
[
diff --git a/examples/ipfs-client-add-files/vite.config.js b/examples/ipfs-client-add-files/vite.config.js
new file mode 100644
index 00000000..1ae5efa8
--- /dev/null
+++ b/examples/ipfs-client-add-files/vite.config.js
@@ -0,0 +1,10 @@
+export default {
+ build: {
+ target: 'esnext',
+ minify: false
+ },
+ define: {
+ 'process.env.NODE_DEBUG': 'false',
+ 'global': 'globalThis'
+ }
+}
diff --git a/examples/run-in-electron/main.js b/examples/run-in-electron/main.js
index a65ad485..ce98e478 100755
--- a/examples/run-in-electron/main.js
+++ b/examples/run-in-electron/main.js
@@ -1,7 +1,4 @@
-"use strict";
-
-const { app, BrowserWindow } = require("electron");
-const IPFS = require("ipfs-core");
+const { app, BrowserWindow } = require('electron')
let mainWindow;
@@ -30,6 +27,7 @@ app.on("ready", async () => {
createWindow();
try {
+ const IPFS = await import('ipfs-core')
const node = await IPFS.create();
const id = await node.id();
console.log(id);
diff --git a/examples/run-in-electron/package.json b/examples/run-in-electron/package.json
index 5fd0fd9f..929e35fd 100644
--- a/examples/run-in-electron/package.json
+++ b/examples/run-in-electron/package.json
@@ -10,15 +10,15 @@
],
"license": "MIT",
"author": "David Dias ",
- "main": "main.js",
+ "main": "main.cjs",
"scripts": {
"clean": "echo 'Nothing to clean...'",
"start": "electron .",
"serve": "npm run start",
- "test": "node test.js"
+ "test": "node test.mjs"
},
"dependencies": {
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2"
},
"devDependencies": {
"electron": "^17.0.0",
diff --git a/examples/run-in-electron/test.js b/examples/run-in-electron/test.js
deleted file mode 100644
index 6c647f54..00000000
--- a/examples/run-in-electron/test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-"use strict";
-
-const { node } = require("test-util-ipfs-example");
-const path = require("path");
-
-async function test() {
- await node.waitForOutput("protocolVersion", "electron", [
- path.resolve(`${__dirname}/main.js`)
- ]);
-}
-
-test();
diff --git a/examples/run-in-electron/test.mjs b/examples/run-in-electron/test.mjs
new file mode 100644
index 00000000..9649a959
--- /dev/null
+++ b/examples/run-in-electron/test.mjs
@@ -0,0 +1,15 @@
+"use strict";
+
+import { node } from "test-util-ipfs-example";
+import path from "path"
+import { fileURLToPath } from 'url'
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
+
+async function test() {
+ await node.waitForOutput("protocolVersion", "electron", [
+ path.resolve(`${__dirname}/main.js`)
+ ]);
+}
+
+test();
diff --git a/examples/running-multiple-nodes/package.json b/examples/running-multiple-nodes/package.json
index eb25d6cc..bb18e0ec 100644
--- a/examples/running-multiple-nodes/package.json
+++ b/examples/running-multiple-nodes/package.json
@@ -2,6 +2,7 @@
"name": "example-running-multiple-nodes",
"version": "2.0.1",
"private": true,
+ "type": "module",
"description": "How to run multiple IPFS nodes at the same time",
"keywords": [],
"license": "MIT",
@@ -13,7 +14,7 @@
"test": "node tests/test.js"
},
"dependencies": {
- "ipfs": "^0.62.0"
+ "ipfs": "^0.63.3"
},
"devDependencies": {
"nanoid": "^3.1.23",
diff --git a/examples/running-multiple-nodes/tests/test.js b/examples/running-multiple-nodes/tests/test.js
index cb73a78a..ce2f06aa 100644
--- a/examples/running-multiple-nodes/tests/test.js
+++ b/examples/running-multiple-nodes/tests/test.js
@@ -1,10 +1,8 @@
-'use strict'
-
-const IPFS = require('ipfs')
-const os = require('os')
-const path = require('path')
-const { nanoid } = require('nanoid')
-const { node } = require('test-util-ipfs-example');
+import * as IPFS from 'ipfs'
+import os from 'os'
+import path from 'path'
+import { nanoid } from 'nanoid'
+import { node } from 'test-util-ipfs-example'
async function startCliNode () {
const repoDir = path.join(os.tmpdir(), `repo-${nanoid()}`)
diff --git a/examples/traverse-ipld-graphs/README.md b/examples/traverse-ipld-graphs/README.md
index e7eb8e15..49e11962 100644
--- a/examples/traverse-ipld-graphs/README.md
+++ b/examples/traverse-ipld-graphs/README.md
@@ -84,15 +84,19 @@ By default IPFS is bundled with [dag-pb](https://www.npmjs.com/package/ipld-dag-
To configure other types, we must pass the `ipld.formats` option to the `IPFS.create()` function:
```javascript
-const IPFS = require("ipfs");
+import * as IPFS from 'ipfs'
+import * as ipldGit from 'ipld-git'
+import * as ipldZcash from 'ipld-zcash'
+import * as ipldBitcoin from 'ipld-bitcoin'
+import * as ipldEth from 'ipld-ethereum'
const node = await IPFS.create({
ipld: {
formats: [
- require("ipld-git"),
- require("ipld-zcash"),
- require("ipld-bitcoin"),
- ...Object.values(require("ipld-ethereum")), // this format exports multiple codecs so flatten into a list
+ ipldGit,
+ ipldZcash,
+ ipldBitcoin,
+ ...Object.values(ipldEth), // this format exports multiple codecs so flatten into a list
// etc, etc
],
},
diff --git a/examples/traverse-ipld-graphs/create-node.js b/examples/traverse-ipld-graphs/create-node.js
index 6698c437..7e424411 100644
--- a/examples/traverse-ipld-graphs/create-node.js
+++ b/examples/traverse-ipld-graphs/create-node.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const IPFS = require('ipfs-core')
+import * as IPFS from 'ipfs-core'
function createNode (options) {
options = options || {}
@@ -20,4 +18,4 @@ function createNode (options) {
})
}
-module.exports = createNode
+export default createNode
diff --git a/examples/traverse-ipld-graphs/eth.js b/examples/traverse-ipld-graphs/eth.js
index 20215a3d..e4c96c41 100644
--- a/examples/traverse-ipld-graphs/eth.js
+++ b/examples/traverse-ipld-graphs/eth.js
@@ -1,19 +1,21 @@
-'use strict'
+import createNode from './create-node.js'
+import path from 'path'
+import { CID } from 'multiformats/cid'
+import * as MultihashDigest from 'multiformats/hashes/digest'
+import fs from 'fs/promises'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { convert } from 'ipld-format-to-blockcodec'
+import sha3 from 'js-sha3'
+import { fileURLToPath } from 'url'
+import * as ipldEth from 'ipld-ethereum'
-const createNode = require('./create-node')
-const path = require('path')
-const { CID } = require('multiformats/cid')
-const MultihashDigest = require('multiformats/hashes/digest')
-const fs = require('fs').promises
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-const { convert } = require('ipld-format-to-blockcodec')
-const sha3 = require('js-sha3')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function main () {
const ipfs = await createNode({
ipld: {
codecs: [
- ...Object.values(require('ipld-ethereum')).map(format => convert(format))
+ ...Object.values(ipldEth).map(format => convert(format))
],
hashers: [{
name: 'keccak-256',
diff --git a/examples/traverse-ipld-graphs/get-path-accross-formats.js b/examples/traverse-ipld-graphs/get-path-accross-formats.js
index 7a2e4471..cc33386c 100644
--- a/examples/traverse-ipld-graphs/get-path-accross-formats.js
+++ b/examples/traverse-ipld-graphs/get-path-accross-formats.js
@@ -1,7 +1,5 @@
-'use strict'
-
-const createNode = require('./create-node')
-const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
+import createNode from './create-node.js'
+import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
async function main () {
const ipfs = await createNode()
diff --git a/examples/traverse-ipld-graphs/get-path.js b/examples/traverse-ipld-graphs/get-path.js
index 0cf13d2c..16205b3f 100644
--- a/examples/traverse-ipld-graphs/get-path.js
+++ b/examples/traverse-ipld-graphs/get-path.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const createNode = require('./create-node')
+import createNode from './create-node.js'
async function main () {
const ipfs = await createNode()
diff --git a/examples/traverse-ipld-graphs/get.js b/examples/traverse-ipld-graphs/get.js
index cf045571..071f6220 100644
--- a/examples/traverse-ipld-graphs/get.js
+++ b/examples/traverse-ipld-graphs/get.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const createNode = require('./create-node')
+import createNode from './create-node.js'
async function main () {
const ipfs = await createNode()
diff --git a/examples/traverse-ipld-graphs/git.js b/examples/traverse-ipld-graphs/git.js
index ff0f7647..8cad07be 100644
--- a/examples/traverse-ipld-graphs/git.js
+++ b/examples/traverse-ipld-graphs/git.js
@@ -1,19 +1,21 @@
-'use strict'
+import createNode from './create-node.js'
+import path from 'path'
+import { CID } from 'multiformats/cid'
+import * as MultihashDigest from 'multiformats/hashes/digest'
+import fs from 'fs/promises'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
+import { convert } from 'ipld-format-to-blockcodec'
+import crypto from 'crypto'
+import { fileURLToPath } from 'url'
+import ipldGit from 'ipld-git'
-const createNode = require('./create-node')
-const path = require('path')
-const { CID } = require('multiformats/cid')
-const MultihashDigest = require('multiformats/hashes/digest')
-const fs = require('fs').promises
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
-const { convert } = require('ipld-format-to-blockcodec')
-const crypto = require('crypto')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function main () {
const ipfs = await createNode({
ipld: {
codecs: [
- convert(require('ipld-git'))
+ convert(ipldGit)
],
hashers: [{
name: 'sha1',
diff --git a/examples/traverse-ipld-graphs/package.json b/examples/traverse-ipld-graphs/package.json
index 520e4c47..5e0d6fcd 100644
--- a/examples/traverse-ipld-graphs/package.json
+++ b/examples/traverse-ipld-graphs/package.json
@@ -2,6 +2,7 @@
"name": "example-traverse-ipld-graphs",
"version": "2.0.1",
"private": true,
+ "type": "module",
"description": "How to traverse IPLD graphs",
"keywords": [],
"license": "MIT",
@@ -14,12 +15,12 @@
},
"dependencies": {
"@ipld/dag-pb": "^2.1.3",
- "ipfs-core": "^0.14.0",
+ "ipfs-core": "^0.15.2",
"ipld-ethereum": "^6.0.0",
"ipld-format-to-blockcodec": "0.0.1",
"ipld-git": "^0.6.1",
"js-sha3": "^0.8.0",
- "multiformats": "^9.4.1"
+ "multiformats": "^9.6.5"
},
"devDependencies": {
"test-util-ipfs-example": "^1.0.2"
diff --git a/examples/traverse-ipld-graphs/put.js b/examples/traverse-ipld-graphs/put.js
index 197425f3..cfd2aac4 100644
--- a/examples/traverse-ipld-graphs/put.js
+++ b/examples/traverse-ipld-graphs/put.js
@@ -1,6 +1,4 @@
-'use strict'
-
-const createNode = require('./create-node')
+import createNode from './create-node.js'
async function main () {
const ipfs = await createNode()
diff --git a/examples/traverse-ipld-graphs/tests/test.js b/examples/traverse-ipld-graphs/tests/test.js
index 7ed9a33b..aa87e6d0 100644
--- a/examples/traverse-ipld-graphs/tests/test.js
+++ b/examples/traverse-ipld-graphs/tests/test.js
@@ -1,7 +1,8 @@
-'use strict'
+import path from 'path'
+import { node } from 'test-util-ipfs-example'
+import { fileURLToPath } from 'url'
-const path = require('path')
-const { node } = require('test-util-ipfs-example');
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
async function runTest () {
console.info('Testing put.js')
diff --git a/examples/types-use-ipfs-from-ts/package.json b/examples/types-use-ipfs-from-ts/package.json
index c98b316f..5f6f0792 100644
--- a/examples/types-use-ipfs-from-ts/package.json
+++ b/examples/types-use-ipfs-from-ts/package.json
@@ -8,7 +8,8 @@
"test": "tsc --noEmit"
},
"dependencies": {
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2",
+ "multiformats": "^9.6.5"
},
"devDependencies": {
"typescript": "^4.5.5"
diff --git a/examples/types-use-ipfs-from-ts/src/main.ts b/examples/types-use-ipfs-from-ts/src/main.ts
index 262a114b..1fbebcdb 100644
--- a/examples/types-use-ipfs-from-ts/src/main.ts
+++ b/examples/types-use-ipfs-from-ts/src/main.ts
@@ -1,5 +1,5 @@
import { IPFS, create } from 'ipfs-core'
-import type { CID } from 'ipfs-core'
+import type { CID } from 'multiformats/cid'
export default async function main() {
const node = await create()
diff --git a/examples/types-use-ipfs-from-typed-js/package.json b/examples/types-use-ipfs-from-typed-js/package.json
index 0c1d1eb6..e6bc10f7 100644
--- a/examples/types-use-ipfs-from-typed-js/package.json
+++ b/examples/types-use-ipfs-from-typed-js/package.json
@@ -8,7 +8,8 @@
"test": "tsc --noEmit"
},
"dependencies": {
- "ipfs-core": "^0.14.0"
+ "ipfs-core": "^0.15.2",
+ "multiformats": "^9.6.5"
},
"devDependencies": {
"typescript": "^4.5.5"
diff --git a/examples/types-use-ipfs-from-typed-js/src/main.js b/examples/types-use-ipfs-from-typed-js/src/main.js
index 2222b4ff..82cacf4d 100644
--- a/examples/types-use-ipfs-from-typed-js/src/main.js
+++ b/examples/types-use-ipfs-from-typed-js/src/main.js
@@ -1,8 +1,8 @@
-const { create } = require('ipfs-core')
+import { create } from 'ipfs-core'
/**
* @typedef {import('ipfs-core').IPFS} IPFS
- * @typedef {import('ipfs-core').CID} CID
+ * @typedef {import('multiformats/cid').CID} CID
*/
async function main () {
diff --git a/lib/test-util-ipfs-example/index.js b/lib/test-util-ipfs-example/index.js
index c81598a6..08cf883a 100644
--- a/lib/test-util-ipfs-example/index.js
+++ b/lib/test-util-ipfs-example/index.js
@@ -1,9 +1,3 @@
-'use strict'
-const playwright = require('./playwright/index')
-const node = require('./node/index')
-
-module.exports = {
- playwright,
- node
-}
+export * as playwright from './playwright/index.js'
+export * as node from './node/index.js'
diff --git a/lib/test-util-ipfs-example/node/execa.js b/lib/test-util-ipfs-example/node/execa.js
index 5f5c4f7d..2051aa15 100644
--- a/lib/test-util-ipfs-example/node/execa.js
+++ b/lib/test-util-ipfs-example/node/execa.js
@@ -1,8 +1,7 @@
-"use strict";
-const fs = require('fs-extra')
-const execa = require('execa')
-const which = require('which')
+import fs from 'fs-extra'
+import { execa } from 'execa'
+import which from 'which'
async function isExecutable(command) {
try {
@@ -37,4 +36,4 @@ async function execaUtil(command, args = [], opts = {}, callback = null) {
return proc
}
-module.exports = execaUtil;
+export default execaUtil;
diff --git a/lib/test-util-ipfs-example/node/index.js b/lib/test-util-ipfs-example/node/index.js
index bb5f8109..132414f5 100644
--- a/lib/test-util-ipfs-example/node/index.js
+++ b/lib/test-util-ipfs-example/node/index.js
@@ -1,9 +1,3 @@
-'use strict'
-const waitForOutput = require('./waitForOutput')
-const execa = require('./execa')
-
-module.exports = {
- waitForOutput,
- execa
-}
+export { default as waitForOutput } from './wait-for-output.js'
+export { default as execa } from './execa.js'
diff --git a/lib/test-util-ipfs-example/node/waitForOutput.js b/lib/test-util-ipfs-example/node/wait-for-output.js
similarity index 88%
rename from lib/test-util-ipfs-example/node/waitForOutput.js
rename to lib/test-util-ipfs-example/node/wait-for-output.js
index f927ccc7..af91f58d 100644
--- a/lib/test-util-ipfs-example/node/waitForOutput.js
+++ b/lib/test-util-ipfs-example/node/wait-for-output.js
@@ -1,7 +1,5 @@
-"use strict";
-
-const execaUtil = require('./execa')
-const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
+import execaUtil from './execa.js'
+import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
async function waitForOutput(expectedOutput, command, args = [], opts = {}) {
const proc = execaUtil(command, args, { ...opts, all: true }, (exec) => {
@@ -60,4 +58,4 @@ async function waitForOutput(expectedOutput, command, args = [], opts = {}) {
}
}
-module.exports = waitForOutput;
+export default waitForOutput
diff --git a/lib/test-util-ipfs-example/package.json b/lib/test-util-ipfs-example/package.json
index 73b98f4c..d8fa7363 100644
--- a/lib/test-util-ipfs-example/package.json
+++ b/lib/test-util-ipfs-example/package.json
@@ -2,6 +2,7 @@
"name": "test-util-ipfs-example",
"version": "1.0.2",
"description": "Utilities to test ipfs examples",
+ "type": "module",
"keywords": [
"test",
"examples",
@@ -18,17 +19,18 @@
"author": "Oliverio Sousa",
"main": "index.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
- "start": "node server.js"
+ "test": "echo \"Error: no test specified\"",
+ "start": "node server.js",
+ "clean": "echo Nothing to clean..."
},
"dependencies": {
- "execa": "^5.1.1",
- "fs-extra": "^9.1.0",
- "ipfsd-ctl": "^10.0.3",
+ "execa": "^6.0.0",
+ "fs-extra": "^10.1.0",
+ "ipfsd-ctl": "^11.0.1",
"polka": "^0.5.2",
- "sirv": "^1.0.12",
+ "sirv": "^2.0.2",
"stoppable": "^1.1.0",
- "uint8arrays": "^2.1.7",
+ "uint8arrays": "^3.0.0",
"which": "^2.0.2"
}
}
diff --git a/lib/test-util-ipfs-example/playwright/daemons.js b/lib/test-util-ipfs-example/playwright/daemons.js
index 8a728b94..5a45d29f 100644
--- a/lib/test-util-ipfs-example/playwright/daemons.js
+++ b/lib/test-util-ipfs-example/playwright/daemons.js
@@ -1,4 +1,4 @@
-const { createFactory } = require('ipfsd-ctl')
+import { createFactory } from 'ipfsd-ctl'
const daemons = (factoryOptions, factoryOverrideOptions, spawnOptions) => {
return {
@@ -25,4 +25,4 @@ const daemons = (factoryOptions, factoryOverrideOptions, spawnOptions) => {
}
}
-module.exports = daemons;
+export default daemons
diff --git a/lib/test-util-ipfs-example/playwright/index.js b/lib/test-util-ipfs-example/playwright/index.js
index 471bfd94..2e67839b 100644
--- a/lib/test-util-ipfs-example/playwright/index.js
+++ b/lib/test-util-ipfs-example/playwright/index.js
@@ -1,9 +1,4 @@
-'use strict'
-const servers = require('./servers')
-const daemons = require('./daemons')
+export { default as servers } from './servers.js'
+export { default as daemons } from './daemons.js'
-module.exports = {
- servers,
- daemons
-}
diff --git a/lib/test-util-ipfs-example/playwright/servers.js b/lib/test-util-ipfs-example/playwright/servers.js
index f2b6c731..55e89c9f 100644
--- a/lib/test-util-ipfs-example/playwright/servers.js
+++ b/lib/test-util-ipfs-example/playwright/servers.js
@@ -1,6 +1,6 @@
-const sirv = require('sirv')
-const polka = require('polka')
-const stoppable = require('stoppable')
+import sirv from 'sirv'
+import polka from 'polka'
+import stoppable from 'stoppable'
const servers = (serverConfiguration = []) => {
return {
@@ -23,7 +23,7 @@ const servers = (serverConfiguration = []) => {
const port = configuration.portToUse + workerInfo.workerIndex;
// Setup polka app.
- const static = sirv(configuration.folderToServe, {
+ const staticFiles = sirv(configuration.folderToServe, {
maxAge: 31536000, // 1Y
immutable: true
});
@@ -34,7 +34,7 @@ const servers = (serverConfiguration = []) => {
promiseServers.push(new Promise((resolve, reject) => {
app
- .use(static)
+ .use(staticFiles)
.listen(port, err => {
if (err) throw err;
@@ -65,4 +65,4 @@ const servers = (serverConfiguration = []) => {
}
}
-module.exports = servers;
+export default servers;
diff --git a/package.json b/package.json
index a3fd89e4..43122351 100644
--- a/package.json
+++ b/package.json
@@ -17,13 +17,14 @@
},
"license": "MIT",
"workspaces": [
- "examples/!(browser-nextjs)"
+ "examples/!(ipfs-client-add-files)",
+ "lib/*"
],
"scripts": {
"clean": "yarn run clean:examples && yarn run clean:yarn && yarn run clean:build && yarn run clean:npm",
"clean:npm": "rimraf ./**/package-lock.json ./**/node_modules",
"clean:yarn": "rimraf ./**/yarn.lock",
- "clean:build": "rimraf ./**/.parcel-cache ./**/build ./**/dist ./**/.next",
+ "clean:build": "rimraf ./**/node_modules/.vite ./**/build ./**/dist ./**/.next",
"clean:examples": "yarn workspaces run clean",
"test:examples": "yarn workspaces run test",
"test": "yarn run test:examples",
@@ -31,5 +32,8 @@
},
"devDependencies": {
"rimraf": "^3.0.2"
+ },
+ "dependencies": {
+ "@libp2p/webrtc-star-signalling-server": "^2.0.1"
}
}
diff --git a/scripts/update-example-deps.js b/scripts/update-example-deps.js
index f09192ad..c0328f7a 100644
--- a/scripts/update-example-deps.js
+++ b/scripts/update-example-deps.js
@@ -1,8 +1,9 @@
-'use strict'
+import path from 'path'
+import fs from 'fs'
+import execa from 'execa'
+import { fileURLToPath } from 'url'
-const path = require('path')
-const fs = require('fs')
-const execa = require('execa')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Where an example depends on `"ipfs": "^0.51.0"` and we've just released `ipfs@0.52.0`,
// go through all of the examples and update the version to `"ipfs": "^0.52.0"` - do