Feature: Support closing dialog windows (#233)

Supports closing dialogs in development. Upgrades gas-client to 1.2.0 and uses new API here: Add scriptHostFunctions for google.script.host gas-client#36
Example button to close dialog in Bootstrap sample
Updates integration tests
This commit is contained in:
Elisha Nuchi
2025-03-16 12:13:30 -04:00
committed by GitHub
parent 85223ca42a
commit 248a90023c
17 changed files with 2494 additions and 2502 deletions
+11 -5
View File
@@ -20,7 +20,7 @@ Two placeholders are used in this file that will need to be replaced in a build
<base target="_top" />
<title>Dev Server</title>
<!-- Load gas-client as external. Exposed global variable is GASClient. -->
<script src="https://unpkg.com/gas-client@1.1.1/dist/index.js"></script>
<script src="https://unpkg.com/gas-client@1.2.0/dist/index.js"></script>
<style>
body,
html {
@@ -37,15 +37,21 @@ Two placeholders are used in this file that will need to be replaced in a build
const iframe = document.getElementById('iframe');
iframe.src = 'https://localhost:' + PORT + '/' + FILE_NAME;
const { serverFunctions } = new window.GASClient.GASClient({
allowedDevelopmentDomains: (origin) =>
/https:\/\/.*\.googleusercontent\.com$/.test(origin),
});
const { serverFunctions, scriptHostFunctions } =
new window.GASClient.GASClient({
allowedDevelopmentDomains: (origin) =>
/https:\/\/.*\.googleusercontent\.com$/.test(origin),
});
const handleRequest = (event) => {
const request = event.data;
const { type, functionName, id, args } = request;
if (type === 'SCRIPT_HOST_FUNCTION_REQUEST') {
scriptHostFunctions[functionName](...args);
}
if (type !== 'REQUEST') return;
serverFunctions[functionName](...args)