make dev build work again
This commit is contained in:
parent
67fe4e8c20
commit
b916e53c68
@ -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",
|
||||
];
|
||||
|
@ -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);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user