From 56c7225ae4b29eb43415c6d214088b0f0b64edf7 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Mon, 30 Sep 2024 18:51:59 +0900 Subject: [PATCH 1/6] Load scripts by webpack completely --- src/web/app.html | 1 - src/web/dialog.html | 1 - webpack.config.js | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/web/app.html b/src/web/app.html index 67406a8..358d943 100644 --- a/src/web/app.html +++ b/src/web/app.html @@ -4,7 +4,6 @@ No title - blank diff --git a/src/web/dialog.html b/src/web/dialog.html index 22e731e..d96318d 100644 --- a/src/web/dialog.html +++ b/src/web/dialog.html @@ -6,7 +6,6 @@ - diff --git a/webpack.config.js b/webpack.config.js index 99f88ff..dfb910d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -52,7 +52,7 @@ module.exports = async (env, options) => { new HtmlWebpackPlugin({ filename: "app.html", template: "./src/web/app.html", - chunks: ["polyfill"], + chunks: ["polyfill", "app"], }), new CopyWebpackPlugin({ patterns: [ @@ -80,7 +80,7 @@ module.exports = async (env, options) => { new HtmlWebpackPlugin({ filename: "dialog.html", template: "./src/web/dialog.html", - chunks: ["polyfill"], + chunks: ["polyfill", "dialog"], }), ], devServer: { From 0f106e74a438d5bd38126c436afff430d7e1615e Mon Sep 17 00:00:00 2001 From: Takashi Hashida Date: Tue, 1 Oct 2024 10:26:53 +0900 Subject: [PATCH 2/6] Rever needless modifications of 18964e9b1c09d3093fea268b278605f43d134e85 --- webpack.config.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index dfb910d..8fda912 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,14 +18,14 @@ module.exports = async (env, options) => { devtool: "source-map", entry: { polyfill: ["core-js/stable", "regenerator-runtime/runtime"], - app: ["./src/web/app.js"], - dialog: ["./src/web/dialog.js"], + app: ["./src/web/app.js", "./src/web/app.html"], + dialog: ["./src/web/dialog.js", "./src/web/dialog.html"], }, output: { clean: true, }, resolve: { - extensions: [".html", ".js"], + extensions: [".html", ".js", ".mjs"], }, module: { rules: [ @@ -39,6 +39,16 @@ module.exports = async (env, options) => { }, }, }, + { + test: /\.html$/, + exclude: /node_modules/, + use: { + loader: "html-loader", + options: { + esModule: true, + }, + }, + }, { test: /\.(png|jpg|jpeg|gif|ico)$/, type: "asset/resource", @@ -56,10 +66,6 @@ module.exports = async (env, options) => { }), new CopyWebpackPlugin({ patterns: [ - { - from: "src/web/*.css", - to: "[name][ext][query]", - }, { from: "assets/*", to: "assets/[name][ext][query]", From caa34f8e3120dd3907d472aba9c33f5ffad00dc4 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Tue, 1 Oct 2024 11:51:57 +0900 Subject: [PATCH 3/6] Export handler functions explicitly --- src/web/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/web/app.js b/src/web/app.js index 1fd52aa..a66899a 100644 --- a/src/web/app.js +++ b/src/web/app.js @@ -126,6 +126,7 @@ function onMessageSend(event) { ); }); } +window.onMessageSend = onMessageSend; // eslint-disable-next-line @typescript-eslint/no-unused-vars function onNewMessageComposeCreated(event) { @@ -138,3 +139,4 @@ function onNewMessageComposeCreated(event) { }); event.completed(); } +window.onNewMessageComposeCreated = onNewMessageComposeCreated; From b127d8b04b65485fd6e5ba71df916942f75528c7 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Tue, 1 Oct 2024 11:52:15 +0900 Subject: [PATCH 4/6] Add more debug prints for development to trace internal operations --- src/web/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/web/app.js b/src/web/app.js index a66899a..805d321 100644 --- a/src/web/app.js +++ b/src/web/app.js @@ -11,8 +11,9 @@ const data = { }, }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -Office.initialize = function (reason) {}; +Office.initialize = function (reason) { + console.debug('Office.initialize reasion = ', reason); +}; function toArray(str) { if (!str) { @@ -31,6 +32,7 @@ function toArray(str) { } async function loadFile(url) { + console.debug('loadFile ', url); try { const response = await fetch(url); const data = await response.text(); @@ -100,6 +102,7 @@ function getAllData(callback) { // eslint-disable-next-line @typescript-eslint/no-unused-vars function onMessageSend(event) { + console.debug('onMessageSend ', event); getAllData(function () { Office.context.ui.displayDialogAsync( window.location.origin + "/dialog.html", @@ -130,6 +133,7 @@ window.onMessageSend = onMessageSend; // eslint-disable-next-line @typescript-eslint/no-unused-vars function onNewMessageComposeCreated(event) { + console.debug('onNewMessageComposeCreated ', event); Office.context.mailbox.item.subject.setAsync("新規メールの件名", function (asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { console.log("件名が設定されました"); From cd622e9d3420a6db7be8086d2f4545f9be741643 Mon Sep 17 00:00:00 2001 From: Takashi Hashida Date: Tue, 1 Oct 2024 12:08:54 +0900 Subject: [PATCH 5/6] Revert "Rever needless modifications of 18964e9b1c09d3093fea268b278605f43d134e85" This reverts commit 0f106e74a438d5bd38126c436afff430d7e1615e. --- webpack.config.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 8fda912..dfb910d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,14 +18,14 @@ module.exports = async (env, options) => { devtool: "source-map", entry: { polyfill: ["core-js/stable", "regenerator-runtime/runtime"], - app: ["./src/web/app.js", "./src/web/app.html"], - dialog: ["./src/web/dialog.js", "./src/web/dialog.html"], + app: ["./src/web/app.js"], + dialog: ["./src/web/dialog.js"], }, output: { clean: true, }, resolve: { - extensions: [".html", ".js", ".mjs"], + extensions: [".html", ".js"], }, module: { rules: [ @@ -39,16 +39,6 @@ module.exports = async (env, options) => { }, }, }, - { - test: /\.html$/, - exclude: /node_modules/, - use: { - loader: "html-loader", - options: { - esModule: true, - }, - }, - }, { test: /\.(png|jpg|jpeg|gif|ico)$/, type: "asset/resource", @@ -66,6 +56,10 @@ module.exports = async (env, options) => { }), new CopyWebpackPlugin({ patterns: [ + { + from: "src/web/*.css", + to: "[name][ext][query]", + }, { from: "assets/*", to: "assets/[name][ext][query]", From e978a16adc5866fb910ed6b2a4d196215283e1a3 Mon Sep 17 00:00:00 2001 From: "YUKI \"Piro\" Hiroshi" Date: Tue, 1 Oct 2024 12:36:35 +0900 Subject: [PATCH 6/6] Use double quote --- src/web/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/web/app.js b/src/web/app.js index 805d321..a7aedd2 100644 --- a/src/web/app.js +++ b/src/web/app.js @@ -12,7 +12,7 @@ const data = { }; Office.initialize = function (reason) { - console.debug('Office.initialize reasion = ', reason); + console.debug("Office.initialize reasion = ", reason); }; function toArray(str) { @@ -32,7 +32,7 @@ function toArray(str) { } async function loadFile(url) { - console.debug('loadFile ', url); + console.debug("loadFile ", url); try { const response = await fetch(url); const data = await response.text(); @@ -102,7 +102,7 @@ function getAllData(callback) { // eslint-disable-next-line @typescript-eslint/no-unused-vars function onMessageSend(event) { - console.debug('onMessageSend ', event); + console.debug("onMessageSend ", event); getAllData(function () { Office.context.ui.displayDialogAsync( window.location.origin + "/dialog.html", @@ -133,7 +133,7 @@ window.onMessageSend = onMessageSend; // eslint-disable-next-line @typescript-eslint/no-unused-vars function onNewMessageComposeCreated(event) { - console.debug('onNewMessageComposeCreated ', event); + console.debug("onNewMessageComposeCreated ", event); Office.context.mailbox.item.subject.setAsync("新規メールの件名", function (asyncResult) { if (asyncResult.status === Office.AsyncResultStatus.Succeeded) { console.log("件名が設定されました");