Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blocks): switch the file-type to @sgtpooki/file-type #6803

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

lawvs
Copy link
Member

@lawvs lawvs commented Apr 18, 2024

Fix toeverything/AFFiNE#6603

This pull request switches the file-type to @sgtpooki/file-type.

It also includes other minor changes and updates.

The file-type is no longer useful since the toeverything/AFFiNE#3245 resolved in toeverything/AFFiNE#5565


More context see toeverything/AFFiNE#3245 #3555 #4818 #5372 sindresorhus/file-type#578


Caveat

The @sgtpooki/file-type is an unofficial fork package from the community. It may need to be source code audited before updating.

Also, thanks to sgtpooki for their strong contribution to @sgtpooki/file-type

Copy link

vercel bot commented Apr 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2024 2:14pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
blocksuite-docs ⬜️ Ignored (Inspect) Visit Preview Apr 22, 2024 2:14pm

Copy link
Contributor

@fourdim fourdim left a comment

Choose a reason for hiding this comment

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

It still depends on buffer: sindresorhus/file-type#578.
The only solution is to reimplement file-type.

@JimmFly
Copy link
Member

JimmFly commented Apr 18, 2024

I also tried upgrading file-type package but got this error in AFFiNE.

Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

@lawvs lawvs changed the title chore: upgrade file-type to v19 and remove buffer fix(blocks): removes the file-type and buffer packages Apr 18, 2024
if (!blob) {
return null;
}

if (!blob.type) {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest that we not delete file-type, because affine's sync backend does not store blob.type. You can expect all blob.types to be empty "". We can only calculate them through file-type when type is needed.

As for the buffer issue of file-type v19 in the browser, affine can workaround by adding node:buffer polyfill.

@lawvs lawvs changed the title fix(blocks): removes the file-type and buffer packages fix(blocks): switch the file-type to @sgtpooki/file-type Apr 18, 2024
@lawvs lawvs closed this Apr 18, 2024
@lawvs lawvs deleted the chore/upgrade-file-type branch April 18, 2024 14:17
@lawvs lawvs restored the chore/upgrade-file-type branch April 19, 2024 07:44
@lawvs lawvs reopened this Apr 19, 2024
@lawvs lawvs marked this pull request as ready for review April 19, 2024 08:07
Copy link
Contributor

@fourdim fourdim left a comment

Choose a reason for hiding this comment

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

@sgtpooki/file-type and it's direct dependencies are audited. No malicious codes found.

Copy link

graphite-app bot commented Apr 22, 2024

Merge activity

Fix toeverything/AFFiNE#6603

This pull request switches the [file-type](https://github.com/sindresorhus/file-type) to [@sgtpooki/file-type](https://github.com/sgtpooki/file-type).

It also includes other minor changes and updates.

~~The `file-type` is no longer useful since the toeverything/AFFiNE#3245 resolved in toeverything/AFFiNE#5565

---

More context see toeverything/AFFiNE#3245 #3555 #4818 #5372 sindresorhus/file-type#578

---

## Caveat

The [@sgtpooki/file-type](https://github.com/sgtpooki/file-type) is an unofficial fork package from the community. It may need to be source code audited before updating.

Also, thanks to sgtpooki for their strong contribution to @sgtpooki/file-type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Cannot copy embedded image to clipboard, or download it​
4 participants