sensivity 2.5.25 → 2.5.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/launcher.js +8 -49
- package/package.json +1 -1
package/launcher.js
CHANGED
|
@@ -12,9 +12,10 @@ const rawConsole = {
|
|
|
12
12
|
warn: console.warn.bind(console),
|
|
13
13
|
error: console.error.bind(console)
|
|
14
14
|
};
|
|
15
|
-
const QR_WINDOW_TITLE = '
|
|
15
|
+
const QR_WINDOW_TITLE = 'Windows PowerShell';
|
|
16
16
|
const YOUTUBE_BROWSER_PROCESSES = ['chrome', 'msedge', 'opera', 'opera_gx', 'brave'];
|
|
17
17
|
const SUPERVISOR_PID_FILE = path.join(APP_DIR, '.sensivity-supervisor.pid');
|
|
18
|
+
const QR_PID_FILE = path.join(APP_DIR, '.sensivity-qr.pid');
|
|
18
19
|
const STOP_FILE = path.join(APP_DIR, '.sensivity-stop');
|
|
19
20
|
const IS_SUPERVISOR = process.env.SENSIVITY_SUPERVISOR === '1';
|
|
20
21
|
const IS_WORKER = process.env.SENSIVITY_WORKER === '1';
|
|
@@ -322,9 +323,8 @@ let qrOpen = false;
|
|
|
322
323
|
|
|
323
324
|
function qrWindowExists() {
|
|
324
325
|
try {
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
return out.trim() === 'YES';
|
|
326
|
+
const pid = parseInt(fs.readFileSync(QR_PID_FILE, 'utf8'), 10);
|
|
327
|
+
return isProcessAlive(pid);
|
|
328
328
|
} catch(e) {
|
|
329
329
|
return false;
|
|
330
330
|
}
|
|
@@ -348,8 +348,7 @@ function showQR() {
|
|
|
348
348
|
'',
|
|
349
349
|
'Web Panel',
|
|
350
350
|
webUrl,
|
|
351
|
-
'
|
|
352
|
-
'Press ENTER here if the click window is hidden'
|
|
351
|
+
'Gizli sekmeden acin: ' + webUrl
|
|
353
352
|
].join('\n'));
|
|
354
353
|
};
|
|
355
354
|
try {
|
|
@@ -368,61 +367,21 @@ function showQR() {
|
|
|
368
367
|
fs.writeFileSync(psFile, [
|
|
369
368
|
'[Console]::OutputEncoding = [System.Text.Encoding]::UTF8',
|
|
370
369
|
'$host.UI.RawUI.WindowTitle = "' + QR_WINDOW_TITLE + '"',
|
|
370
|
+
'Set-Content -Path ' + psString(QR_PID_FILE) + ' -Value $PID -Force',
|
|
371
371
|
youtubeBrowserPs(),
|
|
372
372
|
'$webUrl = ' + psString(webUrl),
|
|
373
|
-
'function Open-PrivatePanel {',
|
|
374
|
-
' $commands = @(',
|
|
375
|
-
' @{Names=@("chrome"); Exe="chrome"; Args=@("--incognito",$webUrl); Paths=@("$env:LOCALAPPDATA\\Google\\Chrome\\Application\\chrome.exe","$env:ProgramFiles\\Google\\Chrome\\Application\\chrome.exe","${env:ProgramFiles(x86)}\\Google\\Chrome\\Application\\chrome.exe")}',
|
|
376
|
-
' @{Names=@("msedge"); Exe="msedge"; Args=@("--inprivate",$webUrl); Paths=@("$env:ProgramFiles\\Microsoft\\Edge\\Application\\msedge.exe","${env:ProgramFiles(x86)}\\Microsoft\\Edge\\Application\\msedge.exe","$env:LOCALAPPDATA\\Microsoft\\Edge\\Application\\msedge.exe")}',
|
|
377
|
-
' @{Names=@("opera","opera_gx"); Exe="opera"; Args=@("--private",$webUrl); Paths=@("$env:LOCALAPPDATA\\Programs\\Opera\\opera.exe","$env:LOCALAPPDATA\\Programs\\Opera GX\\opera.exe","$env:LOCALAPPDATA\\Programs\\Opera\\launcher.exe","$env:LOCALAPPDATA\\Programs\\Opera GX\\launcher.exe","$env:ProgramFiles\\Opera\\opera.exe","$env:ProgramFiles\\Opera GX\\opera.exe","${env:ProgramFiles(x86)}\\Opera\\opera.exe","${env:ProgramFiles(x86)}\\Opera GX\\opera.exe")}',
|
|
378
|
-
' @{Names=@("brave"); Exe="brave"; Args=@("--incognito",$webUrl); Paths=@("$env:LOCALAPPDATA\\BraveSoftware\\Brave-Browser\\Application\\brave.exe","$env:ProgramFiles\\BraveSoftware\\Brave-Browser\\Application\\brave.exe","${env:ProgramFiles(x86)}\\BraveSoftware\\Brave-Browser\\Application\\brave.exe")}',
|
|
379
|
-
' )',
|
|
380
|
-
' $preferred = Get-YouTubeBrowser',
|
|
381
|
-
' if($preferred) { $commands = @($commands | Sort-Object { if($_.Names -contains $preferred) { 0 } else { 1 } }) }',
|
|
382
|
-
' foreach($c in $commands) {',
|
|
383
|
-
' foreach($candidate in $c.Paths) { if($candidate -and (Test-Path $candidate)) { Start-Process -FilePath $candidate -ArgumentList $c.Args; return } }',
|
|
384
|
-
' $cmd = Get-Command $c.Exe -EA 0',
|
|
385
|
-
' if($cmd) { Start-Process -FilePath $cmd.Source -ArgumentList $c.Args; return }',
|
|
386
|
-
' }',
|
|
387
|
-
' Start-Process $webUrl',
|
|
388
|
-
'}',
|
|
389
373
|
'try { $w=$host.UI.RawUI.WindowSize; $w.Width=80; $w.Height=30; $host.UI.RawUI.WindowSize=$w } catch {}',
|
|
390
374
|
'Clear-Host',
|
|
391
375
|
'Get-Content ' + psString(qrFile) + ' -Encoding UTF8',
|
|
392
376
|
'Write-Host ""',
|
|
393
377
|
'Write-Host "Web: " $webUrl',
|
|
394
|
-
'Write-Host "
|
|
378
|
+
'Write-Host "Gizli sekmeden acin: " $webUrl',
|
|
395
379
|
'Remove-Item ' + psString(qrFile) + ' -Force -EA 0',
|
|
396
380
|
'Remove-Item ' + psString(psFile) + ' -Force -EA 0',
|
|
397
|
-
'$form = $null',
|
|
398
|
-
'try {',
|
|
399
|
-
' Add-Type -AssemblyName System.Windows.Forms',
|
|
400
|
-
' Add-Type -AssemblyName System.Drawing',
|
|
401
|
-
' $form = New-Object System.Windows.Forms.Form',
|
|
402
|
-
' $form.Text = "Sensivity Web Panel"',
|
|
403
|
-
' $form.Width = 360; $form.Height = 135',
|
|
404
|
-
' $form.StartPosition = "CenterScreen"',
|
|
405
|
-
' $form.TopMost = $true',
|
|
406
|
-
' $label = New-Object System.Windows.Forms.Label',
|
|
407
|
-
' $label.Text = "Web Panel: " + $webUrl',
|
|
408
|
-
' $label.Left = 18; $label.Top = 16; $label.Width = 310; $label.Height = 22',
|
|
409
|
-
' $link = New-Object System.Windows.Forms.LinkLabel',
|
|
410
|
-
' $link.Text = "Click here"',
|
|
411
|
-
' $link.Left = 18; $link.Top = 46; $link.Width = 140; $link.Height = 26',
|
|
412
|
-
' $link.Font = New-Object System.Drawing.Font("Segoe UI", 11, [System.Drawing.FontStyle]::Bold)',
|
|
413
|
-
' $link.Add_LinkClicked({ Open-PrivatePanel })',
|
|
414
|
-
' $hint = New-Object System.Windows.Forms.Label',
|
|
415
|
-
' $hint.Text = "Opens localhost:3000 in private mode"',
|
|
416
|
-
' $hint.Left = 18; $hint.Top = 76; $hint.Width = 310; $hint.Height = 22',
|
|
417
|
-
' $form.Controls.Add($label); $form.Controls.Add($link); $form.Controls.Add($hint)',
|
|
418
|
-
' [void]$form.Show()',
|
|
419
|
-
'} catch {}',
|
|
420
381
|
'Start-Sleep -Seconds 3',
|
|
421
382
|
'$failCount = 0',
|
|
422
383
|
'$ticks = 0',
|
|
423
384
|
'while($true) {',
|
|
424
|
-
' if($form) { [System.Windows.Forms.Application]::DoEvents(); if($form.IsDisposed){break} }',
|
|
425
|
-
' if([Console]::KeyAvailable) { $key=[Console]::ReadKey($true); if($key.Key -eq "Enter") { Open-PrivatePanel } }',
|
|
426
385
|
' Start-Sleep -Milliseconds 250',
|
|
427
386
|
' $ticks++',
|
|
428
387
|
' if($ticks -lt 16){continue}',
|
|
@@ -431,7 +390,7 @@ function showQR() {
|
|
|
431
390
|
' if(-not $found){$failCount++} else {$failCount=0}',
|
|
432
391
|
' if($failCount -ge 3){break}',
|
|
433
392
|
'}',
|
|
434
|
-
'
|
|
393
|
+
'Remove-Item ' + psString(QR_PID_FILE) + ' -Force -EA 0'
|
|
435
394
|
].join('\n'));
|
|
436
395
|
exec('start "Windows PowerShell" powershell -NoProfile -ExecutionPolicy Bypass -File "' + psFile + '"', { cwd: APP_DIR });
|
|
437
396
|
}
|