try splitting the exports

This commit is contained in:
adueck 2022-10-06 16:46:49 +05:00
parent d1ce881ddc
commit 7b02179bf7
12 changed files with 372 additions and 9 deletions

View File

@ -23,6 +23,8 @@
"outDir": "dist" "outDir": "dist"
}, },
"files": [ "files": [
"src/functions.ts",
"src/components.ts",
"src/library.ts", "src/library.ts",
"src/images.d.ts" "src/images.d.ts"
] ]

View File

@ -1,11 +1,14 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "4.9.12", "version": "4.9.13",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",
"license": "MIT", "license": "MIT",
"main": "dist-cjs/library.js", "exports": {
"./functions": "./dist-cjs/dist/functions.js",
"./components": "./dist-cjs/dist/components.js"
},
"module": "dist/library.js", "module": "dist/library.js",
"types": "dist/library.d.ts", "types": "dist/library.d.ts",
"private": false, "private": false,
@ -55,6 +58,7 @@
"react-scripts": "4.0.3", "react-scripts": "4.0.3",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.79.1", "rollup": "^2.79.1",
"rollup-plugin-multi-input": "^1.3.1",
"typescript": "^4.2.3", "typescript": "^4.2.3",
"web-vitals": "^1.0.1" "web-vitals": "^1.0.1"
}, },

View File

@ -2,6 +2,7 @@ import image from '@rollup/plugin-image';
import { nodeResolve } from '@rollup/plugin-node-resolve'; import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'; import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json'; import pkg from './package.json';
import multiInput from 'rollup-plugin-multi-input';
const banner = ` const banner = `
/** /**
@ -14,16 +15,17 @@ const banner = `
`; `;
export default { export default {
input: 'dist/library.js', input: ['dist/functions.js', 'dist/components.js'],
external: ["react", "react-dom", "react-bootstrap"], external: ["react", "react-dom", "react-bootstrap"],
output: [{ output: [{
file: pkg.main, dir: "dist-cjs",
format: 'cjs', format: 'cjs',
sourcemap: true, sourcemap: true,
banner, banner,
}], }],
plugins: [ plugins: [
// peerDepsExternal(), // peerDepsExternal(),
multiInput(),
commonjs(), commonjs(),
nodeResolve({ nodeResolve({
resolveOnly: Object.keys(pkg.dependencies), resolveOnly: Object.keys(pkg.dependencies),

View File

@ -27,7 +27,7 @@ import { isAdjectiveEntry, isAdverbEntry, isLocativeAdverbEntry, isNounEntry } f
import defualtTextOptions from "./lib/default-text-options"; import defualtTextOptions from "./lib/default-text-options";
import PhraseBuilder from "./components/vp-explorer/VPExplorer"; import PhraseBuilder from "./components/vp-explorer/VPExplorer";
import useStickyState from "./lib/useStickyState"; import useStickyState from "./lib/useStickyState";
import { EPExplorer } from "./library"; import EPExplorer from "./components/ep-explorer/EPExplorer";
type VerbType = "simple" | "stative compound" | "dynamic compound"; type VerbType = "simple" | "stative compound" | "dynamic compound";
const verbTypes: VerbType[] = [ const verbTypes: VerbType[] = [

69
src/components.ts Normal file
View File

@ -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;

View File

@ -7,7 +7,7 @@ import { useState } from "react";
import CompiledPTextDisplay from "../CompiledPTextDisplay"; import CompiledPTextDisplay from "../CompiledPTextDisplay";
import EPBlocksDisplay from "../RenderedBlocksDisplay"; import EPBlocksDisplay from "../RenderedBlocksDisplay";
import ModeSelect, { Mode, ScriptSelect } from "../DisplayModeSelect"; 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 }: { function EPDisplay({ eps, opts, setOmitSubject, justify, onlyOne, length, mode: preferredMode, script: preferredScript }: {
eps: T.EPSelectionState, eps: T.EPSelectionState,

View File

@ -3,7 +3,7 @@ import * as T from "../../types";
import AbbreviationFormSelector from "./AbbreviationFormSelector"; import AbbreviationFormSelector from "./AbbreviationFormSelector";
import { getObjectSelection, getSubjectSelection } from "../../lib/phrase-building/blocks-utils"; import { getObjectSelection, getSubjectSelection } from "../../lib/phrase-building/blocks-utils";
import { completeVPSelection } from "../../lib/phrase-building/vp-tools"; 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 ModeSelect, { LengthSelect, Mode, ScriptSelect } from "../DisplayModeSelect";
import { useState } from "react"; import { useState } from "react";
import CompiledPTextDisplay from "../CompiledPTextDisplay"; import CompiledPTextDisplay from "../CompiledPTextDisplay";

View File

@ -18,7 +18,7 @@ import {
isNoObject, isNoObject,
} from "../../lib/phrase-building/blocks-utils"; } from "../../lib/phrase-building/blocks-utils";
import ComplementPicker from "../ComplementPicker"; import ComplementPicker from "../ComplementPicker";
import { vpsReducer, VpsReducerAction } from "../../library"; import { vpsReducer, VpsReducerAction } from "../../components/vp-explorer/vps-reducer";
function VPPicker({ opts, vps, onChange, entryFeeder }: { function VPPicker({ opts, vps, onChange, entryFeeder }: {
opts: T.TextOptions, opts: T.TextOptions,

259
src/functions.ts Normal file
View File

@ -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,
}

View File

@ -34,7 +34,7 @@ import { findPerfectiveHead, getObjectSelection, getSubjectSelection, makeBlock,
import { renderAPSelection } from "./render-ap"; import { renderAPSelection } from "./render-ap";
import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common"; import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common";
import { renderComplementSelection } from "./render-complement"; 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 { export function renderVP(VP: T.VPSelectionComplete): T.VPRendered {
const subject = getSubjectSelection(VP.blocks).selection; const subject = getSubjectSelection(VP.blocks).selection;

View File

@ -1,3 +1,5 @@
/** /**
* Copyright (c) 2021 lingdocs.com * Copyright (c) 2021 lingdocs.com
* *

View File

@ -3884,6 +3884,11 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== 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: core-js@^3.6.5:
version "3.18.2" version "3.18.2"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.18.2.tgz#63a551e8a29f305cd4123754846e65896619ba5b" 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" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== 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: fast-glob@^3.1.1:
version "3.2.7" version "3.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" 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" "@babel/helper-module-imports" "^7.0.0"
rollup-pluginutils "^2.8.1" 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: rollup-plugin-terser@^5.3.1:
version "5.3.1" version "5.3.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.3.1.tgz#8c650062c22a8426c64268548957463bf981b413" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.3.1.tgz#8c650062c22a8426c64268548957463bf981b413"