Skip to content

Commit

Permalink
fix: some import issues
Browse files Browse the repository at this point in the history
fix: rollup plugin issue
remove: `lib/*` from package
update: move types from `lib/*` to `dist/esm/*`
  • Loading branch information
BANKA2017 committed Nov 20, 2024
1 parent b3a6f16 commit bcddc39
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
!/dist/**
!LICENSE
!README.md
!package.json
!/lib/**
!package.json
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"bugs": {
"url": "https://github.com/BANKA2017/translator-utils/issues"
},
"main": "lib/index.js",
"main": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"types": "./dist/esm/index.d.ts",
"workerd": {
"default": "./dist/esm/translator.mod.js"
},
Expand All @@ -20,7 +22,6 @@
"default": "./dist/esm/index.js"
}
},
"./lib/*": "./lib/*",
"./package.json": "./package.json"
},
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src/index.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { GoogleBrowserTranslate, GoogleBrowserTranslateV2 } from './source/googl
import { MicrosoftBrowserTranslator } from './source/microsoft.js'
import { SogouBrowserTranslator } from './source/sogou.js'

import type { TranslatorFunction } from 'types.js'
import type { BING_LIST, GOOGLE_LIST, SOGOU_LIST, YANDEX_LIST } from 'language.js'
import type { TranslatorFunction } from './types.js'
import type { BING_LIST, GOOGLE_LIST, SOGOU_LIST, YANDEX_LIST } from './language.js'

const Translator: TranslatorFunction = async (text = '', platform, source, target, raw, ext = {}) => {
let result = { content: '', message: '' }
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { GoogleTranslate, GoogleBrowserTranslate, GoogleBrowserTranslateV2, Goog
import { MicrosoftTranslator, MicrosoftBrowserTranslator, GetMicrosoftBrowserTranslatorAuth, GetMicrosoftTranslatorToken, MicrosoftBrowserPredict, MicrosoftTTS, MicrosoftBrowserTTS } from './source/microsoft.js'
import { SogouBrowserTranslator, SogouTTS } from './source/sogou.js'
import { YandexDetect, YandexTranslator, YandexBrowserTranslator } from './source/yandex.js'
import { WatsonDetect, WatsonTranslator } from 'source/watson.js'
import { WatsonDetect, WatsonTranslator } from './source/watson.js'

import { IsChs, IsCht } from './misc.js'
import type { TranslatorFunction } from 'types.js'
import type { BAIDU_LIST, BING_LIST, DEEPL_LIST, GOOGLE_LIST, SOGOU_LIST, WATSON_LIST, YANDEX_LIST } from 'language.js'
import type { TranslatorFunction } from './types.js'
import type { BAIDU_LIST, BING_LIST, DEEPL_LIST, GOOGLE_LIST, SOGOU_LIST, WATSON_LIST, YANDEX_LIST } from './language.js'

const Translator: TranslatorFunction = async (text = '', platform, source, target, raw, ext = {}) => {
let result = { content: '', message: '' }
Expand Down
2 changes: 1 addition & 1 deletion src/language.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TargetFilter } from 'types.js'
import type { TargetFilter } from './types.js'

export type GOOGLE_LIST = 'aa'|'ab'|'ace'|'ach'|'af'|'ak'|'alz'|'am'|'ar'|'as'|'av'|'awa'|'ay'|'az'|'ba'|'bal'|'ban'|'bbc'|'bci'|'be'|'bem'|'ber'|'ber-latn'|'bew'|'bg'|'bho'|'bik'|'bm'|'bm-nkoo'|'bn'|'bo'|'br'|'bs'|'bts'|'btx'|'bua'|'ca'|'ce'|'ceb'|'cgg'|'ch'|'chk'|'chm'|'ckb'|'cnh'|'co'|'crh'|'crs'|'cs'|'cv'|'cy'|'da'|'de'|'din'|'doi'|'dov'|'dv'|'dyu'|'dz'|'ee'|'el'|'en'|'eo'|'es'|'et'|'eu'|'fa'|'fa-af'|'ff'|'fi'|'fj'|'fo'|'fon'|'fr'|'fur'|'fy'|'ga'|'gaa'|'gd'|'gl'|'gn'|'gom'|'gu'|'gv'|'ha'|'haw'|'hi'|'hil'|'hmn'|'hr'|'hrx'|'ht'|'hu'|'hy'|'iba'|'id'|'ig'|'ilo'|'is'|'it'|'iw'|'ja'|'jam'|'jw'|'ka'|'kac'|'kek'|'kg'|'kha'|'kk'|'kl'|'km'|'kn'|'ko'|'kr'|'kri'|'ktu'|'ku'|'kv'|'ky'|'la'|'lb'|'lg'|'li'|'lij'|'lmo'|'ln'|'lo'|'lt'|'ltg'|'luo'|'lus'|'lv'|'mad'|'mai'|'mak'|'mam'|'mfe'|'mg'|'mh'|'mi'|'min'|'mk'|'ml'|'mn'|'mni-mtei'|'mr'|'ms'|'ms-arab'|'mt'|'mwr'|'my'|'ndc-zw'|'ne'|'new'|'nhe'|'nl'|'no'|'nr'|'nso'|'nus'|'ny'|'oc'|'om'|'or'|'os'|'pa'|'pa-arab'|'pag'|'pam'|'pap'|'pl'|'ps'|'pt'|'pt-pt'|'qu'|'rn'|'ro'|'rom'|'ru'|'rw'|'sa'|'sah'|'sat-latn'|'scn'|'sd'|'se'|'sg'|'shn'|'si'|'sk'|'sl'|'sm'|'sn'|'so'|'sq'|'sr'|'ss'|'st'|'su'|'sus'|'sv'|'sw'|'szl'|'ta'|'tcy'|'te'|'tet'|'tg'|'th'|'ti'|'tiv'|'tk'|'tl'|'tn'|'to'|'tpi'|'tr'|'trp'|'ts'|'tt'|'tum'|'ty'|'tyv'|'udm'|'ug'|'uk'|'ur'|'uz'|'ve'|'vec'|'vi'|'war'|'wo'|'xh'|'yi'|'yo'|'yua'|'yue'|'zap'|'zh-cn'|'zh-tw'|'zu'
export const GOOGLE_LANGUAGE: TargetFilter['google'][] = ['aa','ab','ace','ach','af','ak','alz','am','ar','as','av','awa','ay','az','ba','bal','ban','bbc','bci','be','bem','ber','ber-latn','bew','bg','bho','bik','bm','bm-nkoo','bn','bo','br','bs','bts','btx','bua','ca','ce','ceb','cgg','ch','chk','chm','ckb','cnh','co','crh','crs','cs','cv','cy','da','de','din','doi','dov','dv','dyu','dz','ee','el','en','eo','es','et','eu','fa','fa-af','ff','fi','fj','fo','fon','fr','fur','fy','ga','gaa','gd','gl','gn','gom','gu','gv','ha','haw','hi','hil','hmn','hr','hrx','ht','hu','hy','iba','id','ig','ilo','is','it','iw','ja','jam','jw','ka','kac','kek','kg','kha','kk','kl','km','kn','ko','kr','kri','ktu','ku','kv','ky','la','lb','lg','li','lij','lmo','ln','lo','lt','ltg','luo','lus','lv','mad','mai','mak','mam','mfe','mg','mh','mi','min','mk','ml','mn','mni-mtei','mr','ms','ms-arab','mt','mwr','my','ndc-zw','ne','new','nhe','nl','no','nr','nso','nus','ny','oc','om','or','os','pa','pa-arab','pag','pam','pap','pl','ps','pt','pt-pt','qu','rn','ro','rom','ru','rw','sa','sah','sat-latn','scn','sd','se','sg','shn','si','sk','sl','sm','sn','so','sq','sr','ss','st','su','sus','sv','sw','szl','ta','tcy','te','tet','tg','th','ti','tiv','tk','tl','tn','to','tpi','tr','trp','ts','tt','tum','ty','tyv','udm','ug','uk','ur','uz','ve','vec','vi','war','wo','xh','yi','yo','yua','yue','zap','zh-cn','zh-tw','zu']
Expand Down
4 changes: 2 additions & 2 deletions src/source/watson.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WATSON_LANGUAGE } from 'language.js'
import { SupportedLanguage } from 'misc.js'
import { SupportedLanguage } from '../misc.js'
import axiosFetch from 'translator-utils-axios-helper'
import { TranslatorModuleFunction } from 'types.js'
import type { TranslatorModuleFunction } from '../types.js'

const WatsonDetect = async (text: string | string[] = ''): Promise<string | '_'> => {
if (!text) {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BAIDU_LIST, BAIDU_TTS_LIST, BING_LIST, BING_TTS_LIST, MICROSOFT_EDGE_TTS_TYPE, DEEPL_LIST, GOOGLE_LIST, SOGOU_LIST, SOGOU_TTS_LIST, YANDEX_LIST, WATSON_LIST } from 'language.js'
import type { BAIDU_LIST, BAIDU_TTS_LIST, BING_LIST, BING_TTS_LIST, MICROSOFT_EDGE_TTS_TYPE, DEEPL_LIST, GOOGLE_LIST, SOGOU_LIST, SOGOU_TTS_LIST, YANDEX_LIST, WATSON_LIST } from './language.js'

export type TranslatorModuleFunction<P extends Platform> = <R extends boolean = false>(
text: string | string[],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist/esm", // https://github.com/rollup/plugins/issues/1814
"module": "NodeNext"
},
"extends": "./tsconfig.rollup.json"
Expand Down

0 comments on commit bcddc39

Please sign in to comment.