Compare commits

...

2 Commits

Author SHA1 Message Date
adueck d0e1a71827 fix CI 2024-08-14 14:51:15 -04:00
adueck e95116e1b2 try publish with cjs for pashto-inflector as well 2024-08-14 14:38:00 -04:00
9 changed files with 8859 additions and 833 deletions

7888
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,11 @@
{
"name": "pashto-inflector-website",
"version": "7.6.3",
"version": "7.6.5",
"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",
@ -14,16 +13,17 @@
"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",
"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",
"check-all-inflections": "tsx check-all-inflections.ts"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@fortawesome/fontawesome-free": "^5.15.2",
"bootstrap": "4.6.1",
"react": "^18.3.1",
"react-bootstrap": "1.5.1",
"@fortawesome/fontawesome-free": "^5.15.2"
"react-dom": "^18.3.1",
"tsup": "^8.2.4"
},
"devDependencies": {
"@eslint/js": "^9.8.0",
@ -39,6 +39,7 @@
"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,12 +31,24 @@ 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]);
@ -87,6 +99,7 @@ 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.3",
"version": "7.6.5",
"description": "Pashto inflector library module with React components",
"main": "dist/components/library.js",
"module": "dist/components/library.js",

View File

@ -1,8 +1,9 @@
{
"name": "@lingdocs/inflect",
"version": "7.6.3",
"version": "7.6.5",
"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",
"repository": {
"type": "git",

View File

@ -16,8 +16,8 @@ export class DictionaryDb {
// state
private ready = false;
// @ts-expect-error because
public collection: Collection<any>;
// eslint-disable-next-line
public collection: Collection<any> | undefined;
constructor(options: {
url: string;
@ -76,12 +76,15 @@ export class DictionaryDb {
}
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;
}
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,
@ -93,7 +96,7 @@ export class DictionaryDb {
}
);
this.collection.insert(dictionary.entries);
this.lokidb.saveDatabase((err: any) => {
this.lokidb.saveDatabase((err) => {
/* istanbul ignore next */
if (err) {
console.error("error saving database: " + err);
@ -201,8 +204,10 @@ export class DictionaryDb {
notifyUpdateComing();
this.ready = false;
localStorage.removeItem(this.dictionaryInfoLocalStorageKey);
if (this.collection) {
this.collection.clear();
this.lokidb.removeCollection(this.dictionaryCollectionName);
}
await (async () => {
return new Promise((resolve: (value: "done") => void) => {
this.lokidb.saveDatabase(() => {
@ -225,7 +230,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) {
if (!this.ready || !this.collection) {
return undefined;
}
const res = this.collection.by("ts", ts);

View File

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

View File

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

1736
yarn.lock

File diff suppressed because it is too large Load Diff