Skip to content

Commit

Permalink
chore: sdk project
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Feb 5, 2024
1 parent 90813d4 commit bb65acb
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions apps/walletd/dialogs/WalletAddNewDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function getFields({
type: 'text',
title: 'Seed',
onClick: (e) => {
// eslint-disable-next-line @typescript-eslint/no-extra-semi
;(e as MouseEvent<HTMLTextAreaElement>).currentTarget.select()
copySeed()
},
Expand Down
12 changes: 12 additions & 0 deletions libs/sdk/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
21 changes: 21 additions & 0 deletions libs/sdk/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
1 change: 1 addition & 0 deletions libs/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @siafoundation/sdk
7 changes: 7 additions & 0 deletions libs/sdk/README.md
Original file line number Diff line number Diff line change
@@ -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).
10 changes: 10 additions & 0 deletions libs/sdk/jest.config.ts
Original file line number Diff line number Diff line change
@@ -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',
}
8 changes: 8 additions & 0 deletions libs/sdk/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
42 changes: 42 additions & 0 deletions libs/sdk/project.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
18 changes: 18 additions & 0 deletions libs/sdk/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions libs/sdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
23 changes: 23 additions & 0 deletions libs/sdk/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -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"]
}
20 changes: 20 additions & 0 deletions libs/sdk/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit bb65acb

Please sign in to comment.