pinokiod 3.139.0 → 3.141.0
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/kernel/util.js +62 -13
- package/package.json +1 -1
- package/server/public/tab-idle-notifier.js +1 -1
- package/server/views/app.ejs +1 -1
package/kernel/util.js
CHANGED
|
@@ -33,6 +33,32 @@ const platform = os.platform()
|
|
|
33
33
|
const WINDOWS_TOAST_APP_ID = process.env.PINOKIO_WINDOWS_APP_ID || 'computer.pinokio'
|
|
34
34
|
const DEFAULT_CHIME_URL_PATH = '/chime.mp3'
|
|
35
35
|
const pushListeners = new Set()
|
|
36
|
+
let cachedMacNotifierPath
|
|
37
|
+
|
|
38
|
+
function resolveAsarPath(p) {
|
|
39
|
+
if (!p || p.includes('app.asar.unpacked')) {
|
|
40
|
+
return p
|
|
41
|
+
}
|
|
42
|
+
if (p.includes('app.asar')) {
|
|
43
|
+
return p.replace('app.asar', 'app.asar.unpacked')
|
|
44
|
+
}
|
|
45
|
+
return p
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getMacNotifierBinaryPath() {
|
|
49
|
+
if (cachedMacNotifierPath !== undefined) {
|
|
50
|
+
return cachedMacNotifierPath
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const notifierModulePath = require.resolve('toasted-notifier/notifiers/notificationcenter')
|
|
54
|
+
const binaryPath = resolveAsarPath(path.resolve(path.dirname(notifierModulePath), '../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier'))
|
|
55
|
+
cachedMacNotifierPath = binaryPath
|
|
56
|
+
return cachedMacNotifierPath
|
|
57
|
+
} catch (err) {
|
|
58
|
+
cachedMacNotifierPath = null
|
|
59
|
+
return cachedMacNotifierPath
|
|
60
|
+
}
|
|
61
|
+
}
|
|
36
62
|
|
|
37
63
|
function registerPushListener(listener) {
|
|
38
64
|
if (typeof listener !== 'function') {
|
|
@@ -63,15 +89,20 @@ function resolvePublicAssetUrl(filePath) {
|
|
|
63
89
|
return filePath
|
|
64
90
|
}
|
|
65
91
|
try {
|
|
66
|
-
const absolute = path.resolve(filePath)
|
|
92
|
+
const absolute = resolveAsarPath(path.resolve(filePath))
|
|
67
93
|
const publicRoot = path.resolve(__dirname, '../server/public')
|
|
68
|
-
|
|
94
|
+
const unpackedRoot = resolveAsarPath(publicRoot)
|
|
95
|
+
if (absolute === publicRoot || absolute === unpackedRoot) {
|
|
69
96
|
return '/'
|
|
70
97
|
}
|
|
71
|
-
if (absolute.startsWith(publicRoot + path.sep)
|
|
98
|
+
if (absolute.startsWith(publicRoot + path.sep)) {
|
|
72
99
|
const relative = path.relative(publicRoot, absolute).replace(/\\/g, '/')
|
|
73
100
|
return '/' + relative
|
|
74
101
|
}
|
|
102
|
+
if (absolute.startsWith(unpackedRoot + path.sep)) {
|
|
103
|
+
const relative = path.relative(unpackedRoot, absolute).replace(/\\/g, '/')
|
|
104
|
+
return '/' + relative
|
|
105
|
+
}
|
|
75
106
|
} catch (_) {
|
|
76
107
|
// ignore resolution failures
|
|
77
108
|
}
|
|
@@ -86,7 +117,7 @@ function soundTargetToClientUrl(target) {
|
|
|
86
117
|
return target.value
|
|
87
118
|
}
|
|
88
119
|
if (target.kind === 'file') {
|
|
89
|
-
const resolved = path.resolve(target.value)
|
|
120
|
+
const resolved = resolveAsarPath(path.resolve(target.value))
|
|
90
121
|
if (resolved === DEFAULT_CHIME_PATH) {
|
|
91
122
|
return DEFAULT_CHIME_URL_PATH
|
|
92
123
|
}
|
|
@@ -98,9 +129,11 @@ function ensureNotifierBinaries() {
|
|
|
98
129
|
if (platform !== 'darwin') {
|
|
99
130
|
return
|
|
100
131
|
}
|
|
132
|
+
const binaryPath = getMacNotifierBinaryPath()
|
|
133
|
+
if (!binaryPath) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
101
136
|
try {
|
|
102
|
-
const notifierModulePath = require.resolve('toasted-notifier/notifiers/notificationcenter')
|
|
103
|
-
const binaryPath = path.resolve(path.dirname(notifierModulePath), '../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier')
|
|
104
137
|
if (!fs.existsSync(binaryPath)) {
|
|
105
138
|
return
|
|
106
139
|
}
|
|
@@ -629,7 +662,7 @@ const linuxSoundCandidates = [
|
|
|
629
662
|
{ cmd: 'cvlc', args: (filePath) => ['--play-and-exit', filePath] },
|
|
630
663
|
]
|
|
631
664
|
let cachedLinuxSoundPlayer
|
|
632
|
-
const DEFAULT_CHIME_PATH = path.resolve(__dirname, '../server/public/chime.mp3')
|
|
665
|
+
const DEFAULT_CHIME_PATH = resolveAsarPath(path.resolve(__dirname, '../server/public/chime.mp3'))
|
|
633
666
|
function pickLinuxSoundPlayer() {
|
|
634
667
|
if (cachedLinuxSoundPlayer !== undefined) {
|
|
635
668
|
return cachedLinuxSoundPlayer
|
|
@@ -683,10 +716,10 @@ function playSoundFile(filePath) {
|
|
|
683
716
|
return null
|
|
684
717
|
}
|
|
685
718
|
if (platform === 'darwin') {
|
|
686
|
-
return spawn('afplay', [filePath], { stdio: 'ignore' })
|
|
719
|
+
return spawn('afplay', [resolveAsarPath(filePath)], { stdio: 'ignore' })
|
|
687
720
|
}
|
|
688
721
|
if (platform === 'win32') {
|
|
689
|
-
const fileUrl = pathToFileURL(filePath).href.replace(/'/g, "''")
|
|
722
|
+
const fileUrl = pathToFileURL(resolveAsarPath(filePath)).href.replace(/'/g, "''")
|
|
690
723
|
const script = [
|
|
691
724
|
"$ErrorActionPreference = 'Stop'",
|
|
692
725
|
"Add-Type -AssemblyName presentationCore",
|
|
@@ -704,7 +737,8 @@ function playSoundFile(filePath) {
|
|
|
704
737
|
if (!candidate) {
|
|
705
738
|
throw new Error('No supported audio player found for Linux (expected one of paplay, aplay, ffplay, mpg123, mplayer, cvlc).')
|
|
706
739
|
}
|
|
707
|
-
|
|
740
|
+
const preparedPath = resolveAsarPath(filePath)
|
|
741
|
+
return spawn(candidate.cmd, candidate.args(preparedPath), { stdio: 'ignore' })
|
|
708
742
|
}
|
|
709
743
|
function scheduleSoundPlayback(target) {
|
|
710
744
|
if (!target) {
|
|
@@ -715,7 +749,7 @@ function scheduleSoundPlayback(target) {
|
|
|
715
749
|
try {
|
|
716
750
|
let filePath
|
|
717
751
|
if (target.kind === 'file') {
|
|
718
|
-
filePath = target.value
|
|
752
|
+
filePath = resolveAsarPath(target.value)
|
|
719
753
|
} else if (target.kind === 'url') {
|
|
720
754
|
if (!HTTP_URL_REGEX.test(target.value)) {
|
|
721
755
|
throw new Error(`Unsupported sound URL: ${target.value}`)
|
|
@@ -791,17 +825,32 @@ function push(params) {
|
|
|
791
825
|
notifyParams.title = "Pinokio"
|
|
792
826
|
}
|
|
793
827
|
if (!notifyParams.contentImage) {
|
|
794
|
-
notifyParams.contentImage = path.resolve(__dirname, "../server/public/pinokio-black.png")
|
|
828
|
+
notifyParams.contentImage = resolveAsarPath(path.resolve(__dirname, "../server/public/pinokio-black.png"))
|
|
829
|
+
}
|
|
830
|
+
if (isNonEmptyString(notifyParams.contentImage) && !HTTP_URL_REGEX.test(notifyParams.contentImage)) {
|
|
831
|
+
notifyParams.contentImage = resolveAsarPath(notifyParams.contentImage)
|
|
832
|
+
}
|
|
833
|
+
if (isNonEmptyString(notifyParams.image) && !HTTP_URL_REGEX.test(notifyParams.image)) {
|
|
834
|
+
notifyParams.image = resolveAsarPath(notifyParams.image)
|
|
835
|
+
}
|
|
836
|
+
if (isNonEmptyString(notifyParams.icon) && !HTTP_URL_REGEX.test(notifyParams.icon)) {
|
|
837
|
+
notifyParams.icon = resolveAsarPath(notifyParams.icon)
|
|
795
838
|
}
|
|
796
839
|
if (platform === 'win32') {
|
|
797
840
|
// Ensure Windows toast branding aligns with Pinokio assets.
|
|
798
841
|
if (!notifyParams.icon && notifyParams.contentImage) {
|
|
799
|
-
notifyParams.icon = notifyParams.contentImage
|
|
842
|
+
notifyParams.icon = resolveAsarPath(notifyParams.contentImage)
|
|
800
843
|
}
|
|
801
844
|
if (!notifyParams.appID && !notifyParams.appName) {
|
|
802
845
|
notifyParams.appID = WINDOWS_TOAST_APP_ID
|
|
803
846
|
}
|
|
804
847
|
}
|
|
848
|
+
if (platform === 'darwin') {
|
|
849
|
+
const macNotifierPath = getMacNotifierBinaryPath()
|
|
850
|
+
if (macNotifierPath) {
|
|
851
|
+
notifyParams.customPath = macNotifierPath
|
|
852
|
+
}
|
|
853
|
+
}
|
|
805
854
|
|
|
806
855
|
const clientSoundUrl = soundTargetToClientUrl(customSoundTarget)
|
|
807
856
|
if (customSoundTarget) {
|
package/package.json
CHANGED
|
@@ -480,7 +480,7 @@ const ensureTabAccessories = aggregateDebounce(() => {
|
|
|
480
480
|
const title = tab ? tab.textContent.trim() : 'Tab activity';
|
|
481
481
|
//const subtitle = title || 'Pinokio';
|
|
482
482
|
//const message = state.lastInput ? `Last input: ${state.lastInput}` : 'Tab is now idle.';
|
|
483
|
-
const message = state.lastInput ? `
|
|
483
|
+
const message = state.lastInput ? `From: "${state.lastInput}"` : "Tab is now idle."
|
|
484
484
|
const image = resolveTabImage(link);
|
|
485
485
|
|
|
486
486
|
const payload = {
|
package/server/views/app.ejs
CHANGED
|
@@ -5213,7 +5213,7 @@ body.dark {
|
|
|
5213
5213
|
for(let frame of hardFrames) {
|
|
5214
5214
|
// Types of links in the tab
|
|
5215
5215
|
//if (String(port) === "<%=port%>") {
|
|
5216
|
-
if (String(port) === String(location.port) || /https
|
|
5216
|
+
if (String(port) === String(location.port) || /https:\/\/.+\.localhost/.test(origin)) {
|
|
5217
5217
|
// 1. running from <%=port%> => find a frame whose base URL matches the tab's base URL
|
|
5218
5218
|
// Pinokio links
|
|
5219
5219
|
let targetPath = new URL(target.href).pathname
|