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", "name": "pashto-inflector-website",
"version": "7.6.5", "version": "7.6.3",
"type": "module", "type": "module",
"scripts": { "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", "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", "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", "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", "dev": "vite",
"lint": "eslint .", "lint": "eslint .",
"test": "jest", "test": "jest",
@ -13,17 +14,16 @@
"install-all": "yarn install && node get-words.cjs && cd src/lib && yarn install && cd ../components && yarn install", "install-all": "yarn install && node get-words.cjs && cd src/lib && yarn install && cd ../components && yarn install",
"build-website": "tsc -b && vite build", "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-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", "get-words": "node get-words.cjs",
"check-all-inflections": "tsx check-all-inflections.ts" "check-all-inflections": "tsx check-all-inflections.ts"
}, },
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"bootstrap": "4.6.1",
"react": "^18.3.1", "react": "^18.3.1",
"react-bootstrap": "1.5.1",
"react-dom": "^18.3.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": { "devDependencies": {
"@eslint/js": "^9.8.0", "@eslint/js": "^9.8.0",
@ -39,7 +39,6 @@
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2", "jest-extended": "^4.0.2",
"ts-jest": "^29.2.4", "ts-jest": "^29.2.4",
"tsc-alias": "^1.8.10",
"tsx": "^4.17.0", "tsx": "^4.17.0",
"typescript": "^5.5.3", "typescript": "^5.5.3",
"typescript-eslint": "^8.0.0", "typescript-eslint": "^8.0.0",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

1730
yarn.lock

File diff suppressed because it is too large Load Diff