Skip to content

Commit

Permalink
adjust vite config and webViewRequire
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolie Rabideau authored and Jolie Rabideau committed Jan 17, 2024
1 parent d1b8cc0 commit 4eff04b
Show file tree
Hide file tree
Showing 20 changed files with 275 additions and 247 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
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.

Loading

0 comments on commit 4eff04b

Please sign in to comment.