diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index d8cdb7c5..00000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.js.map -diff -*.min.js -diff diff --git a/.github/workflows/check_dependencies.yml b/.github/workflows/check_dependencies.yml deleted file mode 100644 index 59742a4a..00000000 --- a/.github/workflows/check_dependencies.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: check dependencies -on: - push: - branches: ["master"] - pull_request: - paths: - - '**/package.json' - - '.github/workflows/check_dependencies.yml' -jobs: - check-dependencies: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - name: Install dependencies - run: npm i - - name: Check if the dependencies are free of any conflict and match "overrides" in the root package.json - run: npm ls diff --git a/.github/workflows/_common_jobs.yml b/.github/workflows/ci.yml similarity index 54% rename from .github/workflows/_common_jobs.yml rename to .github/workflows/ci.yml index 3d65fbbd..1d1034c7 100644 --- a/.github/workflows/_common_jobs.yml +++ b/.github/workflows/ci.yml @@ -1,36 +1,34 @@ -name: Launch CI jobs for a package or app +name: CI on: - workflow_call: - inputs: - workspace: - required: true - type: string + push: + branches: ["master"] + pull_request: jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm i - - run: npm run lint -w ${{ inputs.workspace }} + - run: npm run lint typecheck: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm i - - run: npm run typecheck -w ${{ inputs.workspace }} + - run: npm run typecheck test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm i - - run: npm run coverage -w ${{ inputs.workspace }} + - run: npm run coverage buildcheck: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: npm i - - run: npm run build -w ${{ inputs.workspace }} + - run: npm run build \ No newline at end of file diff --git a/.github/workflows/ci_packages_cli.yml b/.github/workflows/ci_packages_cli.yml deleted file mode 100644 index 5d8eeb1f..00000000 --- a/.github/workflows/ci_packages_cli.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: packages/cli -on: - push: - branches: ["master"] - pull_request: - paths: - - 'packages/components/**' - - 'packages/cli/**' - - '.github/workflows/_common_jobs.yml' - - '.github/workflows/ci_packages_cli.yml' - - 'eslint.config.js' - - 'package.json' -jobs: - build-components: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4 - - name: Install dependencies - run: npm i - - name: Build components package - run: npm run build -w @hyparam/components - ci: - needs: build-components - uses: ./.github/workflows/_common_jobs.yml - with: - workspace: hyperparam diff --git a/.github/workflows/ci_packages_components.yml b/.github/workflows/ci_packages_components.yml deleted file mode 100644 index 936673a4..00000000 --- a/.github/workflows/ci_packages_components.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: packages/components -on: - push: - branches: ["master"] - pull_request: - paths: - - 'packages/components/**' - - '.github/workflows/_common_jobs.yml' - - '.github/workflows/ci_packages_components.yml' - - 'eslint.config.js' - - 'package.json' -jobs: - ci: - uses: ./.github/workflows/_common_jobs.yml - with: - workspace: '@hyparam/components' diff --git a/.github/workflows/ci_root.yml b/.github/workflows/ci_root.yml deleted file mode 100644 index 5ab17e0a..00000000 --- a/.github/workflows/ci_root.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: root -on: - push: - branches: ["master"] - pull_request: - paths: - - '*' - - 'test/**' - - '.github/workflows/ci_root.yml' - - 'eslint.config.js' -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: npm i - - run: npm run lint - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: npm i - - run: npm run test diff --git a/.gitignore b/.gitignore index cb5d3b0a..bf9ddadb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,34 @@ -package-lock.json +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + node_modules +dist +dist-ssr +*.local +coverage + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +package-lock.json *.tgz .vscode *.parquet -coverage -.DS_Store +/coverage/ + +/lib/ +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/README.md b/README.md index f7201928..7bd32ba7 100644 --- a/README.md +++ b/README.md @@ -1,64 +1,75 @@ -# Hyperparam monorepo +# hyperparam -This is a monorepo for the Hyperparam project. +[![npm](https://img.shields.io/npm/v/hyperparam)](https://www.npmjs.com/package/hyperparam) +[![workflow status](https://github.com/hyparam/hyperparam-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/hyparam/hyperparam-cli/actions) +[![mit license](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) +![coverage](https://img.shields.io/badge/Coverage-35-darkred) -It contains the following packages, published to npm: +This is the hyperparam cli tool. -- [`@hyparam/components`](./packages/components): a library of React components and utilities for building Hyperparam UIs. -- [`hyperparam`](./packages/cli): a cli tool for viewing arbitrarily large datasets in the browser. +The hyperparam cli tool is for viewing arbitrarily large datasets in the browser. -## Use +## Viewer -Install all the workspaces with: +To open a file browser in your current local directory run: -```bash -npm install +```sh +npx hyperparam ``` -Lint all the workspaces: +You can also pass a specific file, folder, or url: -```bash -npm run lint -ws +```sh +npx hyperparam example.parquet +npx hyperparam directory/ +npx hyperparam https://hyperparam-public.s3.amazonaws.com/bunnies.parquet ``` -Test all the workspaces: +## Chat -```bash -npm test -ws +To start a chat with hyperparam: + +```sh +npx hyperparam chat ``` -Compute the coverage for all the workspaces: +## Installation + +Install for all users: -```bash -npm run coverage -ws +```sh +sudo npm i -g hyperparam ``` -Build all the workspaces (they are built in order, so the dependencies are built first - it's defined manually by the order of the workspaces in the `package.json`): +Now you can just run: -```bash -npm run build -ws +```sh +hyperparam ``` -- `hyperparam`: +or: -```bash -npm run dev -w hyperparam +```sh +hyp ``` -- `components`: +## Developers -```bash -npm run dev -w @hyparam/components -``` +To develop the CLI locally: -## Development +```sh +npm i +npm run dev +``` -The monorepo is managed with [npm workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces). Some workspaces are dependencies of others. Currently: +The application will be rebuild automatically when you make changes, and the browser will refresh. -- `@hyparam/components` is a dependency of `hyperparam`. +### Library and application -It means that if you make a change to `@hyparam/components`, you need to rebuild it before developing `hyperparam`. +Hyperparam is an application that relies on node.js scripts in the `bin/` directory and serves the static web application built in the `dist/` directory. -Also, if you increment the version of `@hyparam/components`, you need to update the version of `@hyparam/components` in the `package.json` of `hyperparam`, as we use exact versions in the `package.json` of the workspaces. Note that we don't have to increment the version after every change, only when we want to publish a new version with a significant batch of changes. +The `hyperparam` package also includes a library that can be used in other applications. The library is in the `lib/` directory. For example: -The root package.json contains a special field, `overrides`, which sets the shared dependencies versions we want to have in all the workspaces. The "check_dependencies" GitHub action checks that the dependencies are the same in all the workspaces (`npm ls` would fail if dependency version mismatch). +```js +import { asyncBufferFrom, AsyncBufferFrom, parquetDataFrame } from "hyperparam"; +``` diff --git a/packages/cli/src/chat.js b/bin/chat.js similarity index 100% rename from packages/cli/src/chat.js rename to bin/chat.js diff --git a/packages/cli/src/cli.js b/bin/cli.js similarity index 95% rename from packages/cli/src/cli.js rename to bin/cli.js index 0ce19ebd..c8f27937 100755 --- a/packages/cli/src/cli.js +++ b/bin/cli.js @@ -49,7 +49,7 @@ if (arg === 'chat') { */ function checkForUpdates() { const currentVersion = packageJson.version - return fetch('https://registry.npmjs.org/hyperparam/latest') + return void fetch('https://registry.npmjs.org/hyperparam/latest') .then(response => response.json()) .then(data => { const latestVersion = data.version @@ -58,5 +58,4 @@ function checkForUpdates() { console.log('\x1b[33mRun \'npm install -g hyperparam\' to update\x1b[0m') } }) - .catch(() => {}) // ignore errors } diff --git a/packages/cli/src/serve.js b/bin/serve.js similarity index 96% rename from packages/cli/src/serve.js rename to bin/serve.js index afa2a625..b9688b19 100644 --- a/packages/cli/src/serve.js +++ b/bin/serve.js @@ -80,17 +80,20 @@ function handleRequest(req, serveDirectory) { // get location of hyperparam assets const hyperparamPath = decodeURIComponent(import.meta.url) .replace('file://', '') - .replace('/src/serve.js', '') + .replace('/bin/serve.js', '') if (pathname === '/' || pathname === '/files/') { // redirect to /files return { status: 301, content: '/files' } } else if (pathname.startsWith('/files')) { // serve index.html - return handleStatic(`${hyperparamPath}/public/index.html`) - } else if (pathname.startsWith('/public/')) { + return handleStatic(`${hyperparamPath}/dist/index.html`) + } else if (pathname.startsWith('/assets/') || pathname.startsWith('/favicon') ) { // serve static files - return handleStatic(`${hyperparamPath}${pathname}`) + return handleStatic(`${hyperparamPath}/dist${pathname}`) + // else if (pathname.startsWith('/public/')) { + // // serve static files + // return handleStatic(`${hyperparamPath}${pathname.replace(/^(\/public).*/, '/dist')}`) } else if (serveDirectory && pathname === '/api/store/list') { // serve file list const prefix = parsedUrl.query.prefix || '' diff --git a/packages/cli/src/streamConverters.js b/bin/streamConverters.js similarity index 100% rename from packages/cli/src/streamConverters.js rename to bin/streamConverters.js diff --git a/eslint.config.js b/eslint.config.js index 8034c8bd..bb1ba40b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,8 +1,12 @@ import javascript from '@eslint/js' +import react from 'eslint-plugin-react' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' import globals from 'globals' +import tseslint from 'typescript-eslint' /** @type {import('eslint').Linter.Config.RulesRecord} */ -export const sharedJsRules = { +const sharedJsRules = { 'arrow-spacing': 'error', camelcase: 'off', 'comma-spacing': 'error', @@ -42,28 +46,66 @@ export const sharedJsRules = { } /** @type {import('eslint').Linter.Config.RulesRecord} */ -export const sharedTsRules = { +const sharedTsRules = { '@typescript-eslint/restrict-template-expressions': 'off', '@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/require-await': 'warn', } -/** @type {import('eslint').Linter.Config[]} */ -export default [ +export default tseslint.config( + { ignores: ['coverage/', 'dist/', 'lib/', 'packages/'] }, { - ignores: ['**/coverage/**'], + settings: { react: { version: '18.3' } }, + extends: [javascript.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked], + files: ['**/*.{ts,tsx,js}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + parserOptions: { + project: ['./tsconfig.json', './tsconfig.eslint.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, + plugins: { + 'react': react, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...react.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + ...javascript.configs.recommended.rules, + ...tseslint.configs.recommended.rules, + ...sharedJsRules, + ...sharedTsRules, + 'no-extra-parens': 'warn', + }, }, { + files: ['test/**/*.{ts,tsx}', '*.{js,ts}'], languageOptions: { + ecmaVersion: 2020, globals: { - ...globals.browser, ...globals.node, + ...globals.browser, }, }, - rules: { - ...javascript.configs.recommended.rules, - ...sharedJsRules, + }, + { + files: ['**/*.js'], + ...tseslint.configs.disableTypeChecked, + }, + { + files: ['bin/**/*.js', 'test/bin/**/*.js'], + languageOptions: { + globals: { + ...globals.node, + }, }, - files: ['eslint.config.js', 'test/**/*.js'], }, -] +) diff --git a/packages/cli/public/index.html b/index.html similarity index 73% rename from packages/cli/public/index.html rename to index.html index 0201371a..e29dff84 100644 --- a/packages/cli/public/index.html +++ b/index.html @@ -3,15 +3,14 @@ hyperparam - - +
- + diff --git a/package.json b/package.json index 6eecfc6f..09aea226 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,51 @@ { - "name": "@hyparam/monorepo", - "version": "0.1.0", - "private": true, + "name": "hyperparam", + "version": "0.2.23", + "description": "Hyperparam CLI", + "author": "Hyperparam", + "homepage": "https://hyperparam.app", "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/hyparam/hyperparam-cli.git" + }, "type": "module", - "workspaces": [ - "packages/components", - "packages/cli" + "exports": { + ".": { + "types": "./lib/index.d.ts", + "import": "./lib/index.es.min.js", + "require": "./lib/index.umd.min.js" + } + }, + "bin": { + "hyp": "bin/cli.js", + "hyperparam": "bin/cli.js" + }, + "files": [ + "bin", + "dist", + "lib" ], "scripts": { + "build:types": "tsc -b", + "build:lib": "vite build -c vite.lib.config.ts", + "build:app": "vite build -c vite.app.config.ts", + "build": "run-s build:lib build:types build:app", + "coverage": "vitest run -c vite.lib.config.ts --coverage --coverage.include=src --coverage.include=bin", + "dev": "run-p -l watch:ts watch:vite watch:serve", "lint": "eslint .", - "test": "vitest run --dir test" + "prepublishOnly": "npm run build", + "serve": "node bin/cli.js", + "preserve": "npm run build", + "test": "vitest run -c vite.lib.config.ts", + "typecheck": "tsc --noEmit", + "url": "run-p -l watch:ts watch:vite watch:url", + "watch:ts": "tsc --watch", + "watch:vite": "vite build --watch", + "watch:serve": "nodemon bin/cli.js", + "watch:url": "nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet" }, - "overrides": { - "highlight.js": "11.11.1", + "dependencies": { "hightable": "0.11.0", "hyparquet": "1.8.4", "hyparquet-compressors": "1.0.0", @@ -33,6 +65,8 @@ "eslint-plugin-react-refresh": "0.4.19", "globals": "15.14.0", "jsdom": "26.0.0", + "nodemon": "3.1.9", + "npm-run-all": "4.1.5", "typescript": "5.7.3", "typescript-eslint": "8.25.0", "vite": "6.2.0", diff --git a/packages/cli/.gitignore b/packages/cli/.gitignore deleted file mode 100644 index 9c10912a..00000000 --- a/packages/cli/.gitignore +++ /dev/null @@ -1 +0,0 @@ -public/build/ diff --git a/packages/cli/LICENSE b/packages/cli/LICENSE deleted file mode 100644 index 5523c369..00000000 --- a/packages/cli/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/cli/README.md b/packages/cli/README.md deleted file mode 100644 index e515ba16..00000000 --- a/packages/cli/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# hyperparam - -[![npm](https://img.shields.io/npm/v/hyperparam)](https://www.npmjs.com/package/hyperparam) -[![workflow status](https://github.com/hyparam/hyperparam-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/hyparam/hyperparam-cli/actions) -[![mit license](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) -![coverage](https://img.shields.io/badge/Coverage-35-darkred) - -This is the hyperparam cli tool. - -The hyperparam cli tool is for viewing arbitrarily large datasets in the browser. - -## Viewer - -To open a file browser in your current local directory run: - -```sh -npx hyperparam -``` - -You can also pass a specific file, folder, or url: - -```sh -npx hyperparam example.parquet -npx hyperparam directory/ -npx hyperparam https://hyperparam-public.s3.amazonaws.com/bunnies.parquet -``` - -## Chat - -To start a chat with hyperparam: - -```sh -npx hyperparam chat -``` - -## Installation - -Install for all users: - -```sh -sudo npm i -g hyperparam -``` - -Now you can just run: - -```sh -hyperparam -``` - -or: - -```sh -hyp -``` - -## Developers - -To develop the CLI locally: - -```sh -npm i -npm run build -npm run serve -``` - -When you make changes, make sure to rebuild: - -```sh -npm run build -``` - -Then refresh the browser. diff --git a/packages/cli/eslint.config.js b/packages/cli/eslint.config.js deleted file mode 100644 index ab92bf9b..00000000 --- a/packages/cli/eslint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import javascript from '@eslint/js' -import globals from 'globals' -import typescript from 'typescript-eslint' -import { sharedJsRules } from '../../eslint.config.js' - -export default [ - { - ignores: ['public/build/', 'coverage/'], - }, - { - plugins: { - typescript, - }, - - languageOptions: { - globals: { - ...globals.browser, - ...globals.node, - }, - }, - - rules: { - ...javascript.configs.recommended.rules, - ...typescript.configs.recommended.rules, - ...sharedJsRules, - }, - }, -] diff --git a/packages/cli/package.json b/packages/cli/package.json deleted file mode 100644 index fae7bbf0..00000000 --- a/packages/cli/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "hyperparam", - "version": "0.2.23", - "description": "Hyperparam CLI", - "author": "Hyperparam", - "homepage": "https://hyperparam.app", - "license": "MIT", - "main": "src/cli.js", - "type": "module", - "bin": { - "hyp": "src/cli.js", - "hyperparam": "src/cli.js" - }, - "files": [ - "public", - "src" - ], - "scripts": { - "build": "rollup -c", - "coverage": "vitest run --coverage --coverage.include=src", - "dev": "npm run serve", - "lint": "eslint", - "prepublishOnly": "npm run build", - "serve": "node src/cli.js", - "preserve": "npm run build", - "url": "npm run serve -- https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet", - "test": "vitest run --dir test", - "typecheck": "tsc" - }, - "dependencies": { - "@hyparam/components": "0.1.19", - "highlight.js": "11.11.1", - "hightable": "0.11.0", - "react": "18.3.1", - "react-dom": "18.3.1" - }, - "devDependencies": { - "@rollup/plugin-commonjs": "28.0.2", - "@rollup/plugin-node-resolve": "16.0.0", - "@rollup/plugin-replace": "6.0.2", - "@rollup/plugin-terser": "0.4.4", - "@rollup/plugin-typescript": "12.1.2", - "rollup": "4.34.8", - "rollup-plugin-postcss": "4.0.2", - "tslib": "2.8.1" - } -} diff --git a/packages/cli/rollup.config.js b/packages/cli/rollup.config.js deleted file mode 100644 index 48f8b1b3..00000000 --- a/packages/cli/rollup.config.js +++ /dev/null @@ -1,31 +0,0 @@ -import commonjs from '@rollup/plugin-commonjs' -import resolve from '@rollup/plugin-node-resolve' -import replace from '@rollup/plugin-replace' -import terser from '@rollup/plugin-terser' -import postcss from 'rollup-plugin-postcss' - -export default [ - // app bundle - { - input: 'src/app.js', - output: { - file: 'public/build/app.min.js', - inlineDynamicImports: true, - name: 'hyperparam', - format: 'es', - sourcemap: true, - }, - plugins: [ - commonjs(), - replace({ - 'process.env.NODE_ENV': JSON.stringify('production'), // or 'development' based on your build environment - preventAssignment: true, - }), - resolve({ browser: true }), - terser(), - postcss({ - extensions: ['.css'], - }), - ], - }, -] diff --git a/packages/cli/src/AppComponent.js b/packages/cli/src/AppComponent.js deleted file mode 100644 index 9556aa6c..00000000 --- a/packages/cli/src/AppComponent.js +++ /dev/null @@ -1,28 +0,0 @@ -import { Page, getHttpSource, getHyperparamSource } from '@hyparam/components' -import 'hightable/src/HighTable.css' -import React from 'react' -import '@hyparam/components/components.css' - -export default function App() { - const search = new URLSearchParams(location.search) - const sourceId = search.get('key') ?? '' - const row = search.get('row') === null ? undefined : Number(search.get('row')) - const col = search.get('col') === null ? undefined : Number(search.get('col')) - - const source = getHttpSource(sourceId) ?? getHyperparamSource(sourceId, { endpoint: location.origin }) - - if (!source) { - return React.createElement('div', { children: 'Could not load a data source. You have to pass a valid source in the url.' }) - } - return React.createElement(Page, { - source, - navigation: { row, col }, - config: { - slidePanel: {}, - routes: { - getSourceRouteUrl: ({ sourceId }) => `/files?key=${sourceId}`, - getCellRouteUrl: ({ sourceId, col, row }) => `/files?key=${sourceId}&col=${col}&row=${row}`, - }, - }, - }) -} diff --git a/packages/cli/src/app.js b/packages/cli/src/app.js deleted file mode 100644 index e6367e63..00000000 --- a/packages/cli/src/app.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './AppComponent.js' - -const app = document.getElementById('app') -if (!app) throw new Error('missing app element') - -const root = ReactDOM.createRoot(app) -root.render(React.createElement(App)) diff --git a/packages/cli/test/package.test.js b/packages/cli/test/package.test.js deleted file mode 100644 index caa2f757..00000000 --- a/packages/cli/test/package.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { describe, expect, it } from 'vitest' -import packageJson from '../package.json' with { type: 'json' } - -describe('package.json', () => { - it('should have the correct name', () => { - expect(packageJson.name).toBe('hyperparam') - }) - it('should have a valid version', () => { - expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+$/) - }) - it('should have MIT license', () => { - expect(packageJson.license).toBe('MIT') - }) - it('should have precise dependency versions', () => { - const { dependencies, devDependencies } = packageJson - const allDependencies = { ...dependencies, ...devDependencies } - Object.values(allDependencies).forEach(version => { - expect(version).toMatch(/^\d+\.\d+\.\d+$/) - }) - }) -}) diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json deleted file mode 100644 index 9e65abd5..00000000 --- a/packages/cli/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "jsx": "react", - "lib": ["esnext", "dom"], - "module": "nodenext", - "noEmit": true, - "resolveJsonModule": true, - "strict": true - }, - "include": ["src", "test"] -} diff --git a/packages/cli/vitest.config.js b/packages/cli/vitest.config.js deleted file mode 100644 index 01c465a2..00000000 --- a/packages/cli/vitest.config.js +++ /dev/null @@ -1,16 +0,0 @@ -import react from '@vitejs/plugin-react' -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - plugins: [react()], - test: { - globals: true, - environment: 'jsdom', - coverage: { - exclude: [ - 'node_modules', - 'public', - ], - }, - }, -}) diff --git a/packages/components/.gitignore b/packages/components/.gitignore deleted file mode 100644 index b873cb9e..00000000 --- a/packages/components/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local -coverage - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? - -package-lock.json -*.tgz -.vscode -*.parquet -/coverage/ - -/es \ No newline at end of file diff --git a/packages/components/LICENSE b/packages/components/LICENSE deleted file mode 100644 index 5523c369..00000000 --- a/packages/components/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/components/README.md b/packages/components/README.md deleted file mode 100644 index 6f47e380..00000000 --- a/packages/components/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# React components for hyparam apps - -This package contains the React components for the hyparam apps. - -It depends on [hyparquet](https://github.com/hyparam/hyparquet), [hyparquet-compressors](https://github.com/hyparam/hyparquet-compressors), [hightable](https://github.com/hyparam/hightable/), and requires React to be installed (peer-dependency). - -It is used in [hyperparam](https://github.com/hyparam/hyperparam-cli/tree/master/packages/cli). - -It also contains utilities, in the lib/ subdirectory, that can be used without React. They are used in [hyparquet-demo](https://github.com/hyparam/hyperparam-cli/tree/master/apps/hyparquet-demo). \ No newline at end of file diff --git a/packages/components/demo/App.tsx b/packages/components/demo/App.tsx deleted file mode 100644 index b32800cd..00000000 --- a/packages/components/demo/App.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import 'hightable/src/HighTable.css' -import React from 'react' -import { Page } from '../src/index.js' - -import { getHttpSource } from '../src/index.ts' -export interface Navigation { - col?: number - row?: number -} - -function getNumberParam(search: URLSearchParams, key: string): number | undefined { - const value = search.get(key) - if (value === null) return - const number = Number(value) - if (isNaN(number)) return - return number -} - -export default function App() { - const search = new URLSearchParams(location.search) - const url = search.get('url') - const defaultUrl = '/?url=https://huggingface.co/datasets/severo/test-parquet/resolve/main/parquet/csv-train-00000-of-00001.parquet' - if (!url) { - location.href = defaultUrl - return
Redirecting...
- } - // row, col from url - const row = getNumberParam(search, 'row') - const col = getNumberParam(search, 'col') - - const source = getHttpSource(url) - - if (!source) { - return
Could not load a data source. You have to pass a valid source in the url, eg: {defaultUrl}.
- } - return `/?url=${sourceId}`, - getCellRouteUrl: ({ sourceId, col, row }) => `/?url=${sourceId}&col=${col}&row=${row}`, - }, - }} /> -} diff --git a/packages/components/demo/demo.ts b/packages/components/demo/demo.ts deleted file mode 100644 index 6e79edb3..00000000 --- a/packages/components/demo/demo.ts +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App.tsx' - -const app = document.getElementById('app') -if (!app) throw new Error('missing app element') - -const root = ReactDOM.createRoot(app) -root.render(React.createElement(App)) diff --git a/packages/components/demo/favicon.png b/packages/components/demo/favicon.png deleted file mode 100644 index cd162fdd..00000000 Binary files a/packages/components/demo/favicon.png and /dev/null differ diff --git a/packages/components/demo/file.svg b/packages/components/demo/file.svg deleted file mode 100644 index 90c7f966..00000000 --- a/packages/components/demo/file.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/packages/components/demo/folder.svg b/packages/components/demo/folder.svg deleted file mode 100644 index 1e1bf66d..00000000 --- a/packages/components/demo/folder.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/packages/components/demo/index.html b/packages/components/demo/index.html deleted file mode 100644 index 9f890c7d..00000000 --- a/packages/components/demo/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - hyperparam - - - - - - - - -
- - - diff --git a/packages/components/demo/logo.svg b/packages/components/demo/logo.svg deleted file mode 100644 index 90903e28..00000000 --- a/packages/components/demo/logo.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/packages/components/demo/styles.css b/packages/components/demo/styles.css deleted file mode 100644 index 60c7b5ef..00000000 --- a/packages/components/demo/styles.css +++ /dev/null @@ -1,415 +0,0 @@ -* { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -#app { - display: flex; - font-family: 'Mulish', 'Helvetica Neue', Helvetica, Arial, sans-serif; - flex-direction: column; - height: 100vh; -} - -/* brand logo */ -.brand { - color: #111; - display: flex; - align-items: center; - filter: drop-shadow(0 0 2px #444); - font-family: 'Century Gothic', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 1.1em; - font-weight: bold; - text-orientation: mixed; - opacity: 0.85; - padding: 10px 12px; - user-select: none; - writing-mode: vertical-rl; -} -.brand:hover { - color: #fff; - filter: drop-shadow(0 0 2px #333); - opacity: 0.9; - text-decoration: none; -} -.brand::before { - content: ''; - background: url(logo.svg) no-repeat 0 center; - background-size: 26px; - height: 26px; - width: 26px; - margin-bottom: 10px; -} - -a { - color: #342267; - cursor: pointer; - text-decoration: none; -} -a:hover { - color: #000; - text-decoration: underline; -} - -/* layout */ -main { - display: flex; - height: 100vh; - max-width: 100vw; -} - -/* sidebar */ -.nav { - display: flex; - flex-direction: column; - height: 100vh; - width: 48px; - background-image: linear-gradient(to bottom, #667, #585669); - box-shadow: 0 0 4px rgba(10, 10, 10, 0.5); - height: 100vh; -} - -/* content area */ -.content-container { - min-width: 0; - height: 100vh; - display: flex; - flex-direction: column; - flex: 1; -} -.content { - display: flex; - flex-direction: column; - flex: 1; - height: 100vh; - padding: 0; - /* no outer scrollbars */ - overflow: hidden; -} - -/* top navbar */ -.top-header { - align-items: center; - background: linear-gradient(to right, #353540, #24202b); - color: #dde4ea; - display: flex; - height: 32px; - justify-content: space-between; - min-height: 32px; - padding-left: 8px; -} -.top-header h1 { - font-size: 18px; - margin: 0; -} -.top-header a { - color: #e0e8ee; -} - -/* file path */ -.path { - margin: 0 2px; - margin-right: 4px; - min-width: 0; - overflow: auto; -} -.path::-webkit-scrollbar { - display: none; -} -.path a { - color: #f0f8ff; - font-family: 'Courier New', Courier, monospace; - font-size: 18px; - text-overflow: ellipsis; - white-space: nowrap; - text-decoration-thickness: 1px; -} -/* hide all but the last path link on small screens */ -@media (max-width: 360px) { - .path a:not(:last-child) { - display: none; - } -} - -/* progress bar */ -.progress-bar { - position: fixed; - top: 0; - left: 0; - right: 0; - height: 2px; - z-index: 1000; - transition: width 0.3s; - - /* Shimmer effect overlay */ - background-image: linear-gradient( - to right, - #ddd 0%, - #cbb 50%, - #ddd 100% - ); - background-size: 1000px; - animation: shimmer 4s infinite linear; -} -@keyframes shimmer { - 0% { - background-position: -1000px; - } - 100% { - background-position: 1000px; - } -} -.progress-bar > div { - height: 100%; - background-color: #3a4; -} - -/* error bar */ -.error-bar { - max-height: 0; - padding: 0; - background-color: #dd111199; - font-family: monospace; - overflow: hidden; - transition: max-height 0.3s; - white-space: pre-wrap; -} -.show-error { - max-height: 30%; -} -.error-content { - display: flex; - align-items: center; - justify-content: space-between; - min-height: 100%; - overflow-y: auto; - padding: 10px; -} - -/* error bar close button */ -.close-button, -.close-button:active, -.close-button:focus, -.close-button:focus-visible, -.close-button:hover { - background: none; - border: none; - border-radius: 4px; - padding: 0 8px; - cursor: pointer; - color: #333; - font-size: 30px; - display: flex; - align-items: center; - justify-content: center; - transition: background-color 0.2s; -} -button.close-button:active { - background-color: rgba(0, 0, 0, 0.2); -} -button.close-button:focus { - background-color: rgba(0, 0, 0, 0.1); - outline: 2px solid #a44; -} -button.close-button:hover { - background-color: rgba(0, 0, 0, 0.1); -} - -/* file list */ -.file-list { - flex: 1; - list-style: none; - overflow-y: auto; - /* browsers like to cover the bottom row */ - padding-bottom: 24px; -} -.file-list li { - margin: 0; -} -.file-list li:first-child a { - border-top: none; -} -.file-list a { - border-top: 1px solid #bbb; - color: #444; - display: flex; - padding: 8px 12px; - text-decoration: none; -} -.file-list a:hover { - background-color: #e2e2ee; -} - -.file-list a > span { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.file-name { - flex: 1; - min-width: 80px; -} -.file-size { - color: #666; - margin: 0 16px; - text-align: right; -} -.file-date { - min-width: 90px; - text-align: right; -} - -/* file icons */ -.file { - background: url(file.svg); - background-position: left center; - background-repeat: no-repeat; - background-size: 12px; - padding-left: 22px; -} -.folder { - background-image: url(folder.svg); -} - -/* viewer */ -.viewer { - display: flex; - flex: 1; - flex-direction: column; - white-space: pre-wrap; - overflow-y: auto; -} -.view-header { - align-items: center; - background-color: #ccc; - color: #444; - display: flex; - gap: 16px; - height: 24px; - padding: 0 8px; - /* all one line */ - text-overflow: ellipsis; - white-space: nowrap; -} -/* viewers */ -.text { - background-color: #22222b; - color: #d6d6d6; - display: block; - flex: 1; - padding: 8px; - width: 100%; - overflow-x: auto; - white-space: pre-wrap; -} -/* images */ -.image { - display: block; - flex: 1; - min-width: 0; - object-fit: scale-down; - background-image: - linear-gradient(45deg, #ddd 25%, transparent 25%), - linear-gradient(135deg, #ddd 25%, transparent 25%), - linear-gradient(45deg, transparent 75%, #ddd 75%), - linear-gradient(135deg, transparent 75%, #ddd 75%); - background-size: 32px 32px; - background-position:0 0, 16px 0, 16px -16px, 0px 16px; -} -/* markdown */ -.markdown { - background-color: #222226; - color: #ddd; - flex: 1; - padding: 8px 20px; - white-space: pre-wrap; - overflow-y: auto; -} -.markdown a { - color: #cdf; -} -.markdown p { - margin-block: 1em; -} -.markdown pre { - background-color: #34343a; - border-left: #446 solid 5px; - margin: 0; - padding: 12px 14px; - white-space: pre-wrap; -} -.markdown h1 { - font-size: 32px; - font-weight: 500; - margin-bottom: 8px; -} -.markdown h2 { - font-weight: 500; - margin-bottom: 8px; - margin-top: 16px; -} - -.slideContainer { - display: flex; - flex: 1; - min-height: 0; -} - -.slideMain { - display: flex; - flex: 1; - flex-direction: column; - overflow: auto; -} - -.slidePanel { - display: flex; - flex-direction: column; - width: 0; - transition: width 0.2s; -} - -.resizer { - width: 5px; - cursor: col-resize; - background-color: #bfbbbb; - transition: background-color 0.2s; - user-select: none; -} - -.resizer:hover { - background-color: #9f9999; -} - -/* slide panel close button */ -.slideClose, -.slideClose:active, -.slideClose:focus, -.slideClose:hover { - background: none; - border: none; - color: inherit; - margin-left: auto; - height: 24px; - outline: none; - padding: 0; -} -.slideClose::before { - content: "\27E9\27E9"; -} -.slideClose:hover { - font-weight: bold; -} - -/* viewers */ -.text { - background-color: #22222b; - color: #d6d6d6; - display: block; - flex: 1; - padding: 8px; - width: 100%; - overflow-x: auto; - white-space: pre-wrap; -} \ No newline at end of file diff --git a/packages/components/eslint.config.js b/packages/components/eslint.config.js deleted file mode 100644 index 78dc9e4c..00000000 --- a/packages/components/eslint.config.js +++ /dev/null @@ -1,57 +0,0 @@ -import js from '@eslint/js' -import react from 'eslint-plugin-react' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import globals from 'globals' -import tseslint from 'typescript-eslint' -import { sharedJsRules, sharedTsRules } from '../../eslint.config.js' - -export default tseslint.config( - { ignores: ['coverage/', 'dist/', 'es/'] }, - { - settings: { react: { version: '18.3' } }, - extends: [js.configs.recommended, ...tseslint.configs.strictTypeChecked, ...tseslint.configs.stylisticTypeChecked], - files: ['**/*.{ts,tsx,js}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - parserOptions: { - project: ['./tsconfig.json', './tsconfig.eslint.json'], - tsconfigRootDir: import.meta.dirname, - }, - }, - plugins: { - 'react': react, - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...react.configs.recommended.rules, - ...react.configs['jsx-runtime'].rules, - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - ...js.configs.recommended.rules, - ...tseslint.configs.recommended.rules, - ...sharedJsRules, - ...sharedTsRules, - 'no-extra-parens': 'warn', - }, - }, - { - files: ['test/**/*.{ts,tsx}', '*.{js,ts}'], - languageOptions: { - ecmaVersion: 2020, - globals: { - ...globals.node, - ...globals.browser, - }, - }, - }, - { - files: ['**/*.js'], - ...tseslint.configs.disableTypeChecked, - }, -) diff --git a/packages/components/package.json b/packages/components/package.json deleted file mode 100644 index f91e8ec7..00000000 --- a/packages/components/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@hyparam/components", - "version": "0.1.19", - "description": "React components for hyparam apps", - "keywords": [ - "component", - "data", - "javascript", - "react" - ], - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/hyparam/hyperparam-cli.git", - "directory": "packages/components" - }, - "type": "module", - "main": "dist/index.umd.min.js", - "unpkg": "dist/index.umd.min.js", - "module": "dist/index.es.min.js", - "types": "es/index.d.ts", - "exports": { - ".": { - "types": "./es/index.d.ts", - "import": "./dist/index.es.min.js", - "require": "./dist/index.umd.min.js" - }, - "./components.css": "./dist/components.css" - }, - "files": [ - "dist", - "es" - ], - "scripts": { - "build": "tsc && vite build", - "coverage": "vitest run --coverage --coverage.include=src", - "dev": "vite ./demo", - "lint": "eslint .", - "prepare": "npm run build", - "test": "vitest run", - "typecheck": "tsc" - }, - "dependencies": { - "hightable": "0.11.0", - "hyparquet": "1.8.4", - "hyparquet-compressors": "1.0.0" - }, - "devDependencies": { - "react": "18.3.1", - "react-dom": "18.3.1" - }, - "peerDependencies": { - "react": "^18.3.1", - "react-dom": "^18.3.1" - } -} diff --git a/packages/components/test/package.test.js b/packages/components/test/package.test.js deleted file mode 100644 index 346359f6..00000000 --- a/packages/components/test/package.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import { describe, expect, it } from 'vitest' -import packageJson from '../package.json' with { type: 'json' } - -describe('package.json', () => { - it('should have the correct name', () => { - expect(packageJson.name).toBe('@hyparam/components') - }) - it('should have a valid version', () => { - expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+$/) - }) - it('should have MIT license', () => { - expect(packageJson.license).toBe('MIT') - }) - it('should have precise dependency versions', () => { - const { dependencies, devDependencies } = packageJson - const allDependencies = { ...dependencies, ...devDependencies } - /// peer dependencies are not checked, because the user might have different versions - Object.values(allDependencies).forEach(version => { - expect(version).toMatch(/^\d+\.\d+\.\d+$/) - }) - }) -}) diff --git a/packages/components/tsconfig.eslint.json b/packages/components/tsconfig.eslint.json deleted file mode 100644 index 041d1148..00000000 --- a/packages/components/tsconfig.eslint.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src", "test", "demo", "**/*.js", "**/*.ts", "**/*.tsx"] -} diff --git a/packages/cli/public/favicon.png b/public/favicon.png similarity index 100% rename from packages/cli/public/favicon.png rename to public/favicon.png diff --git a/src/app.tsx b/src/app.tsx new file mode 100644 index 00000000..836348fc --- /dev/null +++ b/src/app.tsx @@ -0,0 +1,13 @@ +import 'hightable/src/HighTable.css' +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import App from './components/App.js' +import './styles/app.css' + +const root = document.getElementById('app') +if (!root) throw new Error('missing root element') +createRoot(root).render( + + + , +) diff --git a/packages/cli/public/file.svg b/src/assets/file.svg similarity index 100% rename from packages/cli/public/file.svg rename to src/assets/file.svg diff --git a/packages/cli/public/folder.svg b/src/assets/folder.svg similarity index 100% rename from packages/cli/public/folder.svg rename to src/assets/folder.svg diff --git a/packages/cli/public/logo.svg b/src/assets/logo.svg similarity index 100% rename from packages/cli/public/logo.svg rename to src/assets/logo.svg diff --git a/packages/cli/public/search.svg b/src/assets/search.svg similarity index 100% rename from packages/cli/public/search.svg rename to src/assets/search.svg diff --git a/src/components/App.tsx b/src/components/App.tsx new file mode 100644 index 00000000..286371e4 --- /dev/null +++ b/src/components/App.tsx @@ -0,0 +1,29 @@ +import { getHttpSource } from '../lib/sources/httpSource.js' +import { getHyperparamSource } from '../lib/sources/hyperparamSource.js' +import Page from './Page.js' + +export default function App() { + const search = new URLSearchParams(location.search) + const sourceId = search.get('key') ?? '' + const row = search.get('row') === null ? undefined : Number(search.get('row')) + const col = search.get('col') === null ? undefined : Number(search.get('col')) + + const source = getHttpSource(sourceId) ?? getHyperparamSource(sourceId, { endpoint: location.origin }) + + if (!source) { + return
Could not load a data source. You have to pass a valid source in the url.
+ } + return ( + `/files?key=${sourceId}`, + getCellRouteUrl: ({ sourceId, col, row }) => `/files?key=${sourceId}&col=${col}&row=${row}`, + }, + }} + /> + ) +} diff --git a/packages/components/src/components/Breadcrumb.tsx b/src/components/Breadcrumb.tsx similarity index 100% rename from packages/components/src/components/Breadcrumb.tsx rename to src/components/Breadcrumb.tsx diff --git a/packages/components/src/components/Cell.tsx b/src/components/Cell.tsx similarity index 100% rename from packages/components/src/components/Cell.tsx rename to src/components/Cell.tsx diff --git a/packages/components/src/components/File.tsx b/src/components/File.tsx similarity index 100% rename from packages/components/src/components/File.tsx rename to src/components/File.tsx diff --git a/packages/components/src/components/Folder.tsx b/src/components/Folder.tsx similarity index 100% rename from packages/components/src/components/Folder.tsx rename to src/components/Folder.tsx diff --git a/packages/components/src/components/Json.tsx b/src/components/Json.tsx similarity index 100% rename from packages/components/src/components/Json.tsx rename to src/components/Json.tsx diff --git a/packages/components/src/components/Layout.tsx b/src/components/Layout.tsx similarity index 100% rename from packages/components/src/components/Layout.tsx rename to src/components/Layout.tsx diff --git a/packages/components/src/components/Markdown.tsx b/src/components/Markdown.tsx similarity index 100% rename from packages/components/src/components/Markdown.tsx rename to src/components/Markdown.tsx diff --git a/packages/components/src/components/Page.tsx b/src/components/Page.tsx similarity index 100% rename from packages/components/src/components/Page.tsx rename to src/components/Page.tsx diff --git a/packages/components/src/components/index.ts b/src/components/index.ts similarity index 100% rename from packages/components/src/components/index.ts rename to src/components/index.ts diff --git a/packages/components/src/components/viewers/CellPanel.tsx b/src/components/viewers/CellPanel.tsx similarity index 100% rename from packages/components/src/components/viewers/CellPanel.tsx rename to src/components/viewers/CellPanel.tsx diff --git a/packages/components/src/components/viewers/ContentHeader.tsx b/src/components/viewers/ContentHeader.tsx similarity index 100% rename from packages/components/src/components/viewers/ContentHeader.tsx rename to src/components/viewers/ContentHeader.tsx diff --git a/packages/components/src/components/viewers/ImageView.tsx b/src/components/viewers/ImageView.tsx similarity index 100% rename from packages/components/src/components/viewers/ImageView.tsx rename to src/components/viewers/ImageView.tsx diff --git a/packages/components/src/components/viewers/JsonView.tsx b/src/components/viewers/JsonView.tsx similarity index 100% rename from packages/components/src/components/viewers/JsonView.tsx rename to src/components/viewers/JsonView.tsx diff --git a/packages/components/src/components/viewers/MarkdownView.tsx b/src/components/viewers/MarkdownView.tsx similarity index 100% rename from packages/components/src/components/viewers/MarkdownView.tsx rename to src/components/viewers/MarkdownView.tsx diff --git a/packages/components/src/components/viewers/ParquetView.tsx b/src/components/viewers/ParquetView.tsx similarity index 100% rename from packages/components/src/components/viewers/ParquetView.tsx rename to src/components/viewers/ParquetView.tsx diff --git a/packages/components/src/components/viewers/SlidePanel.tsx b/src/components/viewers/SlidePanel.tsx similarity index 100% rename from packages/components/src/components/viewers/SlidePanel.tsx rename to src/components/viewers/SlidePanel.tsx diff --git a/packages/components/src/components/viewers/TextView.tsx b/src/components/viewers/TextView.tsx similarity index 100% rename from packages/components/src/components/viewers/TextView.tsx rename to src/components/viewers/TextView.tsx diff --git a/packages/components/src/components/viewers/Viewer.tsx b/src/components/viewers/Viewer.tsx similarity index 100% rename from packages/components/src/components/viewers/Viewer.tsx rename to src/components/viewers/Viewer.tsx diff --git a/packages/components/src/components/viewers/index.ts b/src/components/viewers/index.ts similarity index 100% rename from packages/components/src/components/viewers/index.ts rename to src/components/viewers/index.ts diff --git a/packages/components/src/index.ts b/src/index.ts similarity index 100% rename from packages/components/src/index.ts rename to src/index.ts diff --git a/packages/components/src/lib/index.ts b/src/lib/index.ts similarity index 100% rename from packages/components/src/lib/index.ts rename to src/lib/index.ts diff --git a/packages/components/src/lib/routes.ts b/src/lib/routes.ts similarity index 100% rename from packages/components/src/lib/routes.ts rename to src/lib/routes.ts diff --git a/packages/components/src/lib/sources/httpSource.ts b/src/lib/sources/httpSource.ts similarity index 100% rename from packages/components/src/lib/sources/httpSource.ts rename to src/lib/sources/httpSource.ts diff --git a/packages/components/src/lib/sources/hyperparamSource.ts b/src/lib/sources/hyperparamSource.ts similarity index 100% rename from packages/components/src/lib/sources/hyperparamSource.ts rename to src/lib/sources/hyperparamSource.ts diff --git a/packages/components/src/lib/sources/index.ts b/src/lib/sources/index.ts similarity index 100% rename from packages/components/src/lib/sources/index.ts rename to src/lib/sources/index.ts diff --git a/packages/components/src/lib/sources/types.ts b/src/lib/sources/types.ts similarity index 100% rename from packages/components/src/lib/sources/types.ts rename to src/lib/sources/types.ts diff --git a/packages/components/src/lib/sources/utils.ts b/src/lib/sources/utils.ts similarity index 100% rename from packages/components/src/lib/sources/utils.ts rename to src/lib/sources/utils.ts diff --git a/packages/components/src/lib/tableProvider.ts b/src/lib/tableProvider.ts similarity index 100% rename from packages/components/src/lib/tableProvider.ts rename to src/lib/tableProvider.ts diff --git a/packages/components/src/lib/utils.ts b/src/lib/utils.ts similarity index 100% rename from packages/components/src/lib/utils.ts rename to src/lib/utils.ts diff --git a/packages/components/src/lib/workers/parquetWorker.ts b/src/lib/workers/parquetWorker.ts similarity index 100% rename from packages/components/src/lib/workers/parquetWorker.ts rename to src/lib/workers/parquetWorker.ts diff --git a/packages/components/src/lib/workers/parquetWorkerClient.ts b/src/lib/workers/parquetWorkerClient.ts similarity index 100% rename from packages/components/src/lib/workers/parquetWorkerClient.ts rename to src/lib/workers/parquetWorkerClient.ts diff --git a/packages/components/src/lib/workers/types.ts b/src/lib/workers/types.ts similarity index 100% rename from packages/components/src/lib/workers/types.ts rename to src/lib/workers/types.ts diff --git a/packages/components/src/styles/Json.module.css b/src/styles/Json.module.css similarity index 100% rename from packages/components/src/styles/Json.module.css rename to src/styles/Json.module.css diff --git a/packages/cli/public/styles.css b/src/styles/app.css similarity index 97% rename from packages/cli/public/styles.css rename to src/styles/app.css index 344d5f65..0708e60e 100644 --- a/packages/cli/public/styles.css +++ b/src/styles/app.css @@ -48,7 +48,7 @@ main .table tbody tr:hover th:first-child { } .brand::before { content: ''; - background: url(logo.svg) no-repeat 0 center; + background: url("../assets/logo.svg") no-repeat 0 center; background-size: 26px; height: 26px; width: 26px; @@ -160,7 +160,7 @@ main { } /* search */ input.search { - background: #fff url(/public/search.svg) no-repeat center right 8px; + background: #fff url("../assets/search.svg") no-repeat center right 8px; border: 1px solid transparent; border-radius: 8px; flex-shrink: 1; @@ -341,14 +341,14 @@ button.close-button:hover { /* file icons */ .file { - background: url(/public/file.svg); + background-image: url("../assets/file.svg"); background-position: left center; background-repeat: no-repeat; background-size: 12px; padding-left: 22px; } .folder { - background-image: url(/public/folder.svg); + background-image: url("../assets/folder.svg"); } /* viewer */ diff --git a/packages/components/src/vite-env.d.ts b/src/vite-env.d.ts similarity index 100% rename from packages/components/src/vite-env.d.ts rename to src/vite-env.d.ts diff --git a/packages/cli/test/handleListing.test.js b/test/bin/handleListing.test.js similarity index 97% rename from packages/cli/test/handleListing.test.js rename to test/bin/handleListing.test.js index 1f629048..cedb7947 100644 --- a/packages/cli/test/handleListing.test.js +++ b/test/bin/handleListing.test.js @@ -1,7 +1,7 @@ -import { afterAll, beforeAll, describe, expect, it } from 'vitest' import * as fs from 'fs/promises' import path from 'path' -import { handleListing } from '../src/serve.js' +import { afterAll, beforeAll, describe, expect, it } from 'vitest' +import { handleListing } from '../../bin/serve.js' const tempDir = path.join(__dirname, 'temp-test-dir') diff --git a/packages/cli/test/streamConverters.test.js b/test/bin/streamConverters.test.js similarity index 97% rename from packages/cli/test/streamConverters.test.js rename to test/bin/streamConverters.test.js index fe338062..a71e9945 100644 --- a/packages/cli/test/streamConverters.test.js +++ b/test/bin/streamConverters.test.js @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest' import { pipe, readStreamToReadableStream, -} from '../src/streamConverters.js' +} from '../../bin/streamConverters.js' describe('pipe', () => { it('should pipe data from web ReadableStream to a Writable', async () => { diff --git a/packages/components/test/components/File.test.tsx b/test/components/File.test.tsx similarity index 100% rename from packages/components/test/components/File.test.tsx rename to test/components/File.test.tsx diff --git a/packages/components/test/components/Folder.test.tsx b/test/components/Folder.test.tsx similarity index 100% rename from packages/components/test/components/Folder.test.tsx rename to test/components/Folder.test.tsx diff --git a/packages/components/test/components/Json.test.tsx b/test/components/Json.test.tsx similarity index 100% rename from packages/components/test/components/Json.test.tsx rename to test/components/Json.test.tsx diff --git a/packages/components/test/components/Layout.test.tsx b/test/components/Layout.test.tsx similarity index 100% rename from packages/components/test/components/Layout.test.tsx rename to test/components/Layout.test.tsx diff --git a/packages/components/test/components/Markdown.test.tsx b/test/components/Markdown.test.tsx similarity index 100% rename from packages/components/test/components/Markdown.test.tsx rename to test/components/Markdown.test.tsx diff --git a/packages/components/test/components/viewers/ImageView.test.tsx b/test/components/viewers/ImageView.test.tsx similarity index 100% rename from packages/components/test/components/viewers/ImageView.test.tsx rename to test/components/viewers/ImageView.test.tsx diff --git a/packages/components/test/components/viewers/MarkdownView.test.tsx b/test/components/viewers/MarkdownView.test.tsx similarity index 100% rename from packages/components/test/components/viewers/MarkdownView.test.tsx rename to test/components/viewers/MarkdownView.test.tsx diff --git a/packages/components/test/lib/routes.test.ts b/test/lib/routes.test.ts similarity index 100% rename from packages/components/test/lib/routes.test.ts rename to test/lib/routes.test.ts diff --git a/packages/components/test/lib/sources/httpSource.test.ts b/test/lib/sources/httpSource.test.ts similarity index 100% rename from packages/components/test/lib/sources/httpSource.test.ts rename to test/lib/sources/httpSource.test.ts diff --git a/packages/components/test/lib/sources/hyperparamSource.test.ts b/test/lib/sources/hyperparamSource.test.ts similarity index 100% rename from packages/components/test/lib/sources/hyperparamSource.test.ts rename to test/lib/sources/hyperparamSource.test.ts diff --git a/test/package.test.js b/test/package.test.js index 68b5e552..caa2f757 100644 --- a/test/package.test.js +++ b/test/package.test.js @@ -3,7 +3,7 @@ import packageJson from '../package.json' with { type: 'json' } describe('package.json', () => { it('should have the correct name', () => { - expect(packageJson.name).toBe('@hyparam/monorepo') + expect(packageJson.name).toBe('hyperparam') }) it('should have a valid version', () => { expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+$/) @@ -14,8 +14,8 @@ describe('package.json', () => { it('should have precise dependency versions', () => { const { dependencies, devDependencies } = packageJson const allDependencies = { ...dependencies, ...devDependencies } - Object.values( allDependencies).forEach(version => { - expect(version).toMatch(/^\d+\.\d+\.\d+$/) }, - ) + Object.values(allDependencies).forEach(version => { + expect(version).toMatch(/^\d+\.\d+\.\d+$/) + }) }) }) diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 00000000..1126b701 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "include": ["src", "test", "bin", "**/*.js", "**/*.ts", "**/*.tsx"] +} diff --git a/packages/components/tsconfig.json b/tsconfig.json similarity index 76% rename from packages/components/tsconfig.json rename to tsconfig.json index 228988f6..3c524536 100644 --- a/packages/components/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,12 @@ { "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "NodeNext", + "module": "ESNext", "skipLibCheck": true, - "moduleResolution": "nodenext", + "moduleResolution": "bundler", "isolatedModules": true, "moduleDetection": "force", "jsx": "react-jsx", @@ -18,7 +17,8 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true, - "outDir": "./es", + "rootDir": "src", + "outDir": "./lib", "emitDeclarationOnly": true, "declaration": true }, diff --git a/vite.app.config.ts b/vite.app.config.ts new file mode 100644 index 00000000..9982072c --- /dev/null +++ b/vite.app.config.ts @@ -0,0 +1,7 @@ +import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [react()], +}) diff --git a/packages/components/vite.config.ts b/vite.lib.config.ts similarity index 90% rename from packages/components/vite.config.ts rename to vite.lib.config.ts index 86d4c15f..d4f2a653 100644 --- a/packages/components/vite.config.ts +++ b/vite.lib.config.ts @@ -7,12 +7,12 @@ import { defineConfig } from 'vite' export default defineConfig({ plugins: [react()], build: { - outDir: resolve(__dirname, 'dist'), + outDir: resolve(__dirname, 'lib'), copyPublicDir: false, lib: { entry: resolve(__dirname, 'src/index.ts'), formats: ['es', 'umd'], - name: 'HyperparamComponents', + name: 'Hyperparam', fileName: (format) => `index.${format}.min.js`, }, rollupOptions: {