├── .editorconfig
├── .github
├── dependabot.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── No-real-changes.tmp
├── README.md
├── examples
├── browser-add-readable-stream
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── index.js
│ │ └── style.css
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-angular
│ ├── .browserslistrc
│ ├── .editorconfig
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── .gitignore
│ ├── README.md
│ ├── angular.json
│ ├── extra-webpack.config.js
│ ├── karma.conf.js
│ ├── package.json
│ ├── src
│ │ ├── app
│ │ │ ├── app-routing.module.ts
│ │ │ ├── app.component.css
│ │ │ ├── app.component.html
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ ├── app.module.ts
│ │ │ ├── ipfs.service.spec.ts
│ │ │ └── ipfs.service.ts
│ │ ├── assets
│ │ │ └── .gitkeep
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.css
│ │ └── test.ts
│ ├── tests
│ │ └── test.js
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ └── tsconfig.spec.json
├── browser-create-react-app
│ ├── .env
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ └── screenshot.png
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── robots.txt
│ ├── src
│ │ ├── App.css
│ │ ├── App.js
│ │ ├── App.test.js
│ │ ├── hooks
│ │ │ ├── use-ipfs-factory.js
│ │ │ └── use-ipfs.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── ipfs-logo.svg
│ │ ├── logo.svg
│ │ ├── reportWebVitals.js
│ │ └── setupTests.js
│ └── tests
│ │ └── test.mjs
├── browser-esbuild
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── esbuild.js
│ ├── favicon.ico
│ ├── img
│ │ ├── 1.png
│ │ └── 2.png
│ ├── package.json
│ ├── src
│ │ ├── index.html
│ │ ├── index.js
│ │ ├── ipfs-logo.svg
│ │ └── style.css
│ └── tests
│ │ └── test.js
├── browser-exchange-files
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ ├── connect-1.png
│ │ ├── connect-2.png
│ │ ├── diagram.monopic
│ │ ├── diagram.txt
│ │ ├── fetch.png
│ │ ├── goal.png
│ │ └── pubsub.png
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ ├── download.svg
│ │ ├── ipfs-logo.svg
│ │ └── upload.svg
│ ├── src
│ │ ├── app.css
│ │ └── app.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-ipns-publish
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── index.js
│ │ └── util.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-lit
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ └── screenshot.png
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── index.js
│ │ └── ipfs.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-mfs
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ ├── screenshot_1.png
│ │ └── screenshot_2.png
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── app.css
│ │ ├── filetree.js
│ │ ├── forms.js
│ │ ├── index.js
│ │ └── utils.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-nextjs
│ ├── .eslintrc
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── .gitignore
│ ├── README.md
│ ├── components
│ │ └── ipfs.js
│ ├── next.config.js
│ ├── package.json
│ ├── pages
│ │ ├── _app.js
│ │ ├── api
│ │ │ └── hello.js
│ │ └── index.js
│ ├── public
│ │ ├── favicon.ico
│ │ └── vercel.svg
│ ├── styles
│ │ ├── Home.module.css
│ │ └── globals.css
│ └── tests
│ │ └── test.js
├── browser-readablestream
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── index.js
│ │ ├── style.css
│ │ └── utils.js
│ ├── tests
│ │ ├── test.js
│ │ └── test.mp4
│ └── vite.config.js
├── browser-script-tag
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ └── index.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-service-worker
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ ├── index-view.png
│ │ └── page-view.png
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── app.css
│ │ ├── main.js
│ │ ├── service.js
│ │ ├── service
│ │ │ └── util.js
│ │ └── worker.js
│ ├── tests
│ │ └── test.js
│ ├── tsconfig.json
│ └── webpack.config.js
├── browser-sharing-node-across-tabs
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ └── screenshot.png
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── main.js
│ │ └── worker.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-video-streaming
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ └── index.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-vite
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ ├── 1.png
│ │ └── 2.png
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── index.js
│ │ └── style.css
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── browser-vue
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── .npmrc
│ ├── README.md
│ ├── babel.config.cjs
│ ├── img
│ │ └── ipfs-vue-screenshot.png
│ ├── jsconfig.json
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── App.vue
│ │ ├── assets
│ │ │ ├── logo.svg
│ │ │ └── vue_logo.png
│ │ ├── components
│ │ │ ├── HelloWorld.vue
│ │ │ └── IpfsInfo.vue
│ │ ├── main.js
│ │ └── plugins
│ │ │ └── vue-ipfs.js
│ └── tests
│ │ └── test.js
├── browser-webpack
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ └── 1.png
│ ├── package.json
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── app.css
│ │ ├── app.js
│ │ ├── index.js
│ │ └── ipfs-logo.svg
│ ├── tests
│ │ └── test.js
│ └── webpack.config.js
├── circuit-relaying
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ ├── img1.png
│ │ ├── img2.png
│ │ ├── img3.png
│ │ ├── img4.png
│ │ ├── img5.png
│ │ ├── img6.png
│ │ └── img7.png
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── app.js
│ │ ├── helpers.js
│ │ └── style.css
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── custom-ipfs-repo
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── custom-lock.js
│ ├── index.js
│ ├── package.json
│ └── tests
│ │ └── test.js
├── custom-ipld-formats
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── daemon-node.js
│ ├── in-process-node.js
│ ├── package.json
│ └── tests
│ │ └── test.js
├── custom-libp2p
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── index.js
│ ├── package.json
│ └── tests
│ │ └── test.js
├── http-client-browser-pubsub
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── images
│ │ └── ipfs-logo.svg
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── index.js
│ │ └── util.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── http-client-bundle-webpack
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ └── screenshot.png
│ ├── package.json
│ ├── public
│ │ ├── assets
│ │ │ └── ipfs-logo.svg
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── App.js
│ │ └── index.js
│ ├── tests
│ │ └── test.js
│ └── webpack.config.js
├── http-client-name-api
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ └── index.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── http-client-upload-file
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── img
│ │ └── screenshot.png
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── app.css
│ │ ├── app.jsx
│ │ └── index.jsx
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── ipfs-101
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── hello.txt
│ ├── index.js
│ ├── package.json
│ └── tests
│ │ └── test.js
├── ipfs-client-add-files
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── favicon.ico
│ ├── index.html
│ ├── package.json
│ ├── public
│ │ └── ipfs-logo.svg
│ ├── src
│ │ ├── app.css
│ │ └── app.js
│ ├── tests
│ │ └── test.js
│ └── vite.config.js
├── run-in-electron
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── index.html
│ ├── main.js
│ ├── package.json
│ ├── renderer.js
│ └── test.mjs
├── running-multiple-nodes
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── package.json
│ └── tests
│ │ └── test.js
├── traverse-ipld-graphs
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── create-node.js
│ ├── eth-blocks
│ │ ├── block_302515
│ │ ├── block_302516
│ │ └── block_302517
│ ├── eth.js
│ ├── get-path-accross-formats.js
│ ├── get-path.js
│ ├── get.js
│ ├── git-objects
│ │ ├── 0f328c91df28c5c01b9e9f9f7e663191fa156593
│ │ ├── 177bf18bc707d82b21cdefd0b43b38fc8c5c13fe
│ │ ├── 23cc25f631cb076d5de5036c87678ea713cbaa6a
│ │ ├── 4e425dba7745a781f0712c9a01455899e8c0c249
│ │ ├── 6850c7be7136e6be00976ddbae80671b945c3e9d
│ │ ├── a5095353cd62a178663dd26efc2d61f4f61bccbe
│ │ ├── dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
│ │ ├── e68e6f6e31857877a79fd6b3956898436bb5a76f
│ │ ├── ee62b3d206cb23f939208898f32d8708c0e3fa3c
│ │ └── ee71cef5001b84b0314438f76cf0acd338a2fd21
│ ├── git.js
│ ├── package.json
│ ├── put.js
│ └── tests
│ │ └── test.js
├── types-use-ipfs-from-ts
│ ├── .github
│ │ ├── pull_request_template.md
│ │ └── workflows
│ │ │ └── sync.yml
│ ├── README.md
│ ├── img
│ │ └── preview.png
│ ├── package.json
│ ├── src
│ │ └── main.ts
│ └── tsconfig.json
└── types-use-ipfs-from-typed-js
│ ├── .github
│ ├── pull_request_template.md
│ └── workflows
│ │ └── sync.yml
│ ├── README.md
│ ├── img
│ └── preview.png
│ ├── package.json
│ ├── src
│ └── main.js
│ └── tsconfig.json
├── img
├── repo_details.png
└── repo_settings.png
├── lib
└── test-util-ipfs-example
│ ├── index.js
│ ├── node
│ ├── execa.js
│ ├── index.js
│ └── wait-for-output.js
│ ├── package.json
│ └── playwright
│ ├── daemons.js
│ ├── index.js
│ └── servers.js
├── package.json
└── scripts
└── update-example-deps.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | indent_style = space
3 | indent_size = 2
4 | trim_trailing_whitespace = true
5 | insert_final_newline = true
6 | end_of_line = lf
7 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: "11:00"
8 | open-pull-requests-limit: 50
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | package-lock.json
5 | yarn.lock
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 | pnpm-debug.log*
10 |
11 | # local env files
12 | .env.local
13 | .env.*.local
14 |
15 | # Coverage directory used by tools like istanbul
16 | coverage
17 | .nyc_output
18 | tests_output
19 | cache
20 | .cache
21 | .parcel-cache
22 |
23 | # Dependency directory
24 | node_modules
25 |
26 | # Build artefacts
27 | dist
28 | build
29 | bundle.js
30 | tsconfig-types.aegir.json
31 | .tsbuildinfo
32 | .nuxt
33 |
34 | # Editor files
35 | .idea
36 | .vscode
37 | *.suo
38 | *.ntvs*
39 | *.njsproj
40 | *.sln
41 | *.sw?
42 |
43 | # Operating system files
44 | .DS_Store
45 |
--------------------------------------------------------------------------------
/No-real-changes.tmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/No-real-changes.tmp
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-add-readable-stream"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-add-readable-stream/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-add-readable-stream",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "How to add readable streams in the browser",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-core": "^0.16.0"
19 | },
20 | "devDependencies": {
21 | "@babel/core": "^7.14.8",
22 | "@playwright/test": "^1.12.3",
23 | "playwright": "^1.12.3",
24 | "process": "^0.11.10",
25 | "rimraf": "^3.0.2",
26 | "test-util-ipfs-example": "^1.0.2",
27 | "util": "^0.12.4",
28 | "vite": "^3.1.0"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/src/style.css:
--------------------------------------------------------------------------------
1 | :placeholder {
2 | color: rgb(0 0 0 / 30%);
3 | }
4 |
5 | form {
6 | margin: 1.25rem 0;
7 | }
8 |
9 | .hidden {
10 | display: none;
11 | }
12 |
13 | .window {
14 | display: flex;
15 | flex-direction: column;
16 | background: #222;
17 | color: #fff;
18 | height: 400px;
19 | }
20 |
21 | .window .header {
22 | flex-basis: 3rem;
23 | background: #c6c6c6;
24 | position: relative;
25 | }
26 |
27 | .window .header:after {
28 | content: ". . .";
29 | position: absolute;
30 | left: 12px;
31 | right: 0;
32 | top: -3px;
33 | font-family: "Times New Roman", Times, serif;
34 | font-size: 96px;
35 | color: #fff;
36 | line-height: 0;
37 | letter-spacing: -12px;
38 | }
39 |
40 | .terminal {
41 | margin: 20px;
42 | font-family: monospace;
43 | font-size: 16px;
44 | overflow: auto;
45 | flex: 1;
46 | }
47 |
48 | details > summary {
49 | background-color: #0b3a53;
50 | color: whitesmoke;
51 | cursor: pointer;
52 | padding: 0.5rem 1rem;
53 | }
54 |
55 | details > summary > * {
56 | display: inline;
57 | }
58 |
59 | details > div {
60 | border: 2px solid #0b3a53;
61 | margin-top: 0;
62 | padding: 1rem;
63 | }
64 |
--------------------------------------------------------------------------------
/examples/browser-add-readable-stream/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-angular/.browserslistrc:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # For the full list of supported browsers by the Angular framework, please see:
6 | # https://angular.io/guide/browser-support
7 |
8 | # You can see what browsers were selected by your queries by running:
9 | # npx browserslist
10 |
11 | last 1 Chrome version
12 | last 1 Firefox version
13 | last 2 Edge major versions
14 | last 2 Safari major versions
15 | last 2 iOS major versions
16 | Firefox ESR
17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
18 |
--------------------------------------------------------------------------------
/examples/browser-angular/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.ts]
12 | quote_type = single
13 |
14 | [*.md]
15 | max_line_length = off
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/examples/browser-angular/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-angular/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-angular"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-angular/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events*.json
15 |
16 | # IDEs and editors
17 | /.idea
18 | .project
19 | .classpath
20 | .c9/
21 | *.launch
22 | .settings/
23 | *.sublime-workspace
24 |
25 | # IDE - VSCode
26 | .vscode/*
27 | !.vscode/settings.json
28 | !.vscode/tasks.json
29 | !.vscode/launch.json
30 | !.vscode/extensions.json
31 | .history/*
32 |
33 | # misc
34 | /.sass-cache
35 | /connect.lock
36 | /coverage
37 | /libpeerconnection.log
38 | npm-debug.log
39 | yarn-error.log
40 | testem.log
41 | /typings
42 |
43 | # System Files
44 | .DS_Store
45 | Thumbs.db
46 |
--------------------------------------------------------------------------------
/examples/browser-angular/extra-webpack.config.js:
--------------------------------------------------------------------------------
1 | import webpack from 'webpack';
2 | import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
3 |
4 | export default {
5 | plugins: [
6 | // fixes Module not found: Error: Can't resolve 'stream' in '.../node_modules/nofilter/lib'
7 | new NodePolyfillPlugin({}),
8 | // Note: stream-browserify has assumption about `Buffer` global in its
9 | // dependencies causing runtime errors. This is a workaround to provide
10 | // global `Buffer` until https://github.com/isaacs/core-util-is/issues/29
11 | // is fixed.
12 | new webpack.ProvidePlugin({
13 | global: ['global']
14 | })
15 | ]
16 | };
17 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 |
4 | const routes: Routes = [];
5 |
6 | @NgModule({
7 | imports: [RouterModule.forRoot(routes)],
8 | exports: [RouterModule]
9 | })
10 | export class AppRoutingModule { }
11 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async () => {
7 | await TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | });
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'browser-angular'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.componentInstance;
26 | expect(app.title).toEqual('browser-angular');
27 | });
28 |
29 | it('should render title', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.nativeElement as HTMLElement;
33 | expect(compiled.querySelector('.content span')?.textContent).toContain('browser-angular app is running!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { IpfsService } from './ipfs.service';
3 | import { PeerId } from '@libp2p/interface-peer-id';
4 |
5 | @Component({
6 | selector: 'app-root',
7 | templateUrl: './app.component.html',
8 | styleUrls: ['./app.component.css']
9 | })
10 | export class AppComponent implements OnInit {
11 | title = 'browser-angular';
12 | id: PeerId | null = null;
13 | version: string | null = null;
14 | status: string | null = null;
15 |
16 | constructor(private IPFSService: IpfsService) {}
17 |
18 | ngOnInit() {
19 | this.start();
20 | }
21 |
22 | async start() {
23 | const id = await this.IPFSService.getId();
24 | this.id = id.id;
25 |
26 | const version = await this.IPFSService.getVersion();
27 | this.version = version.version
28 |
29 | const status = await this.IPFSService.getStatus();
30 | this.status = status ? 'Online' : 'Offline'
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { BrowserModule } from '@angular/platform-browser';
3 |
4 | import { AppRoutingModule } from './app-routing.module';
5 | import { AppComponent } from './app.component';
6 | import { IpfsService } from './ipfs.service';
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | imports: [
13 | BrowserModule,
14 | AppRoutingModule
15 | ],
16 | providers: [IpfsService],
17 | bootstrap: [AppComponent]
18 | })
19 | export class AppModule { }
20 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/app/ipfs.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { IpfsService } from './ipfs.service';
4 |
5 | describe('IpfsService', () => {
6 | let service: IpfsService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(IpfsService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-angular/src/assets/.gitkeep
--------------------------------------------------------------------------------
/examples/browser-angular/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-angular/src/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-angular/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IPFS Angular
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/examples/browser-angular/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: {
11 | context(path: string, deep?: boolean, filter?: RegExp): {
12 | keys(): string[];
13 | (id: string): T;
14 | };
15 | };
16 |
17 | // First, initialize the Angular testing environment.
18 | getTestBed().initTestEnvironment(
19 | BrowserDynamicTestingModule,
20 | platformBrowserDynamicTesting()
21 | );
22 | // Then we find all the tests.
23 | const context = require.context('./', true, /\.spec\.ts$/);
24 | // And load the modules.
25 | context.keys().map(context);
26 |
--------------------------------------------------------------------------------
/examples/browser-angular/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('integrate ipfs with angular:', () => {
10 | // DOM
11 | const info = "[data-test=ipfs-info]"
12 | const id = "[data-test=ipfs-info-id]"
13 | const version = "[data-test=ipfs-info-version]"
14 | const status = "[data-test=ipfs-info-status]"
15 |
16 | play.beforeEach(async ({servers, page}) => {
17 | await page.goto(`http://localhost:${servers[0].port}/`);
18 | })
19 |
20 | play('should properly initialized a IPFS node and print some properties', async ({ page }) => {
21 | await page.waitForSelector(info)
22 |
23 | expect(await page.isVisible(id)).toBeTruthy();
24 | expect(await page.isVisible(version)).toBeTruthy();
25 | expect(await page.textContent(status)).toContain('Online');
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/examples/browser-angular/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/app",
6 | "types": []
7 | },
8 | "files": [
9 | "src/main.ts",
10 | "src/polyfills.ts"
11 | ],
12 | "include": [
13 | "src/**/*.d.ts"
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/examples/browser-angular/tsconfig.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "compileOnSave": false,
4 | "compilerOptions": {
5 | "baseUrl": "./",
6 | "outDir": "./dist/out-tsc",
7 | "forceConsistentCasingInFileNames": true,
8 | "strict": true,
9 | "noImplicitReturns": true,
10 | "noFallthroughCasesInSwitch": true,
11 | "sourceMap": true,
12 | "declaration": false,
13 | "downlevelIteration": true,
14 | "experimentalDecorators": true,
15 | "moduleResolution": "node",
16 | "importHelpers": true,
17 | "target": "esnext",
18 | "module": "es2020",
19 | "lib": ["esnext", "dom", "es2020"],
20 | "allowSyntheticDefaultImports": true,
21 | "skipLibCheck": true
22 | },
23 | "angularCompilerOptions": {
24 | "enableI18nLegacyMessageIdFormat": false,
25 | "strictInjectionParameters": true,
26 | "strictInputAccessModifiers": true,
27 | "strictTemplates": true
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/browser-angular/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/spec",
6 | "types": [
7 | "jasmine"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts",
12 | "src/polyfills.ts"
13 | ],
14 | "include": [
15 | "src/**/*.spec.ts",
16 | "src/**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/.env:
--------------------------------------------------------------------------------
1 | # required because react-scripts scans *up* the tree from this project and finds
2 | # a conflicting version of eslint in the node_modules dir for js-ipfs.
3 | SKIP_PREFLIGHT_CHECK=true
4 |
5 | # Turning these on can cause OOM errors
6 | GENERATE_SOURCEMAP=false
7 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-create-react-app"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-create-react-app/img/screenshot.png
--------------------------------------------------------------------------------
/examples/browser-create-react-app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-create-react-app/public/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-create-react-app/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-create-react-app/public/logo192.png
--------------------------------------------------------------------------------
/examples/browser-create-react-app/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-create-react-app/public/logo512.png
--------------------------------------------------------------------------------
/examples/browser-create-react-app/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "IPFS React App",
3 | "name": "IPFS Create React App Example",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/App.css:
--------------------------------------------------------------------------------
1 | .react-logo {
2 | pointer-events: none;
3 | }
4 |
5 | @media (prefers-reduced-motion: no-preference) {
6 | .react-logo {
7 | animation: react-logo-spin infinite 20s linear;
8 | }
9 | }
10 |
11 | .react-header {
12 | text-align: center;
13 | font-size: calc(10px + 2vmin);
14 | color: #282c34;
15 | }
16 |
17 | .react-link {
18 | color: #61dafb;
19 | }
20 |
21 | @keyframes react-logo-spin {
22 | from {
23 | transform: rotate(0deg);
24 | }
25 | to {
26 | transform: rotate(360deg);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/App.test.js:
--------------------------------------------------------------------------------
1 | import { render, screen } from '@testing-library/react';
2 | import App from './App';
3 |
4 | test('renders learn react link', () => {
5 | render();
6 | const linkElement = screen.getByText(/learn react/i);
7 | expect(linkElement).toBeInTheDocument();
8 | });
9 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/hooks/use-ipfs.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 | import { getProperty } from 'dot-prop'
3 | // dot-prop: used to obtain a property of an object when the name of property is a string
4 | // here we get ipfs.id when calling dotProp.get(ipfs, cmd), with cmd = 'id'
5 | // and we get ipfs.hash when calling with cmd = 'hash' etc.
6 |
7 | /*
8 | * Pass the command you'd like to call on an ipfs instance.
9 | *
10 | * callIpfs uses setState write the response as a state variable, so that your component
11 | * will re-render when the result 'res' turns up from the call await ipfsCmd.
12 | *
13 | */
14 | export default function useIpfs (ipfs, cmd, opts) {
15 | const [res, setRes] = useState(null)
16 | useEffect(() => {
17 | callIpfs(ipfs, cmd, setRes, opts)
18 | }, [ipfs, cmd, opts])
19 | return res
20 | }
21 |
22 | async function callIpfs (ipfs, cmd, setRes, ...opts) {
23 | if (!ipfs) return null
24 | console.log(`Call ipfs.${cmd}`)
25 | const ipfsCmd = getProperty(ipfs, cmd)
26 | const res = await ipfsCmd(...opts)
27 | console.log(`Result ipfs.${cmd}`, res)
28 | setRes(res)
29 | }
30 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import 'tachyons'
5 | import "ipfs-css";
6 | import './index.css'
7 |
8 | import App from './App.js';
9 | import reportWebVitals from './reportWebVitals.js';
10 |
11 | ReactDOM.render(
12 |
13 |
14 | ,
15 | document.getElementById('root')
16 | );
17 |
18 | // If you want to start measuring performance in your app, pass a function
19 | // to log results (for example: reportWebVitals(console.log))
20 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
21 | reportWebVitals();
22 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/reportWebVitals.js:
--------------------------------------------------------------------------------
1 | const reportWebVitals = onPerfEntry => {
2 | if (onPerfEntry && onPerfEntry instanceof Function) {
3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4 | getCLS(onPerfEntry);
5 | getFID(onPerfEntry);
6 | getFCP(onPerfEntry);
7 | getLCP(onPerfEntry);
8 | getTTFB(onPerfEntry);
9 | });
10 | }
11 | };
12 |
13 | export default reportWebVitals;
14 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom';
6 |
--------------------------------------------------------------------------------
/examples/browser-create-react-app/tests/test.mjs:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers([{
7 | portToUse: 3000,
8 | folderToServe: 'build'
9 | }]),
10 | });
11 |
12 | play.describe('integrate ipfs with react:', () => {
13 | // DOM
14 | const title = "[data-test=title]"
15 | const id = "[data-test=id]"
16 | const agentVersion = "[data-test=agentVersion]"
17 | const version = "[data-test=version]"
18 |
19 | play.beforeEach(async ({servers, page}) => {
20 | await page.goto(`http://localhost:${servers[0].port}/`);
21 | })
22 |
23 | play('should properly initialized a IPFS node and print some properties', async ({ page }) => {
24 | await page.waitForSelector(title)
25 |
26 | expect(await page.textContent(title)).toContain("Connected to IPFS");
27 | expect(await page.isVisible(id)).toBeTruthy();
28 | expect(await page.isVisible(agentVersion)).toBeTruthy();
29 | expect(await page.isVisible(version)).toBeTruthy();
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/examples/browser-esbuild/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-esbuild/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-esbuild"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-esbuild/esbuild.js:
--------------------------------------------------------------------------------
1 | import { build } from 'esbuild'
2 |
3 | build({
4 | entryPoints: ['./src/index.js'],
5 | outfile: './dist/index.js',
6 | sourcemap: 'external',
7 | minify: true,
8 | bundle: true,
9 | define: {
10 | 'process.env.NODE_DEBUG': 'false',
11 | 'global': 'globalThis'
12 | }
13 | })
14 | .catch(() => process.exit(1))
--------------------------------------------------------------------------------
/examples/browser-esbuild/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-esbuild/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-esbuild/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-esbuild/img/1.png
--------------------------------------------------------------------------------
/examples/browser-esbuild/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-esbuild/img/2.png
--------------------------------------------------------------------------------
/examples/browser-esbuild/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-esbuild",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Bundle js-ipfs with esbuild",
7 | "keywords": [],
8 | "license": "ISC",
9 | "author": "",
10 | "scripts": {
11 | "clean": "rimraf ./dist",
12 | "build": "mkdir -p dist && cp src/index.html src/style.css src/ipfs-logo.svg dist && node esbuild.js",
13 | "start": "npm run build && esbuild --servedir=dist",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-core": "^0.16.0"
19 | },
20 | "devDependencies": {
21 | "@babel/core": "^7.14.8",
22 | "@playwright/test": "^1.12.3",
23 | "esbuild": "^0.15.7",
24 | "playwright": "^1.12.3",
25 | "process": "^0.11.10",
26 | "rimraf": "^3.0.2",
27 | "test-util-ipfs-example": "^1.0.2",
28 | "util": "^0.12.4"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/browser-esbuild/src/style.css:
--------------------------------------------------------------------------------
1 | ::placeholder {
2 | color: rgb(0 0 0 / 30%);
3 | }
4 |
5 | form {
6 | margin: 1.25rem 0;
7 | }
8 |
9 | .window {
10 | display: flex;
11 | flex-direction: column;
12 | background: #222;
13 | color: #fff;
14 | height: 400px;
15 | }
16 |
17 | .window .header {
18 | flex-basis: 3rem;
19 | background: #c6c6c6;
20 | position: relative;
21 | }
22 |
23 | .window .header:after {
24 | content: ". . .";
25 | position: absolute;
26 | left: 12px;
27 | right: 0;
28 | top: -3px;
29 | font-family: "Times New Roman", Times, serif;
30 | font-size: 96px;
31 | color: #fff;
32 | line-height: 0;
33 | letter-spacing: -12px;
34 | }
35 |
36 | .terminal {
37 | margin: 20px;
38 | font-family: monospace;
39 | font-size: 16px;
40 | overflow: auto;
41 | flex: 1;
42 | }
43 |
--------------------------------------------------------------------------------
/examples/browser-esbuild/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('bundle ipfs with esbuild:', () => {
10 | // DOM
11 | const nameInput = "#file-name"
12 | const contentInput = "#file-content"
13 | const submitBtn = "#add-submit"
14 | const output = "#output"
15 |
16 | play.beforeEach(async ({servers, page}) => {
17 | await page.goto(`http://localhost:${servers[0].port}/`);
18 | })
19 |
20 | play('should properly initialized a IPFS node and add/get a file', async ({ page }) => {
21 | const fileName = 'test.txt'
22 | const stringToUse = 'Hello world!'
23 |
24 | await page.fill(nameInput, fileName)
25 | await page.fill(contentInput, stringToUse)
26 | await page.click(submitBtn)
27 |
28 | await page.waitForSelector(`${output}:has-text("/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY")`)
29 |
30 | const outputContent = await page.textContent(output)
31 |
32 | expect(outputContent).toContain("QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
33 | expect(outputContent).toContain("https://ipfs.io/ipfs/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
34 | expect(outputContent).toContain(fileName);
35 | expect(outputContent).toContain(stringToUse);
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-exchange-files"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/connect-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/connect-1.png
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/connect-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/connect-2.png
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/diagram.monopic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/diagram.monopic
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/diagram.txt:
--------------------------------------------------------------------------------
1 | ┌──────────────┐ ┌──────────────┐
2 | │ Browser │ │ Browser │
3 | │ │ WebRTC │ │
4 | │ │◀─────────────────▶│ │
5 | │ │ │ │
6 | └──────────────┘ └──────────────┘
7 | ▲ ▲
8 | │ │
9 | │ │
10 | │ │
11 | │WebSockets WebSockets│
12 | │ │
13 | │ │
14 | │ ┌──────────────┐ │
15 | │ │ Desktop │ │
16 | │ │ │ │
17 | └───────▶│ │◀─────────┘
18 | │ │
19 | └──────────────┘
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/fetch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/fetch.png
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/goal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/goal.png
--------------------------------------------------------------------------------
/examples/browser-exchange-files/img/pubsub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-exchange-files/img/pubsub.png
--------------------------------------------------------------------------------
/examples/browser-exchange-files/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-exchange-files-in-browser",
3 | "version": "1.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "type": "module",
7 | "scripts": {
8 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
9 | "build": "vite build",
10 | "serve": "vite dev --port 8888",
11 | "start": "npm run serve",
12 | "test": "npm run build && playwright test tests --retries=3"
13 | },
14 | "browserslist": "last 1 Chrome version",
15 | "dependencies": {
16 | "@libp2p/websockets": "^3.0.3",
17 | "ipfs-core": "^0.16.0",
18 | "it-all": "^1.0.4",
19 | "uint8arrays": "^3.0.0"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.14.8",
23 | "@libp2p/webrtc-star-signalling-server": "^2.0.1",
24 | "@playwright/test": "^1.12.3",
25 | "ipfs": "^0.64.0",
26 | "ipfs-core-types": "^0.12.0",
27 | "ipfs-http-client": "^58.0.0",
28 | "playwright": "^1.12.3",
29 | "process": "^0.11.10",
30 | "rimraf": "^3.0.2",
31 | "test-util-ipfs-example": "^1.0.2",
32 | "util": "^0.12.4",
33 | "vite": "^3.1.0"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/public/download.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/public/upload.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/browser-exchange-files/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-ipns-publish/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-ipns-publish/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-ipns-publish"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-ipns-publish/src/util.js:
--------------------------------------------------------------------------------
1 | export const Logger = outEl => {
2 | outEl.innerHTML = ''
3 | return message => {
4 | const container = document.createElement('div')
5 | container.innerHTML = message
6 | outEl.appendChild(container)
7 | outEl.scrollTop = outEl.scrollHeight
8 | }
9 | }
10 |
11 | export const onEnterPress = fn => {
12 | return e => {
13 | if (event.which == 13 || event.keyCode == 13) {
14 | e.preventDefault()
15 | fn()
16 | }
17 | }
18 | }
19 |
20 | export const catchAndLog = (fn, log) => {
21 | return async (...args) => {
22 | try {
23 | await fn(...args)
24 | } catch (err) {
25 | console.error(err)
26 | log(`${err.message}`)
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/browser-ipns-publish/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-lit/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-lit/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-lit"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-lit/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-lit/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-lit/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-lit/img/screenshot.png
--------------------------------------------------------------------------------
/examples/browser-lit/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | js-ipfs with lit
8 |
9 |
10 |
11 |
12 |
13 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/browser-lit/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-lit",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "A minimal demonstration of how to use js-ipfs with lit",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-core": "^0.16.0",
19 | "ipfs-css": "^1.3.0",
20 | "lit": "^2.0.2",
21 | "tachyons": "^4.12.0"
22 | },
23 | "devDependencies": {
24 | "@babel/core": "^7.14.8",
25 | "@playwright/test": "^1.12.3",
26 | "playwright": "^1.12.3",
27 | "process": "^0.11.10",
28 | "rimraf": "^3.0.2",
29 | "test-util-ipfs-example": "^1.0.2",
30 | "util": "^0.12.4",
31 | "vite": "^3.1.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/examples/browser-lit/src/index.js:
--------------------------------------------------------------------------------
1 | // Global CSS
2 | import "ipfs-css";
3 | import 'tachyons'
4 |
5 | // Components
6 | import './ipfs'
7 |
--------------------------------------------------------------------------------
/examples/browser-lit/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test'
2 | import { playwright } from 'test-util-ipfs-example'
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('integrate ipfs with lit:', () => {
10 | // DOM
11 | const title = "[data-test=title]"
12 | const id = "[data-test=Id]"
13 | const agentVersion = "[data-test=AgentVersion]"
14 | const version = "[data-test=Version]"
15 |
16 | play.beforeEach(async ({servers, page}) => {
17 | await page.goto(`http://localhost:${servers[0].port}/`);
18 | })
19 |
20 | play('should properly initialized a IPFS node and print some properties', async ({ page }) => {
21 | await page.waitForSelector(title)
22 |
23 | expect(await page.textContent(title)).toContain("Connected to IPFS");
24 | expect(await page.isVisible(id)).toBeTruthy();
25 | expect(await page.isVisible(agentVersion)).toBeTruthy();
26 | expect(await page.isVisible(version)).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/examples/browser-lit/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-mfs/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-mfs/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-mfs"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-mfs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-mfs/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-mfs/img/screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-mfs/img/screenshot_1.png
--------------------------------------------------------------------------------
/examples/browser-mfs/img/screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-mfs/img/screenshot_2.png
--------------------------------------------------------------------------------
/examples/browser-mfs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-mfs",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "How to use ipfs MFS in the browser",
7 | "license": "ISC",
8 | "author": "",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-core": "^0.16.0",
19 | "mime-sniffer": "~0.0.3"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.14.8",
23 | "@playwright/test": "^1.12.3",
24 | "playwright": "^1.12.3",
25 | "process": "^0.11.10",
26 | "rimraf": "^3.0.2",
27 | "test-util-ipfs-example": "^1.0.2",
28 | "util": "^0.12.4",
29 | "vite": "^3.1.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/browser-mfs/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["next", "next/core-web-vitals"],
3 | "root": true
4 | }
5 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-nextjs"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env.local
29 | .env.development.local
30 | .env.test.local
31 | .env.production.local
32 |
33 | # vercel
34 | .vercel
35 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/components/ipfs.js:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react'
2 | import { create } from 'ipfs-core'
3 |
4 | const IpfsComponent = () => {
5 | const [id, setId] = useState(null);
6 | const [ipfs, setIpfs] = useState(null);
7 | const [version, setVersion] = useState(null);
8 | const [isOnline, setIsOnline] = useState(false);
9 |
10 | useEffect(() => {
11 | const init = async () => {
12 | if (ipfs) return
13 |
14 | const node = await create();
15 |
16 | const nodeId = await node.id();
17 | const nodeVersion = await node.version();
18 | const nodeIsOnline = node.isOnline();
19 |
20 | setIpfs(node);
21 | setId(nodeId.id);
22 | setVersion(nodeVersion.version);
23 | setIsOnline(nodeIsOnline);
24 | }
25 |
26 | init()
27 | }, [ipfs]);
28 |
29 | if (!ipfs || !id) {
30 | return Connecting to IPFS...
31 | }
32 |
33 | return (
34 |
35 |
ID: {id.toString()}
36 | Version: {version}
37 | Status: {isOnline ? 'Online' : 'Offline'}
38 |
39 | )
40 | }
41 |
42 | export default IpfsComponent
43 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/next.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | reactStrictMode: true,
3 | // https://github.com/vercel/next.js/issues/21079
4 | // Remove the workaround the issue is fixed
5 | images: {
6 | loader: "imgix",
7 | path: "https://noop/",
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-nextjs",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "scripts": {
7 | "clean": "rimraf ./dist ./.next",
8 | "dev": "next dev",
9 | "build": "next build && next export -o dist",
10 | "serve": "npm run dev",
11 | "start": "next start",
12 | "lint": "next lint",
13 | "test": "npm run build && playwright test tests"
14 | },
15 | "dependencies": {
16 | "ipfs-core": "^0.16.0",
17 | "next": "^12.0.7",
18 | "react": "^17.0.2",
19 | "react-dom": "^17.0.2"
20 | },
21 | "devDependencies": {
22 | "@playwright/test": "^1.12.3",
23 | "eslint": "^8.7.0",
24 | "eslint-config-next": "^12.0.9",
25 | "playwright": "^1.12.3",
26 | "rimraf": "^3.0.2",
27 | "test-util-ipfs-example": "^1.0.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/pages/_app.js:
--------------------------------------------------------------------------------
1 | import '../styles/globals.css'
2 |
3 | function MyApp({ Component, pageProps }) {
4 | return
5 | }
6 |
7 | export default MyApp
8 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/pages/api/hello.js:
--------------------------------------------------------------------------------
1 | // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2 |
3 | export default function handler(req, res) {
4 | res.status(200).json({ name: 'John Doe' })
5 | }
6 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-nextjs/public/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-nextjs/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/styles/globals.css:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7 | }
8 |
9 | a {
10 | color: inherit;
11 | text-decoration: none;
12 | }
13 |
14 | * {
15 | box-sizing: border-box;
16 | }
17 |
--------------------------------------------------------------------------------
/examples/browser-nextjs/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('integrate ipfs with nextjs:', () => {
10 | // DOM
11 | const id = "[data-test=id]"
12 | const version = "[data-test=version]"
13 | const status = "[data-test=status]"
14 |
15 | play.beforeEach(async ({servers, page}) => {
16 | await page.goto(`http://localhost:${servers[0].port}/`);
17 | })
18 |
19 | play('should properly initialized a IPFS node and print some properties', async ({ page }) => {
20 | await page.waitForSelector(id)
21 |
22 | expect(await page.isVisible(id)).toBeTruthy();
23 | expect(await page.isVisible(version)).toBeTruthy();
24 | expect(await page.textContent(status)).toContain('Online');
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-readablestream"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-readablestream/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-readablestream/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | IPFS Videostream example
8 |
9 |
10 |
11 |
12 |
16 |
17 |
18 |
19 |
24 |
25 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-readablestream",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "An example of how to play a video in a browser using a readable stream",
7 | "license": "ISC",
8 | "author": "",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "buffer": "^6.0.3",
19 | "ipfs-core": "^0.16.0",
20 | "it-to-stream": "^1.0.0",
21 | "videostream": "^3.2.0"
22 | },
23 | "devDependencies": {
24 | "@babel/core": "^7.14.8",
25 | "@esbuild-plugins/node-globals-polyfill": "^0.1.1",
26 | "@playwright/test": "^1.12.3",
27 | "@rollup/plugin-inject": "^4.0.4",
28 | "events": "^3.3.0",
29 | "playwright": "^1.12.3",
30 | "process": "^0.11.10",
31 | "rimraf": "^3.0.2",
32 | "test-util-ipfs-example": "^1.0.2",
33 | "util": "^0.12.4",
34 | "vite": "^3.1.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/src/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | padding: 0;
4 | }
5 |
6 | #container {
7 | display: flex;
8 | height: 100vh;
9 | }
10 |
11 | pre {
12 | flex-grow: 2;
13 | padding: 10px;
14 | height: calc(100vh - 45px);
15 | overflow: auto;
16 | }
17 |
18 | #form-wrapper {
19 | padding: 20px;
20 | }
21 |
22 | form {
23 | padding-bottom: 10px;
24 | display: flex;
25 | }
26 |
27 | #hash {
28 | display: inline-block;
29 | margin: 0 10px 10px 0;
30 | font-size: 16px;
31 | flex-grow: 2;
32 | padding: 5px;
33 | }
34 |
35 | button {
36 | display: inline-block;
37 | font-size: 16px;
38 | height: 32px;
39 | }
40 |
41 | video {
42 | max-width: 50vw;
43 | }
44 |
--------------------------------------------------------------------------------
/examples/browser-readablestream/tests/test.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-readablestream/tests/test.mp4
--------------------------------------------------------------------------------
/examples/browser-script-tag/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-script-tag"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-script-tag/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-script-tag/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-script-tag",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Using IPFS in the browser via a script tag",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "devDependencies": {
18 | "@babel/core": "^7.14.8",
19 | "@playwright/test": "^1.12.3",
20 | "playwright": "^1.12.3",
21 | "process": "^0.11.10",
22 | "rimraf": "^3.0.2",
23 | "test-util-ipfs-example": "^1.0.2",
24 | "util": "^0.12.4",
25 | "vite": "^3.1.0"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/src/index.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', async () => {
2 | const insertAfter = (referenceNode, newNode) => {
3 | referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
4 | }
5 |
6 | const node = await Ipfs.create({ repo: 'ipfs-' + Math.random() })
7 | window.node = node
8 |
9 | const status = node.isOnline() ? 'online' : 'offline'
10 | const id = await node.id()
11 |
12 | console.log(`Node status: ${status}`)
13 |
14 | const statusDOM = document.getElementById('status')
15 | statusDOM.innerHTML = `Node status: ${status}`
16 |
17 | const newDiv = document.createElement("div");
18 | newDiv.id = "node"
19 | const newContent = document.createTextNode(`ID: ${id.id}`);
20 | newDiv.appendChild(newContent);
21 |
22 | insertAfter(statusDOM, newDiv);
23 |
24 | // You can write more code here to use it. Use methods like
25 | // node.add, node.get. See the API docs here:
26 | // https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core
27 | })
28 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('using script tag:', () => {
10 | // DOM
11 | const status = "#status"
12 | const node = "#node"
13 |
14 | play.beforeEach(async ({servers, page}) => {
15 | await page.goto(`http://localhost:${servers[0].port}/`);
16 | })
17 |
18 | play('should properly initialized a IPFS node and print the status', async ({ page }) => {
19 | await page.waitForSelector(status)
20 | expect(await page.textContent(status)).toContain("offline");
21 |
22 | expect(await page.textContent(node)).toContain("ID: ");
23 | expect(await page.textContent(status)).toContain("online");
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-service-worker"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/img/index-view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-service-worker/img/index-view.png
--------------------------------------------------------------------------------
/examples/browser-service-worker/img/page-view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-service-worker/img/page-view.png
--------------------------------------------------------------------------------
/examples/browser-service-worker/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-service-worker",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "IPFS with service worker",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist",
11 | "build": "webpack --env production",
12 | "serve": "webpack serve --hot-only --mode=development",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": [
17 | "last 1 Chrome version"
18 | ],
19 | "dependencies": {
20 | "ipfs-core": "^0.16.0",
21 | "ipfs-message-port-client": "^0.13.0",
22 | "ipfs-message-port-protocol": "^0.13.0",
23 | "ipfs-message-port-server": "^0.13.0"
24 | },
25 | "devDependencies": {
26 | "@babel/core": "^7.13.10",
27 | "@babel/preset-env": "^7.13.12",
28 | "@playwright/test": "^1.12.3",
29 | "babel-loader": "^8.2.3",
30 | "copy-webpack-plugin": "^10.0.0",
31 | "css-loader": "^6.2.0",
32 | "html-webpack-plugin": "^5.3.2",
33 | "node-polyfill-webpack-plugin": "^2.0.1",
34 | "playwright": "^1.12.3",
35 | "rimraf": "^3.0.2",
36 | "stream-browserify": "^3.0.0",
37 | "style-loader": "^3.1.0",
38 | "test-util-ipfs-example": "^1.0.2",
39 | "webpack": "^5.45.1",
40 | "webpack-cli": "^4.7.2",
41 | "webpack-dev-server": "^4.6.0",
42 | "webpack-merge": "^5.8.0"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-service-worker/public/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-service-worker/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
12 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/src/app.css:
--------------------------------------------------------------------------------
1 | @media (prefers-color-scheme: dark) {
2 | a,
3 | body {
4 | background: #000;
5 | color: white;
6 | }
7 | }
8 |
9 | @media (prefers-color-scheme: light) {
10 | a,
11 | body {
12 | background: white;
13 | color: #000;
14 | }
15 | }
16 |
17 | body {
18 | font-family: -apple-system, BlinkMacSystemFont, "avenir next", avenir,
19 | "helvetica neue", helvetica, ubuntu, roboto, noto, "segoe ui", arial,
20 | sans-serif;
21 | }
22 |
23 | a {
24 | text-decoration: none;
25 | }
26 |
27 | a:hover {
28 | text-decoration: underline;
29 | }
30 |
31 | .dt {
32 | display: table;
33 | }
34 |
35 | .dtc {
36 | display: table-cell;
37 | }
38 |
39 | .fw6 {
40 | font-weight: 600;
41 | }
42 |
43 | .vh-100 {
44 | height: 100vh;
45 | }
46 |
47 | .w-100 {
48 | width: 100%;
49 | }
50 |
51 | .white {
52 | color: #fff;
53 | }
54 |
55 | .bg-dark-pink {
56 | background-color: #d5008f;
57 | }
58 |
59 | .ph3 {
60 | padding-left: 1rem;
61 | padding-right: 1rem;
62 | }
63 |
64 | .tc {
65 | text-align: center;
66 | }
67 |
68 | .f6 {
69 | font-size: 0.875rem;
70 | }
71 |
72 | .v-mid {
73 | vertical-align: middle;
74 | }
75 |
76 | @media screen and (min-width: 30em) and (max-width: 60em) {
77 | .f2-m {
78 | font-size: 2.25rem;
79 | }
80 | }
81 |
82 | @media screen and (min-width: 60em) {
83 | .ph4-l {
84 | padding-left: 2rem;
85 | padding-right: 2rem;
86 | }
87 |
88 | .f-subheadline-l {
89 | font-size: 5rem;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/examples/browser-service-worker/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "checkJs": true,
5 | "noEmit": true,
6 | "strict": true,
7 | "noImplicitAny": true,
8 | "strictNullChecks": true,
9 | "moduleResolution": "node",
10 | "esModuleInterop": true,
11 | "lib": [
12 | "esnext",
13 | "DOM",
14 | "webworker"
15 | ]
16 | },
17 | "include": [
18 | "src"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-sharing-node-across-tabs"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-sharing-node-across-tabs/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-sharing-node-across-tabs/img/screenshot.png
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Share IPFS across nodes
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-sharing-node-across-tabs",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Sharing IPFS node across browsing contexts",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-core": "^0.16.0",
19 | "ipfs-message-port-client": "^0.13.0",
20 | "ipfs-message-port-server": "^0.13.0"
21 | },
22 | "devDependencies": {
23 | "@babel/core": "^7.14.8",
24 | "@playwright/test": "^1.12.3",
25 | "playwright": "^1.12.3",
26 | "process": "^0.11.10",
27 | "rimraf": "^3.0.2",
28 | "test-util-ipfs-example": "^1.0.2",
29 | "util": "^0.12.4",
30 | "vite": "^3.1.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('share ipfs node:', () => {
10 | // DOM
11 | const link = ".ipfs-add a"
12 | const iframe = "iframe"
13 | const content = "pre"
14 |
15 | play.beforeEach(async ({servers, page}) => {
16 | await page.goto(`http://localhost:${servers[0].port}/`);
17 | })
18 |
19 | play('should properly initialized a IPFS node and share it between tabs', async ({ page, context }) => {
20 | expect(await page.textContent(link)).toContain("/ipfs/QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j/");
21 |
22 | // Get page after a specific action (e.g. clicking a link)
23 | const [newPage] = await Promise.all([
24 | context.waitForEvent('page'),
25 | page.click(link) // Opens a new tab
26 | ])
27 |
28 | await newPage.waitForLoadState();
29 | await newPage.waitForSelector(iframe);
30 |
31 | const handle = await newPage.$(iframe)
32 | const contentFrame = await handle.contentFrame();
33 |
34 | const pre = await contentFrame.$(content);
35 | expect(await pre.textContent()).toBe("hello world!");
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/examples/browser-sharing-node-across-tabs/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-video-streaming"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-video-streaming/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-video-streaming/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | IPFS with HLS-JS
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-video-streaming",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "IPFS browser video streaming example",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests --browser=firefox --retries=3"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "hls.js": "^0.14.17",
19 | "hlsjs-ipfs-loader": "^0.3.0",
20 | "ipfs-core": "^0.16.0"
21 | },
22 | "devDependencies": {
23 | "@babel/core": "^7.14.8",
24 | "@playwright/test": "^1.12.3",
25 | "playwright": "^1.12.3",
26 | "process": "^0.11.10",
27 | "rimraf": "^3.0.2",
28 | "test-util-ipfs-example": "^1.0.2",
29 | "util": "^0.12.4",
30 | "vite": "^3.1.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/src/index.js:
--------------------------------------------------------------------------------
1 | import { create } from 'ipfs-core'
2 | import Hls from 'hls.js'
3 | import HlsjsIpfsLoader from 'hlsjs-ipfs-loader'
4 |
5 | document.addEventListener('DOMContentLoaded', async () => {
6 | const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
7 | const repoPath = 'ipfs-' + Math.random()
8 | const node = await create({ repo: repoPath })
9 |
10 | Hls.DefaultConfig.loader = HlsjsIpfsLoader
11 | Hls.DefaultConfig.debug = false
12 | if (Hls.isSupported()) {
13 | const video = document.getElementById('video')
14 | const status = document.getElementById('status')
15 | const hls = new Hls()
16 | hls.config.ipfs = node
17 | hls.config.ipfsHash = testHash
18 | hls.loadSource('master.m3u8')
19 | hls.attachMedia(video)
20 | hls.on(Hls.Events.MANIFEST_PARSED, () => {
21 | const node = document.createTextNode("Video ready...");
22 | status.appendChild(node);
23 |
24 | video.play()
25 | })
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('browser videostream:', () => {
10 | // DOM
11 | const status = "#status"
12 |
13 | play.beforeEach(async ({servers, page}) => {
14 | await page.goto(`http://localhost:${servers[0].port}/`);
15 | })
16 |
17 | play('should properly initialized a IPFS node and stream a video', async ({ page }) => {
18 | await page.waitForSelector(`${status}:has-text('Video ready')`)
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-vite/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-vite/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-vite"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-vite/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vite/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-vite/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vite/img/1.png
--------------------------------------------------------------------------------
/examples/browser-vite/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vite/img/2.png
--------------------------------------------------------------------------------
/examples/browser-vite/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-vite",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Bundle js-ipfs with vite",
7 | "keywords": [],
8 | "license": "ISC",
9 | "author": "",
10 | "scripts": {
11 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
12 | "build": "vite build",
13 | "serve": "vite dev --port 8888",
14 | "start": "npm run serve",
15 | "test": "npm run build && playwright test tests"
16 | },
17 | "browserslist": "last 1 Chrome version",
18 | "dependencies": {
19 | "ipfs-core": "^0.16.0"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.14.8",
23 | "@playwright/test": "^1.12.3",
24 | "playwright": "^1.12.3",
25 | "process": "^0.11.10",
26 | "rimraf": "^3.0.2",
27 | "test-util-ipfs-example": "^1.0.2",
28 | "util": "^0.12.4",
29 | "vite": "^3.1.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/browser-vite/src/style.css:
--------------------------------------------------------------------------------
1 | ::placeholder {
2 | color: rgb(0 0 0 / 30%);
3 | }
4 |
5 | form {
6 | margin: 1.25rem 0;
7 | }
8 |
9 | .window {
10 | display: flex;
11 | flex-direction: column;
12 | background: #222;
13 | color: #fff;
14 | height: 400px;
15 | }
16 |
17 | .window .header {
18 | flex-basis: 3rem;
19 | background: #c6c6c6;
20 | position: relative;
21 | }
22 |
23 | .window .header:after {
24 | content: ". . .";
25 | position: absolute;
26 | left: 12px;
27 | right: 0;
28 | top: -3px;
29 | font-family: "Times New Roman", Times, serif;
30 | font-size: 96px;
31 | color: #fff;
32 | line-height: 0;
33 | letter-spacing: -12px;
34 | }
35 |
36 | .terminal {
37 | margin: 20px;
38 | font-family: monospace;
39 | font-size: 16px;
40 | overflow: auto;
41 | flex: 1;
42 | }
43 |
--------------------------------------------------------------------------------
/examples/browser-vite/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('bundle ipfs with parceljs:', () => {
10 | // DOM
11 | const nameInput = "#file-name"
12 | const contentInput = "#file-content"
13 | const submitBtn = "#add-submit"
14 | const output = "#output"
15 |
16 | play.beforeEach(async ({servers, page}) => {
17 | await page.goto(`http://localhost:${servers[0].port}/`);
18 | })
19 |
20 | play('should properly initialized a IPFS node and add/get a file', async ({ page }) => {
21 | const fileName = 'test.txt'
22 | const stringToUse = 'Hello world!'
23 |
24 | await page.fill(nameInput, fileName)
25 | await page.fill(contentInput, stringToUse)
26 | await page.click(submitBtn)
27 |
28 | await page.waitForSelector(`${output}:has-text("/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY")`)
29 |
30 | const outputContent = await page.textContent(output)
31 |
32 | expect(outputContent).toContain("QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
33 | expect(outputContent).toContain("https://ipfs.io/ipfs/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
34 | expect(outputContent).toContain(fileName);
35 | expect(outputContent).toContain(stringToUse);
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/examples/browser-vite/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/browser-vue/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-vue/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-vue"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-vue/.npmrc:
--------------------------------------------------------------------------------
1 | legacy-peer-deps=true
2 |
--------------------------------------------------------------------------------
/examples/browser-vue/babel.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/examples/browser-vue/img/ipfs-vue-screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vue/img/ipfs-vue-screenshot.png
--------------------------------------------------------------------------------
/examples/browser-vue/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "esnext",
5 | "baseUrl": "./",
6 | "moduleResolution": "node",
7 | "paths": {
8 | "@/*": [
9 | "src/*"
10 | ]
11 | },
12 | "lib": [
13 | "esnext",
14 | "dom",
15 | "dom.iterable",
16 | "scripthost"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/browser-vue/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vue/public/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-vue/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | IPFS Vue App
9 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/browser-vue/src/assets/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/browser-vue/src/assets/vue_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-vue/src/assets/vue_logo.png
--------------------------------------------------------------------------------
/examples/browser-vue/src/components/IpfsInfo.vue:
--------------------------------------------------------------------------------
1 |
2 | {{ status }}
3 |
4 |
5 | ID: {{ id }}
6 |
7 |
8 | Agent version: {{ agentVersion }}
9 |
10 |
11 |
12 |
13 |
48 |
--------------------------------------------------------------------------------
/examples/browser-vue/src/main.js:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import App from './App.vue'
3 | import VueIpfs from './plugins/vue-ipfs.js'
4 |
5 | // Load our IPFS plugin.
6 | const app = createApp(App)
7 | app.use(VueIpfs)
8 | app.mount('#app')
9 |
--------------------------------------------------------------------------------
/examples/browser-vue/src/plugins/vue-ipfs.js:
--------------------------------------------------------------------------------
1 | import { create } from 'ipfs-core'
2 |
3 | export default {
4 | install: (app, options) => {
5 | app.config.globalProperties.$ipfs = create(options)
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/examples/browser-vue/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('integrate ipfs with vue:', () => {
10 | // DOM
11 | const info = ".ipfs-info"
12 | const id = "#ipfs-info-id"
13 | const agent = "#ipfs-info-agent"
14 |
15 | play.beforeEach(async ({servers, page}) => {
16 | await page.goto(`http://localhost:${servers[0].port}/`);
17 | })
18 |
19 | play('should properly initialized a IPFS node and print some information about the node', async ({ page }) => {
20 | await page.waitForSelector(info)
21 |
22 | expect(await page.textContent(id)).not.toBe("")
23 | expect(await page.textContent(agent)).toContain("js-ipfs/");
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/examples/browser-webpack/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/browser-webpack/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/browser-webpack"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/browser-webpack/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-webpack/img/1.png
--------------------------------------------------------------------------------
/examples/browser-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-browser-webpack",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Bundle js-ipfs with Webpack",
7 | "keywords": [],
8 | "license": "MIT",
9 | "scripts": {
10 | "clean": "rimraf ./dist",
11 | "build": "webpack --env production",
12 | "serve": "webpack serve --hot-only --mode=development",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": [
17 | "last 1 Chrome version"
18 | ],
19 | "dependencies": {
20 | "ipfs-core": "^0.16.0",
21 | "react": "^17.0.2",
22 | "react-dom": "^17.0.2"
23 | },
24 | "devDependencies": {
25 | "@babel/core": "^7.13.10",
26 | "@babel/preset-env": "^7.13.12",
27 | "@babel/preset-react": "^7.12.13",
28 | "@playwright/test": "^1.12.3",
29 | "babel-loader": "^8.2.3",
30 | "copy-webpack-plugin": "^10.0.0",
31 | "css-loader": "^6.2.0",
32 | "html-webpack-plugin": "^5.3.2",
33 | "node-polyfill-webpack-plugin": "^2.0.1",
34 | "playwright": "^1.12.3",
35 | "react-hot-loader": "^4.12.21",
36 | "rimraf": "^3.0.2",
37 | "style-loader": "^3.1.0",
38 | "test-util-ipfs-example": "^1.0.2",
39 | "webpack": "^5.45.1",
40 | "webpack-cli": "^4.7.2",
41 | "webpack-dev-server": "^4.6.0",
42 | "webpack-merge": "^5.8.0"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/examples/browser-webpack/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/browser-webpack/public/favicon.ico
--------------------------------------------------------------------------------
/examples/browser-webpack/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/browser-webpack/src/app.css:
--------------------------------------------------------------------------------
1 | ::placeholder {
2 | color: rgb(0 0 0 / 30%);
3 | }
4 |
5 | form {
6 | margin: 1.25rem 0;
7 | }
8 |
9 | .window {
10 | display: flex;
11 | flex-direction: column;
12 | background: #222;
13 | color: #fff;
14 | height: 400px;
15 | }
16 |
17 | .window .header {
18 | flex-basis: 3rem;
19 | background: #c6c6c6;
20 | position: relative;
21 | }
22 |
23 | .window .header:after {
24 | content: ". . .";
25 | position: absolute;
26 | left: 12px;
27 | right: 0;
28 | top: -3px;
29 | font-family: "Times New Roman", Times, serif;
30 | font-size: 96px;
31 | color: #fff;
32 | line-height: 0;
33 | letter-spacing: -12px;
34 | }
35 |
36 | .terminal {
37 | margin: 20px;
38 | font-family: monospace;
39 | font-size: 16px;
40 | overflow: auto;
41 | flex: 1;
42 | }
43 |
--------------------------------------------------------------------------------
/examples/browser-webpack/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import './app.css';
4 | import App from './app.js'
5 |
6 | ReactDOM.render(
7 |
8 |
9 | ,
10 | document.getElementById('root')
11 | );
12 |
13 | // Check if HMR interface is enabled
14 | if (module.hot) {
15 | // Accept hot update
16 | module.hot.accept()
17 | }
18 |
--------------------------------------------------------------------------------
/examples/browser-webpack/tests/test.js:
--------------------------------------------------------------------------------
1 | import { test, expect } from '@playwright/test';
2 | import { playwright } from 'test-util-ipfs-example';
3 |
4 | // Setup
5 | const play = test.extend({
6 | ...playwright.servers(),
7 | });
8 |
9 | play.describe('bundle ipfs with webpack:', () => {
10 | // DOM
11 | const nameInput = "#file-name"
12 | const contentInput = "#file-content"
13 | const submitBtn = "#add-submit"
14 | const output = "#output"
15 |
16 | play.beforeEach(async ({servers, page}) => {
17 | await page.goto(`http://localhost:${servers[0].port}/`);
18 | })
19 |
20 | play('should properly initialized a IPFS node and add/get a file', async ({ page }) => {
21 | const fileName = 'test.txt'
22 | const stringToUse = 'Hello world!'
23 |
24 | await page.fill(nameInput, fileName)
25 | await page.fill(contentInput, stringToUse)
26 | await page.click(submitBtn)
27 |
28 | await page.waitForSelector(`${output}:has-text("/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY")`)
29 |
30 | const outputContent = await page.textContent(output)
31 |
32 | expect(outputContent).toContain("QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
33 | expect(outputContent).toContain("https://ipfs.io/ipfs/QmQzCQn4puG4qu8PVysxZmscmQ5vT1ZXpqo7f58Uh9QfyY");
34 | expect(outputContent).toContain(fileName);
35 | expect(outputContent).toContain(stringToUse);
36 | });
37 | });
38 |
--------------------------------------------------------------------------------
/examples/circuit-relaying/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/circuit-relaying/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/circuit-relaying"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img1.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img2.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img3.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img4.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img5.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img6.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/img/img7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/circuit-relaying/img/img7.png
--------------------------------------------------------------------------------
/examples/circuit-relaying/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-circuit-relaying",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "IPFS quick msg",
6 | "license": "MIT",
7 | "type": "module",
8 | "author": "Dmitriy Ryajov ",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "deploy": "ipfs add -r --quieter dist",
12 | "build": "vite build",
13 | "serve": "vite dev --port 8888",
14 | "start": "npm run serve",
15 | "test": "npm run build && playwright test tests"
16 | },
17 | "browserslist": "last 1 Chrome version",
18 | "dependencies": {
19 | "@libp2p/websockets": "^3.0.3",
20 | "delay": "^5.0.0",
21 | "ipfs-core": "^0.16.0",
22 | "ipfs-css": "^1.3.0",
23 | "ipfs-pubsub-room": "^3.0.0",
24 | "uint8arrays": "^3.0.0"
25 | },
26 | "devDependencies": {
27 | "@babel/core": "^7.14.8",
28 | "@playwright/test": "^1.12.3",
29 | "events": "^3.3.0",
30 | "fs-extra": "^10.0.0",
31 | "ipfs-http-client": "^58.0.0",
32 | "playwright": "^1.12.3",
33 | "process": "^0.11.10",
34 | "rimraf": "^3.0.2",
35 | "test-util-ipfs-example": "^1.0.2",
36 | "util": "^0.12.4",
37 | "vite": "^3.1.0"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/examples/circuit-relaying/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/custom-ipfs-repo/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/custom-ipfs-repo/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/custom-ipfs-repo"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/custom-ipfs-repo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-custom-ipfs-repo",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Customizing your ipfs repo",
7 | "license": "MIT",
8 | "main": "index.js",
9 | "scripts": {
10 | "clean": "echo 'Nothing to clean...'",
11 | "start": "node index.js",
12 | "serve": "npm run start",
13 | "test": "node tests/test.js"
14 | },
15 | "dependencies": {
16 | "@ipld/dag-cbor": "^7.0.0",
17 | "@ipld/dag-pb": "^2.1.3",
18 | "blockstore-datastore-adapter": "^3.0.1",
19 | "datastore-fs": "^8.0.0",
20 | "ipfs-core": "^0.16.0",
21 | "ipfs-repo": "^15.0.2",
22 | "it-all": "^1.0.4",
23 | "multiformats": "^9.6.5",
24 | "uint8arrays": "^3.0.0",
25 | "why-is-node-running": "^2.2.2"
26 | },
27 | "devDependencies": {
28 | "test-util-ipfs-example": "^1.0.2"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/examples/custom-ipfs-repo/tests/test.js:
--------------------------------------------------------------------------------
1 | import { node } from 'test-util-ipfs-example'
2 | import path from 'path'
3 | import fs from 'fs'
4 | import { fileURLToPath } from 'url'
5 |
6 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
7 |
8 | async function test () {
9 | await node.execa('node', [path.join(__dirname, '../index.js')], {
10 | cwd: path.resolve(__dirname),
11 | all: true
12 | }, (exec) => {
13 | exec.all.on('data', (data) => {
14 | process.stdout.write(data)
15 | })
16 | })
17 |
18 | if (!fs.existsSync('/tmp/custom-repo/.ipfs')) {
19 | throw new Error('Custom repo was not created at /tmp/custom-repo/.ipfs')
20 | }
21 | }
22 |
23 | test();
24 |
--------------------------------------------------------------------------------
/examples/custom-ipld-formats/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/custom-ipld-formats/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/custom-ipld-formats"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/custom-ipld-formats/in-process-node.js:
--------------------------------------------------------------------------------
1 | import * as IPFS from 'ipfs-core'
2 | import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
3 | import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
4 |
5 | async function main () {
6 | // see https://github.com/multiformats/js-multiformats#multicodec-encoders--decoders--codecs for the interface definition
7 | const codec = {
8 | name: 'dag-test',
9 | code: 392091,
10 | encode: (data) => uint8ArrayFromString(JSON.stringify(data)),
11 | decode: (buf) => JSON.parse(uint8ArrayToString(buf))
12 | }
13 |
14 | const node = await IPFS.create({
15 | ipld: {
16 | codecs: [
17 | codec
18 | ]
19 | }
20 | })
21 |
22 | const data = {
23 | hello: 'world'
24 | }
25 |
26 | const cid = await node.dag.put(data, {
27 | storeCodec: 'dag-test',
28 | hashAlg: 'sha2-256'
29 | })
30 |
31 | console.info(`Put ${JSON.stringify(data)} = CID(${cid})`)
32 |
33 | const {
34 | value
35 | } = await node.dag.get(cid)
36 |
37 | console.info(`Get CID(${cid}) = ${JSON.stringify(value)}`)
38 |
39 | await node.stop()
40 | }
41 |
42 | main()
43 | .catch(err => {
44 | console.error(err)
45 | process.exit(1)
46 | })
47 | .then(() => {
48 | // https://github.com/libp2p/js-libp2p/issues/779
49 | process.exit(0)
50 | })
51 |
--------------------------------------------------------------------------------
/examples/custom-ipld-formats/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-custom-ipld-formats",
3 | "version": "1.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "type": "module",
7 | "scripts": {
8 | "clean": "echo 'Nothing to clean...'",
9 | "start": "node in-process-node.js & node daemon-node.js",
10 | "serve": "npm run start",
11 | "test": "node tests/test.js"
12 | },
13 | "dependencies": {
14 | "dag-jose": "^2.0.1",
15 | "ipfs-core": "^0.16.0",
16 | "ipfs-daemon": "^0.14.0",
17 | "ipfs-http-client": "^58.0.0",
18 | "multiformats": "^9.6.5",
19 | "uint8arrays": "^3.0.0"
20 | },
21 | "devDependencies": {
22 | "test-util-ipfs-example": "^1.0.2"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/examples/custom-ipld-formats/tests/test.js:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { node } from 'test-util-ipfs-example'
3 | import { fileURLToPath } from 'url'
4 |
5 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
6 |
7 | const testInProcessNode = async () => {
8 | await node.waitForOutput(
9 | 'Put {"hello":"world"} = CID(bagn7ofysecj2eolrvekol2wl6cuneukuzwrqtq6by4x3xgiu2r6gb46lnakyq)\n' +
10 | 'Get CID(bagn7ofysecj2eolrvekol2wl6cuneukuzwrqtq6by4x3xgiu2r6gb46lnakyq) = {"hello":"world"}', 'node', [path.resolve(__dirname, '../in-process-node.js')])
11 | }
12 |
13 | const testDaemonNode = async () => {
14 | await node.waitForOutput(
15 | 'Put {"hello":"world"} = CID(bagn7ofysecj2eolrvekol2wl6cuneukuzwrqtq6by4x3xgiu2r6gb46lnakyq)\n' +
16 | 'Get CID(bagn7ofysecj2eolrvekol2wl6cuneukuzwrqtq6by4x3xgiu2r6gb46lnakyq) = {"hello":"world"}', 'node', [path.resolve(__dirname, '../daemon-node.js')])
17 | }
18 |
19 | async function test () {
20 | console.info('Testing in-process node')
21 | await testInProcessNode()
22 |
23 | console.info('Testing daemon node')
24 | await testDaemonNode()
25 | }
26 |
27 | test();
28 |
--------------------------------------------------------------------------------
/examples/custom-libp2p/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/custom-libp2p/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/custom-libp2p"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/custom-libp2p/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-custom-libp2p",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Customizing your libp2p node",
7 | "license": "MIT",
8 | "main": "index.js",
9 | "scripts": {
10 | "clean": "echo 'Nothing to clean...'",
11 | "start": "node index.js",
12 | "serve": "npm run start",
13 | "test": "node tests/test.js"
14 | },
15 | "dependencies": {
16 | "@chainsafe/libp2p-noise": "^8.0.1",
17 | "@libp2p/bootstrap": "^2.0.0",
18 | "@libp2p/kad-dht": "^3.0.4",
19 | "@libp2p/mdns": "^3.0.0",
20 | "@libp2p/mplex": "^5.2.0",
21 | "@libp2p/tcp": "^3.0.6",
22 | "ipfs-core": "^0.16.0",
23 | "libp2p": "^0.39.0",
24 | "uint8arrays": "^3.0.0"
25 | },
26 | "devDependencies": {
27 | "test-util-ipfs-example": "^1.0.2"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/http-client-browser-pubsub"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-browser-pubsub/favicon.ico
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-http-client-browser-pubsub-example",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "An example demonstrating pubsub in the browser",
7 | "license": "MIT",
8 | "author": "Alan Shaw",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests --retries=3"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-http-client": "^58.0.0",
19 | "kubo-rpc-client": "^1.0.1"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.14.8",
23 | "@playwright/test": "^1.12.3",
24 | "go-ipfs": "^0.15.0",
25 | "ipfs": "^0.64.0",
26 | "playwright": "^1.12.3",
27 | "process": "^0.11.10",
28 | "rimraf": "^3.0.2",
29 | "test-util-ipfs-example": "^1.0.2",
30 | "util": "^0.12.4",
31 | "vite": "^3.1.0"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/src/util.js:
--------------------------------------------------------------------------------
1 | export const sleep = (ms = 1000) => new Promise(resolve => setTimeout(resolve, ms))
2 |
3 | export const Logger = outEl => {
4 | outEl.innerHTML = ''
5 | return message => {
6 | const container = document.createElement('div')
7 | container.innerHTML = message
8 | outEl.appendChild(container)
9 | outEl.scrollTop = outEl.scrollHeight
10 | }
11 | }
12 |
13 | export const onEnterPress = fn => {
14 | return e => {
15 | if (event.which == 13 || event.keyCode == 13) {
16 | e.preventDefault()
17 | fn()
18 | }
19 | }
20 | }
21 |
22 | export const catchAndLog = (fn, log) => {
23 | return async (...args) => {
24 | try {
25 | await fn(...args)
26 | } catch (err) {
27 | console.error(err)
28 | log(`${err.message}`)
29 | }
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/examples/http-client-browser-pubsub/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/http-client-bundle-webpack"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-bundle-webpack/img/screenshot.png
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-http-client-bundle-webpack",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Bundle js-ipfs-http-client with Webpack",
7 | "keywords": [],
8 | "license": "MIT",
9 | "author": "Victor Bjelkholm ",
10 | "scripts": {
11 | "clean": "rimraf ./dist",
12 | "build": "webpack --env production",
13 | "serve": "webpack serve --hot-only --mode=development",
14 | "start": "npm run serve",
15 | "test": "npm run build && playwright test tests"
16 | },
17 | "browserslist": [
18 | "last 1 Chrome version"
19 | ],
20 | "dependencies": {
21 | "ipfs-http-client": "^58.0.0",
22 | "react": "^17.0.2",
23 | "react-dom": "^17.0.2"
24 | },
25 | "devDependencies": {
26 | "@babel/core": "^7.13.14",
27 | "@babel/preset-env": "^7.13.12",
28 | "@babel/preset-react": "^7.13.13",
29 | "@playwright/test": "^1.12.3",
30 | "babel-loader": "^8.2.3",
31 | "copy-webpack-plugin": "^10.0.0",
32 | "css-loader": "^6.2.0",
33 | "html-webpack-plugin": "^5.3.1",
34 | "ipfs": "^0.64.0",
35 | "node-polyfill-webpack-plugin": "^2.0.1",
36 | "playwright": "^1.12.3",
37 | "react-hot-loader": "^4.12.21",
38 | "rimraf": "^3.0.2",
39 | "style-loader": "^3.1.0",
40 | "test-util-ipfs-example": "^1.0.2",
41 | "webpack": "^5.28.0",
42 | "webpack-cli": "^4.5.0",
43 | "webpack-merge": "^5.8.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-bundle-webpack/public/favicon.ico
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/http-client-bundle-webpack/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom'
3 | import App from './App.js'
4 |
5 | ReactDOM.render(, document.getElementById('root'))
6 |
7 | // Check if HMR interface is enabled
8 | if (module.hot) {
9 | // Accept hot update
10 | module.hot.accept()
11 | }
12 |
--------------------------------------------------------------------------------
/examples/http-client-name-api/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/http-client-name-api/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/http-client-name-api"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/http-client-name-api/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-name-api/favicon.ico
--------------------------------------------------------------------------------
/examples/http-client-name-api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-http-client-name-api",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "",
7 | "license": "MIT",
8 | "author": "Tara Vancil ",
9 | "scripts": {
10 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
11 | "build": "vite build",
12 | "serve": "vite dev --port 8888",
13 | "start": "npm run serve",
14 | "test": "npm run build && playwright test tests"
15 | },
16 | "browserslist": "last 1 Chrome version",
17 | "dependencies": {
18 | "ipfs-http-client": "^58.0.0",
19 | "kubo-rpc-client": "^1.0.1"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.14.8",
23 | "@playwright/test": "^1.12.3",
24 | "go-ipfs": "^0.15.0",
25 | "playwright": "^1.12.3",
26 | "process": "^0.11.10",
27 | "rimraf": "^3.0.2",
28 | "test-util-ipfs-example": "^1.0.2",
29 | "util": "^0.12.4",
30 | "vite": "^3.1.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/examples/http-client-name-api/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/http-client-upload-file"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-upload-file/favicon.ico
--------------------------------------------------------------------------------
/examples/http-client-upload-file/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/http-client-upload-file/img/screenshot.png
--------------------------------------------------------------------------------
/examples/http-client-upload-file/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | IPFS http client
8 |
9 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-http-client-upload-file",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "Upload file to IPFS via browser using js-ipfs-http-client",
7 | "license": "MIT",
8 | "author": "Harlan T Wood ",
9 | "contributors": [
10 | "Victor Bjelkholm "
11 | ],
12 | "scripts": {
13 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
14 | "build": "vite build",
15 | "serve": "vite dev --port 8888",
16 | "start": "npm run serve",
17 | "test": "npm run build && playwright test tests"
18 | },
19 | "browserslist": "last 1 Chrome version",
20 | "dependencies": {
21 | "ipfs-http-client": "^58.0.0",
22 | "react": "^17.0.2",
23 | "react-dom": "^17.0.2"
24 | },
25 | "devDependencies": {
26 | "@babel/core": "^7.14.8",
27 | "@playwright/test": "^1.12.3",
28 | "ipfs": "^0.64.0",
29 | "playwright": "^1.12.3",
30 | "process": "^0.11.10",
31 | "rimraf": "^3.0.2",
32 | "test-util-ipfs-example": "^1.0.2",
33 | "util": "^0.12.4",
34 | "vite": "^3.1.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/src/index.jsx:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-unused-vars */
2 | 'use strict'
3 | import React from 'react'
4 | import ReactDOM from 'react-dom'
5 | import App from './app.jsx'
6 |
7 | ReactDOM.render(, document.getElementById('root'))
8 |
--------------------------------------------------------------------------------
/examples/http-client-upload-file/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/ipfs-101/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/ipfs-101/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/ipfs-101"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/ipfs-101/hello.txt:
--------------------------------------------------------------------------------
1 | Hello, how are you today? Welcome to the Distributed Web!
2 |
--------------------------------------------------------------------------------
/examples/ipfs-101/index.js:
--------------------------------------------------------------------------------
1 | import * as IPFS from 'ipfs-core'
2 | import all from 'it-all'
3 | import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
4 | import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
5 | import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
6 |
7 | async function main () {
8 | const node = await IPFS.create()
9 | const version = await node.version()
10 |
11 | console.log('Version:', version.version)
12 |
13 | const file = await node.add({
14 | path: 'hello.txt',
15 | content: uint8ArrayFromString('Hello World 101')
16 | })
17 |
18 | console.log('Added file:', file.path, file.cid.toString())
19 |
20 | const data = uint8ArrayConcat(await all(node.cat(file.cid)))
21 |
22 | console.log('Added file contents:', uint8ArrayToString(data))
23 | }
24 |
25 | main()
26 |
--------------------------------------------------------------------------------
/examples/ipfs-101/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-ipfs-101",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "this package.json needs to exist because of new npm config https://github.com/ipfs/js-ipfs/issues/977#issuecomment-326741092",
7 | "license": "MIT",
8 | "author": "David Dias ",
9 | "main": "1.js",
10 | "scripts": {
11 | "clean": "echo 'Nothing to clean...'",
12 | "start": "node index.js",
13 | "serve": "npm run start",
14 | "test": "node tests/test.js"
15 | },
16 | "dependencies": {
17 | "ipfs-core": "^0.16.0",
18 | "it-all": "^1.0.4",
19 | "uint8arrays": "^3.0.0"
20 | },
21 | "devDependencies": {
22 | "test-util-ipfs-example": "^1.0.2"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/examples/ipfs-101/tests/test.js:
--------------------------------------------------------------------------------
1 | import { node } from 'test-util-ipfs-example'
2 | import path from 'path'
3 | import { fileURLToPath } from 'url'
4 |
5 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
6 |
7 | async function test () {
8 | await node.waitForOutput('Added file contents: Hello World 101', 'node', [path.resolve(__dirname, '../index.js')])
9 | }
10 |
11 | test();
12 |
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/ipfs-client-add-files"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/ipfs-client-add-files/favicon.ico
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-ipfs-client-add-files",
3 | "version": "1.0.0",
4 | "private": true,
5 | "type": "module",
6 | "description": "",
7 | "scripts": {
8 | "clean": "rimraf ./dist ./.cache ./node_modules/.vite",
9 | "build": "vite build",
10 | "serve": "vite dev --port 8888",
11 | "start": "npm run serve",
12 | "test": "npm run build && playwright test tests"
13 | },
14 | "browserslist": "last 1 Chrome version",
15 | "dependencies": {
16 | "ipfs-client": "^0.8.2"
17 | },
18 | "devDependencies": {
19 | "@babel/core": "^7.14.8",
20 | "@playwright/test": "^1.12.3",
21 | "ipfs": "^0.64.0",
22 | "playwright": "^1.12.3",
23 | "process": "^0.11.10",
24 | "rimraf": "^3.0.2",
25 | "test-util-ipfs-example": "^1.0.2",
26 | "util": "^0.12.4",
27 | "vite": "^3.1.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/src/app.css:
--------------------------------------------------------------------------------
1 | ::placeholder {
2 | color: rgb(0 0 0 / 30%);
3 | }
4 |
5 | form {
6 | margin: 1.25rem 0;
7 | }
8 |
9 | .hidden {
10 | display: none;
11 | }
12 |
13 | .window {
14 | display: flex;
15 | flex-direction: column;
16 | background: #222;
17 | color: #fff;
18 | height: 400px;
19 | }
20 |
21 | .window .header {
22 | flex-basis: 3rem;
23 | background: #c6c6c6;
24 | position: relative;
25 | }
26 |
27 | .window .header:after {
28 | content: ". . .";
29 | position: absolute;
30 | left: 12px;
31 | right: 0;
32 | top: -3px;
33 | font-family: "Times New Roman", Times, serif;
34 | font-size: 96px;
35 | color: #fff;
36 | line-height: 0;
37 | letter-spacing: -12px;
38 | }
39 |
40 | .terminal {
41 | margin: 20px;
42 | font-family: monospace;
43 | font-size: 16px;
44 | overflow: auto;
45 | flex: 1;
46 | }
47 |
48 | .terminal::-webkit-scrollbar {
49 | width: 10px;
50 | }
51 |
52 | .terminal::-webkit-scrollbar-track {
53 | background-color: whitesmoke;
54 | border-radius: 100px;
55 | }
56 |
57 | .terminal::-webkit-scrollbar-thumb {
58 | box-shadow: inset 0 0 12px rgb(0 0 0 / 80%);
59 | border-radius: 100px;
60 | }
61 |
--------------------------------------------------------------------------------
/examples/ipfs-client-add-files/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 |
3 | export default defineConfig({
4 | build: {
5 | target: 'es2020',
6 | minify: false,
7 | // disable @rollup/plugin-commonjs https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
8 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
9 | commonjsOptions: {
10 | include: []
11 | }
12 | },
13 | define: {
14 | 'process.env.NODE_DEBUG': 'false',
15 | 'global': 'globalThis'
16 | },
17 | optimizeDeps: {
18 | // enable esbuild dep optimization during build https://github.com/vitejs/vite/issues/9703#issuecomment-1216662109
19 | // should be removable with vite 4 https://vitejs.dev/blog/announcing-vite3.html#esbuild-deps-optimization-at-build-time-experimental
20 | disabled: false,
21 |
22 | // target: es2020 added as workaround to make big ints work
23 | // - should be removable with vite 4
24 | // https://github.com/vitejs/vite/issues/9062#issuecomment-1182818044
25 | esbuildOptions: {
26 | target: 'es2020'
27 | }
28 | }
29 | })
30 |
--------------------------------------------------------------------------------
/examples/run-in-electron/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/run-in-electron/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/run-in-electron"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/run-in-electron/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | IPFS Electron
8 |
9 |
10 |
11 |
12 | IPFS in electron!
13 | now check your console
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/run-in-electron/main.js:
--------------------------------------------------------------------------------
1 | const { app, BrowserWindow } = require('electron')
2 |
3 | let mainWindow;
4 |
5 | function createWindow() {
6 | mainWindow = new BrowserWindow({
7 | width: 800,
8 | height: 600,
9 | webPreferences: {
10 | nodeIntegration: true
11 | }
12 | });
13 |
14 | // and load the index.html of the app.
15 | mainWindow.loadFile("index.html");
16 |
17 | // Open the DevTools.
18 | mainWindow.webContents.openDevTools();
19 |
20 | // Emitted when the window is closed.
21 | mainWindow.on("closed", () => {
22 | mainWindow = null;
23 | });
24 | }
25 |
26 | app.on("ready", async () => {
27 | createWindow();
28 |
29 | try {
30 | const IPFS = await import('ipfs-core')
31 | const node = await IPFS.create();
32 | const id = await node.id();
33 | console.log(id);
34 | } catch (err) {
35 | console.error(err);
36 | }
37 | });
38 |
39 | // Quit when all windows are closed.
40 | app.on("window-all-closed", () => {
41 | if (process.platform !== "darwin") {
42 | app.quit();
43 | }
44 | });
45 |
46 | app.on("activate", () => {
47 | if (mainWindow === null) {
48 | createWindow();
49 | }
50 | });
51 |
52 | // In this file you can include the rest of your app's specific main process
53 | // code. You can also put them in separate files and require them here.
54 |
--------------------------------------------------------------------------------
/examples/run-in-electron/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-js-ipfs-in-electron",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "A minimal Electron application with js-ipfs",
6 | "keywords": [
7 | "Electron",
8 | "IPFS",
9 | "Example"
10 | ],
11 | "license": "MIT",
12 | "author": "David Dias ",
13 | "main": "main.js",
14 | "scripts": {
15 | "clean": "echo 'Nothing to clean...'",
16 | "start": "electron .",
17 | "serve": "npm run start",
18 | "test": "xvfb-maybe node test.mjs"
19 | },
20 | "dependencies": {
21 | "ipfs-core": "^0.16.0"
22 | },
23 | "devDependencies": {
24 | "electron": "^20.1.1",
25 | "electron-rebuild": "^3.1.1",
26 | "test-util-ipfs-example": "^1.0.2",
27 | "xvfb-maybe": "^0.2.1"
28 | },
29 | "greenkeeper": {
30 | "ignore": [
31 | "electron"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/run-in-electron/renderer.js:
--------------------------------------------------------------------------------
1 | // This file is required by the index.html file and will
2 | // be executed in the renderer process for that window.
3 | // All of the Node.js APIs are available in this process.
4 |
--------------------------------------------------------------------------------
/examples/run-in-electron/test.mjs:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | import { node } from "test-util-ipfs-example";
4 | import path from "path"
5 | import { fileURLToPath } from 'url'
6 |
7 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
8 |
9 | async function test() {
10 | await node.waitForOutput("protocolVersion", "electron", [
11 | path.resolve(`${__dirname}/main.js`)
12 | ]);
13 | }
14 |
15 | test();
16 |
--------------------------------------------------------------------------------
/examples/running-multiple-nodes/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/running-multiple-nodes/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/running-multiple-nodes"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/running-multiple-nodes/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-running-multiple-nodes",
3 | "version": "2.0.1",
4 | "private": true,
5 | "type": "module",
6 | "description": "How to run multiple IPFS nodes at the same time",
7 | "keywords": [],
8 | "license": "MIT",
9 | "main": "index.js",
10 | "scripts": {
11 | "clean": "echo 'Nothing to clean...'",
12 | "start": "npm run test",
13 | "serve": "npm run start",
14 | "test": "node tests/test.js"
15 | },
16 | "dependencies": {
17 | "ipfs": "^0.64.0"
18 | },
19 | "devDependencies": {
20 | "nanoid": "^4.0.0",
21 | "test-util-ipfs-example": "^1.0.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/traverse-ipld-graphs"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/create-node.js:
--------------------------------------------------------------------------------
1 | import * as IPFS from 'ipfs-core'
2 |
3 | function createNode (options) {
4 | options = options || {}
5 | options.path = options.path || '/tmp/ipfs' + Math.random()
6 | return IPFS.create({
7 | repo: options.path,
8 | config: {
9 | Addresses: {
10 | Swarm: [
11 | '/ip4/0.0.0.0/tcp/0'
12 | ],
13 | API: '/ip4/127.0.0.1/tcp/0',
14 | Gateway: '/ip4/127.0.0.1/tcp/0'
15 | }
16 | },
17 | ipld: options.ipld
18 | })
19 | }
20 |
21 | export default createNode
22 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302515:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/eth-blocks/block_302515
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/eth-blocks/block_302516
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302517:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/eth-blocks/block_302517
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get-path-accross-formats.js:
--------------------------------------------------------------------------------
1 | import createNode from './create-node.js'
2 | import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
3 |
4 | async function main () {
5 | const ipfs = await createNode()
6 |
7 | console.log('\nStart of the example:')
8 |
9 | const someData = uint8ArrayFromString('capoeira')
10 | const pbNode = {
11 | Data: someData,
12 | Links: []
13 | }
14 |
15 | const pbNodeCid = await ipfs.dag.put(pbNode, {
16 | storeCodec: 'dag-pb',
17 | hashAlg: 'sha2-256'
18 | })
19 |
20 | const myData = {
21 | name: 'David',
22 | likes: ['js-ipfs', 'icecream', 'steak'],
23 | hobbies: [pbNodeCid]
24 | }
25 |
26 | const cborNodeCid = await ipfs.dag.put(myData, {
27 | storeCodec: 'dag-cbor',
28 | hashAlg: 'sha2-512'
29 | })
30 |
31 | const result = await ipfs.dag.get(cborNodeCid, {
32 | path: 'hobbies/0/Data'
33 | })
34 |
35 | console.log(result.value.toString())
36 | }
37 |
38 | main()
39 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get-path.js:
--------------------------------------------------------------------------------
1 | import createNode from './create-node.js'
2 |
3 | async function main () {
4 | const ipfs = await createNode()
5 |
6 | console.log('\nStart of the example:')
7 |
8 | const myData = {
9 | name: 'David',
10 | likes: ['js-ipfs', 'icecream', 'steak']
11 | }
12 |
13 | const cid = await ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' })
14 | let result
15 |
16 | result = await ipfs.dag.get(cid, { path: 'name' })
17 | console.log(result.value)
18 |
19 | result = await ipfs.dag.get(cid, { path: 'likes' })
20 | console.log(result.value)
21 |
22 | result = await ipfs.dag.get(cid, { path: '/likes/0' })
23 | console.log(result.value)
24 | }
25 |
26 | main()
27 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get.js:
--------------------------------------------------------------------------------
1 | import createNode from './create-node.js'
2 |
3 | async function main () {
4 | const ipfs = await createNode()
5 |
6 | console.log('\nStart of the example:')
7 |
8 | const myData = {
9 | name: 'David',
10 | likes: ['js-ipfs', 'icecream', 'steak']
11 | }
12 |
13 | const cid = await ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' })
14 | const result = await ipfs.dag.get(cid)
15 |
16 | console.log(JSON.stringify(result.value))
17 | }
18 |
19 | main()
20 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/0f328c91df28c5c01b9e9f9f7e663191fa156593:
--------------------------------------------------------------------------------
1 | commit 175 tree dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
2 | author John Doe 1504619620 +0200
3 | committer John Doe 1504619620 +0200
4 |
5 | Initial commit
6 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/177bf18bc707d82b21cdefd0b43b38fc8c5c13fe:
--------------------------------------------------------------------------------
1 | blob 14 Git IPLD demo
2 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/23cc25f631cb076d5de5036c87678ea713cbaa6a:
--------------------------------------------------------------------------------
1 | blob 21 echo 'Hello, World!'
2 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/4e425dba7745a781f0712c9a01455899e8c0c249:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/git-objects/4e425dba7745a781f0712c9a01455899e8c0c249
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/6850c7be7136e6be00976ddbae80671b945c3e9d:
--------------------------------------------------------------------------------
1 | tag 142 object e68e6f6e31857877a79fd6b3956898436bb5a76f
2 | type commit
3 | tag v1.0.0
4 | tagger John Doe 1504620173 +0200
5 |
6 | Release v1.0.0
7 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/a5095353cd62a178663dd26efc2d61f4f61bccbe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/git-objects/a5095353cd62a178663dd26efc2d61f4f61bccbe
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/dc9bd15e8b81b6565d3736f9c308bd1bba60f33a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/git-objects/dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/e68e6f6e31857877a79fd6b3956898436bb5a76f:
--------------------------------------------------------------------------------
1 | commit 222 tree 4e425dba7745a781f0712c9a01455899e8c0c249
2 | parent 0f328c91df28c5c01b9e9f9f7e663191fa156593
3 | author John Doe 1504620164 +0200
4 | committer John Doe 1504620164 +0200
5 |
6 | Improve hello
7 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/ee62b3d206cb23f939208898f32d8708c0e3fa3c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/traverse-ipld-graphs/git-objects/ee62b3d206cb23f939208898f32d8708c0e3fa3c
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/ee71cef5001b84b0314438f76cf0acd338a2fd21:
--------------------------------------------------------------------------------
1 | blob 20 echo 'hello world!'
2 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-traverse-ipld-graphs",
3 | "version": "2.0.1",
4 | "private": true,
5 | "type": "module",
6 | "description": "How to traverse IPLD graphs",
7 | "keywords": [],
8 | "license": "MIT",
9 | "main": "index.js",
10 | "scripts": {
11 | "clean": "echo 'Nothing to clean...'",
12 | "start": "npm run test",
13 | "serve": "npm run start",
14 | "test": "node tests/test.js"
15 | },
16 | "dependencies": {
17 | "@ipld/dag-pb": "^2.1.3",
18 | "ipfs-core": "^0.16.0",
19 | "ipld-ethereum": "^6.0.0",
20 | "ipld-format-to-blockcodec": "0.0.1",
21 | "ipld-git": "^0.6.1",
22 | "js-sha3": "^0.8.0",
23 | "multiformats": "^9.6.5"
24 | },
25 | "devDependencies": {
26 | "test-util-ipfs-example": "^1.0.2"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/put.js:
--------------------------------------------------------------------------------
1 | import createNode from './create-node.js'
2 |
3 | async function main () {
4 | const ipfs = await createNode()
5 |
6 | console.log('\nStart of the example:')
7 |
8 | const myData = {
9 | name: 'David',
10 | likes: ['js-ipfs', 'icecream', 'steak']
11 | }
12 |
13 | const cid = await ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' })
14 | console.log(cid.toString())
15 | // should print:
16 | // bafyreigsccjrxlioppkkzv27se4gxh2aygbxfnsobkaxxqiuni544uk66a
17 | }
18 |
19 | main()
20 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/tests/test.js:
--------------------------------------------------------------------------------
1 | import path from 'path'
2 | import { node } from 'test-util-ipfs-example'
3 | import { fileURLToPath } from 'url'
4 |
5 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
6 |
7 | async function runTest () {
8 | console.info('Testing put.js')
9 | await node.waitForOutput('bafyreigsccjrxlioppkkzv27se4gxh2aygbxfnsobkaxxqiuni544uk66a', 'node', [path.resolve(__dirname, '../put.js')])
10 |
11 | console.info('Testing get.js')
12 | await node.waitForOutput('{"name":"David","likes":["js-ipfs","icecream","steak"]}', 'node', [path.resolve(__dirname, '../get.js')])
13 |
14 | console.info('Testing get-path.js')
15 | await node.waitForOutput('js-ipfs', 'node', [path.resolve(__dirname, '../get-path.js')])
16 |
17 | console.info('Testing get-path-accross-formats.js')
18 | await node.waitForOutput('capoeira', 'node', [path.resolve(__dirname, '../get-path-accross-formats.js')])
19 |
20 | console.info('Testing eth.js')
21 | await node.waitForOutput('302516', 'node', [path.resolve(__dirname, '../eth.js')])
22 |
23 | console.info('Testing git.js')
24 | await node.waitForOutput("CID(baf4bcfhgrzxw4mmfpb32ph6wwokwrgcdno22o3y)", 'node', [path.resolve(__dirname, '../git.js')])
25 |
26 | console.info('Done!')
27 | }
28 |
29 | runTest()
30 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/types-use-ipfs-from-ts"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/img/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/types-use-ipfs-from-ts/img/preview.png
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-types-use-ipfs-from-ts",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "Template for using js-ipfs in typescript project",
6 | "scripts": {
7 | "clean": "echo 'Nothing to clean...'",
8 | "test": "tsc --noEmit"
9 | },
10 | "dependencies": {
11 | "ipfs-core": "^0.16.0",
12 | "multiformats": "^9.6.5"
13 | },
14 | "devDependencies": {
15 | "typescript": "^4.5.5"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/src/main.ts:
--------------------------------------------------------------------------------
1 | import { IPFS, create } from 'ipfs-core'
2 | import type { CID } from 'multiformats/cid'
3 |
4 | export default async function main() {
5 | const node = await create()
6 | const version = await node.version()
7 |
8 | console.log('Version:', version.version)
9 |
10 | const file = await node.add({
11 | path: 'hello.txt',
12 | content: new TextEncoder().encode('Hello World 101')
13 | })
14 |
15 | console.log('Added file:', file.path, file.cid.toString())
16 | try {
17 | // @ts-expect-error CID has no toUpperCase method
18 | file.cid.toUpperCase()
19 | } catch (error) {
20 |
21 | }
22 |
23 | const content = await readFile(node, file.cid)
24 |
25 | console.log('Added file contents:', content)
26 | }
27 |
28 | const readFile = async (ipfs: IPFS, cid: CID): Promise => {
29 | const decoder = new TextDecoder()
30 | let content = ''
31 |
32 | for await (const chunk of ipfs.cat(cid)) {
33 | content += decoder.decode(chunk, {
34 | stream: true
35 | })
36 | }
37 |
38 | return content
39 | }
40 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-ts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "skipLibCheck": true,
5 | "noImplicitAny": false,
6 | "esModuleInterop": true,
7 | "moduleResolution": "node",
8 | "noEmit": true,
9 | "lib": ["ES2020", "ES2020.Promise", "ES2020.String", "ES2020.BigInt", "DOM", "DOM.Iterable"]
10 | },
11 | "include": [
12 | "src"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | **IMPORTANT: Please do not create a Pull Request for this repository.**
2 |
3 | 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.
4 |
5 | Please open a PR against [IPFS Examples](https://github.com/ipfs-examples/js-ipfs-examples) instead.
6 |
7 | ## Contributing
8 |
9 | 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**.
10 |
11 | 1. Fork the [IPFS Examples Project](https://github.com/ipfs-examples/js-ipfs-examples)
12 | 2. Create your Feature Branch (`git checkout -b feature/amazing-example`)
13 | 3. Commit your Changes (`git commit -a -m 'feat: add some amazing example'`)
14 | 4. Push to the Branch (`git push origin feature/amazing-example`)
15 | 5. Open a Pull Request
16 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Sync
2 | on:
3 | workflow_dispatch:
4 | schedule:
5 | - cron: "0 0 * * *"
6 |
7 | jobs:
8 | sync:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - name: Pull from another repository
13 | uses: ipfs-examples/actions-pull-directory-from-repo@main
14 | with:
15 | source-repo: "ipfs-examples/js-ipfs-examples"
16 | source-folder-path: "examples/types-use-ipfs-from-typed-js"
17 | source-branch: "master"
18 | target-branch: "main"
19 | git-username: github-actions
20 | git-email: github-actions@github.com
21 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/img/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/examples/types-use-ipfs-from-typed-js/img/preview.png
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example-types-use-ipfs-from-typed-js",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "Template for setting up a project with JSDoc",
6 | "scripts": {
7 | "clean": "echo 'Nothing to clean...'",
8 | "test": "tsc --noEmit"
9 | },
10 | "dependencies": {
11 | "ipfs-core": "^0.16.0",
12 | "multiformats": "^9.6.5"
13 | },
14 | "devDependencies": {
15 | "typescript": "^4.5.5"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/src/main.js:
--------------------------------------------------------------------------------
1 | import { create } from 'ipfs-core'
2 |
3 | /**
4 | * @typedef {import('ipfs-core').IPFS} IPFS
5 | * @typedef {import('multiformats/cid').CID} CID
6 | */
7 |
8 | async function main () {
9 | const node = await create()
10 | const version = await node.version()
11 |
12 | console.log('Version:', version.version)
13 |
14 | const file = await node.add({
15 | path: 'hello.txt',
16 | content: new TextEncoder().encode('Hello World 101')
17 | })
18 |
19 | console.log('Added file:', file.path, file.cid.toString())
20 | try {
21 | // @ts-expect-error CID has no toUpperCase method
22 | file.cid.toUpperCase()
23 | } catch(error) {
24 |
25 | }
26 |
27 | const content = await readFile(node, file.cid)
28 |
29 | console.log('Added file contents:', content)
30 | }
31 |
32 | /**
33 | * @param {IPFS} ipfs
34 | * @param {CID} cid
35 | * @returns {Promise}
36 | */
37 | const readFile = async (ipfs, cid) => {
38 | const decoder = new TextDecoder()
39 | let content = ''
40 |
41 | for await (const chunk of ipfs.cat(cid)) {
42 | content += decoder.decode(chunk, {
43 | stream: true
44 | })
45 | }
46 |
47 | return content
48 | }
49 |
50 | main()
51 |
--------------------------------------------------------------------------------
/examples/types-use-ipfs-from-typed-js/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowJs": true,
4 | "checkJs": true,
5 | "strict": true,
6 | "skipLibCheck": true,
7 | "noImplicitAny": false,
8 | "esModuleInterop": true,
9 | "moduleResolution": "node",
10 | "noEmit": true,
11 | "lib": ["ES2020", "ES2020.Promise", "ES2020.String", "ES2020.BigInt", "DOM", "DOM.Iterable"]
12 | },
13 | "include": [
14 | "src"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/img/repo_details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/img/repo_details.png
--------------------------------------------------------------------------------
/img/repo_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ipfs-examples/js-ipfs-examples/8ff05484398ad240e6829120dbce22aabf885ace/img/repo_settings.png
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/index.js:
--------------------------------------------------------------------------------
1 |
2 | export * as playwright from './playwright/index.js'
3 | export * as node from './node/index.js'
4 |
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/node/execa.js:
--------------------------------------------------------------------------------
1 |
2 | import fs from 'fs-extra'
3 | import { execa } from 'execa'
4 | import which from 'which'
5 |
6 | async function isExecutable(command) {
7 | try {
8 | await fs.access(command, fs.constants.X_OK, () => {});
9 |
10 | return true;
11 | } catch (err) {
12 | if (err.code === "ENOENT") {
13 | return await isExecutable(await which(command));
14 | }
15 |
16 | if (err.code === "EACCES") {
17 | return false;
18 | }
19 |
20 | throw err;
21 | }
22 | }
23 |
24 | async function execaUtil(command, args = [], opts = {}, callback = null) {
25 | if (!(await isExecutable(command))) {
26 | args.unshift(command);
27 | command = "node";
28 | }
29 |
30 | const proc = execa(command, args, { ...opts, all: true });
31 |
32 | if (callback) {
33 | callback(proc)
34 | }
35 |
36 | return proc
37 | }
38 |
39 | export default execaUtil;
40 |
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/node/index.js:
--------------------------------------------------------------------------------
1 |
2 | export { default as waitForOutput } from './wait-for-output.js'
3 | export { default as execa } from './execa.js'
4 |
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test-util-ipfs-example",
3 | "version": "1.0.2",
4 | "description": "Utilities to test ipfs examples",
5 | "type": "module",
6 | "keywords": [
7 | "test",
8 | "examples",
9 | "ipfs"
10 | ],
11 | "bugs": {
12 | "url": "https://github.com/ipfs-examples/js-ipfs-examples/issues"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/ipfs-examples/js-ipfs-examples.git"
17 | },
18 | "license": "MIT",
19 | "author": "Oliverio Sousa",
20 | "main": "index.js",
21 | "scripts": {
22 | "test": "echo \"Error: no test specified\"",
23 | "start": "node server.js",
24 | "clean": "echo Nothing to clean..."
25 | },
26 | "dependencies": {
27 | "execa": "^6.0.0",
28 | "fs-extra": "^10.1.0",
29 | "ipfsd-ctl": "^12.0.2",
30 | "polka": "^0.5.2",
31 | "sirv": "^2.0.2",
32 | "stoppable": "^1.1.0",
33 | "uint8arrays": "^3.0.0",
34 | "which": "^2.0.2"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/playwright/daemons.js:
--------------------------------------------------------------------------------
1 | import { createFactory } from 'ipfsd-ctl'
2 |
3 | const daemons = (factoryOptions, factoryOverrideOptions, spawnOptions) => {
4 | return {
5 | // "server" fixture starts automatically for every worker - we pass "auto" for that.
6 | daemons: async ({}, use) => {
7 | console.log("Creating ipfs daemons...")
8 | const daemons = [];
9 |
10 | for (const spawnOption of spawnOptions) {
11 | const df = createFactory(factoryOptions, factoryOverrideOptions)
12 | const daemon = await df.spawn(spawnOption)
13 |
14 | daemons.push(daemon)
15 | }
16 |
17 | // Use the server in the tests.
18 | await use(daemons);
19 |
20 | // Cleanup.
21 | await new Promise(done => {
22 | Promise.all(daemons.map(daemon => daemon.stop())).then(() => done());
23 | });
24 | }
25 | }
26 | }
27 |
28 | export default daemons
29 |
--------------------------------------------------------------------------------
/lib/test-util-ipfs-example/playwright/index.js:
--------------------------------------------------------------------------------
1 |
2 | export { default as servers } from './servers.js'
3 | export { default as daemons } from './daemons.js'
4 |
5 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "js-ipfs-examples",
3 | "version": "1.0.0",
4 | "private": "true",
5 | "description": "Collection of opinionated and real-world examples of how you can use js-ipfs to build things",
6 | "keywords": [
7 | "examples",
8 | "js-ipfs"
9 | ],
10 | "homepage": "https://github.com/ipfs-examples/js-ipfs-examples#readme",
11 | "bugs": {
12 | "url": "https://github.com/ipfs-examples/js-ipfs-examples/issues"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/ipfs-examples/js-ipfs-examples.git"
17 | },
18 | "license": "MIT",
19 | "workspaces": [
20 | "examples/!(ipfs-client-add-files)",
21 | "lib/*"
22 | ],
23 | "scripts": {
24 | "clean": "yarn run clean:examples && yarn run clean:yarn && yarn run clean:build && yarn run clean:npm",
25 | "clean:npm": "rimraf ./**/package-lock.json ./**/node_modules",
26 | "clean:yarn": "rimraf ./**/yarn.lock",
27 | "clean:build": "rimraf ./**/node_modules/.vite ./**/build ./**/dist ./**/.next",
28 | "clean:examples": "yarn workspaces run clean",
29 | "test:examples": "yarn workspaces run test",
30 | "test": "yarn run test:examples",
31 | "chore:update-dependencies": "node scripts/update-example-deps.js"
32 | },
33 | "devDependencies": {
34 | "rimraf": "^3.0.2"
35 | },
36 | "dependencies": {
37 | "@libp2p/webrtc-star-signalling-server": "^2.0.1"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------