Skip to content

Commit

Permalink
Added project settings service and useProjectSetting hook (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcouch-sil authored Feb 15, 2024
2 parents 488c1d0 + ffe368c commit 02f1522
Show file tree
Hide file tree
Showing 33 changed files with 2,778 additions and 284 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"papis",
"paranext",
"paratext",
"PDPE",
"pdpf",
"pdps",
"plusplus",
Expand Down
10 changes: 8 additions & 2 deletions extensions/src/hello-world/src/types/hello-world.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare module 'hello-world' {
import type { DataProviderDataType, IDataProvider, MandatoryProjectDataType } from '@papi/core';
import type { DataProviderDataType, IDataProvider, MandatoryProjectDataTypes } from '@papi/core';

export type MyProjectDataType = MandatoryProjectDataType & {
export type MyProjectDataType = MandatoryProjectDataTypes & {
MyProjectData: DataProviderDataType<string, string, string>;
};

Expand All @@ -23,6 +23,7 @@ declare module 'hello-world' {

declare module 'papi-shared-types' {
import type { MyProjectDataProvider } from 'hello-world';
import type { IProjectStorageInterpreter } from 'papi-shared-types';

export interface CommandHandlers {
'helloWorld.helloWorld': () => string;
Expand All @@ -32,4 +33,9 @@ declare module 'papi-shared-types' {
export interface ProjectDataProviders {
'helloWorld.myExtensionProjectTypeName': MyProjectDataProvider;
}

export interface ProjectStorageInterpreters {
/** Placeholder. Implementation TBD */
'helloWorld.myExtensionProjectTypeName': IProjectStorageInterpreter;
}
}
32 changes: 30 additions & 2 deletions extensions/src/usfm-data-provider/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare module 'usfm-data-provider' {
DataProviderUpdateInstructions,
ExtensionDataScope,
IDataProvider,
MandatoryProjectDataType,
MandatoryProjectDataTypes,
} from '@papi/core';
import { UnsubscriberAsync } from 'platform-bible-utils';

Expand All @@ -25,7 +25,7 @@ declare module 'usfm-data-provider' {
*
* This is not yet a complete list of the data types available from Paratext projects.
*/
export type ParatextStandardProjectDataTypes = MandatoryProjectDataType & {
export type ParatextStandardProjectDataTypes = MandatoryProjectDataTypes & {
/** Gets/sets the "raw" USFM data for the specified book */
BookUSFM: DataProviderDataType<VerseRef, string | undefined, string>;
/** Gets/sets the "raw" USFM data for the specified chapter */
Expand Down Expand Up @@ -364,12 +364,40 @@ declare module 'usfm-data-provider' {

declare module 'papi-shared-types' {
import type { ParatextStandardProjectDataProvider, UsfmDataProvider } from 'usfm-data-provider';
import type { IProjectStorageInterpreter } from 'papi-shared-types';

export interface ProjectDataProviders {
ParatextStandard: ParatextStandardProjectDataProvider;
}

export interface ProjectStorageInterpreters {
/** Placeholder. Implementation TBD */
ParatextStandard: IProjectStorageInterpreter;
}

export interface DataProviders {
usfm: UsfmDataProvider;
}

export interface ProjectSettingTypes {
/**
* Which versification scheme this Scripture project uses
*
* WARNING: This setting is an example and needs to be updated to support proper versification
* specification! For the moment, it simply corresponds to
* [`ScrVersType`](https://github.com/sillsdev/libpalaso/blob/master/SIL.Scripture/Versification.cs#L1340),
* but this is not correct and full design.
*/
'platformScripture.versification': number;
/**
* Which books are present in this Scripture project. Represented as a string with 0 or 1 for
* each possible book by [standardized book
* code](https://github.com/sillsdev/libpalaso/blob/master/SIL.Scripture/Canon.cs#L226) (123
* characters long)
*
* @example
* '100111000000000000110000001000000000010111111111111111111111111111000000000000000000000000000000000000000000100000000000000'
*/
'platformScripture.booksPresent': string;
}
}
Loading

0 comments on commit 02f1522

Please sign in to comment.