Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform.bible extension poc #1003

Merged
merged 60 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a925d7d
initial extension commit
hahn-kev Aug 5, 2024
221534b
FW Lite, setup cors to allow all origins in development
hahn-kev Aug 5, 2024
23b9368
setup para-next-extension to use the FW Lite web component.
hahn-kev Aug 5, 2024
7503cf5
attempt to add menu to trigger search
hahn-kev Aug 5, 2024
ae5a86c
fix encoding issue with menu and localized strings (removed BOM)
hahn-kev Aug 5, 2024
464b1c7
rename extension folder from para-next-extension to platform.bible-ex…
hahn-kev Aug 7, 2024
fe4eb0e
fix in memory api service support for semantic domains and parts of s…
hahn-kev Aug 7, 2024
efc08dc
don't use field configs to render the editors, be explicit instead
hahn-kev Aug 7, 2024
a9614f1
fix style issue due to no FieldEditors being in scope
hahn-kev Aug 7, 2024
394df98
simplify SingleOptionEditor and MultiOptionEditor by requiring the us…
hahn-kev Aug 7, 2024
3cbcbcf
refactor FieldConfig out of FieldTitle
hahn-kev Aug 7, 2024
03e550a
pull FieldConfig out of Field editors
hahn-kev Aug 8, 2024
8212ae3
refactor editors into sub folders based on how they are used
hahn-kev Aug 8, 2024
9d626e3
fix a bunch of imports
hahn-kev Aug 8, 2024
ee65790
move `hideEmptyFields` to view settings and remove showExtraFields. M…
hahn-kev Aug 8, 2024
10825f2
remove most references to View Config
hahn-kev Aug 8, 2024
0fbea73
pass readonly from ProjectView to Editor
hahn-kev Aug 8, 2024
a6119df
give better feedback when the viewer app is not built
hahn-kev Aug 8, 2024
de214a1
enable creating new entries from the search bar
hahn-kev Aug 9, 2024
3c7da9e
only display active writing systems
hahn-kev Aug 9, 2024
98f277e
simplify the openWithValue function in NewEntryDialog
hahn-kev Aug 9, 2024
b0799df
refactor out getContext into useWritingSystems
hahn-kev Aug 9, 2024
d100f8a
remember selected view in local storage
hahn-kev Aug 9, 2024
714b4db
load semantic domains on demand
hahn-kev Aug 9, 2024
06d3d51
load parts of speech on demand
hahn-kev Aug 9, 2024
54bdc3e
add search icon to multiselect field
hahn-kev Aug 9, 2024
3e83d2c
show semantic domain codes in list
hahn-kev Aug 9, 2024
71b033f
trim search bar on paste
hahn-kev Aug 13, 2024
fa3638b
update extension readme
hahn-kev Aug 13, 2024
c3a90d2
Merge branch 'refs/heads/chore/988-refactor-fw-lite-ui' into feat/par…
hahn-kev Aug 13, 2024
a0c42d9
resolve merge conflict in search bar
hahn-kev Aug 13, 2024
426cd26
only include exemplars if word starts with that character
hahn-kev Aug 13, 2024
ad352a7
ensure selected entry is in the list by filtering the list, instead o…
hahn-kev Aug 13, 2024
0ea1dfe
load parts of speech when calling `usePartsOfSpeech()` instead of sem…
hahn-kev Aug 13, 2024
861a9e8
fix bug with replacing a semantic domain with a new one
hahn-kev Aug 13, 2024
26d6048
lookup selected semantic domains in sense editor on change
hahn-kev Aug 13, 2024
ec77e11
pick default ws when creating new entry from the search bar
hahn-kev Aug 13, 2024
53c242e
move project name context configuration into ProjectView.svelte
hahn-kev Aug 13, 2024
33b4627
fix history and activity view issues causing the editor to be too tall
hahn-kev Aug 14, 2024
f674bea
increase activity endpoint limit to 20
hahn-kev Aug 14, 2024
951d874
change activity endpoint to return most recent changes, also provide …
hahn-kev Aug 14, 2024
98f7d17
refactor views to be laid out using grid areas, make the field order …
hahn-kev Aug 14, 2024
32b2335
Merge branch 'chore/988-refactor-fw-lite-ui' into feat/paranext-exten…
hahn-kev Sep 4, 2024
61d047c
Merge branch 'merge-me' into feat/paranext-extension
hahn-kev Sep 4, 2024
168fa8f
Merge branch 'develop' into feat/paranext-extension
hahn-kev Sep 4, 2024
fdce58f
allow specifying connection options for signalr
hahn-kev Sep 4, 2024
fa51551
Merge branch 'develop' into feat/paranext-extension
hahn-kev Sep 4, 2024
22081be
Merge branch 'develop' into feat/paranext-extension
hahn-kev Nov 6, 2024
1277445
fix up some migration issues
hahn-kev Nov 6, 2024
5fa2dac
setup a taskfile for the paratext extension to run the build steps re…
hahn-kev Nov 6, 2024
7b577bd
introduce some config values to control browser opening, file logging…
hahn-kev Nov 7, 2024
ade84dc
configure extension to launch local web app without cors, browser ope…
hahn-kev Nov 7, 2024
672a00b
add icon for extension view, add package command to task file
hahn-kev Nov 7, 2024
db87d66
ignore platform bible extension in docker
hahn-kev Nov 11, 2024
3e19367
Point LocalWebApp at correct viewer output directory
myieye Nov 12, 2024
daae122
Make tasks wait for viewer before building local web app
myieye Nov 12, 2024
0fa30db
Remove margin around our extension
myieye Nov 13, 2024
4a704e2
Merge remote-tracking branch 'origin/develop' into feat/paranext-exte…
myieye Nov 13, 2024
1e450bb
Revert "Make tasks wait for viewer before building local web app"
myieye Nov 13, 2024
18d878a
Revert "Point LocalWebApp at correct viewer output directory"
myieye Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Frozen;
using System.Globalization;
using System.Reflection;
using System.Text;
using FwDataMiniLcmBridge.Api.UpdateProxy;
Expand Down Expand Up @@ -521,8 +522,9 @@ public IAsyncEnumerable<Entry> GetEntries(
if (value is null || value.Length < exemplar.Length) return false;
//exemplar is normalized, so we can use StartsWith
//there may still be cases where value.StartsWith(value[0].ToString()) == false (e.g. "آبراهام")
//another example is "เพือ" does not start with "เ"
//but I don't have the data to test that
return value.StartsWith(exemplar, StringComparison.InvariantCultureIgnoreCase);
return CultureInfo.InvariantCulture.CompareInfo.IsPrefix(value, exemplar, CompareOptions.IgnoreCase);
});
}

Expand Down
5 changes: 4 additions & 1 deletion backend/FwLite/FwDataMiniLcmBridge/Api/LcmHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using SIL.LCModel.Core.KernelInterfaces;

namespace FwDataMiniLcmBridge.Api;
Expand Down Expand Up @@ -62,7 +63,9 @@ internal static void ContributeExemplars(ITsMultiString multiString, IReadOnlyDi
var value = tsString.Text.AsSpan().Trim(WhitespaceAndFormattingChars);
if (!value.IsEmpty && wsExemplars.TryGetValue(ws, out var exemplars))
{
exemplars.Add(char.ToUpperInvariant(value[0]));
//some cases the first character is not a prefix.
if (CultureInfo.InvariantCulture.CompareInfo.IsPrefix(value, value[0..1], CompareOptions.IgnoreCase))
exemplars.Add(char.ToUpperInvariant(value[0]));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions backend/FwLite/LocalWebApp/LocalAppKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public static IServiceCollection AddLocalAppServices(this IServiceCollection ser
services.AddFwLiteProjectSync();
services.AddFwDataBridge();

services.AddOptions<LocalWebAppConfig>().BindConfiguration("LocalWebApp");

services.AddOptions<JsonOptions>().PostConfigure<IOptions<CrdtConfig>>((jsonOptions, crdtConfig) =>
{
jsonOptions.SerializerOptions.TypeInfoResolver = crdtConfig.Value.MakeJsonTypeResolver();
Expand Down
1 change: 1 addition & 0 deletions backend/FwLite/LocalWebApp/LocalWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.10" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.64.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions backend/FwLite/LocalWebApp/LocalWebAppConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace LocalWebApp;

public class LocalWebAppConfig
{
public bool CorsAllowAny { get; init; } = false;
public bool OpenBrowser { get; init; } = true;
public string? LogFileName { get; init; } = null;
}
19 changes: 17 additions & 2 deletions backend/FwLite/LocalWebApp/LocalWebAppServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.StaticFiles.Infrastructure;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using NReco.Logging.File;

namespace LocalWebApp;

Expand All @@ -17,7 +19,7 @@ public static class LocalWebAppServer
public static WebApplication SetupAppServer(WebApplicationOptions options, Action<WebApplicationBuilder>? configure = null)
{
var builder = WebApplication.CreateBuilder(options);
if (!builder.Environment.IsDevelopment())
if (!builder.Environment.IsDevelopment() && options.Args?.Contains("--urls") != true)
builder.WebHost.UseUrls("http://127.0.0.1:0");
if (builder.Environment.IsDevelopment())
{
Expand All @@ -35,6 +37,11 @@ public static WebApplication SetupAppServer(WebApplicationOptions options, Actio
config.LexboxServers = [new(new("https://staging.languagedepot.org"), "Lexbox Staging")]);
builder.Services.Configure<AuthConfig>(c => c.ClientId = "becf2856-0690-434b-b192-a4032b72067f");
builder.Logging.AddDebug();
if (builder.Configuration.GetValue<string>("LocalWebApp:LogFileName") is { Length: > 0 } logFileName)
{
builder.Logging.AddFile(logFileName);
}
builder.Services.AddCors();
builder.Services.AddLocalAppServices(builder.Environment);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
Expand All @@ -54,7 +61,15 @@ public static WebApplication SetupAppServer(WebApplicationOptions options, Actio
app.UseSwaggerUI();
}

//configure dotnet to serve static files from the embedded resources
if (app.Services.GetRequiredService<IOptions<LocalWebAppConfig>>().Value.CorsAllowAny)
{
app.UseCors(policyBuilder =>
{
policyBuilder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
});
}

//configure dotnet to serve static files from the embedded resources
SharedOptions sharedOptions;
try
{
Expand Down
4 changes: 3 additions & 1 deletion backend/FwLite/LocalWebApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

using LocalWebApp;
using Microsoft.Extensions.Options;

var app = LocalWebAppServer.SetupAppServer(new() {Args = args});
await using (app)
{
await app.StartAsync();
var openBrowser = app.Services.GetRequiredService<IOptions<LocalWebAppConfig>>().Value.OpenBrowser;

if (!app.Environment.IsDevelopment())
if (openBrowser)
{
var url = app.Urls.First();
LocalAppLauncher.LaunchBrowser(url);
Expand Down
5 changes: 5 additions & 0 deletions backend/FwLite/LocalWebApp/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"Default": "Information",
"LocalWebApp.Auth.LoggerAdapter": "Warning",
}
},
"LocalWebApp": {
"CorsAllowAny": false,
"OpenBrowser": true,
"LogFileName": null
}
}
1 change: 1 addition & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
viewer/node_modules
tests
test-results
platform.bible-extension
1 change: 1 addition & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default [
'**/generated/**',
'viewer/',
'https-proxy/',
'platform.bible-extension/'
],
},
js.configs.recommended,
Expand Down
13 changes: 13 additions & 0 deletions frontend/platform.bible-extension/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100

[*.md]
trim_trailing_whitespace = false
31 changes: 31 additions & 0 deletions frontend/platform.bible-extension/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Please keep this file in sync with .prettierignore and .stylelintignore

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# OSX
.DS_Store

.idea
npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

# Packager output
dist
release
temp-build

# generated files
package-lock.json
135 changes: 135 additions & 0 deletions frontend/platform.bible-extension/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
module.exports = {
extends: [
// https://github.com/electron-react-boilerplate/eslint-config-erb/blob/main/index.js
// airbnb rules are embedded in erb https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb
'erb',
],

rules: {
// #region From paranext-core root .eslintrc.js
// Some rules are commented out since they have overrides in the
// 'Overrides from paranext-core extension .eslintrc.cjs' section

// #region ERB rules

'import/extensions': 'off',
// A temporary hack related to IDE not resolving correct package.json
'import/no-extraneous-dependencies': 'off',
'import/no-import-module-exports': 'off',
// 'import/no-unresolved': 'error',
'react/jsx-filename-extension': 'off',
'react/react-in-jsx-scope': 'off',

// #endregion

// #region Paranext rules

// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
'error',
'always',
{ exceptAfterSingleLine: true, exceptAfterOverload: true },
],
'@typescript-eslint/member-ordering': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': [
'error',
{
allow: ['arrowFunctions', 'functions', 'methods'],
},
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, allowNamedExports: true, typedefs: false, ignoreTypeReferences: true },
],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
{
assert: 'either',
},
],
// Should use our logger anytime you want logs that persist. Otherwise use console only in testing
'no-console': 'warn',
'no-null/no-null': 2,
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['shared/*', 'renderer/*', 'extension-host/*', 'node/*', 'client/*', 'main/*'],
message: `Importing from this path is not allowed. Try importing from @papi/core. Imports from paths like 'shared', 'renderer', 'node', 'client' and 'main' are not allowed to prevent unnecessary import break.`,
},
],
},
],
'prettier/prettier': ['warn', { tabWidth: 2, trailingComma: 'all' }],
'react/jsx-indent-props': ['warn', 2],
'react/jsx-props-no-spreading': ['error', { custom: 'ignore' }],
'react/require-default-props': 'off',

// #endregion

// #endregion

// #region Overrides from paranext-core extension .eslintrc.cjs

'import/no-unresolved': ['error', { ignore: ['@papi'] }],

// #endregion
},
globals: {
globalThis: 'readonly',
},
overrides: [
{
files: ['*.js'],
rules: {
strict: 'off',
},
},
{
// Don't require extensions to have a default export for "activate()"
files: ['*.ts'],
rules: {
'import/prefer-default-export': 'off',
},
},
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: __dirname,
createDefaultProgram: true,
},
plugins: ['@typescript-eslint', 'no-null'],
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
};
30 changes: 30 additions & 0 deletions frontend/platform.bible-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
release
dist-ssr
*.local

# formatting and linting
.eslintcache

# Editor directories and files
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Temporary intermediate build files
temp-build
public/fw-lite
31 changes: 31 additions & 0 deletions frontend/platform.bible-extension/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Please keep this file in sync with .eslintignore and .stylelintignore

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

# OSX
.DS_Store

.idea
npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts

# Packager output
dist
release
temp-build

# generated files
package-lock.json
Loading
Loading