Comments (11)
Thanks for the quick check! Agreed on both points. 0.2.12 accepts Uint8Array and drops Buffer for non-Node magika.
from magika.
facing the same issue :
Could not find a declaration file for module 'magika'. '/node_modules/magika/magika.js' implicitly has an 'any' type.
from magika.
Thanks for reporting, looking into it.
from magika.
See #129, not sure if it's related.
from magika.
I tried adding types to DefinitelyTyped to use Magika with TypeScript. However, I encountered the following error, and the tests did not pass. Does Magika not support CommonJS?
A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers.
CommonJS consumers will need to use a dynamic import.
DefinitelyTyped's pull request is below:
DefinitelyTyped/DefinitelyTyped#68765
from magika.
@reyammer
It appears that Magica doesn't seem to support CommonJS, as shown in #129. This suggests that we should be able to add types to DefinitelyTyped.
module.exports = { Magika };
from magika.
@chris-si
I have added type definitions for Magika to DefinitelyTyped. With this, you can now run it in TypeScript without any errors.
npm: https://www.npmjs.com/package/@types/magika
Please execute the following command.
npm install --save-dev @types/magika
or
pnpm add -D @types/magika
Additional information:
Magika did not support CommonJS and didn't pass the tests at DefinitelyTyped, the DefinitelyTyped team has been modified to allow the tests to pass even if the library does not support CommonJS.
from magika.
We've published a version with commonJS support, and the library has been rewritten in Typescript as of yesterday.
Our types should be bundled with the package. Please take a look and let me know if they are as expected.
from magika.
That's great to hear! I'll give it a try in the coming days.
from magika.
That's great. I tried 0.2.10 out right away.
I'm using Magika as a client application. While doing so, I encountered an issue concerning the argument types of the identifyBytesFull and identifyBytes methods.
The type of fileBytes being Uint16Array | Buffer required the following configuration in webpack.
// webpack.config.js
module.exports = {
//...
resolve: {
fallback: {
fs: false
}
},
};
Buffer is a type specific to Node.js and is not suitable for use in the browser. Additionally, for files used in the browser, the type Uint8Array is more commonly used instead of Uint16Array.
I would like the type of fileBytes to be changed to Uint8Array for comfortable use in a browser environment.
from magika.
I tried it out and it works like expected! Thanks for improving the js/ts lib!
from magika.
Related Issues (20)
- Import reported gh issues misdetections in the tests dataset
- [NEW CONTENT TYPE REQUEST] CodeBlocks Project
- [NEW CONTENT TYPE REQUEST] Viminfo
- [NEW CONTENT TYPE REQUEST] Elixir
- [NEW CONTENT TYPE REQUEST] Metal
- [NEW CONTENT TYPE REQUEST] Ring
- [NEW CONTENT TYPE REQUEST] hOON
- [NEW CONTENT TYPE REQUEST] Emacs Lisp
- [NEW CONTENT TYPE REQUEST] Meson Build File
- [NEW CONTENT TYPE REQUEST] Yacc
- [NEW CONTENT TYPE REQUEST] Lex
- [NEW CONTENT TYPE REQUEST] Roff
- [NEW CONTENT TYPE REQUEST] Stata
- [NEW CONTENT TYPE REQUEST] VHDL
- [NEW CONTENT TYPE REQUEST] Nix
- [NEW CONTENT TYPE REQUEST] Cuda
- [NEW CONTENT TYPE REQUEST] Super Cascading Style Sheets
- [NEW CONTENT TYPE REQUEST] API Blueprint
- [Misdetection] PHP file misdetected as image when image is injected at the start of the file
- [Misdetection] AVIF image files are labeled as video
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magika.