gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (f4e1e8e6e -> 4da4a1b33)


From: gnunet
Subject: [taler-wallet-core] branch master updated (f4e1e8e6e -> 4da4a1b33)
Date: Wed, 04 Jan 2023 19:46:41 +0100

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

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

    from f4e1e8e6e -minor insufficient balance tweaks
     new 590cda1dd split foreground and background api
     new 4da4a1b33 introduce TranslatedString type to require an string but 
exclude non-translated strings

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-util/src/i18n.ts                    |  21 ++--
 .../src/background.dev.ts                          |   2 +-
 .../taler-wallet-webextension/src/background.ts    |   2 +-
 .../taler-wallet-webextension/src/chromeBadge.ts   |   2 +-
 .../src/context/iocContext.ts                      |   2 +-
 .../src/hooks/useAutoOpenPermissions.ts            |   2 +-
 .../src/hooks/useClipboardPermissions.ts           |   2 +-
 .../taler-wallet-webextension/src/platform/api.ts  | 139 +++++++++++----------
 .../state.ts => platform/background.ts}            |  10 +-
 .../src/platform/chrome.ts                         |  68 +++++-----
 .../taler-wallet-webextension/src/platform/dev.ts  |   5 +-
 .../src/platform/firefox.ts                        |   4 +-
 .../state.ts => platform/foreground.ts}            |  10 +-
 .../src/popup/Application.tsx                      |   2 +-
 .../src/popup/TalerActionFound.tsx                 |   2 +-
 .../src/popupEntryPoint.dev.tsx                    |   2 +-
 .../src/popupEntryPoint.tsx                        |   2 +-
 .../taler-wallet-webextension/src/stories.test.ts  |   2 +-
 .../src/wallet/AddNewActionView.tsx                |   2 +-
 .../src/wallet/Application.tsx                     |   2 +-
 .../src/wallet/Settings.tsx                        |   2 +-
 .../src/wallet/Welcome.tsx                         |   2 +-
 .../src/walletEntryPoint.dev.tsx                   |   2 +-
 .../src/walletEntryPoint.tsx                       |   2 +-
 packages/taler-wallet-webextension/src/wxApi.ts    |   6 +-
 .../taler-wallet-webextension/src/wxBackend.ts     |   4 +-
 26 files changed, 159 insertions(+), 142 deletions(-)
 copy 
packages/taler-wallet-webextension/src/{wallet/EmptyComponentExample/state.ts 
=> platform/background.ts} (77%)
 copy 
packages/taler-wallet-webextension/src/{wallet/EmptyComponentExample/state.ts 
=> platform/foreground.ts} (77%)

diff --git a/packages/taler-util/src/i18n.ts b/packages/taler-util/src/i18n.ts
index 001735325..f43f543ea 100644
--- a/packages/taler-util/src/i18n.ts
+++ b/packages/taler-util/src/i18n.ts
@@ -10,7 +10,7 @@ export let jed: any = undefined;
  * Set up jed library for internationalization,
  * based on browser language settings.
  */
-export function setupI18n(lang: string, strings: { [s: string]: any }): any {
+export function setupI18n(lang: string, strings: { [s: string]: any }): void {
   lang = lang.replace("_", "-");
 
   if (!strings[lang]) {
@@ -28,10 +28,13 @@ export function internalSetStrings(langStrings: any): void {
   jed = new jedLib.Jed(langStrings);
 }
 
+declare const __translated: unique symbol;
+export type TranslatedString = string & { [__translated]: true };
+
 /**
  * Convert template strings to a msgid
  */
-function toI18nString(stringSeq: ReadonlyArray<string>): string {
+function toI18nString(stringSeq: ReadonlyArray<string>): TranslatedString {
   let s = "";
   for (let i = 0; i < stringSeq.length; i++) {
     s += stringSeq[i];
@@ -39,7 +42,7 @@ function toI18nString(stringSeq: ReadonlyArray<string>): 
string {
       s += `%${i + 1}$s`;
     }
   }
-  return s;
+  return s as TranslatedString;
 }
 
 /**
@@ -48,7 +51,7 @@ function toI18nString(stringSeq: ReadonlyArray<string>): 
string {
 export function singular(
   stringSeq: TemplateStringsArray,
   ...values: any[]
-): string {
+): TranslatedString {
   const s = toI18nString(stringSeq);
   const tr = jed
     .translate(s)
@@ -63,10 +66,10 @@ export function singular(
 export function translate(
   stringSeq: TemplateStringsArray,
   ...values: any[]
-): any[] {
+): TranslatedString[] {
   const s = toI18nString(stringSeq);
   if (!s) return [];
-  const translation: string = jed.ngettext(s, s, 1);
+  const translation: TranslatedString = jed.ngettext(s, s, 1);
   return replacePlaceholderWithValues(translation, values);
 }
 
@@ -83,7 +86,7 @@ export function Translate({
   const c = [].concat(children);
   const s = stringifyArray(c);
   if (!s) return [];
-  const translation: string = jed.ngettext(s, s, 1);
+  const translation: TranslatedString = jed.ngettext(s, s, 1);
   if (debug) {
     console.log("looking for ", s, "got", translation);
   }
@@ -104,12 +107,12 @@ export function getJsonI18n<K extends string>(
 
 export function getTranslatedArray(array: Array<any>) {
   const s = stringifyArray(array);
-  const translation: string = jed.ngettext(s, s, 1);
+  const translation: TranslatedString = jed.ngettext(s, s, 1);
   return replacePlaceholderWithValues(translation, array);
 }
 
 function replacePlaceholderWithValues(
-  translation: string,
+  translation: TranslatedString,
   childArray: Array<any>,
 ): Array<any> {
   const tr = translation.split(/%(\d+)\$s/);
diff --git a/packages/taler-wallet-webextension/src/background.dev.ts 
b/packages/taler-wallet-webextension/src/background.dev.ts
index d81df11df..cac62c44d 100644
--- a/packages/taler-wallet-webextension/src/background.dev.ts
+++ b/packages/taler-wallet-webextension/src/background.dev.ts
@@ -23,7 +23,7 @@
 /**
  * Imports.
  */
-import { platform, setupPlatform } from "./platform/api.js";
+import { platform, setupPlatform } from "./platform/background.js";
 import devAPI from "./platform/dev.js";
 import { wxMain } from "./wxBackend.js";
 
diff --git a/packages/taler-wallet-webextension/src/background.ts 
b/packages/taler-wallet-webextension/src/background.ts
index 0e2ea3f3a..7382120aa 100644
--- a/packages/taler-wallet-webextension/src/background.ts
+++ b/packages/taler-wallet-webextension/src/background.ts
@@ -23,7 +23,7 @@
 /**
  * Imports.
  */
-import { platform, setupPlatform } from "./platform/api.js";
+import { platform, setupPlatform } from "./platform/background.js";
 import chromeAPI from "./platform/chrome.js";
 import firefoxAPI from "./platform/firefox.js";
 import { wxMain } from "./wxBackend.js";
diff --git a/packages/taler-wallet-webextension/src/chromeBadge.ts 
b/packages/taler-wallet-webextension/src/chromeBadge.ts
index 350920e93..63d0372b6 100644
--- a/packages/taler-wallet-webextension/src/chromeBadge.ts
+++ b/packages/taler-wallet-webextension/src/chromeBadge.ts
@@ -14,7 +14,7 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { platform } from "./platform/api.js";
+import { platform } from "./platform/background.js";
 
 /**
  * Polyfill for requestAnimationFrame, which
diff --git a/packages/taler-wallet-webextension/src/context/iocContext.ts 
b/packages/taler-wallet-webextension/src/context/iocContext.ts
index c7fee0bc0..89f984f2f 100644
--- a/packages/taler-wallet-webextension/src/context/iocContext.ts
+++ b/packages/taler-wallet-webextension/src/context/iocContext.ts
@@ -21,7 +21,7 @@
 
 import { createContext, h, VNode } from "preact";
 import { useContext } from "preact/hooks";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 interface Type {
   findTalerUriInActiveTab: () => Promise<string | undefined>;
diff --git 
a/packages/taler-wallet-webextension/src/hooks/useAutoOpenPermissions.ts 
b/packages/taler-wallet-webextension/src/hooks/useAutoOpenPermissions.ts
index e375f4958..cf2fd880e 100644
--- a/packages/taler-wallet-webextension/src/hooks/useAutoOpenPermissions.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useAutoOpenPermissions.ts
@@ -18,7 +18,7 @@ import { TalerError } from "@gnu-taler/taler-wallet-core";
 import { useEffect, useState } from "preact/hooks";
 import { useBackendContext } from "../context/backend.js";
 import { ToggleHandler } from "../mui/handlers.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 export function useAutoOpenPermissions(): ToggleHandler {
   const api = useBackendContext();
diff --git 
a/packages/taler-wallet-webextension/src/hooks/useClipboardPermissions.ts 
b/packages/taler-wallet-webextension/src/hooks/useClipboardPermissions.ts
index 3f2824d6b..0f035d0f2 100644
--- a/packages/taler-wallet-webextension/src/hooks/useClipboardPermissions.ts
+++ b/packages/taler-wallet-webextension/src/hooks/useClipboardPermissions.ts
@@ -18,7 +18,7 @@ import { TalerError } from "@gnu-taler/taler-wallet-core";
 import { useEffect, useState } from "preact/hooks";
 import { useBackendContext } from "../context/backend.js";
 import { ToggleHandler } from "../mui/handlers.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 export function useClipboardPermissions(): ToggleHandler {
   const [enabled, setEnabled] = useState(false);
diff --git a/packages/taler-wallet-webextension/src/platform/api.ts 
b/packages/taler-wallet-webextension/src/platform/api.ts
index 7df190303..cd09f6438 100644
--- a/packages/taler-wallet-webextension/src/platform/api.ts
+++ b/packages/taler-wallet-webextension/src/platform/api.ts
@@ -85,7 +85,7 @@ export interface WalletWebExVersion {
  * Compatibility helpers needed for browsers that don't implement
  * WebExtension APIs consistently.
  */
-export interface PlatformAPI {
+export interface BackgroundPlatformAPI {
   /**
    * Guarantee that the service workers don't die
    */
@@ -97,61 +97,35 @@ export interface PlatformAPI {
    */
   isFirefox(): boolean;
 
-  /**
-   * Permission API for checking and add a listener
-   */
-  getPermissionsApi(): CrossBrowserPermissionsApi;
-
-  /**
-   * Backend API
-   *
-   * Register a callback to be called when the wallet is ready to start
-   * @param callback
-   */
-  notifyWhenAppIsReady(callback: () => void): void;
+  registerOnInstalled(callback: () => void): void;
 
   /**
-   * Popup API
-   *
-   * Used when an TalerURI is found and open up from the popup UI.
-   * Closes the popup and open the URI into the wallet UI.
    *
-   * @param talerUri
+   * Check if background process run as service worker. This is used from the
+   * wallet use different http api and crypto worker.
    */
-  openWalletURIFromPopup(talerUri: string): void;
-
+  useServiceWorkerAsBackgroundProcess(): boolean;
   /**
-   * Backend API
    *
    * Open a page into the wallet UI
    * @param page
    */
   openWalletPage(page: string): void;
-
   /**
-   * Popup API
    *
-   * Open a page into the wallet UI and closed the popup
-   * @param page
-   */
-  openWalletPageFromPopup(page: string): void;
-
-  /**
-   * Backend API
-   *
-   * When a tab has been detected to have a Taler action the background process
-   * can use this function to redirect the tab to the wallet UI
-   *
-   * @param tabId
-   * @param page
+   * Register a callback to be called when the wallet is ready to start
+   * @param callback
    */
-  redirectTabToWalletPage(tabId: number, page: string): void;
+  notifyWhenAppIsReady(callback: () => void): void;
 
   /**
    * Get the wallet version from manifest
    */
   getWalletWebExVersion(): WalletWebExVersion;
-
+  /**
+   * Frontend API
+   */
+  containsTalerHeaderListener(): boolean;
   /**
    * Backend API
    */
@@ -166,22 +140,75 @@ export interface PlatformAPI {
   registerTalerHeaderListener(
     onHeader: (tabId: number, url: string) => void,
   ): void;
+
   /**
-   * Frontend API
+   * Permission API for checking and add a listener
    */
-  containsTalerHeaderListener(): boolean;
+  getPermissionsApi(): CrossBrowserPermissionsApi;
+  /**
+ * Used by the wallet backend to send notification about new information
+ * @param message
+ */
+  sendMessageToAllChannels(message: MessageFromBackend): void;
+
   /**
    * Backend API
+   *
+   * When a tab has been detected to have a Taler action the background process
+   * can use this function to redirect the tab to the wallet UI
+   *
+   * @param tabId
+   * @param page
    */
-  registerOnInstalled(callback: () => void): void;
+  redirectTabToWalletPage(tabId: number, page: string): void;
+  /**
+   * Use by the wallet backend to receive operations from frontend (popup & 
wallet)
+   * and send a response back.
+   *
+   * @param onNewMessage
+   */
+  listenToAllChannels(
+    notifyNewMessage: <Op extends WalletOperations | BackgroundOperations>(
+      message: MessageFromFrontend<Op> & { id: string },
+    ) => Promise<MessageResponse>,
+  ): void;
+}
+export interface ForegroundPlatformAPI {
+  /**
+   * FIXME: should not be needed
+   *
+   * check if the platform is firefox
+   */
+  isFirefox(): boolean;
 
   /**
-   * Backend API
+   * Permission API for checking and add a listener
+   */
+  getPermissionsApi(): CrossBrowserPermissionsApi;
+
+  /**
+   * Popup API
    *
-   * Check if background process run as service worker. This is used from the
-   * wallet use different http api and crypto worker.
+   * Used when an TalerURI is found and open up from the popup UI.
+   * Closes the popup and open the URI into the wallet UI.
+   *
+   * @param talerUri
    */
-  useServiceWorkerAsBackgroundProcess(): boolean;
+  openWalletURIFromPopup(talerUri: string): void;
+
+
+  /**
+   * Popup API
+   *
+   * Open a page into the wallet UI and closed the popup
+   * @param page
+   */
+  openWalletPageFromPopup(page: string): void;
+
+  /**
+   * Get the wallet version from manifest
+   */
+  getWalletWebExVersion(): WalletWebExVersion;
 
   /**
    * Popup API
@@ -222,26 +249,4 @@ export interface PlatformAPI {
     listener: (message: MessageFromBackend) => void,
   ): () => void;
 
-  /**
-   * Use by the wallet backend to receive operations from frontend (popup & 
wallet)
-   * and send a response back.
-   *
-   * @param onNewMessage
-   */
-  listenToAllChannels(
-    notifyNewMessage: <Op extends WalletOperations | BackgroundOperations>(
-      message: MessageFromFrontend<Op> & { id: string },
-    ) => Promise<MessageResponse>,
-  ): void;
-
-  /**
-   * Used by the wallet backend to send notification about new information
-   * @param message
-   */
-  sendMessageToAllChannels(message: MessageFromBackend): void;
-}
-
-export let platform: PlatformAPI = undefined as any;
-export function setupPlatform(impl: PlatformAPI): void {
-  platform = impl;
 }
diff --git 
a/packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts 
b/packages/taler-wallet-webextension/src/platform/background.ts
similarity index 77%
copy from 
packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts
copy to packages/taler-wallet-webextension/src/platform/background.ts
index 31a351579..9f3764c25 100644
--- 
a/packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts
+++ b/packages/taler-wallet-webextension/src/platform/background.ts
@@ -14,11 +14,9 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { Props, State } from "./index.js";
+import { BackgroundPlatformAPI } from "./api.js";
 
-export function useComponentState({ p }: Props): State {
-  return {
-    status: "ready",
-    error: undefined,
-  };
+export let platform: BackgroundPlatformAPI = undefined as any;
+export function setupPlatform(impl: BackgroundPlatformAPI): void {
+  platform = impl;
 }
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts 
b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 744283913..e5efdec4e 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -15,23 +15,19 @@
  */
 
 import {
-  classifyTalerUri,
-  CoreApiResponse,
-  Logger,
-  TalerUriType,
+  classifyTalerUri, Logger,
+  TalerUriType
 } from "@gnu-taler/taler-util";
 import { WalletOperations } from "@gnu-taler/taler-wallet-core";
 import { BackgroundOperations } from "../wxApi.js";
 import {
-  CrossBrowserPermissionsApi,
-  MessageFromBackend,
+  BackgroundPlatformAPI, CrossBrowserPermissionsApi, ForegroundPlatformAPI, 
MessageFromBackend,
   MessageFromFrontend,
   MessageResponse,
-  Permissions,
-  PlatformAPI,
+  Permissions
 } from "./api.js";
 
-const api: PlatformAPI = {
+const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   isFirefox,
   findTalerUriInActiveTab,
   findTalerUriInClipboard,
@@ -310,16 +306,28 @@ function openWalletPageFromPopup(page: string): void {
   });
 }
 
-let i = 0;
 
+let nextMessageIndex = 0;
+
+/**
+ * To be used by the foreground
+ * @param message 
+ * @returns 
+ */
 async function sendMessageToBackground<
   Op extends WalletOperations | BackgroundOperations,
 >(message: MessageFromFrontend<Op>): Promise<MessageResponse> {
-  const messageWithId = { ...message, id: `id_${i++ % 1000}` };
+  const messageWithId = { ...message, id: `id_${nextMessageIndex++ % 1000}` };
 
   return new Promise<any>((resolve, reject) => {
     logger.trace("send operation to the wallet background", message);
+    let timedout = false
+    setTimeout(() => {
+      timedout = true
+      reject("timedout")
+    }, 2000);
     chrome.runtime.sendMessage(messageWithId, (backgroundResponse) => {
+      if (timedout) return false
       if (chrome.runtime.lastError) {
         reject(chrome.runtime.lastError.message);
       } else {
@@ -331,6 +339,9 @@ async function sendMessageToBackground<
   });
 }
 
+/**
+ * To be used by the foreground
+ */
 let notificationPort: chrome.runtime.Port | undefined;
 function listenToWalletBackground(listener: (m: any) => void): () => void {
   if (notificationPort === undefined) {
@@ -347,6 +358,7 @@ function listenToWalletBackground(listener: (m: any) => 
void): () => void {
 
 const allPorts: chrome.runtime.Port[] = [];
 
+
 function sendMessageToAllChannels(message: MessageFromBackend): void {
   for (const notif of allPorts) {
     // const message: MessageFromBackend = { type: msg.type };
@@ -566,26 +578,26 @@ function setAlertedIcon(): void {
 
 interface OffscreenCanvasRenderingContext2D
   extends CanvasState,
-    CanvasTransform,
-    CanvasCompositing,
-    CanvasImageSmoothing,
-    CanvasFillStrokeStyles,
-    CanvasShadowStyles,
-    CanvasFilters,
-    CanvasRect,
-    CanvasDrawPath,
-    CanvasUserInterface,
-    CanvasText,
-    CanvasDrawImage,
-    CanvasImageData,
-    CanvasPathDrawingStyles,
-    CanvasTextDrawingStyles,
-    CanvasPath {
+  CanvasTransform,
+  CanvasCompositing,
+  CanvasImageSmoothing,
+  CanvasFillStrokeStyles,
+  CanvasShadowStyles,
+  CanvasFilters,
+  CanvasRect,
+  CanvasDrawPath,
+  CanvasUserInterface,
+  CanvasText,
+  CanvasDrawImage,
+  CanvasImageData,
+  CanvasPathDrawingStyles,
+  CanvasTextDrawingStyles,
+  CanvasPath {
   readonly canvas: OffscreenCanvas;
 }
 declare const OffscreenCanvasRenderingContext2D: {
   prototype: OffscreenCanvasRenderingContext2D;
-  new (): OffscreenCanvasRenderingContext2D;
+  new(): OffscreenCanvasRenderingContext2D;
 };
 
 interface OffscreenCanvas extends EventTarget {
@@ -598,7 +610,7 @@ interface OffscreenCanvas extends EventTarget {
 }
 declare const OffscreenCanvas: {
   prototype: OffscreenCanvas;
-  new (width: number, height: number): OffscreenCanvas;
+  new(width: number, height: number): OffscreenCanvas;
 };
 
 function createCanvas(size: number): OffscreenCanvas {
diff --git a/packages/taler-wallet-webextension/src/platform/dev.ts 
b/packages/taler-wallet-webextension/src/platform/dev.ts
index df40b29e7..d57072c80 100644
--- a/packages/taler-wallet-webextension/src/platform/dev.ts
+++ b/packages/taler-wallet-webextension/src/platform/dev.ts
@@ -18,15 +18,16 @@ import { CoreApiResponse } from "@gnu-taler/taler-util";
 import { WalletOperations } from "@gnu-taler/taler-wallet-core";
 import { BackgroundOperations } from "../wxApi.js";
 import {
+  BackgroundPlatformAPI,
+  ForegroundPlatformAPI,
   MessageFromBackend,
   MessageFromFrontend,
   MessageResponse,
-  PlatformAPI,
 } from "./api.js";
 
 const frames = ["popup", "wallet"];
 
-const api: PlatformAPI = {
+const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   isFirefox: () => false,
   keepAlive: (cb: VoidFunction) => cb(),
   findTalerUriInActiveTab: async () => undefined,
diff --git a/packages/taler-wallet-webextension/src/platform/firefox.ts 
b/packages/taler-wallet-webextension/src/platform/firefox.ts
index 943168956..a36859a0b 100644
--- a/packages/taler-wallet-webextension/src/platform/firefox.ts
+++ b/packages/taler-wallet-webextension/src/platform/firefox.ts
@@ -14,7 +14,7 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { CrossBrowserPermissionsApi, Permissions, PlatformAPI } from 
"./api.js";
+import { BackgroundPlatformAPI, CrossBrowserPermissionsApi, 
ForegroundPlatformAPI, Permissions } from "./api.js";
 import chromePlatform, {
   containsHostPermissions as chromeHostContains,
   removeHostPermissions as chromeHostRemove,
@@ -24,7 +24,7 @@ import chromePlatform, {
   requestClipboardPermissions as chromeClipRequest,
 } from "./chrome.js";
 
-const api: PlatformAPI = {
+const api: BackgroundPlatformAPI & ForegroundPlatformAPI = {
   ...chromePlatform,
   isFirefox,
   getPermissionsApi,
diff --git 
a/packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts 
b/packages/taler-wallet-webextension/src/platform/foreground.ts
similarity index 77%
copy from 
packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts
copy to packages/taler-wallet-webextension/src/platform/foreground.ts
index 31a351579..ae8dc8a95 100644
--- 
a/packages/taler-wallet-webextension/src/wallet/EmptyComponentExample/state.ts
+++ b/packages/taler-wallet-webextension/src/platform/foreground.ts
@@ -14,11 +14,9 @@
  GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import { Props, State } from "./index.js";
+import { ForegroundPlatformAPI } from "./api.js";
 
-export function useComponentState({ p }: Props): State {
-  return {
-    status: "ready",
-    error: undefined,
-  };
+export let platform: ForegroundPlatformAPI = undefined as any;
+export function setupPlatform(impl: ForegroundPlatformAPI): void {
+  platform = impl;
 }
diff --git a/packages/taler-wallet-webextension/src/popup/Application.tsx 
b/packages/taler-wallet-webextension/src/popup/Application.tsx
index 9cae0d048..13ce71974 100644
--- a/packages/taler-wallet-webextension/src/popup/Application.tsx
+++ b/packages/taler-wallet-webextension/src/popup/Application.tsx
@@ -35,7 +35,7 @@ import {
 } from "../context/translation.js";
 import { useTalerActionURL } from "../hooks/useTalerActionURL.js";
 import { PopupNavBarOptions, Pages, PopupNavBar } from "../NavigationBar.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 import { BackupPage } from "../wallet/BackupPage.js";
 import { ProviderDetailPage } from "../wallet/ProviderDetailPage.js";
 import { BalancePage } from "./BalancePage.js";
diff --git a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx 
b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx
index dc2b8bfae..5c435a9a5 100644
--- a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx
+++ b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx
@@ -24,7 +24,7 @@ import { Fragment, h, VNode } from "preact";
 import { Title } from "../components/styled/index.js";
 import { useTranslationContext } from "../context/translation.js";
 import { Button } from "../mui/Button.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 export interface Props {
   url: string;
diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.dev.tsx 
b/packages/taler-wallet-webextension/src/popupEntryPoint.dev.tsx
index e50bb8f49..6b42e5809 100644
--- a/packages/taler-wallet-webextension/src/popupEntryPoint.dev.tsx
+++ b/packages/taler-wallet-webextension/src/popupEntryPoint.dev.tsx
@@ -23,7 +23,7 @@
 import { setupI18n } from "@gnu-taler/taler-util";
 import { h, render } from "preact";
 import { strings } from "./i18n/strings.js";
-import { setupPlatform } from "./platform/api.js";
+import { setupPlatform } from "./platform/foreground.js";
 import devAPI from "./platform/dev.js";
 import { Application } from "./popup/Application.js";
 
diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx 
b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
index 1c2580310..22aba6c9d 100644
--- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
@@ -23,7 +23,7 @@
 import { setupI18n } from "@gnu-taler/taler-util";
 import { h, render } from "preact";
 import { strings } from "./i18n/strings.js";
-import { setupPlatform } from "./platform/api.js";
+import { setupPlatform } from "./platform/foreground.js";
 import chromeAPI from "./platform/chrome.js";
 import firefoxAPI from "./platform/firefox.js";
 import { Application } from "./popup/Application.js";
diff --git a/packages/taler-wallet-webextension/src/stories.test.ts 
b/packages/taler-wallet-webextension/src/stories.test.ts
index bd8ac0b24..47061282d 100644
--- a/packages/taler-wallet-webextension/src/stories.test.ts
+++ b/packages/taler-wallet-webextension/src/stories.test.ts
@@ -20,7 +20,7 @@
  */
 import { setupI18n } from "@gnu-taler/taler-util";
 import { parseGroupImport } from "@gnu-taler/web-util/lib/index.browser";
-import { setupPlatform } from "./platform/api.js";
+import { setupPlatform } from "./platform/foreground.js";
 import chromeAPI from "./platform/chrome.js";
 import { renderNodeOrBrowser } from "./test-utils.js";
 
diff --git a/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx 
b/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx
index c704c8085..666334214 100644
--- a/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/AddNewActionView.tsx
@@ -16,7 +16,7 @@
 import { classifyTalerUri, TalerUriType } from "@gnu-taler/taler-util";
 import { Fragment, h, VNode } from "preact";
 import { useState } from "preact/hooks";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 import { InputWithLabel } from "../components/styled/index.js";
 import { useTranslationContext } from "../context/translation.js";
 import { Button } from "../mui/Button.js";
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx 
b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 8b77e152c..372db847c 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -52,7 +52,7 @@ import {
   WithdrawPageFromURI,
 } from "../cta/Withdraw/index.js";
 import { WalletNavBarOptions, Pages, WalletNavBar } from "../NavigationBar.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 import { AddBackupProviderPage } from "./AddBackupProvider/index.js";
 import { BackupPage } from "./BackupPage.js";
 import { DepositPage } from "./DepositPage/index.js";
diff --git a/packages/taler-wallet-webextension/src/wallet/Settings.tsx 
b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
index c9b2205c5..768a4ca6a 100644
--- a/packages/taler-wallet-webextension/src/wallet/Settings.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Settings.tsx
@@ -43,7 +43,7 @@ import { useBackupDeviceName } from 
"../hooks/useBackupDeviceName.js";
 import { useClipboardPermissions } from "../hooks/useClipboardPermissions.js";
 import { ToggleHandler } from "../mui/handlers.js";
 import { Pages } from "../NavigationBar.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : 
undefined;
 
diff --git a/packages/taler-wallet-webextension/src/wallet/Welcome.tsx 
b/packages/taler-wallet-webextension/src/wallet/Welcome.tsx
index 659a6c2cf..0b64417b8 100644
--- a/packages/taler-wallet-webextension/src/wallet/Welcome.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Welcome.tsx
@@ -28,7 +28,7 @@ import { useTranslationContext } from 
"../context/translation.js";
 import { useDiagnostics } from "../hooks/useDiagnostics.js";
 import { useAutoOpenPermissions } from "../hooks/useAutoOpenPermissions.js";
 import { ToggleHandler } from "../mui/handlers.js";
-import { platform } from "../platform/api.js";
+import { platform } from "../platform/foreground.js";
 
 export function WelcomePage(): VNode {
   const permissionToggle = useAutoOpenPermissions();
diff --git a/packages/taler-wallet-webextension/src/walletEntryPoint.dev.tsx 
b/packages/taler-wallet-webextension/src/walletEntryPoint.dev.tsx
index 4cc217e47..c2906373c 100644
--- a/packages/taler-wallet-webextension/src/walletEntryPoint.dev.tsx
+++ b/packages/taler-wallet-webextension/src/walletEntryPoint.dev.tsx
@@ -23,7 +23,7 @@
 import { setupI18n } from "@gnu-taler/taler-util";
 import { h, render } from "preact";
 import { strings } from "./i18n/strings.js";
-import { setupPlatform } from "./platform/api.js";
+import { setupPlatform } from "./platform/foreground.js";
 import devAPI from "./platform/dev.js";
 import { Application } from "./wallet/Application.js";
 
diff --git a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx 
b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
index 6f1d6e06b..84822b8e6 100644
--- a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
@@ -23,7 +23,7 @@
 import { setupI18n } from "@gnu-taler/taler-util";
 import { h, render } from "preact";
 import { strings } from "./i18n/strings.js";
-import { setupPlatform } from "./platform/api.js";
+import { setupPlatform } from "./platform/foreground.js";
 import chromeAPI from "./platform/chrome.js";
 import firefoxAPI from "./platform/firefox.js";
 import { Application } from "./wallet/Application.js";
diff --git a/packages/taler-wallet-webextension/src/wxApi.ts 
b/packages/taler-wallet-webextension/src/wxApi.ts
index 0d33719be..5c2a577b3 100644
--- a/packages/taler-wallet-webextension/src/wxApi.ts
+++ b/packages/taler-wallet-webextension/src/wxApi.ts
@@ -34,12 +34,10 @@ import {
   WalletCoreRequestType,
   WalletCoreResponseType,
 } from "@gnu-taler/taler-wallet-core";
+import { MessageFromBackend, MessageFromFrontendBackground, 
MessageFromFrontendWallet } from "./platform/api.js";
 import {
-  MessageFromBackend,
-  MessageFromFrontendBackground,
-  MessageFromFrontendWallet,
   platform,
-} from "./platform/api.js";
+} from "./platform/foreground.js";
 
 /**
  *
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts 
b/packages/taler-wallet-webextension/src/wxBackend.ts
index 0f0beb41f..b75e92004 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -46,11 +46,13 @@ import {
   WalletStoresV1,
 } from "@gnu-taler/taler-wallet-core";
 import { BrowserHttpLib } from "./browserHttpLib.js";
+import {
+  platform,
+} from "./platform/background.js";
 import {
   MessageFromBackend,
   MessageFromFrontend,
   MessageResponse,
-  platform,
 } from "./platform/api.js";
 import { SynchronousCryptoWorkerFactory } from 
"./serviceWorkerCryptoWorkerFactory.js";
 import { ServiceWorkerHttpLib } from "./serviceWorkerHttpLib.js";

-- 
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]