The Platform.Bible extension for managing the lexicon for your project's target/vernacular language.
The general file structure is as follows:
package.jsoncontains information about this extension's npm package. It is required for Platform.Bible to use the extension properly. It is copied into the build foldermanifest.jsonis the manifest file that defines the extension and important properties for Platform.Bible. It is copied into the build foldersrc/contains the source code for the extensionsrc/components/contains stand-alone (i.e., WebView- and service-independent) componentssrc/main.tsis the main entry file for the extensionsrc/services/contains services to be used withnetworkObjects.set()insrc/main.tssrc/types/lexicon.d.tsis this extension's types file that defines how other extensions can use this extension through thepapi. It is copied into the build foldersrc/utils/contains utility classes and functionssrc/web-views/contains WebView components to be used withregisterWebViewProvider()insrc/main.ts*.web-view.tsxfiles will be treated as React WebViews*.web-view.htmlfiles are a conventional way to provide HTML WebViews (no special functionality)
assets/contains asset files the extension and its WebViews can retrieve using thepapi-extension:protocol, as well as textual descriptions in various languages. It is copied into the build folderassets/displayData.jsoncontains (optionally) a path to the extension's icon file as well as text for the extension's display name, short summary, and path to the full description fileassets/descriptions/contains textual descriptions of the extension in various languagesassets/descriptions/description-<locale>.mdcontains a brief description of the extension in the language specified by<locale>
contributions/contains JSON files the platform uses to extend data structures for things like menus and settings. The JSON files are referenced from the manifestpublic/contains other static files that are copied into the build folderwebpack/contains configs, scripts, and utils used bywebpack.config.tsin the root folderdist/is a generated folder containing the built extension filesrelease/is a generated folder containing a zip of the built extension files
See the Extension Anatomy wiki page for more information about the various files that comprise an extension and their relationships to each other.
In order to interact with paranext-core, you must clone paranext-core in the same parent directory in which you cloned this repository so you do not have to reconfigure paths to paranext-core. For example, if you cloned this repository in C:\dev\LexBox\, you would clone paranext-core in C:\dev\paranext-core\.
- In the
paranext-corerepository, runnpm install - In this folder, run
npm installto install local and published dependencies
First, you must build FieldWorks Lite (FW Lite) using the task defined in this folder:
task build-fw-liteThis is a normal production build, so changes to FW Lite files will not be rebuilt automatically. If you want to do FW Lite development, look at README.md
To run Platform.Bible with this extension:
npm start
Note: The built extension will be in the dist folder. In order for Platform.Bible to run this extension, you must provide the directory to this built extension to Platform.Bible via a command-line argument. This command-line argument is already provided in this package.json's start script. If you want to start Platform.Bible and use this extension any other way, you must provide this command-line argument or put the dist folder into Platform.Bible's extensions folder.
To watch extension files (in src) for changes:
npm run watch
To build the extension once:
npm run build
This extension has a network service that can be used by other extensions. Here's how to make it available for active development of another extension:
-
In
platform.bible-extension/: runtask build-fw-lite, thennpm run package, thennpm run core:copy-package. -
In
.eslintrc.js, in the'import/no-unresolved'rule, add'lexicon'to theignorearray:
-'import/no-unresolved': ['error', { ignore: ['@papi'] }],
+'import/no-unresolved': ['error', { ignore: ['@papi', 'lexicon'] }],- Example uses of this network service are found in add-word.web-view.tsx and find-word.web-view.tsx. Note the following key elements:
- With types
NetworkObjectimported from'@papi/core'andIEntryServiceimported from'lexicon':
const [lexiconService, setLexiconService] = useState<NetworkObject<IEntryService> | undefined>();- With
networkObjectsimported from'@papi/frontend', get the network service via
useEffect(() => {
networkObjects.get<IEntryService>('lexicon.entryService').then(setLexiconService);
}, []);- The current PT project id (which the example WebViews get via their props).
- Call any method defined in entry-service.ts
- To use
lexiconService.addEntry, also import typesIEntryandPartialEntryfrom'lexicon'. - To use
lexiconService.getEntries, also import typesIEntryQueryandPartialEntryfrom'lexicon'.
- To use
This extension is based on paranext-extension-template. Tooling updates (linting, formatting, build config, etc.) can be pulled in interactively using the sync script.
Clone paranext-extension-template as a sibling of the languageforge-lexbox monorepo root:
git clone https://github.com/paranext/paranext-extension-template ../paranext-extension-templatenpm run template:syncThe script:
- Runs
git pull --ff-onlyin the template repo to get the latest changes. - Lists every tracked template file (respecting
.gitignore) and shows agit difffor each file that differs from this extension. - Prompts you to choose an action for each differing file.
For each differing file the prompt shows (color-coded to match the diff):
| Key | Color | Action |
|---|---|---|
e |
green | Keep the extension version — no change |
t |
red | Apply the template version directly |
d |
yellow | Defer — skip for now and revisit after the main pass |
b |
orange | Do both — copy the template version, then defer to review/edit |
Files that have extension-specific modifications (package.json, manifest.json, README.md, config files, etc.) have [t] blocked, ensuring that if you apply the template version, you have to review them.
Files in contributions/ and assets/ are surfaced for reference but block both [t] and [b] — adapt those manually.
After the main pass, deferred files are listed and the script pauses so you can edit them. Press Enter to do another pass over only the deferred files. Repeat until all deferred files are resolved.
- Commit changes to your working branch.
- Review a diff of that branch from
developto verify you haven't removed extension-specific updates. - Delete
package-lock.jsonandnode_modules/, then runnpm i --no-scriptsto regeneratepackage-lock.json. - Run
npm run buildandnpm run lintand fix any failures. If failures arise from (e.g.) changed lint rules in the template, don't just revert the rule change; either update the code or add a targeted exemption. - Commit all, push, and create a pr.