updates for v0.1.0, update some js packages

This commit is contained in:
sawka 2023-01-16 23:44:50 -08:00
parent 8a7a114671
commit daeef7a4d0
6 changed files with 519 additions and 407 deletions

View File

@ -1,6 +1,6 @@
{
"name": "Prompt",
"version": "0.1.0",
"version": "0.1.1",
"main": "dist/emain.js",
"license": "Proprietary",
"dependencies": {

View File

@ -20,6 +20,8 @@ let DistDir = (isDev ? "dist-dev" : "dist");
let GlobalAuthKey = "";
let instanceId = uuidv4();
let oldConsoleLog = console.log;
let wasActive = true;
let wasInFg = true;
// these are either "darwin/amd64" or "darwin/arm64"
// normalize darwin/x64 to darwin/amd64 for GOARCH compatibility
@ -180,6 +182,9 @@ function createMainWindow(clientData) {
let indexHtml = (isDev ? "index-dev.html" : "index.html");
win.loadFile(path.join(getAppBasePath(), "static", indexHtml));
win.webContents.on("before-input-event", (e, input) => {
if (win.isFocused()) {
wasActive = true;
}
if (input.type != "keyDown") {
return;
}
@ -250,6 +255,10 @@ function createMainWindow(clientData) {
win.webContents.on("will-navigate", shNavHandler);
win.on("resized", debounce(400, mainResizeHandler));
win.on("moved", debounce(400, mainResizeHandler));
win.on("focus", () => {
wasInFg = true;
wasActive = true;
});
win.on("close", () => {
MainWindow = null;
});
@ -483,6 +492,24 @@ async function sleep(ms) {
return new Promise((resolve, reject) => setTimeout(resolve, ms));
}
function logActiveState() {
let activeState = {fg: wasInFg, active: wasActive, open: true};
let url = getBaseHostPort() + "/api/log-active-state";
let fetchHeaders = getFetchHeaders();
fetch(url, {method: "post", body: JSON.stringify(activeState), headers: fetchHeaders}).then((resp) => handleJsonFetchResponse(url, resp)).catch((err) => {
console.log("error logging active state", err)
});
// for next iteration
wasInFg = (MainWindow != null && MainWindow.isFocused());
wasActive = false;
}
// this isn't perfect, but gets the job done without being complicated
function runActiveTimer() {
logActiveState();
setTimeout(runActiveTimer, 60000);
}
// ====== MAIN ====== //
@ -501,6 +528,7 @@ async function sleep(ms) {
console.log(e.toString());
}
await sleep(1000); // TODO remove this sleep, poll getClientData() in createMainWindow
setTimeout(runActiveTimer, 5000); // start active timer, wait 5s just to be safe
await app.whenReady();
await createMainWindowWrap();
app.on('activate', () => {

View File

@ -3,7 +3,7 @@ const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const VERSION = "v0.1.0";
const VERSION = "v0.1.1";
var merged = merge.merge(common, {
mode: "development",

View File

@ -2,7 +2,7 @@ const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.electron.js');
const moment = require("dayjs");
const VERSION = "v0.1.0";
const VERSION = "v0.1.1";
const path = require("path");
function makeBuildStr() {

View File

@ -2,7 +2,7 @@ const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const moment = require("dayjs");
const VERSION = "v0.1.0";
const VERSION = "v0.1.1";
const path = require("path");
function makeBuildStr() {

890
yarn.lock

File diff suppressed because it is too large Load Diff