Skip to content

Commit 978e31f

Browse files
authored
remove the concept of filesystem, we don't need it (#114)
* remove the concept of filesystem, we don't need it * remove duplicated code * source.ts -> types.ts * getHttpSource only generates FileSource
1 parent de9b50c commit 978e31f

29 files changed

+186
-224
lines changed

packages/components/demo/App.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { Page } from '../src/index.js'
33

4-
import { Source, createHttpFileSystem, getSource } from '../src/index.ts'
4+
import { getHttpSource } from '../src/index.ts'
55
export interface Navigation {
66
col?: number
77
row?: number
@@ -15,10 +15,6 @@ function getNumberParam(search: URLSearchParams, key: string): number | undefine
1515
return number
1616
}
1717

18-
const fileSystems = [
19-
createHttpFileSystem(),
20-
]
21-
2218
export default function App() {
2319
const search = new URLSearchParams(location.search)
2420
const url = search.get('url')
@@ -31,20 +27,13 @@ export default function App() {
3127
const row = getNumberParam(search, 'row')
3228
const col = getNumberParam(search, 'col')
3329

34-
let source: Source | undefined = undefined
35-
for (const fileSystem of fileSystems) {
36-
const fsSource = getSource(url, fileSystem)
37-
if (fsSource){
38-
source = fsSource
39-
break
40-
}
41-
}
30+
const source = getHttpSource(url)
4231

4332
if (!source) {
4433
return <div>Could not load a data source. You have to pass a valid source in the url, eg: <a href={defaultUrl}>{defaultUrl}</a>.</div>
4534
}
4635
return <Page source={source} navigation={{ row, col }} config={{
47-
slidePanel: { minWidth: 250, maxWidth: 750 },
36+
slidePanel: { minWidth: 250 },
4837
routes: {
4938
getSourceRouteUrl: ({ sourceId }) => `/?url=${sourceId}`,
5039
getCellRouteUrl: ({ sourceId, col, row }) => `/?url=${sourceId}&col=${col}&row=${row}`,

packages/components/src/components/Breadcrumb.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RoutesConfig } from '../lib/routes.js'
2-
import { Source } from '../lib/source.js'
2+
import { Source } from '../lib/sources/types.js'
33

44
export type BreadcrumbConfig = RoutesConfig
55
interface BreadcrumbProps {

packages/components/src/components/Cell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { asyncRows } from 'hightable'
22
import { asyncBufferFromUrl, parquetMetadataAsync } from 'hyparquet'
33
import { useEffect, useState } from 'react'
4-
import { FileSource } from '../lib/source.js'
4+
import { FileSource } from '../lib/sources/types.js'
55
import { parquetDataFrame } from '../lib/tableProvider.js'
66
import Breadcrumb, { BreadcrumbConfig } from './Breadcrumb.js'
77
import Layout from './Layout.js'

packages/components/src/components/File.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react'
2-
import { FileSource } from '../lib/source.js'
2+
import { FileSource } from '../lib/sources/types.js'
33
import Breadcrumb, { BreadcrumbConfig } from './Breadcrumb.js'
44
import Layout from './Layout.js'
55
import Viewer, { ViewerConfig } from './viewers/Viewer.js'

packages/components/src/components/Folder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from 'react'
2-
import type { DirSource, FileMetadata } from '../lib/source.js'
2+
import type { DirSource, FileMetadata } from '../lib/sources/types.js'
33
import { cn, formatFileSize, getFileDate, getFileDateShort } from '../lib/utils.js'
44
import Breadcrumb, { BreadcrumbConfig } from './Breadcrumb.js'
55
import Layout, { Spinner } from './Layout.js'

packages/components/src/components/Page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Source } from '../lib/source.js'
1+
import { Source } from '../lib/sources/types.js'
22
import { BreadcrumbConfig } from './Breadcrumb.js'
33
import Cell from './Cell.js'
44
import File, { FileConfig } from './File.js'

packages/components/src/components/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Breadcrumb, { BreadcrumbConfig } from './Breadcrumb.js'
22
import Cell, { CellConfig } from './Cell.js'
33
import File, { FileConfig } from './File.js'
44
import Folder, { FolderConfig } from './Folder.js'
5-
import Layout from './Layout.js'
5+
import Layout, { Spinner } from './Layout.js'
66
import Markdown from './Markdown.js'
77
import Page, { PageConfig } from './Page.js'
88
export * from './viewers/index.js'
9-
export { Breadcrumb, Cell, File, Folder, Layout, Markdown, Page }
9+
export { Breadcrumb, Cell, File, Folder, Layout, Markdown, Page, Spinner }
1010
export type { BreadcrumbConfig, CellConfig, FileConfig, FolderConfig, PageConfig }

packages/components/src/components/viewers/ImageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from 'react'
2-
import { FileSource } from '../../lib/source.js'
2+
import { FileSource } from '../../lib/sources/types.js'
33
import { contentTypes, parseFileSize } from '../../lib/utils.js'
44
import { Spinner } from '../Layout.js'
55
import ContentHeader from './ContentHeader.js'

packages/components/src/components/viewers/MarkdownView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from 'react'
2-
import { FileSource } from '../../lib/source.js'
2+
import { FileSource } from '../../lib/sources/types.js'
33
import { parseFileSize } from '../../lib/utils.js'
44
import { Spinner } from '../Layout.js'
55
import Markdown from '../Markdown.js'

packages/components/src/components/viewers/ParquetView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import HighTable, { DataFrame, rowCache } from 'hightable'
22
import { asyncBufferFromUrl, parquetMetadataAsync } from 'hyparquet'
33
import React, { useCallback, useEffect, useState } from 'react'
44
import { RoutesConfig, appendSearchParams } from '../../lib/routes.js'
5-
import { FileSource } from '../../lib/source.js'
5+
import { FileSource } from '../../lib/sources/types.js'
66
import { parquetDataFrame } from '../../lib/tableProvider.js'
77
import { Spinner } from '../Layout.js'
88
import CellPanel from './CellPanel.js'

0 commit comments

Comments
 (0)