Merge branch 'pickle-com:main' into main
This commit is contained in:
commit
22f53918e0
@ -13,6 +13,12 @@ publish:
|
|||||||
repo: glass
|
repo: glass
|
||||||
releaseType: draft
|
releaseType: draft
|
||||||
|
|
||||||
|
# Protocols configuration for deep linking
|
||||||
|
protocols:
|
||||||
|
name: PickleGlass Protocol
|
||||||
|
schemes:
|
||||||
|
- pickleglass
|
||||||
|
|
||||||
# List of files to be included in the app package
|
# List of files to be included in the app package
|
||||||
files:
|
files:
|
||||||
- src/**/*
|
- src/**/*
|
||||||
@ -29,6 +35,27 @@ extraResources:
|
|||||||
asarUnpack:
|
asarUnpack:
|
||||||
- "src/assets/SystemAudioDump"
|
- "src/assets/SystemAudioDump"
|
||||||
|
|
||||||
|
# Windows configuration
|
||||||
|
win:
|
||||||
|
icon: src/assets/logo.ico
|
||||||
|
target:
|
||||||
|
- target: nsis
|
||||||
|
arch: x64
|
||||||
|
- target: portable
|
||||||
|
arch: x64
|
||||||
|
publisherName: Pickle Team
|
||||||
|
requestedExecutionLevel: asInvoker
|
||||||
|
|
||||||
|
# NSIS installer configuration for Windows
|
||||||
|
nsis:
|
||||||
|
oneClick: false
|
||||||
|
perMachine: false
|
||||||
|
allowToChangeInstallationDirectory: true
|
||||||
|
deleteAppDataOnUninstall: true
|
||||||
|
createDesktopShortcut: always
|
||||||
|
createStartMenuShortcut: true
|
||||||
|
shortcutName: Glass
|
||||||
|
|
||||||
# macOS specific configuration
|
# macOS specific configuration
|
||||||
mac:
|
mac:
|
||||||
# The application category type
|
# The application category type
|
||||||
|
@ -2,9 +2,20 @@ const crypto = require('crypto');
|
|||||||
|
|
||||||
function ipcRequest(req, channel, payload) {
|
function ipcRequest(req, channel, payload) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
// 즉시 브리지 상태 확인 - 문제있으면 바로 실패
|
||||||
|
if (!req.bridge || typeof req.bridge.emit !== 'function') {
|
||||||
|
reject(new Error('IPC bridge is not available'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const responseChannel = `${channel}-${crypto.randomUUID()}`;
|
const responseChannel = `${channel}-${crypto.randomUUID()}`;
|
||||||
|
|
||||||
req.bridge.once(responseChannel, (response) => {
|
req.bridge.once(responseChannel, (response) => {
|
||||||
|
if (!response) {
|
||||||
|
reject(new Error(`No response received from ${channel}`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
} else {
|
} else {
|
||||||
@ -12,7 +23,12 @@ function ipcRequest(req, channel, payload) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
req.bridge.emit('web-data-request', channel, responseChannel, payload);
|
try {
|
||||||
|
req.bridge.emit('web-data-request', channel, responseChannel, payload);
|
||||||
|
} catch (error) {
|
||||||
|
req.bridge.removeAllListeners(responseChannel);
|
||||||
|
reject(new Error(`Failed to emit IPC request: ${error.message}`));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,22 @@ router.get('/profile', async (req, res) => {
|
|||||||
|
|
||||||
router.post('/find-or-create', async (req, res) => {
|
router.post('/find-or-create', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
console.log('[API] find-or-create request received:', req.body);
|
||||||
|
|
||||||
|
if (!req.body || !req.body.uid) {
|
||||||
|
return res.status(400).json({ error: 'User data with uid is required' });
|
||||||
|
}
|
||||||
|
|
||||||
const user = await ipcRequest(req, 'find-or-create-user', req.body);
|
const user = await ipcRequest(req, 'find-or-create-user', req.body);
|
||||||
|
console.log('[API] find-or-create response:', user);
|
||||||
res.status(200).json(user);
|
res.status(200).json(user);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to find or create user via IPC:', error);
|
console.error('Failed to find or create user via IPC:', error);
|
||||||
res.status(500).json({ error: 'Failed to find or create user' });
|
console.error('Request body:', req.body);
|
||||||
|
res.status(500).json({
|
||||||
|
error: 'Failed to find or create user',
|
||||||
|
details: error.message
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,8 +2,17 @@ const sqliteClient = require('../../services/sqliteClient');
|
|||||||
|
|
||||||
function findOrCreate(user) {
|
function findOrCreate(user) {
|
||||||
const db = sqliteClient.getDb();
|
const db = sqliteClient.getDb();
|
||||||
|
|
||||||
|
if (!user || !user.uid) {
|
||||||
|
throw new Error('User object and uid are required');
|
||||||
|
}
|
||||||
|
|
||||||
const { uid, displayName, email } = user;
|
const { uid, displayName, email } = user;
|
||||||
const now = Math.floor(Date.now() / 1000);
|
const now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
|
// Validate inputs
|
||||||
|
const safeDisplayName = displayName || 'User';
|
||||||
|
const safeEmail = email || 'no-email@example.com';
|
||||||
|
|
||||||
const query = `
|
const query = `
|
||||||
INSERT INTO users (uid, display_name, email, created_at)
|
INSERT INTO users (uid, display_name, email, created_at)
|
||||||
@ -14,11 +23,15 @@ function findOrCreate(user) {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db.prepare(query).run(uid, displayName, email, now);
|
console.log('[SQLite] Creating/updating user:', { uid, displayName: safeDisplayName, email: safeEmail });
|
||||||
return getById(uid);
|
db.prepare(query).run(uid, safeDisplayName, safeEmail, now);
|
||||||
|
const result = getById(uid);
|
||||||
|
console.log('[SQLite] User operation successful:', result);
|
||||||
|
return result;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('SQLite: Failed to find or create user:', err);
|
console.error('SQLite: Failed to find or create user:', err);
|
||||||
throw err;
|
console.error('SQLite: User data:', { uid, displayName: safeDisplayName, email: safeEmail });
|
||||||
|
throw new Error(`Failed to create user in database: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
70
src/index.js
70
src/index.js
@ -61,28 +61,28 @@ function setupProtocolHandling() {
|
|||||||
|
|
||||||
let protocolUrl = null;
|
let protocolUrl = null;
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
// Search through all command line arguments for a valid protocol URL
|
||||||
// Windows
|
for (const arg of commandLine) {
|
||||||
const lastArg = commandLine.length > 0 ? commandLine[commandLine.length - 1] : null;
|
if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {
|
||||||
if (lastArg &&
|
// Clean up the URL by removing problematic characters
|
||||||
typeof lastArg === 'string' &&
|
const cleanUrl = arg.replace(/[\\₩]/g, '');
|
||||||
lastArg.startsWith('pickleglass://') &&
|
|
||||||
!lastArg.includes('\\') &&
|
// Additional validation for Windows
|
||||||
!lastArg.includes('₩')) {
|
if (process.platform === 'win32') {
|
||||||
protocolUrl = lastArg;
|
// On Windows, ensure the URL doesn't contain file path indicators
|
||||||
}
|
if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {
|
||||||
} else {
|
protocolUrl = cleanUrl;
|
||||||
// Linux or etc
|
break;
|
||||||
const lastArg = commandLine.length > 0 ? commandLine[commandLine.length - 1] : null;
|
}
|
||||||
if (lastArg &&
|
} else {
|
||||||
typeof lastArg === 'string' &&
|
protocolUrl = cleanUrl;
|
||||||
lastArg.startsWith('pickleglass://')) {
|
break;
|
||||||
protocolUrl = lastArg;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocolUrl) {
|
if (protocolUrl) {
|
||||||
console.log('[Protocol] Valid URL found from second instance (last arg):', protocolUrl);
|
console.log('[Protocol] Valid URL found from second instance:', protocolUrl);
|
||||||
handleCustomUrl(protocolUrl);
|
handleCustomUrl(protocolUrl);
|
||||||
} else {
|
} else {
|
||||||
console.log('[Protocol] No valid protocol URL found in command line arguments');
|
console.log('[Protocol] No valid protocol URL found in command line arguments');
|
||||||
@ -135,16 +135,17 @@ function focusMainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
const lastArg = process.argv.length > 0 ? process.argv[process.argv.length - 1] : null;
|
for (const arg of process.argv) {
|
||||||
|
if (arg && typeof arg === 'string' && arg.startsWith('pickleglass://')) {
|
||||||
if (lastArg &&
|
// Clean up the URL by removing problematic characters (korean characters issue...)
|
||||||
typeof lastArg === 'string' &&
|
const cleanUrl = arg.replace(/[\\₩]/g, '');
|
||||||
lastArg.startsWith('pickleglass://') &&
|
|
||||||
!lastArg.includes('\\') &&
|
if (!cleanUrl.includes(':') || cleanUrl.indexOf('://') === cleanUrl.lastIndexOf(':')) {
|
||||||
!lastArg.includes('₩')) {
|
console.log('[Protocol] Found protocol URL in initial arguments:', cleanUrl);
|
||||||
|
pendingDeepLinkUrl = cleanUrl;
|
||||||
console.log('[Protocol] Found protocol URL in initial arguments (last arg):', lastArg);
|
break;
|
||||||
pendingDeepLinkUrl = lastArg;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[Protocol] Initial process.argv:', process.argv);
|
console.log('[Protocol] Initial process.argv:', process.argv);
|
||||||
@ -376,16 +377,19 @@ async function handleCustomUrl(url) {
|
|||||||
try {
|
try {
|
||||||
console.log('[Custom URL] Processing URL:', url);
|
console.log('[Custom URL] Processing URL:', url);
|
||||||
|
|
||||||
// val url
|
// Validate and clean URL
|
||||||
if (!url || typeof url !== 'string' || !url.startsWith('pickleglass://')) {
|
if (!url || typeof url !== 'string' || !url.startsWith('pickleglass://')) {
|
||||||
console.error('[Custom URL] Invalid URL format:', url);
|
console.error('[Custom URL] Invalid URL format:', url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// val url
|
// Clean up URL by removing problematic characters
|
||||||
if (url.includes('\\') || url.includes('₩')) {
|
const cleanUrl = url.replace(/[\\₩]/g, '');
|
||||||
console.error('[Custom URL] URL contains invalid path characters:', url);
|
|
||||||
return;
|
// Additional validation
|
||||||
|
if (cleanUrl !== url) {
|
||||||
|
console.log('[Custom URL] Cleaned URL from:', url, 'to:', cleanUrl);
|
||||||
|
url = cleanUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user