diff --git a/README.md b/README.md index c938c4375..b8afa38e5 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ User interfaces for the Sia software. The latest Sia software takes a modular ap ### [renterd](apps/renterd) -![stability-beta](https://img.shields.io/badge/stability-beta-yellow.svg) +![stability-mature](https://img.shields.io/badge/stability-mature-008000.svg) The [`renterd`](https://github.com/siafoundation/renterd) user interface, focused on renting functionality. ### [hostd](apps/hostd) -![stability-beta](https://img.shields.io/badge/stability-beta-yellow.svg) +![stability-mature](https://img.shields.io/badge/stability-mature-008000.svg) The [`hostd`](https://github.com/siafoundation/hostd) user interface, focused on hosting functionality. @@ -40,13 +40,14 @@ The `explorer` user interface, a Sia blockchain explorer interface that powers [ The Sia web libraries provide developers with convenient TypeScript SDKs for using Sia core types, blockchain utilities, data fetching, daemon-specific React hooks, and components for common functionality such as Siacoin/fiat input fields, transaction lists, files, and more. +- [@siafoundation/sdk](libs/sdk) - SDK for interacting directly with the Sia network from browsers and web clients. - [@siafoundation/react-core](libs/react-core) - Core library for building React hooks for interacting with a Sia daemon. - [@siafoundation/react-renterd](libs/react-renterd) - React hooks for interacting with `renterd`. - [@siafoundation/react-hostd](libs/react-hostd) - React hooks for interacting with `hostd`. - [@siafoundation/react-walletd](libs/react-walletd) - React hooks for interacting with `walletd`. +- [@siafoundation/design-system](libs/design-system) - React-based design system used across Sia apps and websites. - [@siafoundation/react-sia-central](libs/react-sia-central) - React hooks for interacting with the Sia Central API. - [@siafoundation/sia-central](libs/sia-central) - Methods and types for interacting with the Sia Central API. -- [@siafoundation/design-system](libs/design-system) - React-based design system used across Sia apps and websites. - [@siafoundation/data-sources](libs/data-sources) - Data sources used for stats on the website. - [@siafoundation/fonts](libs/fonts) - Next font configuration for use across apps. - [@siafoundation/units](libs/units) - Methods and types for converting and displaying units. diff --git a/apps/walletd/dialogs/WalletAddNewDialog/index.tsx b/apps/walletd/dialogs/WalletAddNewDialog/index.tsx index ee4736520..f8bcb1555 100644 --- a/apps/walletd/dialogs/WalletAddNewDialog/index.tsx +++ b/apps/walletd/dialogs/WalletAddNewDialog/index.tsx @@ -63,6 +63,7 @@ function getFields({ type: 'text', title: 'Seed', onClick: (e) => { + // eslint-disable-next-line @typescript-eslint/no-extra-semi ;(e as MouseEvent).currentTarget.select() copySeed() }, diff --git a/libs/sdk/.babelrc b/libs/sdk/.babelrc new file mode 100644 index 000000000..1ea870ead --- /dev/null +++ b/libs/sdk/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/sdk/.eslintrc.json b/libs/sdk/.eslintrc.json new file mode 100644 index 000000000..99b3d19a0 --- /dev/null +++ b/libs/sdk/.eslintrc.json @@ -0,0 +1,21 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "rules": { + "@nx/dependency-checks": [ + "error", + { + "ignoredFiles": ["libs/sdk/rollup.config.js"] + } + ] + }, + "overrides": [ + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/libs/sdk/CHANGELOG.md b/libs/sdk/CHANGELOG.md new file mode 100644 index 000000000..05eed702e --- /dev/null +++ b/libs/sdk/CHANGELOG.md @@ -0,0 +1 @@ +# @siafoundation/sdk diff --git a/libs/sdk/README.md b/libs/sdk/README.md new file mode 100644 index 000000000..9ab3b9739 --- /dev/null +++ b/libs/sdk/README.md @@ -0,0 +1,7 @@ +# sdk + +SDK for interacting directly with the Sia network from browsers and web clients. + +## Running unit tests + +Run `nx test sdk` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/sdk/jest.config.ts b/libs/sdk/jest.config.ts new file mode 100644 index 000000000..0d66fb738 --- /dev/null +++ b/libs/sdk/jest.config.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +export default { + displayName: 'sdk', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/libs/sdk', +} diff --git a/libs/sdk/package.json b/libs/sdk/package.json new file mode 100644 index 000000000..f5555632e --- /dev/null +++ b/libs/sdk/package.json @@ -0,0 +1,8 @@ +{ + "name": "@siafoundation/sdk", + "description": "SDK for interacting directly with the Sia network from browsers and web clients.", + "version": "0.3.2", + "license": "MIT", + "dependencies": {}, + "types": "./src/index.d.ts" +} diff --git a/libs/sdk/project.json b/libs/sdk/project.json new file mode 100644 index 000000000..65cc40a4c --- /dev/null +++ b/libs/sdk/project.json @@ -0,0 +1,42 @@ +{ + "name": "sdk", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/sdk/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nrwl/rollup:rollup", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/sdk", + "tsConfig": "libs/sdk/tsconfig.lib.json", + "project": "libs/sdk/package.json", + "entryFile": "libs/sdk/src/index.ts", + "external": ["react/jsx-runtime"], + "compiler": "tsc", + "outputFileName": "index.js", + "rollupConfig": "libs/sdk/rollup.config.js", + "assets": [ + { + "glob": "libs/sdk/*.md", + "input": ".", + "output": "." + } + ] + }, + "configurations": {} + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/libs/sdk"], + "options": { + "jestConfig": "libs/sdk/jest.config.ts" + } + } + } +} diff --git a/libs/sdk/rollup.config.js b/libs/sdk/rollup.config.js new file mode 100644 index 000000000..3f5e4e997 --- /dev/null +++ b/libs/sdk/rollup.config.js @@ -0,0 +1,18 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const preserveDirectives = require('rollup-plugin-preserve-directives') + +// https://github.com/rollup/rollup/issues/4699#issuecomment-1465302665 +function getRollupOptions(options) { + return { + ...options, + output: { + ...options.output, + preserveModules: true, + format: 'esm', + sourcemap: true, + }, + plugins: options.plugins.concat(preserveDirectives.default()), + } +} + +module.exports = getRollupOptions diff --git a/libs/sdk/tsconfig.json b/libs/sdk/tsconfig.json new file mode 100644 index 000000000..4c089585e --- /dev/null +++ b/libs/sdk/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/sdk/tsconfig.lib.json b/libs/sdk/tsconfig.lib.json new file mode 100644 index 000000000..621db72d7 --- /dev/null +++ b/libs/sdk/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../node_modules/@nx/react/typings/image.d.ts" + ], + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx", + "jest.config.ts" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/libs/sdk/tsconfig.spec.json b/libs/sdk/tsconfig.spec.json new file mode 100644 index 000000000..a85d573fc --- /dev/null +++ b/libs/sdk/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx", + "**/*.test.js", + "**/*.spec.js", + "**/*.test.jsx", + "**/*.spec.jsx", + "**/*.d.ts", + "jest.config.ts" + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index bd0bc7c50..97d2a9905 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -29,7 +29,8 @@ "@siafoundation/react-walletd": ["libs/react-walletd/src/index.ts"], "@siafoundation/sia-central": ["libs/sia-central/src/index.ts"], "@siafoundation/types": ["libs/types/src/index.ts"], - "@siafoundation/units": ["libs/units/src/index.ts"] + "@siafoundation/units": ["libs/units/src/index.ts"], + "@siafoundation/sdk": ["libs/sdk/src/index.ts"] } }, "exclude": ["node_modules", "tmp"]