From 7b02179bf7145d42faf0a2fced67634a49ce8efb Mon Sep 17 00:00:00 2001 From: adueck Date: Thu, 6 Oct 2022 16:46:49 +0500 Subject: [PATCH] try splitting the exports --- library-tsconfig.json | 2 + package.json | 8 +- rollup.config.js | 6 +- src/App.tsx | 2 +- src/components.ts | 69 ++++++ src/components/ep-explorer/EPDisplay.tsx | 2 +- src/components/vp-explorer/VPDisplay.tsx | 2 +- src/components/vp-explorer/VPPicker.tsx | 2 +- src/functions.ts | 259 +++++++++++++++++++++++ src/lib/phrase-building/render-vp.ts | 2 +- src/library.ts | 2 + yarn.lock | 25 +++ 12 files changed, 372 insertions(+), 9 deletions(-) create mode 100644 src/components.ts create mode 100644 src/functions.ts diff --git a/library-tsconfig.json b/library-tsconfig.json index 0e3a305..3182996 100644 --- a/library-tsconfig.json +++ b/library-tsconfig.json @@ -23,6 +23,8 @@ "outDir": "dist" }, "files": [ + "src/functions.ts", + "src/components.ts", "src/library.ts", "src/images.d.ts" ] diff --git a/package.json b/package.json index 731e4f8..3c0806d 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,14 @@ { "name": "@lingdocs/pashto-inflector", - "version": "4.9.12", + "version": "4.9.13", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", "license": "MIT", - "main": "dist-cjs/library.js", + "exports": { + "./functions": "./dist-cjs/dist/functions.js", + "./components": "./dist-cjs/dist/components.js" + }, "module": "dist/library.js", "types": "dist/library.d.ts", "private": false, @@ -55,6 +58,7 @@ "react-scripts": "4.0.3", "rimraf": "^3.0.2", "rollup": "^2.79.1", + "rollup-plugin-multi-input": "^1.3.1", "typescript": "^4.2.3", "web-vitals": "^1.0.1" }, diff --git a/rollup.config.js b/rollup.config.js index f721891..1b13ec1 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,6 +2,7 @@ import image from '@rollup/plugin-image'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import pkg from './package.json'; +import multiInput from 'rollup-plugin-multi-input'; const banner = ` /** @@ -14,16 +15,17 @@ const banner = ` `; export default { - input: 'dist/library.js', + input: ['dist/functions.js', 'dist/components.js'], external: ["react", "react-dom", "react-bootstrap"], output: [{ - file: pkg.main, + dir: "dist-cjs", format: 'cjs', sourcemap: true, banner, }], plugins: [ // peerDepsExternal(), + multiInput(), commonjs(), nodeResolve({ resolveOnly: Object.keys(pkg.dependencies), diff --git a/src/App.tsx b/src/App.tsx index 5506d62..5284e4d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,7 +27,7 @@ import { isAdjectiveEntry, isAdverbEntry, isLocativeAdverbEntry, isNounEntry } f import defualtTextOptions from "./lib/default-text-options"; import PhraseBuilder from "./components/vp-explorer/VPExplorer"; import useStickyState from "./lib/useStickyState"; -import { EPExplorer } from "./library"; +import EPExplorer from "./components/ep-explorer/EPExplorer"; type VerbType = "simple" | "stative compound" | "dynamic compound"; const verbTypes: VerbType[] = [ diff --git a/src/components.ts b/src/components.ts new file mode 100644 index 0000000..c0cbb45 --- /dev/null +++ b/src/components.ts @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2021 lingdocs.com + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +import InflectionsTable from "./components/InflectionsTable"; +import Pashto from "./components/Pashto"; +import Phonetics from "./components/Phonetics"; +import InlinePs from "./components/InlinePs"; +import ButtonSelect from "./components/ButtonSelect"; +import VerbFormDisplay from "./components/VerbFormDisplay"; +import VerbTable from "./components/VerbTable"; +import EPDisplay from "./components/ep-explorer/EPDisplay"; +import Examples from "./components/Examples"; +import Hider from "./components/Hider"; +import EntrySelect from "./components/EntrySelect"; +import VerbInfo, { RootsAndStems } from "./components/verb-info/VerbInfo"; +import VPExplorer from "./components/vp-explorer/VPExplorer"; +import { makeVPSelectionState } from "./components/vp-explorer/verb-selection"; +import { vpsReducer } from "./components/vp-explorer/vps-reducer"; +import type { VpsReducerAction as VpsA } from "./components/vp-explorer/vps-reducer"; +import useStickyState from "./lib/useStickyState"; +import Block, { NPBlock, APBlock } from "./components/blocks/Block"; +import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; +import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; +import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; +import NPPicker from "./components/np-picker/NPPicker"; +import EPPicker from "./components/ep-explorer/EPPicker"; +import EPExplorer from "./components/ep-explorer/EPExplorer"; +import APPicker from "./components/ap-picker/APPicker"; +import VPDisplay from "./components/vp-explorer/VPDisplay"; +import VPPicker from "./components/vp-explorer/VPPicker"; + +export { + useStickyState, + roleIcon, + vpsReducer, + makeVPSelectionState, + EPExplorer, + VPExplorer, + Examples, + VerbFormDisplay, + VerbTable, + VerbInfo, + RootsAndStems, + InflectionsTable, + Pashto, + Phonetics, + InlinePs, + ButtonSelect, + Hider, + EntrySelect, + NPPicker, + APPicker, + NPBlock, + APBlock, + Block, + EPDisplay, + VPDisplay, + EPPicker, + VPPicker, + CompiledPTextDisplay, + RenderedBlocksDisplay, +} + +export type VpsReducerAction = VpsA; \ No newline at end of file diff --git a/src/components/ep-explorer/EPDisplay.tsx b/src/components/ep-explorer/EPDisplay.tsx index 6bd0e52..4cd4cc8 100644 --- a/src/components/ep-explorer/EPDisplay.tsx +++ b/src/components/ep-explorer/EPDisplay.tsx @@ -7,7 +7,7 @@ import { useState } from "react"; import CompiledPTextDisplay from "../CompiledPTextDisplay"; import EPBlocksDisplay from "../RenderedBlocksDisplay"; import ModeSelect, { Mode, ScriptSelect } from "../DisplayModeSelect"; -import { useStickyState } from "../../library"; +import useStickyState from "../../lib/useStickyState"; function EPDisplay({ eps, opts, setOmitSubject, justify, onlyOne, length, mode: preferredMode, script: preferredScript }: { eps: T.EPSelectionState, diff --git a/src/components/vp-explorer/VPDisplay.tsx b/src/components/vp-explorer/VPDisplay.tsx index 421795d..d687e52 100644 --- a/src/components/vp-explorer/VPDisplay.tsx +++ b/src/components/vp-explorer/VPDisplay.tsx @@ -3,7 +3,7 @@ import * as T from "../../types"; import AbbreviationFormSelector from "./AbbreviationFormSelector"; import { getObjectSelection, getSubjectSelection } from "../../lib/phrase-building/blocks-utils"; import { completeVPSelection } from "../../lib/phrase-building/vp-tools"; -import { renderVP } from "../../library"; +import { renderVP } from "../../lib/phrase-building/render-vp"; import ModeSelect, { LengthSelect, Mode, ScriptSelect } from "../DisplayModeSelect"; import { useState } from "react"; import CompiledPTextDisplay from "../CompiledPTextDisplay"; diff --git a/src/components/vp-explorer/VPPicker.tsx b/src/components/vp-explorer/VPPicker.tsx index d98496c..320c13e 100644 --- a/src/components/vp-explorer/VPPicker.tsx +++ b/src/components/vp-explorer/VPPicker.tsx @@ -18,7 +18,7 @@ import { isNoObject, } from "../../lib/phrase-building/blocks-utils"; import ComplementPicker from "../ComplementPicker"; -import { vpsReducer, VpsReducerAction } from "../../library"; +import { vpsReducer, VpsReducerAction } from "../../components/vp-explorer/vps-reducer"; function VPPicker({ opts, vps, onChange, entryFeeder }: { opts: T.TextOptions, diff --git a/src/functions.ts b/src/functions.ts new file mode 100644 index 0000000..b01db6f --- /dev/null +++ b/src/functions.ts @@ -0,0 +1,259 @@ +/** + * Copyright (c) 2021 lingdocs.com + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + + import { + conjugateVerb, +} from "./lib/verb-conjugation"; +import { + inflectWord, +} from "./lib/pashto-inflector"; +import { + getVerbInfo, + getPassiveRootsAndStems, + getAbilityRootsAndStems, +} from "./lib/verb-info"; +import { makeVPSelectionState } from "./components/vp-explorer/verb-selection"; +import { vpsReducer } from "./components/vp-explorer/vps-reducer"; +import { isPastTense } from "./lib/phrase-building/vp-tools"; +import { + getInflectionPattern, + humanReadableInflectionPattern, +} from "./lib/inflection-pattern"; +import { + makePsString, + removeFVarients, +} from "./lib/accent-and-ps-utils"; +import { + addToForm, + concatPsString, + isVerbBlock, + isImperativeBlock, + isPluralInflectionSet, + isUnisexSet, + isInflectionSet, + addEnglish, + endsWith, + hasBaParticle, + psRemove, + firstVariation, + psStringFromEntry, + getLong, + capitalizeFirstLetter, +} from "./lib/p-text-helpers"; +import { + getEnglishWord, +} from "./lib/get-english-word"; +import { + standardizePashto, + standardizePhonetics, +} from "./lib/standardize-pashto"; +import { phoneticsToDiacritics } from "./lib/phonetics-to-diacritics"; +import { + randomPerson, + isInvalidSubjObjCombo, + randomSubjObj, + getEnglishVerb, +} from "./lib/np-tools"; +import { + getEnglishFromRendered, + getPashtoFromRendered, +} from "./lib/phrase-building/np-tools"; // TODO should be one np-tools file? +import { + convertSpelling, + revertSpelling, +} from "./lib/convert-spelling"; +import { + dictionaryEntryBooleanFields, + dictionaryEntryNumberFields, + dictionaryEntryTextFields, +} from "./lib/fields"; +import { + validateEntry, + standardizeEntry, +} from "./lib/validate-entry"; +import { + psJSXMap, +} from "./lib/jsx-map"; +import { + readDictionary, + writeDictionary, + readDictionaryInfo, + writeDictionaryInfo, +} from "./lib/protobuf"; +import { + pashtoConsonants, +} from "./lib/pashto-consonants"; +import { + isNounAdjOrVerb, + getEnglishPersonInfo, + getPersonFromVerbForm, + getPersonNumber, + personFromVerbBlockPos, + getVerbBlockPosFromPerson, + personIsPlural, + personGender, + parseEc, + personNumber, + randFromArray, + chooseLength, + isFirstPerson, + isSecondPerson, + isThirdPerson, + blank, + kidsBlank, + ensureNonComboVerbInfo, +} from "./lib/misc-helpers"; +import { + simplifyPhonetics, +} from "./lib/simplify-phonetics"; +import { + translatePhonetics, +} from "./lib/translate-phonetics"; +import { + addDiacritics, +} from "./lib/diacritics"; +import { + removeAccents, + hasAccents, + splitUpSyllables, + countSyllables, +} from "./lib/accent-helpers"; +import { + makeNounSelection, +} from "./components/np-picker/picker-tools"; +import { + renderEP, +} from "./lib/phrase-building/render-ep"; +import { + renderVP, +} from "./lib/phrase-building/render-vp"; +import { + renderNPSelection, +} from "./lib/phrase-building/render-np"; +import { + compileEP, + compileVP, + flattenLengths, +} from "./lib/phrase-building/compile"; +import { + isPashtoScript, +} from "./lib/is-pashto"; +import { + renderAPSelection, +} from "./lib/phrase-building/render-ap"; +import { + humanReadableVerbForm, + humanReadableEquativeTense, +} from "./lib/human-readable"; +import shuffleArray from "./lib/shuffle-array"; +import defaultTextOptions from "./lib/default-text-options"; +import * as grammarUnits from "./lib/grammar-units"; +import genderColors from "./lib/gender-colors"; +import * as Types from "./types"; +import * as typePredicates from "./lib/type-predicates"; +import * as blockUtils from "./lib/phrase-building/blocks-utils"; + +export { + // FUNCTIONS + conjugateVerb, + getVerbInfo, + getPassiveRootsAndStems, + getAbilityRootsAndStems, + inflectWord, + addToForm, + concatPsString, + makePsString, + removeFVarients, + standardizePashto, + standardizePhonetics, + convertSpelling, + revertSpelling, + validateEntry, + standardizeEntry, + isNounAdjOrVerb, + simplifyPhonetics, + phoneticsToDiacritics, + addDiacritics, + translatePhonetics, + getEnglishPersonInfo, + getPersonFromVerbForm, + getPersonNumber, + isVerbBlock, + isImperativeBlock, + isInflectionSet, + isPluralInflectionSet, + isUnisexSet, + personFromVerbBlockPos, + removeAccents, + hasAccents, + getEnglishWord, + getVerbBlockPosFromPerson, + personIsPlural, + personGender, + addEnglish, + parseEc, + endsWith, + splitUpSyllables, + countSyllables, + hasBaParticle, + psRemove, + firstVariation, + capitalizeFirstLetter, + psStringFromEntry, + getLong, + randomPerson, + isInvalidSubjObjCombo, + randomSubjObj, + shuffleArray, + personNumber, + makeNounSelection, + randFromArray, + renderEP, + renderVP, + compileEP, + compileVP, + chooseLength, + flattenLengths, + isFirstPerson, + isSecondPerson, + isThirdPerson, + isPastTense, + psJSXMap, + renderNPSelection, + getEnglishFromRendered, + getPashtoFromRendered, + renderAPSelection, + getEnglishVerb, + humanReadableVerbForm, + humanReadableEquativeTense, + humanReadableInflectionPattern, + ensureNonComboVerbInfo, + vpsReducer, + makeVPSelectionState, + blockUtils, + blank, + kidsBlank, + isPashtoScript, + getInflectionPattern, + // protobuf helpers + readDictionary, + writeDictionary, + readDictionaryInfo, + writeDictionaryInfo, + // OTHER + typePredicates, + grammarUnits, + pashtoConsonants, + defaultTextOptions, + dictionaryEntryTextFields, + dictionaryEntryNumberFields, + dictionaryEntryBooleanFields, + genderColors, + // TYPES + Types, +} diff --git a/src/lib/phrase-building/render-vp.ts b/src/lib/phrase-building/render-vp.ts index a9c7347..dc2d55b 100644 --- a/src/lib/phrase-building/render-vp.ts +++ b/src/lib/phrase-building/render-vp.ts @@ -34,7 +34,7 @@ import { findPerfectiveHead, getObjectSelection, getSubjectSelection, makeBlock, import { renderAPSelection } from "./render-ap"; import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common"; import { renderComplementSelection } from "./render-complement"; -import { makeNounSelection } from "../../library"; +import { makeNounSelection } from "../../components/np-picker/picker-tools"; export function renderVP(VP: T.VPSelectionComplete): T.VPRendered { const subject = getSubjectSelection(VP.blocks).selection; diff --git a/src/library.ts b/src/library.ts index 2ad7005..5bc51cc 100644 --- a/src/library.ts +++ b/src/library.ts @@ -1,3 +1,5 @@ + + /** * Copyright (c) 2021 lingdocs.com * diff --git a/yarn.lock b/yarn.lock index 2ff9618..1c5e3fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3884,6 +3884,11 @@ core-js@^2.4.0: resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== +core-js@^3.1.3: + version "3.25.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.5.tgz#e86f651a2ca8a0237a5f064c2fe56cef89646e27" + integrity sha512-nbm6eZSjm+ZuBQxCUPQKQCoUEfFOXjUZ8dTTyikyKaWrTYmAVbykQfwsKE5dBK88u3QCkCrzsx/PPlKfhsvgpw== + core-js@^3.6.5: version "3.18.2" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.18.2.tgz#63a551e8a29f305cd4123754846e65896619ba5b" @@ -5253,6 +5258,17 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-glob@^3.0.0: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-glob@^3.1.1: version "3.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" @@ -10099,6 +10115,15 @@ rollup-plugin-babel@^4.3.3: "@babel/helper-module-imports" "^7.0.0" rollup-pluginutils "^2.8.1" +rollup-plugin-multi-input@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-multi-input/-/rollup-plugin-multi-input-1.3.1.tgz#07b903b618c005871fea1bd0c4efae7d1aac4fa1" + integrity sha512-bPsxHR6dUney7zsCAAlfkq7lbuy5xph2CvUstSv88oqhtRiLWXwVjiA1Gb4HVjC6I9sJI2eZeQlozXa+GXJKDA== + dependencies: + core-js "^3.1.3" + fast-glob "^3.0.0" + lodash "^4.17.11" + rollup-plugin-terser@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.3.1.tgz#8c650062c22a8426c64268548957463bf981b413"