From d71ee64dfb46f2db52ee2d198eeded2255d293f7 Mon Sep 17 00:00:00 2001 From: aayan Date: Tue, 26 Nov 2024 13:46:58 -0800 Subject: [PATCH 1/8] implemented Levenshtein distance, first iteration of filtering for UnkownName conflict --- src/conflicts/UnknownName.ts | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/conflicts/UnknownName.ts b/src/conflicts/UnknownName.ts index b0d4a6e57..7284e3f93 100644 --- a/src/conflicts/UnknownName.ts +++ b/src/conflicts/UnknownName.ts @@ -18,6 +18,46 @@ export class UnknownName extends Conflict { this.type = type; } + levenshtein(a: string, b: string): number { + // convert both input strings to lowercase to perform check case-insensitively + a = a.toLowerCase() + b = b.toLowerCase() + + const an = a ? a.length : 0; + const bn = b ? b.length : 0; + if (an === 0) { + return bn; + } + if (bn === 0) { + return an; + } + + const matrix = new Array(bn + 1); + for (let i = 0; i <= bn; ++i) { + let row = matrix[i] = new Array(an + 1); + row[0] = i; + } + const firstRow = matrix[0]; + for (let j = 1; j <= an; ++j) { + firstRow[j] = j; + } + for (let i = 1; i <= bn; ++i) { + for (let j = 1; j <= an; ++j) { + if (b.charAt(i - 1) === a.charAt(j - 1)) { + matrix[i][j] = matrix[i - 1][j - 1]; + } + else { + matrix[i][j] = Math.min( + matrix[i - 1][j - 1], // substitution + matrix[i][j - 1], // insertion + matrix[i - 1][j] // deletion + ) + 1; + } + } + } + return matrix[bn][an]; + }; + getConflictingNodes(context: Context) { let names: Refer[] = []; if (this.name instanceof Reference) { @@ -27,6 +67,16 @@ export class UnknownName extends Conflict { false, context, ); + + const userInput: string = this.name.name.text.text // user input + + for (let i = names.length-1; i >= 0; i--) { + const currName: string = names[i].definition.names.names[0].name.text.text // loop through every name + + if (this.levenshtein(userInput, currName) > 1) { // check if levenshtein distance is greater than 1 + names.splice(i, 1) // filter out names that dissimilar + } + }; } return { From d75cd9fa72737b538e1668126536aeaaf9fde1c5 Mon Sep 17 00:00:00 2001 From: aayan Date: Wed, 4 Dec 2024 18:01:37 -0800 Subject: [PATCH 2/8] added truncation of names array to cap number of names checked --- src/conflicts/UnknownName.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conflicts/UnknownName.ts b/src/conflicts/UnknownName.ts index 7284e3f93..21f2afccb 100644 --- a/src/conflicts/UnknownName.ts +++ b/src/conflicts/UnknownName.ts @@ -69,12 +69,14 @@ export class UnknownName extends Conflict { ); const userInput: string = this.name.name.text.text // user input + const maxNames: number = 1000; // the maximum number of names we want to check + names = names.slice(0, maxNames) // truncate the names array after the desired amount for (let i = names.length-1; i >= 0; i--) { const currName: string = names[i].definition.names.names[0].name.text.text // loop through every name - + if (this.levenshtein(userInput, currName) > 1) { // check if levenshtein distance is greater than 1 - names.splice(i, 1) // filter out names that dissimilar + names.splice(i, 1) // filter out names that are dissimilar } }; } From 2f28b930218edeea05a2ec31f09a22d0fc4dc243 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 04:14:37 +0000 Subject: [PATCH 3/8] Bump nanoid from 3.3.7 to 3.3.8 Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.7 to 3.3.8. - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 04413d65c..64ec1e9cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8975,9 +8975,9 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "dev": true, "funding": [ { From 1b9410afbd7b0a920507f3bdf3f6ed76e52cdd87 Mon Sep 17 00:00:00 2001 From: aayan Date: Wed, 11 Dec 2024 17:45:19 -0800 Subject: [PATCH 4/8] updated maxNames cap after testing --- src/conflicts/UnknownName.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conflicts/UnknownName.ts b/src/conflicts/UnknownName.ts index 21f2afccb..c0193ddf6 100644 --- a/src/conflicts/UnknownName.ts +++ b/src/conflicts/UnknownName.ts @@ -68,12 +68,12 @@ export class UnknownName extends Conflict { context, ); - const userInput: string = this.name.name.text.text // user input - const maxNames: number = 1000; // the maximum number of names we want to check - names = names.slice(0, maxNames) // truncate the names array after the desired amount - + const userInput: string = this.name.name.text.text // unknown name input by user + const maxNames: number = 50; // the maximum number of names we want to check edit distance for (cap for performance) + names.splice(maxNames) // truncate the names array after the desired amount + for (let i = names.length-1; i >= 0; i--) { - const currName: string = names[i].definition.names.names[0].name.text.text // loop through every name + const currName: string = names[i].definition.names.names[0].name.text.text // get name in string form from Refer object if (this.levenshtein(userInput, currName) > 1) { // check if levenshtein distance is greater than 1 names.splice(i, 1) // filter out names that are dissimilar From 9d618c4e9a7d8d2715b00edec710d0c2f146eaa2 Mon Sep 17 00:00:00 2001 From: aayan Date: Thu, 12 Dec 2024 11:43:28 -0800 Subject: [PATCH 5/8] testing deploy to firebase failure --- src/conflicts/UnknownName.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conflicts/UnknownName.ts b/src/conflicts/UnknownName.ts index c0193ddf6..199a0839f 100644 --- a/src/conflicts/UnknownName.ts +++ b/src/conflicts/UnknownName.ts @@ -76,7 +76,7 @@ export class UnknownName extends Conflict { const currName: string = names[i].definition.names.names[0].name.text.text // get name in string form from Refer object if (this.levenshtein(userInput, currName) > 1) { // check if levenshtein distance is greater than 1 - names.splice(i, 1) // filter out names that are dissimilar + names.splice(i, 1) // remove dissimilar names } }; } From dd0d9e72e4e514b8bd4adcdad706488c68bee19c Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Sat, 14 Dec 2024 18:32:50 -1000 Subject: [PATCH 6/8] Added ability to change user interface font to one of the supported fonts. --- CHANGELOG.md | 6 + src/app.html | 12 +- src/basis/Fonts.ts | 1 + src/components/settings/Settings.svelte | 221 ++++++++++++++---------- src/db/FaceSetting.ts | 14 ++ src/db/SettingsDatabase.ts | 10 ++ src/locale/UITexts.ts | 2 + src/locale/en-US.json | 1 + src/routes/+layout.svelte | 83 ++++++--- static/locales/de-DE/de-DE.json | 3 +- static/locales/es-MX/es-MX.json | 6 +- static/locales/example/example.json | 3 +- static/locales/fr-FR/fr-FR.json | 3 +- static/locales/hi-IN/hi-IN.json | 3 +- static/locales/ja-JP/ja-JP.json | 3 +- static/locales/ko-KR/ko-KR.json | 3 +- static/locales/zh-CN/zh-CN.json | 3 +- static/locales/zh-TW/zh-TW.json | 3 +- static/schemas/LocaleText.json | 5 + 19 files changed, 261 insertions(+), 124 deletions(-) create mode 100644 src/db/FaceSetting.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b729a09..7052d191c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ We'll note all notable changes in this file, including bug fixes, enhancements, and all closed issues. Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http://semver.org/) format. +## 0.13.3 2024-12-14 + +### Added + +- Added ability to change user interface font to one of the supported fonts. + ## 0.13.2 2024-12-09 ### Added diff --git a/src/app.html b/src/app.html index e105ebf1b..9ec2401e7 100644 --- a/src/app.html +++ b/src/app.html @@ -275,10 +275,6 @@ background-color: var(--wordplay-background); padding: 0; margin: 0; - font-family: var(--wordplay-app-font); - font-weight: var(--wordplay-font-weight); - font-size: var(--wordplay-font-size); - color: var(--wordplay-foreground); } html { @@ -369,6 +365,14 @@ width: 50%; text-align: center; } + + hr { + width: 100%; + height: var(--wordplay-border-width); + border: none; + border-bottom: var(--wordplay-border-width) solid + var(--wordplay-border-color); + } %sveltekit.head% diff --git a/src/basis/Fonts.ts b/src/basis/Fonts.ts index 8fa2aabe1..98a808a19 100644 --- a/src/basis/Fonts.ts +++ b/src/basis/Fonts.ts @@ -599,6 +599,7 @@ export class FontManager { const Fonts = new FontManager(); export default Fonts; +/** The Wordplay text union type representing all valid font face names. */ export const SupportedFontsFamiliesType = SupportedFaces.map( (font) => `"${font}"`, ).join(OR_SYMBOL); diff --git a/src/components/settings/Settings.svelte b/src/components/settings/Settings.svelte index c3bb667d0..505e4f9ee 100644 --- a/src/components/settings/Settings.svelte +++ b/src/components/settings/Settings.svelte @@ -22,6 +22,8 @@ import CreatorView from '../app/CreatorView.svelte'; import { Creator } from '../../db/CreatorDatabase'; import { AnimationFactorIcons } from '@db/AnimationFactorSetting'; + import { SupportedFaces } from '@basis/Fonts'; + import { FaceSetting } from '@db/FaceSetting'; let user = getUser(); @@ -71,109 +73,144 @@ }} description={$locales.get((l) => l.ui.dialog.settings)} > - l.ui.dialog.settings.mode.layout)} - choice={$arrangement === Arrangement.Responsive - ? 0 - : $arrangement === Arrangement.Horizontal - ? 1 - : $arrangement === Arrangement.Vertical - ? 2 - : 3} - select={(choice) => - Settings.setArrangement( - choice == 0 - ? Arrangement.Responsive - : choice === 1 - ? Arrangement.Horizontal - : choice === 2 - ? Arrangement.Vertical - : Arrangement.Free, - )} - modes={['📐', '↔️', '↕', '⏹️']} - /> - l.ui.dialog.settings.mode.animate, - )} - choice={$animationFactor} - select={(choice) => Settings.setAnimationFactor(choice)} - modes={AnimationFactorIcons} - /> - {#if devicesRetrieved} -