Compare commits

..

No commits in common. "d0e1a718277aa9c77ca6214c982c702720a270f0" and "db2749bd0a3d1a441c9f6ee6c4687e29b08cff2c" have entirely different histories.

9 changed files with 830 additions and 8856 deletions

7888
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
{
"name": "pashto-inflector-website",
"version": "7.6.5",
"version": "7.6.3",
"type": "module",
"scripts": {
"patch": "npm version patch --no-git-tag-version && cd src/lib && npm version patch --no-git-tag-version && cd ../components && npm version patch --no-git-tag-version",
"minor": "npm version minor --no-git-tag-version && cd src/lib && npm version minor --no-git-tag-version && cd ../components && npm version minor --no-git-tag-version",
"major": "npm version major --no-git-tag-version && cd src/lib && npm version major --no-git-tag-version && cd ../components && npm version major --no-git-tag-version",
"preinstall": "echo '*** Be sure to use 'yarn install-all' not 'yarn install' ***!'",
"dev": "vite",
"lint": "eslint .",
"test": "jest",
@ -13,17 +14,16 @@
"install-all": "yarn install && node get-words.cjs && cd src/lib && yarn install && cd ../components && yarn install",
"build-website": "tsc -b && vite build",
"build-components": "rm -rf src/components/dist && tsc --project src/components/tsconfig.json && cd src/components && node post-build.cjs",
"build-lib": "rm -rf src/lib/dist && tsc --project src/lib/tsconfig.json && tsup src/lib/library.ts --format cjs && mv dist/library.cjs src/lib/dist/lib",
"build-lib": "rm -rf src/lib/dist && tsc --project src/lib/tsconfig.json",
"get-words": "node get-words.cjs",
"check-all-inflections": "tsx check-all-inflections.ts"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"bootstrap": "4.6.1",
"react": "^18.3.1",
"react-bootstrap": "1.5.1",
"react-dom": "^18.3.1",
"tsup": "^8.2.4"
"bootstrap": "4.6.1",
"react-bootstrap": "1.5.1",
"@fortawesome/fontawesome-free": "^5.15.2"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
@ -39,7 +39,6 @@
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"ts-jest": "^29.2.4",
"tsc-alias": "^1.8.10",
"tsx": "^4.17.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0",

View File

@ -7,7 +7,7 @@
*/
import { useEffect, useState } from "react";
import { dictionary } from "./lib/src/dictionary/dictionary";
import ButtonSelect from "./components/src/selects/ButtonSelect";
import { Modal } from "react-bootstrap";
import * as T from "./types";
@ -31,24 +31,12 @@ function App() {
defualtTextOptions,
"textOpts1"
);
const [dictionaryReady, setDictionaryIsReady] = useState<boolean>(false);
const [theme, setTheme] = useStickyState<"light" | "dark">("light", "theme1");
const [showing, setShowing] = useState<string>("");
function handleHiderClick(label: string) {
setShowing((os) => (os === label ? "" : label));
}
useEffect(() => {
console.log("WILL INIT");
dictionary
.initialize()
.then(() => {
console.log("DONE INIT");
setDictionaryIsReady(true);
})
.catch(console.error);
}, []);
useEffect(() => {
document.documentElement.setAttribute("data-theme", theme);
}, [theme]);
@ -99,7 +87,6 @@ function App() {
<h1 className="display-4 mt-2">
<code>Pashto Inflector</code>
</h1>
{dictionaryReady && <div>READY</div>}
<p
className="lead my-3"
style={{ maxWidth: "600px", margin: "0 auto" }}

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/ps-react",
"version": "7.6.5",
"version": "7.6.3",
"description": "Pashto inflector library module with React components",
"main": "dist/components/library.js",
"module": "dist/components/library.js",

View File

@ -1,9 +1,8 @@
{
"name": "@lingdocs/inflect",
"version": "7.6.5",
"version": "7.6.3",
"description": "Pashto inflector library",
"main": "dist/lib/library.cjs",
"module": "dist/lib/library.js",
"main": "dist/lib/library.js",
"types": "dist/lib/library.d.ts",
"repository": {
"type": "git",

View File

@ -16,8 +16,8 @@ export class DictionaryDb {
// state
private ready = false;
// eslint-disable-next-line
public collection: Collection<any> | undefined;
// @ts-expect-error because
public collection: Collection<any>;
constructor(options: {
url: string;
@ -76,15 +76,12 @@ export class DictionaryDb {
}
private async downloadDictionaryInfo(): Promise<T.DictionaryInfo> {
const res = await fetch(this.dictionaryInfoUrl + ".json");
const res = await fetch(this.dictionaryInfoUrl);
return (await res.json()) as T.DictionaryInfo;
}
private async addDictionaryToLoki(dictionary: T.Dictionary): Promise<"done"> {
return await new Promise((resolve: (value: "done") => void, reject) => {
if (!this.collection) {
reject("dictionary not initialized");
}
// Add it to Lokijs
this.collection = this.lokidb.addCollection(
this.dictionaryCollectionName,
@ -96,7 +93,7 @@ export class DictionaryDb {
}
);
this.collection.insert(dictionary.entries);
this.lokidb.saveDatabase((err) => {
this.lokidb.saveDatabase((err: any) => {
/* istanbul ignore next */
if (err) {
console.error("error saving database: " + err);
@ -204,10 +201,8 @@ export class DictionaryDb {
notifyUpdateComing();
this.ready = false;
localStorage.removeItem(this.dictionaryInfoLocalStorageKey);
if (this.collection) {
this.collection.clear();
this.lokidb.removeCollection(this.dictionaryCollectionName);
}
this.collection.clear();
this.lokidb.removeCollection(this.dictionaryCollectionName);
await (async () => {
return new Promise((resolve: (value: "done") => void) => {
this.lokidb.saveDatabase(() => {
@ -230,7 +225,7 @@ export class DictionaryDb {
*/
// TODO: not working in app usage now now with new 'this' issues
public findOneByTs(ts: number): T.DictionaryEntry | undefined {
if (!this.ready || !this.collection) {
if (!this.ready) {
return undefined;
}
const res = this.collection.by("ts", ts);

View File

@ -9,14 +9,11 @@ const dictionaryInfoUrl = `${dictionaryBaseUrl}/dictionary-info`;
const dictDb = new DictionaryDb({
url: dictionaryUrl,
infoUrl: dictionaryInfoUrl,
collectionName: "inflector-dict5",
infoLocalStorageKey: "inflector-dict5",
collectionName: "inflector-dict",
infoLocalStorageKey: "inflector-dict",
});
function queryP(p: string): T.DictionaryEntry[] {
if (!dictDb.collection) {
return [];
}
return dictDb.collection.find({ p });
}
const memoizedQueryP = queryP;

View File

@ -1,11 +1,10 @@
{
"compilerOptions": {
"target": "ES2022",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"module": "ES2022",
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ES2020",
"skipLibCheck": true,
"esModuleInterop": true,
/* Bundler mode */
"moduleResolution": "Bundler",

1730
yarn.lock

File diff suppressed because it is too large Load Diff