diff --git a/@types/index.d.ts b/@types/index.d.ts new file mode 100644 index 0000000..34b9ddc --- /dev/null +++ b/@types/index.d.ts @@ -0,0 +1,52 @@ +declare module "@loilo-inc/eld" { + class LanguageResult { + language: string; + getScores(): Record; + isReliable(): boolean; + } + interface EldInfo { + "Data type": string; + Languages: string[]; + "Dynamic subset": boolean | Record; + } + interface Eld { + detect(text: string): LanguageResult; + cleanText(clean: boolean): void; + dynamicLanguSubset( + languages: Record + ): Record; + saveSubset(languages: Record): void; + info(): EldInfo; + } + interface EldWithNgramLoador extends Eld { + loadNgrams( + file: "ngramL60.js" | "ngramM60.js" | "ngramS60.js" | "ngramXS60.js" + ): Promise; + } + export const eld: EldWithNgramLoador; +} + +declare module "@loilo-inc/eld/src/entries/static.M60.js" { + import { Eld } from "@loilo-inc/eld"; + export const eld: Eld; +} + +declare module "@loilo-inc/eld/src/entries/static.L60.js" { + import { Eld } from "@loilo-inc/eld"; + export const eld: Eld; +} + +declare module "@loilo-inc/eld/src/entries/static.M60.js" { + import { Eld } from "@loilo-inc/eld"; + export const eld: Eld; +} + +declare module "@loilo-inc/eld/src/entries/static.S60.js" { + import { Eld } from "@loilo-inc/eld"; + export const eld: Eld; +} + +declare module "@loilo-inc/eld/src/entries/static.XS60.js" { + import { Eld } from "@loilo-inc/eld"; + export const eld: Eld; +} diff --git a/package.json b/package.json index ddd32a4..171514c 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,41 @@ { - "name": "eld", + "name": "@loilo-inc/eld", "version": "1.0.1", "description": "Fast and accurate natural language detection. Detector written in Javascript. Efficient language detector, Nito-ELD, ELD.", "main": "src/entries/dynamic.js", "type": "module", + "types": "@types/index.d.ts", "repository": { "type": "git", - "url": "git+https://github.com/nitotm/efficient-language-detector-js.git" + "url": "git+https://github.com/loilo-inc/efficient-language-detector-js.git" + }, + "files": [ + "src", + "@types", + "LICENSE", + "README.md" + ], + "exports": { + ".": { + "import": "./src/entries/dynamic.js", + "types": "./@types/index.d.ts" + }, + "./src/entries/static.L60.js": { + "import": "./src/entries/static.L60.js", + "types": "./@types/index.d.ts" + }, + "./src/entries/static.M60.js": { + "import": "./src/entries/static.M60.js", + "types": "./@types/index.d.ts" + }, + "./src/entries/static.S60.js": { + "import": "./src/entries/static.S60.js", + "types": "./@types/index.d.ts" + }, + "./src/entries/static.XS60.js": { + "import": "./src/entries/static.XS60.js", + "types": "./@types/index.d.ts" + } }, "keywords": [ "nlp",