Compare commits
2 Commits
db2749bd0a
...
d0e1a71827
Author | SHA1 | Date |
---|---|---|
adueck | d0e1a71827 | |
adueck | e95116e1b2 |
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
|
@ -1,12 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector-website",
|
"name": "pashto-inflector-website",
|
||||||
"version": "7.6.3",
|
"version": "7.6.5",
|
||||||
"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",
|
||||||
|
@ -14,16 +13,17 @@
|
||||||
"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",
|
"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",
|
||||||
"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": {
|
||||||
"react": "^18.3.1",
|
"@fortawesome/fontawesome-free": "^5.15.2",
|
||||||
"react-dom": "^18.3.1",
|
|
||||||
"bootstrap": "4.6.1",
|
"bootstrap": "4.6.1",
|
||||||
|
"react": "^18.3.1",
|
||||||
"react-bootstrap": "1.5.1",
|
"react-bootstrap": "1.5.1",
|
||||||
"@fortawesome/fontawesome-free": "^5.15.2"
|
"react-dom": "^18.3.1",
|
||||||
|
"tsup": "^8.2.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.8.0",
|
"@eslint/js": "^9.8.0",
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
"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",
|
||||||
|
|
15
src/App.tsx
15
src/App.tsx
|
@ -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,12 +31,24 @@ 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]);
|
||||||
|
@ -87,6 +99,7 @@ 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" }}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/ps-react",
|
"name": "@lingdocs/ps-react",
|
||||||
"version": "7.6.3",
|
"version": "7.6.5",
|
||||||
"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",
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/inflect",
|
"name": "@lingdocs/inflect",
|
||||||
"version": "7.6.3",
|
"version": "7.6.5",
|
||||||
"description": "Pashto inflector library",
|
"description": "Pashto inflector library",
|
||||||
"main": "dist/lib/library.js",
|
"main": "dist/lib/library.cjs",
|
||||||
|
"module": "dist/lib/library.js",
|
||||||
"types": "dist/lib/library.d.ts",
|
"types": "dist/lib/library.d.ts",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -16,8 +16,8 @@ export class DictionaryDb {
|
||||||
// state
|
// state
|
||||||
private ready = false;
|
private ready = false;
|
||||||
|
|
||||||
// @ts-expect-error because
|
// eslint-disable-next-line
|
||||||
public collection: Collection<any>;
|
public collection: Collection<any> | undefined;
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -76,12 +76,15 @@ export class DictionaryDb {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async downloadDictionaryInfo(): Promise<T.DictionaryInfo> {
|
private async downloadDictionaryInfo(): Promise<T.DictionaryInfo> {
|
||||||
const res = await fetch(this.dictionaryInfoUrl);
|
const res = await fetch(this.dictionaryInfoUrl + ".json");
|
||||||
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,
|
||||||
|
@ -93,7 +96,7 @@ export class DictionaryDb {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.collection.insert(dictionary.entries);
|
this.collection.insert(dictionary.entries);
|
||||||
this.lokidb.saveDatabase((err: any) => {
|
this.lokidb.saveDatabase((err) => {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error("error saving database: " + err);
|
console.error("error saving database: " + err);
|
||||||
|
@ -201,8 +204,10 @@ export class DictionaryDb {
|
||||||
notifyUpdateComing();
|
notifyUpdateComing();
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
localStorage.removeItem(this.dictionaryInfoLocalStorageKey);
|
localStorage.removeItem(this.dictionaryInfoLocalStorageKey);
|
||||||
this.collection.clear();
|
if (this.collection) {
|
||||||
this.lokidb.removeCollection(this.dictionaryCollectionName);
|
this.collection.clear();
|
||||||
|
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(() => {
|
||||||
|
@ -225,7 +230,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) {
|
if (!this.ready || !this.collection) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const res = this.collection.by("ts", ts);
|
const res = this.collection.by("ts", ts);
|
||||||
|
|
|
@ -9,11 +9,14 @@ const dictionaryInfoUrl = `${dictionaryBaseUrl}/dictionary-info`;
|
||||||
const dictDb = new DictionaryDb({
|
const dictDb = new DictionaryDb({
|
||||||
url: dictionaryUrl,
|
url: dictionaryUrl,
|
||||||
infoUrl: dictionaryInfoUrl,
|
infoUrl: dictionaryInfoUrl,
|
||||||
collectionName: "inflector-dict",
|
collectionName: "inflector-dict5",
|
||||||
infoLocalStorageKey: "inflector-dict",
|
infoLocalStorageKey: "inflector-dict5",
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
"target": "ES2022",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||||
"module": "ES2020",
|
"module": "ES2022",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
|
|
Loading…
Reference in New Issue