Skip to content

Commit

Permalink
Rename ipm to ipmc
Browse files Browse the repository at this point in the history
  • Loading branch information
undyingwraith committed May 7, 2024
1 parent 71d34d4 commit 5d43bb0
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 248 deletions.
18 changes: 10 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"files.insertFinalNewline": true,
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"files.insertFinalNewline": true,
"typescript.enablePromptUseWorkspaceTsdk": true,
"editor.formatOnSave": true,
"editor.detectIndentation": false,
"editor.insertSpaces": false
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ yarn install

Run the following commands in paralell:
```bash
yarn workspace ipm-core run watch
yarn workspace ipm-desktop run dev
yarn workspace ipmc-core run watch
yarn workspace ipmc-desktop run dev
```

## Concepts
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ipm",
"name": "ipmc",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"scripts": {
"watch": "yarn workspaces foreach -Api run watch",
"build": "yarn workspaces foreach -At run build",
"cli": "yarn workspace ipm-tools run cli"
"cli": "yarn workspace ipmc-tools run cli"
},
"workspaces": [
"packages/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ipm-core",
"name": "ipmc-core",
"packageManager": "[email protected]",
"main": "./dist",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ipm-desktop",
"name": "ipmc-desktop",
"version": "1.0.0",
"description": "An Electron application with React and TypeScript",
"main": "./out/main/index.js",
Expand Down Expand Up @@ -38,7 +38,7 @@
"datastore-level": "^10.1.8",
"electron-updater": "6.2.1",
"helia": "^4.1.1",
"ipm-core": "workspace:^",
"ipmc-core": "workspace:^",
"kubo-rpc-client": "^4.1.1",
"libp2p": "^1.3.0",
"multiformats": "^13.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/tools/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ipm-tools",
"name": "ipmc-tools",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
"dependencies": {
"cli-progress": "^3.12.0",
"fluent-ffmpeg": "^2.1.2",
"ipm-core": "workspace:^",
"ipmc-core": "workspace:^",
"kubo-rpc-client": "^4.1.1",
"yargs": "^17.7.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/webui/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ipm-webui",
"name": "ipmc-webui",
"type": "module",
"scripts": {
"watch": "vite",
Expand All @@ -21,7 +21,7 @@
"helia": "^4.1.1",
"i18next": "^23.11.2",
"i18next-browser-languagedetector": "^7.2.1",
"ipm-core": "workspace:^",
"ipmc-core": "workspace:^",
"libp2p": "^1.3.0",
"libp2p-pnet": "^0.1.0",
"react": "^18.3.1",
Expand Down
31 changes: 9 additions & 22 deletions packages/webui/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React from 'react';
import { AppContextProvider } from './AppContext';
import { CssBaseline, ThemeProvider } from "@mui/material";
import { theme } from "./Theme";
import { MovieList } from "./components/MovieList";
import { AppBar } from "./components/AppBar";
import { IFileInfo, IpmApp } from 'ipm-core';
import { IFileInfo, IpmApp } from 'ipmc-core';

import { webSockets } from '@libp2p/websockets';
import { webTransport } from '@libp2p/webtransport';
Expand Down Expand Up @@ -43,7 +38,7 @@ export function App() {
nodeService={{
async create(profile) {
const libp2p = await createLibp2p({
...(profile.swarmKey ? {
...(profile?.swarmKey ? {
connectionProtector: preSharedKey({
psk: new TextEncoder().encode(profile.swarmKey),
}),
Expand All @@ -54,7 +49,7 @@ export function App() {
],
peerDiscovery: [
bootstrap({
list: profile.bootstrap ?? [
list: profile?.bootstrap ?? [
// a list of bootstrap peer multiaddrs to connect to on node startup
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
Expand All @@ -64,21 +59,21 @@ export function App() {
],
connectionEncryption: [noise()],
});
const datastore = new IDBDatastore(`${profile.name}/data`);

const datastore = new IDBDatastore(`${profile?.name ?? 'default'}/data`);
await datastore.open();
const blockstore = new IDBBlockstore(`${profile.name}/data`);
const blockstore = new IDBBlockstore(`${profile?.name ?? 'default'}/data`);
await blockstore.open();

const helia = await createHelia({
start: true,
datastore,
blockstore,
libp2p: libp2p,
});

const fs = unixfs(helia);

return ({
async ls(cid: string) {
const files: IFileInfo[] = [];
Expand Down Expand Up @@ -133,13 +128,5 @@ export function App() {
},
}}
/>
return <ThemeProvider theme={theme}>
<CssBaseline />
<AppContextProvider>
<AppBar />
<div>Started</div>
<MovieList />
</AppContextProvider>
</ThemeProvider>;
};

13 changes: 0 additions & 13 deletions packages/webui/src/components/AppBar.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions packages/webui/src/components/ConnectionStatus.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions packages/webui/src/components/LanguageSelector.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions packages/webui/src/components/ListItem.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions packages/webui/src/components/MovieList.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions packages/webui/src/components/StartConfiguration.tsx

This file was deleted.

71 changes: 3 additions & 68 deletions packages/webui/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,7 @@
import * as React from 'react';
import {createRoot} from 'react-dom/client';
import i18n from "i18next";
import {initReactI18next} from "react-i18next";
import languageDetector from 'i18next-browser-languagedetector';

import en from 'ipm-core/translations/en.json'
import de from 'ipm-core/translations/de.json'
import {IAppConfiguration, IConfigurationService, IpmApp} from "ipm-core";
import {IDBDatastore} from "datastore-idb";
import {IDBBlockstore} from "blockstore-idb";


i18n
.use(initReactI18next) // passes i18n down to react-i18next
.use(languageDetector)
.init({
resources: {
en: {
translation: en
},
de: {
translation: de
}
},
fallbackLng: "en",
interpolation: {
escapeValue: false // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
}
});
import { createRoot } from 'react-dom/client';
import { App } from './App';

const root = createRoot(document.getElementById('root')!)

class LocalStorageConfigService implements IConfigurationService {
getNodeConfig(): IAppConfiguration {
const data = window.localStorage.getItem('ipm-config')
if (data) {
return JSON.parse(data)
}
const params = new URLSearchParams(window.location.search);
if (params.has('init')) {
console.debug(atob(params.get('init')!));
const test = JSON.parse(atob(params.get('init')!))
test.bootstrap.push('/ip4/185.66.109.132/udp/4002/quic/12D3KooWT32d14NuEWbGLrAhZFyqQHFzmeDDtLiw7FsTDFJU8Xhz')
test.bootstrap.push('/ip4/185.66.109.132/tcp/4002/ws/12D3KooWT32d14NuEWbGLrAhZFyqQHFzmeDDtLiw7FsTDFJU8Xhz')
// setConfig(test); //JSON.parse(atob(params.get('init')!)))
return test;
}
return {
swarmKey: '',
bootstrap: []
};
}

setNodeConfig(config: IAppConfiguration): void {
window.localStorage.setItem('ipm-config', JSON.stringify(config))
}
}

// root.render(<App/>);
root.render(<IpmApp init={async () => {
const datastore = new IDBDatastore('data');
await datastore.open();
const blockstore = new IDBBlockstore('blocks');
await blockstore.open();

return {
datastore,
blockstore,
configService: new LocalStorageConfigService()
};
}}/>);
root.render(<App />);
Loading

0 comments on commit 5d43bb0

Please sign in to comment.