Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/crisp-impalas-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Revert debug information
6 changes: 6 additions & 0 deletions .changeset/cuddly-books-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Add ignore signal and improve multi-channel polyimc handling
6 changes: 6 additions & 0 deletions .changeset/green-laws-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Fix polyIMC any channel would handle all channels under same window (view) ID
6 changes: 6 additions & 0 deletions .changeset/modern-stamps-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Fix platformAPI for FS
24 changes: 14 additions & 10 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"mode": "pre",
"tag": "alpha",
"tag": "beta",
"initialVersions": {
"pulse-editor-desktop": "0.0.1",
"pulse-editor-mobile": "0.0.1",
"@pulse-editor/react-api": "0.1.1-beta.1",
"@pulse-editor/shared-utils": "0.1.1-beta.1",
"pulse-editor-vscode": "0.0.3",
"@pulse-editor/web": "0.1.1-beta.1",
"@pulse-editor/desktop": "0.0.1",
"@pulse-editor/capacitor-plugin": "0.0.1",
"@pulse-editor/mobile": "0.0.1",
"@pulse-editor/capacitor-plugin": "0.0.1"
"@pulse-editor/react-api": "0.1.1-alpha.54",
"@pulse-editor/shared-utils": "0.1.1-alpha.54",
"pulse-editor-vscode": "0.0.3",
"@pulse-editor/web": "0.1.1-alpha.13"
},
"changesets": [
"angry-llamas-smash",
Expand All @@ -22,8 +19,10 @@
"clean-mangos-swim",
"cold-shrimps-give",
"crazy-cities-stand",
"crisp-impalas-search",
"cruel-waves-double",
"cruel-zoos-play",
"cuddly-books-send",
"curvy-places-wash",
"cute-foxes-wink",
"dirty-swans-rescue",
Expand All @@ -35,11 +34,13 @@
"fruity-goats-look",
"full-beans-stop",
"fuzzy-sheep-pay",
"green-laws-lose",
"hot-symbols-fry",
"hot-windows-march",
"large-moose-tap",
"lazy-zebras-mate",
"mighty-ghosts-crash",
"modern-stamps-learn",
"odd-hounds-enjoy",
"petite-memes-fix",
"polite-lines-dance",
Expand All @@ -51,16 +52,19 @@
"sharp-memes-give",
"shiny-doodles-jump",
"silent-glasses-kick",
"slick-olives-wink",
"slick-roses-fix",
"social-donkeys-cross",
"soft-cases-share",
"stale-groups-poke",
"sunny-symbols-flash",
"tender-jeans-occur",
"tender-phones-ring",
"tough-aliens-appear",
"true-suits-fly",
"vast-places-rhyme",
"weak-beers-watch",
"wicked-spoons-fry"
"wicked-spoons-fry",
"young-jeans-behave"
]
}
6 changes: 6 additions & 0 deletions .changeset/slick-olives-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Release BETA packages
6 changes: 6 additions & 0 deletions .changeset/sunny-symbols-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Fix imc intent typo
6 changes: 6 additions & 0 deletions .changeset/young-jeans-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pulse-editor/shared-utils": patch
"@pulse-editor/react-api": patch
---

Fix IMC handshake async bug
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-tailwindcss"
]
}
16 changes: 8 additions & 8 deletions desktop/forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ForgeConfig } from "@electron-forge/shared-types";
import path from "path";
import fs from "fs-extra";
import path from "path";

function moveModule(moduleList: string[], resourcePath: string) {
function copyModule(moduleList: string[], resourcePath: string) {
moduleList.forEach((module) => {
fs.moveSync(
fs.copySync(
path.join("./node_modules", module),
path.join(resourcePath, "app/node_modules", module)
path.join(resourcePath, "app/node_modules", module),
);
});
}
Expand All @@ -27,11 +27,11 @@ const config: ForgeConfig = {
// We need electron-serve to exist inside the electron build's node_modules.
// All other modules from nextjs are not needed and can be removed.
if (platform === "win32") {
moveModule(electronModules, path.join(extractPath, "resources"));
copyModule(electronModules, path.join(extractPath, "resources"));
} else if (platform === "darwin") {
moveModule(
copyModule(
electronModules,
path.join(extractPath, "pulse-editor.app/Contents/Resources")
path.join(extractPath, "pulse-editor.app/Contents/Resources"),
);
} else if (platform === "linux") {
}
Expand All @@ -47,7 +47,7 @@ const config: ForgeConfig = {
options: {
icon: path.join(
__dirname,
"../shared-assets/icons/electron/pulse_logo_round"
"../shared-assets/icons/electron/pulse_logo_round",
),
},
},
Expand Down
30 changes: 13 additions & 17 deletions desktop/lib/node-pty-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from "http";
import { WebSocketServer } from "ws";
import os from "os";
import pty from "node-pty";
import os from "os";
import { WebSocketServer } from "ws";

let sharedPtyProcess = null;
let sharedTerminalMode = false;
Expand All @@ -25,14 +25,20 @@ const setSharedTerminalMode = (useSharedTerminal) => {
const handleTerminalConnection = (ws) => {
let ptyProcess = sharedTerminalMode ? sharedPtyProcess : spawnShell();

ws.on("message", (command) => {
const processedCommand = commandProcessor(command);
ptyProcess.write(processedCommand);
ws.on("message", (data) => {
const dataObj = JSON.parse(data);

if (dataObj.type === "input") {
const command = dataObj.payload;
ptyProcess.write(command);
} else if (dataObj.type === "resize") {
const { cols, rows } = dataObj.payload;
ptyProcess.resize(cols, rows);
}
});

ptyProcess.on("data", (rawOutput) => {
const processedOutput = outputProcessor(rawOutput);
ws.send(processedOutput);
ws.send(JSON.stringify({ type: "output", payload: rawOutput }));
});

ws.on("close", () => {
Expand All @@ -42,16 +48,6 @@ const handleTerminalConnection = (ws) => {
});
};

// Utility function to process commands
const commandProcessor = (command) => {
return command;
};

// Utility function to process output
const outputProcessor = (output) => {
return output;
};

/* Host ws node-pty server */
setSharedTerminalMode(false); // Set this to false to allow a shared session
const port = 6060;
Expand Down
89 changes: 83 additions & 6 deletions desktop/main.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { app, BrowserWindow, dialog, ipcMain } from "electron";
import { app, BrowserWindow, dialog, ipcMain, session } from "electron";
import serve from "electron-serve";
import path from "path";
import { fileURLToPath } from "url";

import fs from "fs";
import { createTerminalServer } from "./lib/node-pty-server.js";
import ignore from "ignore";
import { createTerminalServer } from "./lib/node-pty-server.js";

// Change path to "Pulse Editor"
app.setName("Pulse Editor");
app.setPath(
"userData",
app.getPath("userData").replace("pulse-editor-desktop", "Pulse Editor")
app.getPath("userData").replace("pulse-editor-desktop", "Pulse Editor"),
);

// Get the file path of the current module
Expand All @@ -34,7 +34,9 @@ serve({
scheme: "extension",
});

function createWindow() {
let mainWindow = null;

function createMainWindow() {
const win = new BrowserWindow({
width: 960,
height: 600,
Expand All @@ -47,6 +49,7 @@ function createWindow() {
},
icon: path.join(__dirname, "../shared-assets/icons/electron/pulse_editor"),
});
mainWindow = win;

win.menuBarVisible = false;

Expand Down Expand Up @@ -134,7 +137,7 @@ async function listPathContent(uri, options, baseUri = undefined) {
(file) =>
(options?.include === "folders" && file.isDirectory()) ||
(options?.include === "files" && file.isFile()) ||
options?.include === "all"
options?.include === "all",
)
// Filter by gitignore
.filter((file) => {
Expand Down Expand Up @@ -263,6 +266,77 @@ function handleGetInstallationPath(event) {
return uri;
}

async function handleLogin(event) {
const cookieName = "pulse-editor.session-token";

// Use the default session so cookies are shared automatically
const loginWindow = new BrowserWindow({
width: 600,
height: 700,
show: true,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
session: session.defaultSession, // ← important
},
});

const signinUrl = "https://pulse-editor.com/api/auth/signin";
await loginWindow.loadURL(signinUrl);

const loginSession = loginWindow.webContents.session;

const interval = setInterval(async () => {
try {
const cookies = await loginSession.cookies.get({ name: cookieName });
if (cookies.length > 0) {
clearInterval(interval);

// Login successful
loginWindow.close();
console.log(`Login successful, cookie "${cookieName}" present.`);

// Reload main window
if (mainWindow) {
mainWindow.reload();
}
}
} catch (err) {
console.error("Error checking cookie:", err);
}
}, 1000);
}

async function handleLogout() {
const mainSession = session.defaultSession;
const cookieName = "pulse-editor.session-token";

try {
const cookies = await mainSession.cookies.get({ name: cookieName });

for (const cookie of cookies) {
const url = cookie.domain.startsWith(".")
? `https://${cookie.domain.slice(1)}${cookie.path}`
: `https://${cookie.domain}${cookie.path}`;

await mainSession.cookies.remove(url, cookie.name);
}

console.log(`Cookie "${cookieName}" removed. Logout successful.`);

// Reload main window
if (mainWindow) {
mainWindow.reload();
}

// Return success to renderer
return { success: true };
} catch (err) {
console.error("Error during logout:", err);
return { success: false, error: err.message };
}
}

let isCreatedTerminal = false;
function handleCreateTerminal(event) {
if (!isCreatedTerminal) {
Expand Down Expand Up @@ -303,7 +377,10 @@ app.whenReady().then(() => {

ipcMain.handle("create-terminal", handleCreateTerminal);

createWindow();
ipcMain.handle("login", handleLogin);
ipcMain.handle("logout", handleLogout);

createMainWindow();
});

app.on("window-all-closed", () => {
Expand Down
Loading