Skip to content

Commit

Permalink
Follow up to replace papi-components with two libraries (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolierabideau authored Jan 17, 2024
2 parents c2dd689 + ba696ec commit 786ce6a
Show file tree
Hide file tree
Showing 28 changed files with 343 additions and 317 deletions.
32 changes: 8 additions & 24 deletions extensions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions extensions/src/hello-someone/src/hello-someone.web-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<script>
const papi = require('@papi/frontend');
const { logger } = require('@papi/frontend');
const { htmlEncode, serialize } = require('platform-bible-utils');

function print(input) {
logger.debug(input);
Expand All @@ -50,7 +51,7 @@
const nameInput = document.getElementById('name-input');
const greeting = await peopleDataProvider.getGreeting(nameInput.value.toLowerCase());
const helloSomeoneOutput = document.getElementById('greetings-button-output');
helloSomeoneOutput.textContent = papi.utils.htmlEncode(greeting || '');
helloSomeoneOutput.textContent = htmlEncode(greeting || '');
print(greeting);
});
greetingsButton.addEventListener('contextmenu', async (e) => {
Expand All @@ -69,7 +70,7 @@
const nameInput = document.getElementById('name-input');
const success = await peopleDataProvider.deletePerson(nameInput.value.toLowerCase());
const helloSomeoneOutput = document.getElementById('greetings-button-output');
helloSomeoneOutput.textContent = papi.utils.htmlEncode(
helloSomeoneOutput.textContent = htmlEncode(
`${success ? 'Successfully' : 'Unsuccessfully'} deleted ${nameInput.value}.${
success ? ' RIP ⚰️' : ''
}`.replace(/'/g, '`'),
Expand All @@ -87,7 +88,7 @@
setGreetingsInput.value,
);
const helloSomeoneOutput = document.getElementById('greetings-button-output');
helloSomeoneOutput.textContent = papi.utils.htmlEncode(
helloSomeoneOutput.textContent = htmlEncode(
`${success ? 'Successfully' : 'Unsuccessfully'} set ${name}'s greeting!`.replace(
/'/g,
'`',
Expand All @@ -106,16 +107,16 @@
parseInt(setAgeInput.value),
);
const helloSomeoneOutput = document.getElementById('greetings-button-output');
helloSomeoneOutput.textContent = papi.utils.htmlEncode(
helloSomeoneOutput.textContent = htmlEncode(
`${success ? 'Successfully' : 'Unsuccessfully'} set ${name}'s age!`.replace(/'/g, '`'),
);
});

// Update the 'people' display on load and on updates
peopleDataProvider.subscribePeople(undefined, (people) => {
const peopleData = document.getElementById('people-data');
const peopleString = papi.utils.serialize(people, undefined, 2);
peopleData.textContent = papi.utils.htmlEncode(peopleString.replace(/"/g, '`'));
const peopleString = serialize(people, undefined, 2);
peopleData.textContent = htmlEncode(peopleString.replace(/"/g, '`'));
print(peopleString);
});

Expand All @@ -126,9 +127,7 @@
() => {
peopleUpdateCount += 1;
const peopleUpdateCountDiv = document.getElementById('people-update-count');
peopleUpdateCountDiv.textContent = papi.utils.htmlEncode(
`People Updates: ${peopleUpdateCount}`,
);
peopleUpdateCountDiv.textContent = htmlEncode(`People Updates: ${peopleUpdateCount}`);
},
{ retrieveDataImmediately: false },
);
Expand All @@ -142,7 +141,7 @@
const billAnyGreetingsUpdateCountDiv = document.getElementById(
'bill-any-greetings-update-count',
);
billAnyGreetingsUpdateCountDiv.textContent = papi.utils.htmlEncode(
billAnyGreetingsUpdateCountDiv.textContent = htmlEncode(
`Any Greetings Updates (via Bill): ${billAnyGreetingsUpdateCount}`,
);
},
Expand All @@ -156,7 +155,7 @@
const billGreetingsUpdateCountDiv = document.getElementById(
'bill-greetings-update-count',
);
billGreetingsUpdateCountDiv.textContent = papi.utils.htmlEncode(
billGreetingsUpdateCountDiv.textContent = htmlEncode(
`Bill Greetings Updates: ${billGreetingsUpdateCount}`,
);
});
Expand All @@ -168,7 +167,7 @@
() => {
billAnyAgeUpdateCount += 1;
const billAnyAgeUpdateCountDiv = document.getElementById('bill-any-age-update-count');
billAnyAgeUpdateCountDiv.textContent = papi.utils.htmlEncode(
billAnyAgeUpdateCountDiv.textContent = htmlEncode(
`Any Age Updates (via Bill): ${billAnyAgeUpdateCount}`,
);
},
Expand All @@ -180,9 +179,7 @@
peopleDataProvider.subscribeAge('bIlL', () => {
billAgeUpdateCount += 1;
const billAgeUpdateCountDiv = document.getElementById('bill-age-update-count');
billAgeUpdateCountDiv.textContent = papi.utils.htmlEncode(
`Bill Age Updates: ${billAgeUpdateCount}`,
);
billAgeUpdateCountDiv.textContent = htmlEncode(`Bill Age Updates: ${billAgeUpdateCount}`);
});

// Attach handler for new-web-view-button
Expand Down
3 changes: 1 addition & 2 deletions extensions/src/project-notes-data-provider/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { VerseRef } from '@sillsdev/scripture';
import type {
DataProviderDataType,
DataProviderSubscriberOptions,
Unsubscriber,
IDataProvider,
} from '@papi/core';
import { PlatformEvent } from 'platform-bible-utils';
import { PlatformEvent, Unsubscriber } from 'platform-bible-utils';

declare module 'project-notes-data-provider' {
export type ProjectNotesProviderDataTypes = {
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/usfm-data-provider/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ declare module 'usfm-data-provider' {
ExtensionDataScope,
IDataProvider,
MandatoryProjectDataType,
Unsubscriber,
} from '@papi/core';
import { Unsubscriber } from 'platform-bible-utils';

export type UsfmProviderDataTypes = {
BookNames: DataProviderDataType<boolean, string[], never>;
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const config: Config = {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/src',
}),
'^platform-bible-react$': '<rootDir>/node_modules/platform-bible-react/dist/index.es.js',
'^platform-bible-utils$': '<rootDir>/node_modules/platform-bible-utils/dist/index.es.js',
'^platform-bible-react$': '<rootDir>/node_modules/platform-bible-react/dist/index.js',
'^platform-bible-utils$': '<rootDir>/node_modules/platform-bible-utils/dist/index.js',
},
testEnvironment: 'jsdom',
testEnvironmentOptions: {
Expand Down
43 changes: 43 additions & 0 deletions lib/papi-dts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions lib/papi-dts/papi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4656,7 +4656,6 @@ declare module '@papi/core' {
export type { ExecutionToken } from 'node/models/execution-token.model';
export type { DialogTypes } from 'renderer/components/dialogs/dialog-definition.model';
export type { UseDialogCallbackOptions } from 'renderer/hooks/papi-hooks/use-dialog-callback.hook';
export type { UsePromiseOptions } from 'platform-bible-react';
export type { default as IDataProvider } from 'shared/models/data-provider.interface';
export type {
DataProviderUpdateInstructions,
Expand All @@ -4666,12 +4665,6 @@ declare module '@papi/core' {
export type { WithNotifyUpdate } from 'shared/models/data-provider-engine.model';
export type { default as IDataProviderEngine } from 'shared/models/data-provider-engine.model';
export type { DialogOptions } from 'shared/models/dialog-options.model';
export type {
Unsubscriber,
UnsubscriberAsync,
PlatformEvent,
default as PlatformEventEmitter,
} from 'platform-bible-utils';
export type {
ExtensionDataScope,
MandatoryProjectDataType,
Expand Down
Loading

0 comments on commit 786ce6a

Please sign in to comment.