Skip to content

[wip] Components package - #14

Merged
severo merged 47 commits into
masterfrom
components-package
Nov 6, 2024
Merged

severo merged 47 commits into
masterfrom
components-package

Conversation

@severo

@severo severo commented Nov 4, 2024 •

Copy link
Copy Markdown
Contributor

Missing:

  • use the worker and the source maps from @hyparam/components in the app build
  • remove the vite boilerplate (demo)
  • fix the linting errors
  • incorporate the fixes from the HF space
  • format the code in a coherent way (prettier?)
  • setup eslint for the lib

Then, follow-up work (check means an issue/PR has been created):

  • remove TODO(SL) and create issues instead
  • are we OK with inlining the workers?
  • publish the source files (TSX) as well as the bundle
  • remove hardcoded routes like /files?key= or /api/store/get?key=
  • see how to handle the CSS: which part goes to the components? which part goes to the app? will we use CSS modules (one per component)?
  • setup the CI to lint/build/deploy the lib + update the app
  • create a demo for the @hyparam/components lib
  • incorporate new (HF-related) features from the space + authentication (headers)
  • give instructions in the README of packages/components to use the library
  • publish the lib
  • use the lib in the space, in the hyparquet demo, in the hightable demo, and other apps
  • move the app to a package in the npm workspace, instead of keeping it at the root? (reference: https://github.com/NiGhTTraX/ts-monorepo, for example)
  • use vite for the app too, instead of rollup? (with https://www.npmjs.com/package/vite-node?)
  • find a better name than parsedKey and find the correct abstraction ([wip] Components package #14 (comment))

Comment thread packages/components/package.json Resolved
Comment thread packages/components/tsconfig.app.json Resolved
Comment thread rollup.config.js Resolved
Comment thread src/streamConverters.js Resolved
severo added 15 commits November 5, 2024 10:28
Note the size of the bundled JS:

$ npm run build

> @hyparam/components@0.1.0 build
> tsc -b ./tsconfig.lib.json && vite build

vite v5.4.10 building for production...
✓ 39 modules transformed.

[vite:dts] Start generate declaration files...
computing gzip size (0)...[vite:dts] Declaration files built in 2044ms.

dist/main.es.js  234.34 kB │ gzip: 123.03 kB │ map: 119.65 kB
dist/main.umd.js  223.48 kB │ gzip: 121.78 kB │ map: 116.58 kB
✓ built in 2.79s
it prepares the way to parse Hugging Face URLs
@severo
severo requested a review from platypii November 6, 2024 00:30
@severo
severo marked this pull request as ready for review November 6, 2024 00:30
Comment thread .github/workflows/ci.yml Resolved
Comment thread packages/components/eslint.config.js Resolved
Comment thread packages/components/README.md Resolved
interface ViewerProps {
file: string
setError: (error: Error) => void
parsedKey: UrlKey | FileKey

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure that parsedKey is the name I would go for here. Maybe content? In the other repo I moved toward ViewerProps accepting:

interface ViewerProps {
  content: AsyncBufferFrom
  ...
}
export type AsyncBufferFrom = FileContent<void> | AsyncBufferFromFile

So basically solving the same problem but slightly different names. Ultimately what's important is that it is an object that defines how to construct an AsyncBuffer object. It needs to be a serializable object so that we can send it to the webworker. And the two cases are either: from a url or from a dropped file.

In the case of a UrlKey: it should also include a byteLength property. Why? Otherwise we might need to make a HEAD request every time we want to construct an AsyncBuffer.

This is ok for now for merging the PR. We can evolve this over time. But I think both repos have not found exactly the right abstraction here.

@severo severo Nov 6, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly! I couldn't find a good name, and key is a reserved word in React so we cannot use it to pass the data as key={key}.
Note that my intent is also to do the URL/path parsing once, and avoid doing it again (will be maybe more important when we will include the parsing of HF URLs, since the different parts of the URL have different meanings, see https://github.com/severo/hyparam--space/blob/main/src/lib/huggingface.ts).

Maybe the abstraction is somewhat like a filesystem (as in https://filesystem-spec.readthedocs.io): being able to handle and navigate through files stored locally, remotely on a standard HTTP hosting, on S3, on HF, inside ZIP, etc. using the same code.

Comment thread packages/components/src/main.ts Resolved
Comment thread packages/components/tsconfig.json Resolved
Comment thread rollup.config.js Resolved
@severo
severo requested a review from platypii November 6, 2024 15:38

@platypii platypii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Only minor comments. Also there's a test failing due to multiple matches of / instead of just one. not sure why that changed in the dom?

Approved conditional on tests passing. 👍

Comment thread .github/workflows/ci.yml Resolved
@severo

severo commented Nov 6, 2024

Copy link
Copy Markdown
Contributor Author

Looks good. Only minor comments. Also there's a test failing due to multiple matches of / instead of just one. not sure why that changed in the dom?

OK, the culprit was:

79894fd#diff-6af28ba0149c36fb2e0a4050a592e6c070d37f04359a949ccb21b39fa05e5583R42

Fixed.

@severo
severo force-pushed the components-package branch from 22cc4a9 to e637788 Compare November 6, 2024 22:00
@severo

severo commented Nov 6, 2024

Copy link
Copy Markdown
Contributor Author

Merging! Tomorrow, I'll start creating PRs (or issues) for the points listed in the description

@severo
severo merged commit c536f49 into master Nov 6, 2024
@severo
severo deleted the components-package branch November 6, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants