mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-30 21:59:46 +02:00
Merge upstream/dev into feat/vision-autocomplete
This commit is contained in:
commit
d7315e7f27
142 changed files with 9440 additions and 3390 deletions
|
|
@ -30,6 +30,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0",
|
||||
"chokidar": "^5.0.0",
|
||||
"electron-store": "^11.0.2",
|
||||
"electron-updater": "^6.8.3",
|
||||
"get-port-please": "^3.2.0",
|
||||
"node-mac-permissions": "^2.5.0"
|
||||
|
|
|
|||
168
surfsense_desktop/pnpm-lock.yaml
generated
168
surfsense_desktop/pnpm-lock.yaml
generated
|
|
@ -11,6 +11,12 @@ importers:
|
|||
bindings:
|
||||
specifier: ^1.5.0
|
||||
version: 1.5.0
|
||||
chokidar:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
electron-store:
|
||||
specifier: ^11.0.2
|
||||
version: 11.0.2
|
||||
electron-updater:
|
||||
specifier: ^6.8.3
|
||||
version: 6.8.3
|
||||
|
|
@ -362,6 +368,14 @@ packages:
|
|||
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
ajv-formats@3.0.1:
|
||||
resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==}
|
||||
peerDependencies:
|
||||
ajv: ^8.0.0
|
||||
peerDependenciesMeta:
|
||||
ajv:
|
||||
optional: true
|
||||
|
||||
ajv-keywords@3.5.2:
|
||||
resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==}
|
||||
peerDependencies:
|
||||
|
|
@ -370,6 +384,9 @@ packages:
|
|||
ajv@6.14.0:
|
||||
resolution: {integrity: sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==}
|
||||
|
||||
ajv@8.18.0:
|
||||
resolution: {integrity: sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==}
|
||||
|
||||
ansi-regex@5.0.1:
|
||||
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
|
@ -421,6 +438,9 @@ packages:
|
|||
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
|
||||
engines: {node: '>= 4.0.0'}
|
||||
|
||||
atomically@2.1.1:
|
||||
resolution: {integrity: sha512-P4w9o2dqARji6P7MHprklbfiArZAWvo07yW7qs3pdljb3BWr12FIB7W+p0zJiuiVsUpRO0iZn1kFFcpPegg0tQ==}
|
||||
|
||||
axios@1.13.6:
|
||||
resolution: {integrity: sha512-ChTCHMouEe2kn713WHbQGcuYrr6fXTBiu460OTwWrWob16g1bXn4vtz07Ope7ewMozJAnEquLk5lWQWtBig9DQ==}
|
||||
|
||||
|
|
@ -490,6 +510,10 @@ packages:
|
|||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
chokidar@5.0.0:
|
||||
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
|
||||
engines: {node: '>= 20.19.0'}
|
||||
|
||||
chownr@3.0.0:
|
||||
resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -559,6 +583,10 @@ packages:
|
|||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
conf@15.1.0:
|
||||
resolution: {integrity: sha512-Uy5YN9KEu0WWDaZAVJ5FAmZoaJt9rdK6kH+utItPyGsCqCgaTKkrmZx3zoE0/3q6S3bcp3Ihkk+ZqPxWxFK5og==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
core-util-is@1.0.2:
|
||||
resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==}
|
||||
|
||||
|
|
@ -572,6 +600,10 @@ packages:
|
|||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
debounce-fn@6.0.0:
|
||||
resolution: {integrity: sha512-rBMW+F2TXryBwB54Q0d8drNEI+TfoS9JpNTAoVpukbWEhjXQq4rySFYLaqXMFXwdv61Zb2OHtj5bviSoimqxRQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
debug@4.4.3:
|
||||
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
|
||||
engines: {node: '>=6.0'}
|
||||
|
|
@ -623,6 +655,10 @@ packages:
|
|||
os: [darwin]
|
||||
hasBin: true
|
||||
|
||||
dot-prop@10.1.0:
|
||||
resolution: {integrity: sha512-MVUtAugQMOff5RnBy2d9N31iG0lNwg1qAoAOn7pOK5wf94WIaE3My2p3uwTQuvS2AcqchkcR3bHByjaM0mmi7Q==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
dotenv-expand@11.0.7:
|
||||
resolution: {integrity: sha512-zIHwmZPRshsCdpMDyVsqGmgyP0yT8GAgXUnkdAoJisxvf33k7yO6OuoKmcTGuXPWSsm8Oh88nZicRLA9Y0rUeA==}
|
||||
engines: {node: '>=12'}
|
||||
|
|
@ -658,6 +694,10 @@ packages:
|
|||
electron-publish@26.8.1:
|
||||
resolution: {integrity: sha512-q+jrSTIh/Cv4eGZa7oVR+grEJo/FoLMYBAnSL5GCtqwUpr1T+VgKB/dn1pnzxIxqD8S/jP1yilT9VrwCqINR4w==}
|
||||
|
||||
electron-store@11.0.2:
|
||||
resolution: {integrity: sha512-4VkNRdN+BImL2KcCi41WvAYbh6zLX5AUTi4so68yPqiItjbgTjqpEnGAqasgnG+lB6GuAyUltKwVopp6Uv+gwQ==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
electron-updater@6.8.3:
|
||||
resolution: {integrity: sha512-Z6sgw3jgbikWKXei1ENdqFOxBP0WlXg3TtKfz0rgw2vIZFJUyI4pD7ZN7jrkm7EoMK+tcm/qTnPUdqfZukBlBQ==}
|
||||
|
||||
|
|
@ -686,6 +726,10 @@ packages:
|
|||
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
env-paths@3.0.0:
|
||||
resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
err-code@2.0.3:
|
||||
resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==}
|
||||
|
||||
|
|
@ -739,6 +783,9 @@ packages:
|
|||
fast-json-stable-stringify@2.1.0:
|
||||
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
|
||||
|
||||
fast-uri@3.1.0:
|
||||
resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==}
|
||||
|
||||
fd-slicer@1.1.0:
|
||||
resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==}
|
||||
|
||||
|
|
@ -969,6 +1016,12 @@ packages:
|
|||
json-schema-traverse@0.4.1:
|
||||
resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}
|
||||
|
||||
json-schema-traverse@1.0.0:
|
||||
resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==}
|
||||
|
||||
json-schema-typed@8.0.2:
|
||||
resolution: {integrity: sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==}
|
||||
|
||||
json-stringify-safe@5.0.1:
|
||||
resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==}
|
||||
|
||||
|
|
@ -999,6 +1052,9 @@ packages:
|
|||
lodash@4.17.23:
|
||||
resolution: {integrity: sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==}
|
||||
|
||||
lodash@4.18.1:
|
||||
resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==}
|
||||
|
||||
log-symbols@4.1.0:
|
||||
resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==}
|
||||
engines: {node: '>=10'}
|
||||
|
|
@ -1043,6 +1099,10 @@ packages:
|
|||
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
mimic-function@5.0.1:
|
||||
resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
mimic-response@1.0.1:
|
||||
resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==}
|
||||
engines: {node: '>=4'}
|
||||
|
|
@ -1245,10 +1305,18 @@ packages:
|
|||
resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
readdirp@5.0.0:
|
||||
resolution: {integrity: sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==}
|
||||
engines: {node: '>= 20.19.0'}
|
||||
|
||||
require-directory@2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
require-from-string@2.0.2:
|
||||
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
resedit@1.7.2:
|
||||
resolution: {integrity: sha512-vHjcY2MlAITJhC0eRD/Vv8Vlgmu9Sd3LX9zZvtGzU5ZImdTN3+d6e/4mnTyV8vEbyf1sgNIrWxhWlrys52OkEA==}
|
||||
engines: {node: '>=12', npm: '>=6'}
|
||||
|
|
@ -1388,6 +1456,12 @@ packages:
|
|||
resolution: {integrity: sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
stubborn-fs@2.0.0:
|
||||
resolution: {integrity: sha512-Y0AvSwDw8y+nlSNFXMm2g6L51rBGdAQT20J3YSOqxC53Lo3bjWRtr2BKcfYoAf352WYpsZSTURrA0tqhfgudPA==}
|
||||
|
||||
stubborn-utils@1.0.2:
|
||||
resolution: {integrity: sha512-zOh9jPYI+xrNOyisSelgym4tolKTJCQd5GBhK0+0xJvcYDcwlOoxF/rnFKQ2KRZknXSG9jWAp66fwP6AxN9STg==}
|
||||
|
||||
sumchecker@3.0.1:
|
||||
resolution: {integrity: sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==}
|
||||
engines: {node: '>= 8.0'}
|
||||
|
|
@ -1400,6 +1474,10 @@ packages:
|
|||
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
tagged-tag@1.0.0:
|
||||
resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
tar@7.5.11:
|
||||
resolution: {integrity: sha512-ChjMH33/KetonMTAtpYdgUFr0tbz69Fp2v7zWxQfYZX4g5ZN2nOBXm1R2xyA+lMIKrLKIoKAwFj93jE/avX9cQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
|
@ -1442,11 +1520,19 @@ packages:
|
|||
resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
type-fest@5.5.0:
|
||||
resolution: {integrity: sha512-PlBfpQwiUvGViBNX84Yxwjsdhd1TUlXr6zjX7eoirtCPIr08NAmxwa+fcYBTeRQxHo9YC9wwF3m9i700sHma8g==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
typescript@5.9.3:
|
||||
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
uint8array-extras@1.5.0:
|
||||
resolution: {integrity: sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
undici-types@7.16.0:
|
||||
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
|
||||
|
||||
|
|
@ -1490,6 +1576,9 @@ packages:
|
|||
wcwidth@1.0.1:
|
||||
resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==}
|
||||
|
||||
when-exit@2.1.5:
|
||||
resolution: {integrity: sha512-VGkKJ564kzt6Ms1dbgPP/yuIoQCrsFAnRbptpC5wOEsDaNsbCB2bnfnaA8i/vRs5tjUSEOtIuvl9/MyVsvQZCg==}
|
||||
|
||||
which@2.0.2:
|
||||
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
|
@ -1850,6 +1939,10 @@ snapshots:
|
|||
|
||||
agent-base@7.1.4: {}
|
||||
|
||||
ajv-formats@3.0.1(ajv@8.18.0):
|
||||
optionalDependencies:
|
||||
ajv: 8.18.0
|
||||
|
||||
ajv-keywords@3.5.2(ajv@6.14.0):
|
||||
dependencies:
|
||||
ajv: 6.14.0
|
||||
|
|
@ -1861,6 +1954,13 @@ snapshots:
|
|||
json-schema-traverse: 0.4.1
|
||||
uri-js: 4.4.1
|
||||
|
||||
ajv@8.18.0:
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.3
|
||||
fast-uri: 3.1.0
|
||||
json-schema-traverse: 1.0.0
|
||||
require-from-string: 2.0.2
|
||||
|
||||
ansi-regex@5.0.1: {}
|
||||
|
||||
ansi-regex@6.2.2: {}
|
||||
|
|
@ -1932,6 +2032,11 @@ snapshots:
|
|||
|
||||
at-least-node@1.0.0: {}
|
||||
|
||||
atomically@2.1.1:
|
||||
dependencies:
|
||||
stubborn-fs: 2.0.0
|
||||
when-exit: 2.1.5
|
||||
|
||||
axios@1.13.6:
|
||||
dependencies:
|
||||
follow-redirects: 1.15.11
|
||||
|
|
@ -2046,6 +2151,10 @@ snapshots:
|
|||
ansi-styles: 4.3.0
|
||||
supports-color: 7.2.0
|
||||
|
||||
chokidar@5.0.0:
|
||||
dependencies:
|
||||
readdirp: 5.0.0
|
||||
|
||||
chownr@3.0.0: {}
|
||||
|
||||
chromium-pickle-js@0.2.0: {}
|
||||
|
|
@ -2106,6 +2215,18 @@ snapshots:
|
|||
tree-kill: 1.2.2
|
||||
yargs: 17.7.2
|
||||
|
||||
conf@15.1.0:
|
||||
dependencies:
|
||||
ajv: 8.18.0
|
||||
ajv-formats: 3.0.1(ajv@8.18.0)
|
||||
atomically: 2.1.1
|
||||
debounce-fn: 6.0.0
|
||||
dot-prop: 10.1.0
|
||||
env-paths: 3.0.0
|
||||
json-schema-typed: 8.0.2
|
||||
semver: 7.7.4
|
||||
uint8array-extras: 1.5.0
|
||||
|
||||
core-util-is@1.0.2:
|
||||
optional: true
|
||||
|
||||
|
|
@ -2123,6 +2244,10 @@ snapshots:
|
|||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
|
||||
debounce-fn@6.0.0:
|
||||
dependencies:
|
||||
mimic-function: 5.0.1
|
||||
|
||||
debug@4.4.3:
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
|
|
@ -2188,6 +2313,10 @@ snapshots:
|
|||
verror: 1.10.1
|
||||
optional: true
|
||||
|
||||
dot-prop@10.1.0:
|
||||
dependencies:
|
||||
type-fest: 5.5.0
|
||||
|
||||
dotenv-expand@11.0.7:
|
||||
dependencies:
|
||||
dotenv: 16.6.1
|
||||
|
|
@ -2246,6 +2375,11 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
electron-store@11.0.2:
|
||||
dependencies:
|
||||
conf: 15.1.0
|
||||
type-fest: 5.5.0
|
||||
|
||||
electron-updater@6.8.3:
|
||||
dependencies:
|
||||
builder-util-runtime: 9.5.1
|
||||
|
|
@ -2264,7 +2398,7 @@ snapshots:
|
|||
'@electron/asar': 3.4.1
|
||||
debug: 4.4.3
|
||||
fs-extra: 7.0.1
|
||||
lodash: 4.17.23
|
||||
lodash: 4.18.1
|
||||
temp: 0.9.4
|
||||
optionalDependencies:
|
||||
'@electron/windows-sign': 1.2.2
|
||||
|
|
@ -2294,6 +2428,8 @@ snapshots:
|
|||
|
||||
env-paths@2.2.1: {}
|
||||
|
||||
env-paths@3.0.0: {}
|
||||
|
||||
err-code@2.0.3: {}
|
||||
|
||||
es-define-property@1.0.1: {}
|
||||
|
|
@ -2367,6 +2503,8 @@ snapshots:
|
|||
|
||||
fast-json-stable-stringify@2.1.0: {}
|
||||
|
||||
fast-uri@3.1.0: {}
|
||||
|
||||
fd-slicer@1.1.0:
|
||||
dependencies:
|
||||
pend: 1.2.0
|
||||
|
|
@ -2624,6 +2762,10 @@ snapshots:
|
|||
|
||||
json-schema-traverse@0.4.1: {}
|
||||
|
||||
json-schema-traverse@1.0.0: {}
|
||||
|
||||
json-schema-typed@8.0.2: {}
|
||||
|
||||
json-stringify-safe@5.0.1:
|
||||
optional: true
|
||||
|
||||
|
|
@ -2651,6 +2793,8 @@ snapshots:
|
|||
|
||||
lodash@4.17.23: {}
|
||||
|
||||
lodash@4.18.1: {}
|
||||
|
||||
log-symbols@4.1.0:
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
|
|
@ -2697,6 +2841,8 @@ snapshots:
|
|||
|
||||
mimic-fn@2.1.0: {}
|
||||
|
||||
mimic-function@5.0.1: {}
|
||||
|
||||
mimic-response@1.0.1: {}
|
||||
|
||||
mimic-response@3.1.0: {}
|
||||
|
|
@ -2899,8 +3045,12 @@ snapshots:
|
|||
string_decoder: 1.3.0
|
||||
util-deprecate: 1.0.2
|
||||
|
||||
readdirp@5.0.0: {}
|
||||
|
||||
require-directory@2.1.1: {}
|
||||
|
||||
require-from-string@2.0.2: {}
|
||||
|
||||
resedit@1.7.2:
|
||||
dependencies:
|
||||
pe-library: 0.4.1
|
||||
|
|
@ -3038,6 +3188,12 @@ snapshots:
|
|||
dependencies:
|
||||
ansi-regex: 6.2.2
|
||||
|
||||
stubborn-fs@2.0.0:
|
||||
dependencies:
|
||||
stubborn-utils: 1.0.2
|
||||
|
||||
stubborn-utils@1.0.2: {}
|
||||
|
||||
sumchecker@3.0.1:
|
||||
dependencies:
|
||||
debug: 4.4.3
|
||||
|
|
@ -3052,6 +3208,8 @@ snapshots:
|
|||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
|
||||
tagged-tag@1.0.0: {}
|
||||
|
||||
tar@7.5.11:
|
||||
dependencies:
|
||||
'@isaacs/fs-minipass': 4.0.1
|
||||
|
|
@ -3098,8 +3256,14 @@ snapshots:
|
|||
type-fest@0.13.1:
|
||||
optional: true
|
||||
|
||||
type-fest@5.5.0:
|
||||
dependencies:
|
||||
tagged-tag: 1.0.0
|
||||
|
||||
typescript@5.9.3: {}
|
||||
|
||||
uint8array-extras@1.5.0: {}
|
||||
|
||||
undici-types@7.16.0: {}
|
||||
|
||||
undici-types@7.18.2: {}
|
||||
|
|
@ -3145,6 +3309,8 @@ snapshots:
|
|||
dependencies:
|
||||
defaults: 1.0.4
|
||||
|
||||
when-exit@2.1.5: {}
|
||||
|
||||
which@2.0.2:
|
||||
dependencies:
|
||||
isexe: 2.0.0
|
||||
|
|
|
|||
|
|
@ -17,4 +17,19 @@ export const IPC_CHANNELS = {
|
|||
DISMISS_SUGGESTION: 'dismiss-suggestion',
|
||||
SET_AUTOCOMPLETE_ENABLED: 'set-autocomplete-enabled',
|
||||
GET_AUTOCOMPLETE_ENABLED: 'get-autocomplete-enabled',
|
||||
// Folder sync channels
|
||||
FOLDER_SYNC_SELECT_FOLDER: 'folder-sync:select-folder',
|
||||
FOLDER_SYNC_ADD_FOLDER: 'folder-sync:add-folder',
|
||||
FOLDER_SYNC_REMOVE_FOLDER: 'folder-sync:remove-folder',
|
||||
FOLDER_SYNC_GET_FOLDERS: 'folder-sync:get-folders',
|
||||
FOLDER_SYNC_GET_STATUS: 'folder-sync:get-status',
|
||||
FOLDER_SYNC_FILE_CHANGED: 'folder-sync:file-changed',
|
||||
FOLDER_SYNC_WATCHER_READY: 'folder-sync:watcher-ready',
|
||||
FOLDER_SYNC_PAUSE: 'folder-sync:pause',
|
||||
FOLDER_SYNC_RESUME: 'folder-sync:resume',
|
||||
FOLDER_SYNC_RENDERER_READY: 'folder-sync:renderer-ready',
|
||||
FOLDER_SYNC_GET_PENDING_EVENTS: 'folder-sync:get-pending-events',
|
||||
FOLDER_SYNC_ACK_EVENTS: 'folder-sync:ack-events',
|
||||
BROWSE_FILES: 'browse:files',
|
||||
READ_LOCAL_FILES: 'browse:read-local-files',
|
||||
} as const;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,20 @@ import {
|
|||
requestScreenRecording,
|
||||
restartApp,
|
||||
} from '../modules/permissions';
|
||||
import {
|
||||
selectFolder,
|
||||
addWatchedFolder,
|
||||
removeWatchedFolder,
|
||||
getWatchedFolders,
|
||||
getWatcherStatus,
|
||||
getPendingFileEvents,
|
||||
acknowledgeFileEvents,
|
||||
pauseWatcher,
|
||||
resumeWatcher,
|
||||
markRendererReady,
|
||||
browseFiles,
|
||||
readLocalFiles,
|
||||
} from '../modules/folder-watcher';
|
||||
|
||||
export function registerIpcHandlers(): void {
|
||||
ipcMain.on(IPC_CHANNELS.OPEN_EXTERNAL, (_event, url: string) => {
|
||||
|
|
@ -38,4 +52,41 @@ export function registerIpcHandlers(): void {
|
|||
ipcMain.handle(IPC_CHANNELS.RESTART_APP, () => {
|
||||
restartApp();
|
||||
});
|
||||
|
||||
// Folder sync handlers
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_SELECT_FOLDER, () => selectFolder());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_ADD_FOLDER, (_event, config) =>
|
||||
addWatchedFolder(config)
|
||||
);
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_REMOVE_FOLDER, (_event, folderPath: string) =>
|
||||
removeWatchedFolder(folderPath)
|
||||
);
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_GET_FOLDERS, () => getWatchedFolders());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_GET_STATUS, () => getWatcherStatus());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_PAUSE, () => pauseWatcher());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_RESUME, () => resumeWatcher());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_RENDERER_READY, () => {
|
||||
markRendererReady();
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_GET_PENDING_EVENTS, () =>
|
||||
getPendingFileEvents()
|
||||
);
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_ACK_EVENTS, (_event, eventIds: string[]) =>
|
||||
acknowledgeFileEvents(eventIds)
|
||||
);
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.BROWSE_FILES, () => browseFiles());
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.READ_LOCAL_FILES, (_event, paths: string[]) =>
|
||||
readLocalFiles(paths)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { setupAutoUpdater } from './modules/auto-updater';
|
|||
import { setupMenu } from './modules/menu';
|
||||
import { registerQuickAsk, unregisterQuickAsk } from './modules/quick-ask';
|
||||
import { registerAutocomplete, unregisterAutocomplete } from './modules/autocomplete';
|
||||
import { registerFolderWatcher, unregisterFolderWatcher } from './modules/folder-watcher';
|
||||
import { registerIpcHandlers } from './ipc/handlers';
|
||||
|
||||
registerGlobalErrorHandlers();
|
||||
|
|
@ -30,6 +31,7 @@ app.whenReady().then(async () => {
|
|||
createMainWindow('/dashboard');
|
||||
registerQuickAsk();
|
||||
registerAutocomplete();
|
||||
registerFolderWatcher();
|
||||
setupAutoUpdater();
|
||||
|
||||
handlePendingDeepLink();
|
||||
|
|
@ -50,4 +52,5 @@ app.on('window-all-closed', () => {
|
|||
app.on('will-quit', () => {
|
||||
unregisterQuickAsk();
|
||||
unregisterAutocomplete();
|
||||
unregisterFolderWatcher();
|
||||
});
|
||||
|
|
|
|||
534
surfsense_desktop/src/modules/folder-watcher.ts
Normal file
534
surfsense_desktop/src/modules/folder-watcher.ts
Normal file
|
|
@ -0,0 +1,534 @@
|
|||
import { BrowserWindow, dialog } from 'electron';
|
||||
import chokidar, { type FSWatcher } from 'chokidar';
|
||||
import { randomUUID } from 'crypto';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { IPC_CHANNELS } from '../ipc/channels';
|
||||
|
||||
export interface WatchedFolderConfig {
|
||||
path: string;
|
||||
name: string;
|
||||
excludePatterns: string[];
|
||||
fileExtensions: string[] | null;
|
||||
rootFolderId: number | null;
|
||||
searchSpaceId: number;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
interface WatcherEntry {
|
||||
config: WatchedFolderConfig;
|
||||
watcher: FSWatcher | null;
|
||||
}
|
||||
|
||||
type MtimeMap = Record<string, number>;
|
||||
type FolderSyncAction = 'add' | 'change' | 'unlink';
|
||||
|
||||
export interface FolderSyncFileChangedEvent {
|
||||
id: string;
|
||||
rootFolderId: number | null;
|
||||
searchSpaceId: number;
|
||||
folderPath: string;
|
||||
folderName: string;
|
||||
relativePath: string;
|
||||
fullPath: string;
|
||||
action: FolderSyncAction;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
const STORE_KEY = 'watchedFolders';
|
||||
const OUTBOX_STORE_KEY = 'events';
|
||||
const MTIME_TOLERANCE_S = 1.0;
|
||||
|
||||
let store: any = null;
|
||||
let mtimeStore: any = null;
|
||||
let outboxStore: any = null;
|
||||
let watchers: Map<string, WatcherEntry> = new Map();
|
||||
|
||||
/**
|
||||
* In-memory cache of mtime maps, keyed by folder path.
|
||||
* Persisted to electron-store on mutation.
|
||||
*/
|
||||
const mtimeMaps: Map<string, MtimeMap> = new Map();
|
||||
|
||||
let rendererReady = false;
|
||||
const outboxEvents: Map<string, FolderSyncFileChangedEvent> = new Map();
|
||||
let outboxLoaded = false;
|
||||
|
||||
export function markRendererReady() {
|
||||
rendererReady = true;
|
||||
}
|
||||
|
||||
async function getStore() {
|
||||
if (!store) {
|
||||
const { default: Store } = await import('electron-store');
|
||||
store = new Store({
|
||||
name: 'folder-watcher',
|
||||
defaults: {
|
||||
[STORE_KEY]: [] as WatchedFolderConfig[],
|
||||
},
|
||||
});
|
||||
}
|
||||
return store;
|
||||
}
|
||||
|
||||
async function getMtimeStore() {
|
||||
if (!mtimeStore) {
|
||||
const { default: Store } = await import('electron-store');
|
||||
mtimeStore = new Store({
|
||||
name: 'folder-mtime-maps',
|
||||
defaults: {} as Record<string, MtimeMap>,
|
||||
});
|
||||
}
|
||||
return mtimeStore;
|
||||
}
|
||||
|
||||
async function getOutboxStore() {
|
||||
if (!outboxStore) {
|
||||
const { default: Store } = await import('electron-store');
|
||||
outboxStore = new Store({
|
||||
name: 'folder-sync-outbox',
|
||||
defaults: {
|
||||
[OUTBOX_STORE_KEY]: [] as FolderSyncFileChangedEvent[],
|
||||
},
|
||||
});
|
||||
}
|
||||
return outboxStore;
|
||||
}
|
||||
|
||||
function makeEventKey(event: Pick<FolderSyncFileChangedEvent, 'folderPath' | 'relativePath'>): string {
|
||||
return `${event.folderPath}:${event.relativePath}`;
|
||||
}
|
||||
|
||||
function persistOutbox() {
|
||||
getOutboxStore().then((s) => {
|
||||
s.set(OUTBOX_STORE_KEY, Array.from(outboxEvents.values()));
|
||||
});
|
||||
}
|
||||
|
||||
async function loadOutbox() {
|
||||
if (outboxLoaded) return;
|
||||
const s = await getOutboxStore();
|
||||
const stored: FolderSyncFileChangedEvent[] = s.get(OUTBOX_STORE_KEY, []);
|
||||
outboxEvents.clear();
|
||||
for (const event of stored) {
|
||||
if (!event?.id || !event.folderPath || !event.relativePath) continue;
|
||||
outboxEvents.set(makeEventKey(event), event);
|
||||
}
|
||||
outboxLoaded = true;
|
||||
}
|
||||
|
||||
function sendFileChangedEvent(
|
||||
data: Omit<FolderSyncFileChangedEvent, 'id'>
|
||||
) {
|
||||
const event: FolderSyncFileChangedEvent = {
|
||||
id: randomUUID(),
|
||||
...data,
|
||||
};
|
||||
|
||||
outboxEvents.set(makeEventKey(event), event);
|
||||
persistOutbox();
|
||||
|
||||
if (rendererReady) {
|
||||
sendToRenderer(IPC_CHANNELS.FOLDER_SYNC_FILE_CHANGED, event);
|
||||
}
|
||||
}
|
||||
|
||||
function loadMtimeMap(folderPath: string): MtimeMap {
|
||||
return mtimeMaps.get(folderPath) ?? {};
|
||||
}
|
||||
|
||||
function persistMtimeMap(folderPath: string) {
|
||||
const map = mtimeMaps.get(folderPath) ?? {};
|
||||
getMtimeStore().then((s) => s.set(folderPath, map));
|
||||
}
|
||||
|
||||
function walkFolderMtimes(config: WatchedFolderConfig): MtimeMap {
|
||||
const root = config.path;
|
||||
const result: MtimeMap = {};
|
||||
const excludes = new Set(config.excludePatterns);
|
||||
|
||||
function walk(dir: string) {
|
||||
let entries: fs.Dirent[];
|
||||
try {
|
||||
entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const entry of entries) {
|
||||
const name = entry.name;
|
||||
|
||||
if (name.startsWith('.') || excludes.has(name)) continue;
|
||||
|
||||
const full = path.join(dir, name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
walk(full);
|
||||
} else if (entry.isFile()) {
|
||||
if (
|
||||
config.fileExtensions &&
|
||||
config.fileExtensions.length > 0
|
||||
) {
|
||||
const ext = path.extname(name).toLowerCase();
|
||||
if (!config.fileExtensions.includes(ext)) continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const stat = fs.statSync(full);
|
||||
const rel = path.relative(root, full);
|
||||
result[rel] = stat.mtimeMs;
|
||||
} catch {
|
||||
// File may have been removed between readdir and stat
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(root);
|
||||
return result;
|
||||
}
|
||||
|
||||
function getMainWindow(): BrowserWindow | null {
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
return windows.length > 0 ? windows[0] : null;
|
||||
}
|
||||
|
||||
function sendToRenderer(channel: string, data: any) {
|
||||
const win = getMainWindow();
|
||||
if (win && !win.isDestroyed()) {
|
||||
win.webContents.send(channel, data);
|
||||
}
|
||||
}
|
||||
|
||||
async function startWatcher(config: WatchedFolderConfig) {
|
||||
if (watchers.has(config.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ms = await getMtimeStore();
|
||||
const storedMap: MtimeMap = ms.get(config.path) ?? {};
|
||||
mtimeMaps.set(config.path, { ...storedMap });
|
||||
|
||||
const ignored = [
|
||||
/(^|[/\\])\../, // dotfiles by default
|
||||
...config.excludePatterns.map((p) => `**/${p}/**`),
|
||||
];
|
||||
|
||||
const watcher = chokidar.watch(config.path, {
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
awaitWriteFinish: {
|
||||
stabilityThreshold: 500,
|
||||
pollInterval: 100,
|
||||
},
|
||||
ignored,
|
||||
});
|
||||
|
||||
let ready = false;
|
||||
|
||||
watcher.on('ready', () => {
|
||||
ready = true;
|
||||
|
||||
const currentMap = walkFolderMtimes(config);
|
||||
const storedSnapshot = loadMtimeMap(config.path);
|
||||
const now = Date.now();
|
||||
|
||||
// Track which files are unchanged so we can selectively update the mtime map
|
||||
const unchangedMap: MtimeMap = {};
|
||||
|
||||
for (const [rel, currentMtime] of Object.entries(currentMap)) {
|
||||
const storedMtime = storedSnapshot[rel];
|
||||
if (storedMtime === undefined) {
|
||||
sendFileChangedEvent({
|
||||
rootFolderId: config.rootFolderId,
|
||||
searchSpaceId: config.searchSpaceId,
|
||||
folderPath: config.path,
|
||||
folderName: config.name,
|
||||
relativePath: rel,
|
||||
fullPath: path.join(config.path, rel),
|
||||
action: 'add',
|
||||
timestamp: now,
|
||||
});
|
||||
} else if (Math.abs(currentMtime - storedMtime) >= MTIME_TOLERANCE_S * 1000) {
|
||||
sendFileChangedEvent({
|
||||
rootFolderId: config.rootFolderId,
|
||||
searchSpaceId: config.searchSpaceId,
|
||||
folderPath: config.path,
|
||||
folderName: config.name,
|
||||
relativePath: rel,
|
||||
fullPath: path.join(config.path, rel),
|
||||
action: 'change',
|
||||
timestamp: now,
|
||||
});
|
||||
} else {
|
||||
unchangedMap[rel] = currentMtime;
|
||||
}
|
||||
}
|
||||
|
||||
for (const rel of Object.keys(storedSnapshot)) {
|
||||
if (!(rel in currentMap)) {
|
||||
sendFileChangedEvent({
|
||||
rootFolderId: config.rootFolderId,
|
||||
searchSpaceId: config.searchSpaceId,
|
||||
folderPath: config.path,
|
||||
folderName: config.name,
|
||||
relativePath: rel,
|
||||
fullPath: path.join(config.path, rel),
|
||||
action: 'unlink',
|
||||
timestamp: now,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Only update the mtime map for unchanged files; changed files keep their
|
||||
// stored mtime so they'll be re-detected if the app crashes before indexing.
|
||||
mtimeMaps.set(config.path, unchangedMap);
|
||||
persistMtimeMap(config.path);
|
||||
|
||||
sendToRenderer(IPC_CHANNELS.FOLDER_SYNC_WATCHER_READY, {
|
||||
rootFolderId: config.rootFolderId,
|
||||
folderPath: config.path,
|
||||
});
|
||||
});
|
||||
|
||||
const handleFileEvent = (filePath: string, action: FolderSyncAction) => {
|
||||
if (!ready) return;
|
||||
|
||||
const relativePath = path.relative(config.path, filePath);
|
||||
|
||||
if (
|
||||
config.fileExtensions &&
|
||||
config.fileExtensions.length > 0
|
||||
) {
|
||||
const ext = path.extname(filePath).toLowerCase();
|
||||
if (!config.fileExtensions.includes(ext)) return;
|
||||
}
|
||||
|
||||
const map = mtimeMaps.get(config.path);
|
||||
if (map) {
|
||||
if (action === 'unlink') {
|
||||
delete map[relativePath];
|
||||
} else {
|
||||
try {
|
||||
map[relativePath] = fs.statSync(filePath).mtimeMs;
|
||||
} catch {
|
||||
// File may have been removed between event and stat
|
||||
}
|
||||
}
|
||||
persistMtimeMap(config.path);
|
||||
}
|
||||
|
||||
sendFileChangedEvent({
|
||||
rootFolderId: config.rootFolderId,
|
||||
searchSpaceId: config.searchSpaceId,
|
||||
folderPath: config.path,
|
||||
folderName: config.name,
|
||||
relativePath,
|
||||
fullPath: filePath,
|
||||
action,
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
watcher.on('add', (fp) => handleFileEvent(fp, 'add'));
|
||||
watcher.on('change', (fp) => handleFileEvent(fp, 'change'));
|
||||
watcher.on('unlink', (fp) => handleFileEvent(fp, 'unlink'));
|
||||
|
||||
watchers.set(config.path, { config, watcher });
|
||||
}
|
||||
|
||||
function stopWatcher(folderPath: string) {
|
||||
persistMtimeMap(folderPath);
|
||||
const entry = watchers.get(folderPath);
|
||||
if (entry?.watcher) {
|
||||
entry.watcher.close();
|
||||
}
|
||||
watchers.delete(folderPath);
|
||||
}
|
||||
|
||||
export async function selectFolder(): Promise<string | null> {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory'],
|
||||
title: 'Select a folder to watch',
|
||||
});
|
||||
if (result.canceled || result.filePaths.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return result.filePaths[0];
|
||||
}
|
||||
|
||||
export async function addWatchedFolder(
|
||||
config: WatchedFolderConfig
|
||||
): Promise<WatchedFolderConfig[]> {
|
||||
const s = await getStore();
|
||||
const folders: WatchedFolderConfig[] = s.get(STORE_KEY, []);
|
||||
|
||||
const existing = folders.findIndex((f: WatchedFolderConfig) => f.path === config.path);
|
||||
if (existing >= 0) {
|
||||
folders[existing] = config;
|
||||
} else {
|
||||
folders.push(config);
|
||||
}
|
||||
|
||||
s.set(STORE_KEY, folders);
|
||||
|
||||
if (config.active) {
|
||||
await startWatcher(config);
|
||||
}
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
export async function removeWatchedFolder(
|
||||
folderPath: string
|
||||
): Promise<WatchedFolderConfig[]> {
|
||||
const s = await getStore();
|
||||
const folders: WatchedFolderConfig[] = s.get(STORE_KEY, []);
|
||||
const updated = folders.filter((f: WatchedFolderConfig) => f.path !== folderPath);
|
||||
s.set(STORE_KEY, updated);
|
||||
|
||||
stopWatcher(folderPath);
|
||||
|
||||
mtimeMaps.delete(folderPath);
|
||||
const ms = await getMtimeStore();
|
||||
ms.delete(folderPath);
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
export async function getWatchedFolders(): Promise<WatchedFolderConfig[]> {
|
||||
const s = await getStore();
|
||||
return s.get(STORE_KEY, []);
|
||||
}
|
||||
|
||||
export async function getWatcherStatus(): Promise<
|
||||
{ path: string; active: boolean; watching: boolean }[]
|
||||
> {
|
||||
const s = await getStore();
|
||||
const folders: WatchedFolderConfig[] = s.get(STORE_KEY, []);
|
||||
return folders.map((f: WatchedFolderConfig) => ({
|
||||
path: f.path,
|
||||
active: f.active,
|
||||
watching: watchers.has(f.path),
|
||||
}));
|
||||
}
|
||||
|
||||
export async function getPendingFileEvents(): Promise<FolderSyncFileChangedEvent[]> {
|
||||
await loadOutbox();
|
||||
return Array.from(outboxEvents.values()).sort((a, b) => a.timestamp - b.timestamp);
|
||||
}
|
||||
|
||||
export async function acknowledgeFileEvents(eventIds: string[]): Promise<{ acknowledged: number }> {
|
||||
if (!eventIds || eventIds.length === 0) return { acknowledged: 0 };
|
||||
await loadOutbox();
|
||||
|
||||
const ackSet = new Set(eventIds);
|
||||
let acknowledged = 0;
|
||||
|
||||
for (const [key, event] of outboxEvents.entries()) {
|
||||
if (ackSet.has(event.id)) {
|
||||
outboxEvents.delete(key);
|
||||
acknowledged += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (acknowledged > 0) {
|
||||
persistOutbox();
|
||||
}
|
||||
|
||||
return { acknowledged };
|
||||
}
|
||||
|
||||
export async function pauseWatcher(): Promise<void> {
|
||||
for (const [, entry] of watchers) {
|
||||
if (entry.watcher) {
|
||||
await entry.watcher.close();
|
||||
entry.watcher = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function resumeWatcher(): Promise<void> {
|
||||
for (const [, entry] of watchers) {
|
||||
if (!entry.watcher && entry.config.active) {
|
||||
await startWatcher(entry.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function registerFolderWatcher(): Promise<void> {
|
||||
await loadOutbox();
|
||||
const s = await getStore();
|
||||
const folders: WatchedFolderConfig[] = s.get(STORE_KEY, []);
|
||||
|
||||
for (const config of folders) {
|
||||
if (config.active && fs.existsSync(config.path)) {
|
||||
await startWatcher(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function unregisterFolderWatcher(): Promise<void> {
|
||||
for (const [folderPath] of watchers) {
|
||||
stopWatcher(folderPath);
|
||||
}
|
||||
watchers.clear();
|
||||
}
|
||||
|
||||
export async function browseFiles(): Promise<string[] | null> {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
title: 'Select files',
|
||||
});
|
||||
if (result.canceled || result.filePaths.length === 0) return null;
|
||||
return result.filePaths;
|
||||
}
|
||||
|
||||
const MIME_MAP: Record<string, string> = {
|
||||
'.pdf': 'application/pdf',
|
||||
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'.html': 'text/html', '.htm': 'text/html',
|
||||
'.csv': 'text/csv',
|
||||
'.txt': 'text/plain',
|
||||
'.md': 'text/markdown', '.markdown': 'text/markdown',
|
||||
'.mp3': 'audio/mpeg', '.mpeg': 'audio/mpeg', '.mpga': 'audio/mpeg',
|
||||
'.mp4': 'audio/mp4', '.m4a': 'audio/mp4',
|
||||
'.wav': 'audio/wav',
|
||||
'.webm': 'audio/webm',
|
||||
'.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',
|
||||
'.png': 'image/png',
|
||||
'.bmp': 'image/bmp',
|
||||
'.webp': 'image/webp',
|
||||
'.tiff': 'image/tiff',
|
||||
'.doc': 'application/msword',
|
||||
'.rtf': 'application/rtf',
|
||||
'.xml': 'application/xml',
|
||||
'.epub': 'application/epub+zip',
|
||||
'.xls': 'application/vnd.ms-excel',
|
||||
'.ppt': 'application/vnd.ms-powerpoint',
|
||||
'.eml': 'message/rfc822',
|
||||
'.odt': 'application/vnd.oasis.opendocument.text',
|
||||
'.msg': 'application/vnd.ms-outlook',
|
||||
};
|
||||
|
||||
export interface LocalFileData {
|
||||
name: string;
|
||||
data: ArrayBuffer;
|
||||
mimeType: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export function readLocalFiles(filePaths: string[]): LocalFileData[] {
|
||||
return filePaths.map((p) => {
|
||||
const buf = fs.readFileSync(p);
|
||||
const ext = path.extname(p).toLowerCase();
|
||||
return {
|
||||
name: path.basename(p),
|
||||
data: buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength),
|
||||
mimeType: MIME_MAP[ext] || 'application/octet-stream',
|
||||
size: buf.byteLength,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -38,4 +38,34 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||
dismissSuggestion: () => ipcRenderer.invoke(IPC_CHANNELS.DISMISS_SUGGESTION),
|
||||
setAutocompleteEnabled: (enabled: boolean) => ipcRenderer.invoke(IPC_CHANNELS.SET_AUTOCOMPLETE_ENABLED, enabled),
|
||||
getAutocompleteEnabled: () => ipcRenderer.invoke(IPC_CHANNELS.GET_AUTOCOMPLETE_ENABLED),
|
||||
|
||||
// Folder sync
|
||||
selectFolder: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_SELECT_FOLDER),
|
||||
addWatchedFolder: (config: any) => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_ADD_FOLDER, config),
|
||||
removeWatchedFolder: (folderPath: string) => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_REMOVE_FOLDER, folderPath),
|
||||
getWatchedFolders: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_GET_FOLDERS),
|
||||
getWatcherStatus: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_GET_STATUS),
|
||||
onFileChanged: (callback: (data: any) => void) => {
|
||||
const listener = (_event: unknown, data: any) => callback(data);
|
||||
ipcRenderer.on(IPC_CHANNELS.FOLDER_SYNC_FILE_CHANGED, listener);
|
||||
return () => {
|
||||
ipcRenderer.removeListener(IPC_CHANNELS.FOLDER_SYNC_FILE_CHANGED, listener);
|
||||
};
|
||||
},
|
||||
onWatcherReady: (callback: (data: any) => void) => {
|
||||
const listener = (_event: unknown, data: any) => callback(data);
|
||||
ipcRenderer.on(IPC_CHANNELS.FOLDER_SYNC_WATCHER_READY, listener);
|
||||
return () => {
|
||||
ipcRenderer.removeListener(IPC_CHANNELS.FOLDER_SYNC_WATCHER_READY, listener);
|
||||
};
|
||||
},
|
||||
pauseWatcher: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_PAUSE),
|
||||
resumeWatcher: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_RESUME),
|
||||
signalRendererReady: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_RENDERER_READY),
|
||||
getPendingFileEvents: () => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_GET_PENDING_EVENTS),
|
||||
acknowledgeFileEvents: (eventIds: string[]) => ipcRenderer.invoke(IPC_CHANNELS.FOLDER_SYNC_ACK_EVENTS, eventIds),
|
||||
|
||||
// Browse files via native dialog
|
||||
browseFiles: () => ipcRenderer.invoke(IPC_CHANNELS.BROWSE_FILES),
|
||||
readLocalFiles: (paths: string[]) => ipcRenderer.invoke(IPC_CHANNELS.READ_LOCAL_FILES, paths),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue