gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 06/07: make dev build work again


From: gnunet
Subject: [taler-wallet-core] 06/07: make dev build work again
Date: Thu, 01 Jun 2023 17:24:50 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit b916e53c68fc4e31fc7d945c450aaf9b0aeefc50
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jun 1 12:22:27 2023 -0300

    make dev build work again
---
 packages/taler-wallet-webextension/dev.mjs         | 14 +++++-----
 .../taler-wallet-webextension/src/platform/dev.ts  | 31 +++++++++++++++-------
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/packages/taler-wallet-webextension/dev.mjs 
b/packages/taler-wallet-webextension/dev.mjs
index 4ba649a7e..5577b1f0e 100755
--- a/packages/taler-wallet-webextension/dev.mjs
+++ b/packages/taler-wallet-webextension/dev.mjs
@@ -15,18 +15,16 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import linaria from "@linaria/esbuild";
+import { getFilesInDirectory, initializeDev } from "@gnu-taler/web-util/build";
 import { serve } from "@gnu-taler/web-util/node";
-import { initializeDev, getFilesInDirectory } from "@gnu-taler/web-util/build";
+import linaria from "@linaria/esbuild";
 
-const allStaticFiles = getFilesInDirectory("static");
+const allStaticFiles = getFilesInDirectory("src/spa");
 
 const devEntryPoints = [
-  "src/popupEntryPoint.tsx",
-  "src/walletEntryPoint.tsx",
-  "src/background.ts",
-  "src/taler-wallet-interaction-loader.ts",
-  "src/taler-wallet-interaction-support.ts",
+  "src/popupEntryPoint.dev.tsx",
+  "src/walletEntryPoint.dev.tsx",
+  "src/background.dev.ts",
   "src/browserWorkerEntry.ts",
   "src/stories.tsx",
 ];
diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts 
b/packages/taler-wallet-webextension/src/platform/dev.ts
index 1d43ad549..005421876 100644
--- a/packages/taler-wallet-webextension/src/platform/dev.ts
+++ b/packages/taler-wallet-webextension/src/platform/dev.ts
@@ -14,7 +14,7 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { CoreApiResponse, TalerUri } from "@gnu-taler/taler-util";
+import { Logger, TalerUri } from "@gnu-taler/taler-util";
 import { WalletOperations } from "@gnu-taler/taler-wallet-core";
 import { BackgroundOperations } from "../wxApi.js";
 import {
@@ -26,7 +26,7 @@ import {
   defaultSettings,
 } from "./api.js";
 
-const frames = ["popup", "wallet"];
+const logger = new Logger("dev.ts");
 
 const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   isFirefox: () => false,
@@ -47,15 +47,17 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
     version: "none",
   }),
   notifyWhenAppIsReady: () => {
-    let total = frames.length;
+    const knownFrames = ["popup", "wallet"];
+    let total = knownFrames.length;
     return new Promise((fn) => {
       function waitAndNotify(): void {
         total--;
+        logger.trace(`waitAndNotify  ${total}`);
         if (total < 1) {
           fn();
         }
       }
-      frames.forEach((f) => {
+      knownFrames.forEach((f) => {
         const theFrame = window.frames[f as any];
         if (theFrame.location.href === "about:blank") {
           waitAndNotify();
@@ -67,11 +69,15 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   },
 
   openWalletPage: (page: string) => {
-    window.frames["wallet" as any].location = `/wallet.html#${page}`;
+    // @ts-ignore
+    window.parent.redirectWallet(`wallet.html#${page}`);
   },
   openWalletPageFromPopup: (page: string) => {
-    window.parent.frames["wallet" as any].location = `/wallet.html#${page}`;
-    window.location.href = "about:blank";
+    // @ts-ignore
+    window.parent.redirectWallet(`wallet.html#${page}`);
+    // close the popup
+    // @ts-ignore
+    window.parent.closePopup();
   },
   openWalletURIFromPopup: (page: TalerUri) => {
     alert("openWalletURIFromPopup not implemented yet");
@@ -87,14 +93,16 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   useServiceWorkerAsBackgroundProcess: () => false,
 
   listenToAllChannels: (
-    fn: (m: any, s: any, c: (r: CoreApiResponse) => void) => void,
+    notifyNewMessage: (message: any) => Promise<MessageResponse>,
   ) => {
     window.addEventListener(
       "message",
       (event: MessageEvent<IframeMessageType>) => {
         if (event.data.type !== "command") return;
         const sender = event.data.header.replyMe;
-        fn(event.data.body, sender, (resp: CoreApiResponse) => {
+
+        notifyNewMessage(event.data.body as any).then((resp) => {
+          logger.trace(`listenToAllChannels: from ${sender}`, event);
           if (event.source) {
             const msg: IframeMessageResponse = {
               type: "response",
@@ -121,6 +129,7 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   },
   listenToWalletBackground: (onNewMessage: (m: MessageFromBackend) => void) => 
{
     function listener(event: MessageEvent<IframeMessageType>): void {
+      logger.trace(`listenToWalletBackground: `, event);
       if (event.data.type !== "notification") return;
       onNewMessage(event.data.body);
     }
@@ -141,7 +150,8 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
       header: { replyMe },
       body: payload,
     };
-    window.parent.postMessage(message);
+
+    logger.trace(`sendMessageToBackground: `, message);
 
     return new Promise((res, rej) => {
       function listener(event: MessageEvent<IframeMessageType>): void {
@@ -155,6 +165,7 @@ const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
         window.parent.removeEventListener("message", listener);
       }
       window.parent.addEventListener("message", listener, {});
+      window.parent.postMessage(message);
     });
   },
 };

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]