@r_masseater/masseater-utils 0.9.0 → 0.9.2
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/README.md +1 -1
- package/dist/app-name.d.mts +1 -2
- package/dist/browser-test/vite.d.mts +1 -2
- package/dist/browser-test/vite.mjs +1 -1
- package/dist/{browser-test-vite-DS3fTcyM.mjs → browser-test-vite-DtB8cExi.mjs} +1 -1
- package/dist/{browser-test-vite-DS3fTcyM.mjs.map → browser-test-vite-DtB8cExi.mjs.map} +1 -1
- package/dist/{button-980Op0uF.mjs → button-Cu09f5VU.mjs} +4 -4
- package/dist/{button-980Op0uF.mjs.map → button-Cu09f5VU.mjs.map} +1 -1
- package/dist/{button-variants-BLMlMm-s.mjs → button-variants-BlDbQ4DD.mjs} +1 -1
- package/dist/{button-variants-BLMlMm-s.mjs.map → button-variants-BlDbQ4DD.mjs.map} +1 -1
- package/dist/{button-variants-Bupz7GI3.d.mts → button-variants-YGBhQ_mb.d.mts} +1 -2
- package/dist/{client-BS-MCJ0I.mjs → client-DX2jXirb.mjs} +39 -42
- package/dist/client-DX2jXirb.mjs.map +1 -0
- package/dist/{cn-DtxpfSUK.mjs → cn-COS9Py_F.mjs} +1 -1
- package/dist/{cn-DtxpfSUK.mjs.map → cn-COS9Py_F.mjs.map} +1 -1
- package/dist/{context-B_4aJtEC.mjs → context-COCO-Ecg.mjs} +1 -1
- package/dist/{context-B_4aJtEC.mjs.map → context-COCO-Ecg.mjs.map} +1 -1
- package/dist/desktop-shell/media-notes/protocol.d.mts +1 -1
- package/dist/desktop-shell/media-notes/protocol.mjs +1 -1
- package/dist/desktop-shell/media-notes.d.mts +5 -5
- package/dist/desktop-shell/media-notes.mjs +7 -7
- package/dist/desktop-shell/media-notes.mjs.map +1 -1
- package/dist/desktop-shell/release-cli.mjs +2 -2
- package/dist/desktop-shell/telemetry.d.mts +1 -2
- package/dist/desktop-shell/telemetry.mjs +2 -2
- package/dist/desktop-shell/vite.d.mts +1 -2
- package/dist/desktop-shell/vite.mjs +2 -2
- package/dist/effect2cs.d.mts +1 -2
- package/dist/effect2rs.d.mts +2 -3
- package/dist/effect2rs.mjs +4 -4
- package/dist/{failure-CjeINRVu.mjs → failure-BhLz69b6.mjs} +1 -1
- package/dist/{failure-CjeINRVu.mjs.map → failure-BhLz69b6.mjs.map} +1 -1
- package/dist/github-workflow.d.mts +2 -3
- package/dist/github-workflow.mjs +1 -1
- package/dist/{headers-Cr6gAurg.mjs → headers-Bpv9DhNS.mjs} +2 -2
- package/dist/{headers-Cr6gAurg.mjs.map → headers-Bpv9DhNS.mjs.map} +1 -1
- package/dist/{headers-BK-aW9Kw.d.mts → headers-NUwRihYD.d.mts} +1 -2
- package/dist/{heading-class-H4Z13Bpn.mjs → heading-class-Cj0jHgsZ.mjs} +1 -1
- package/dist/{heading-class-H4Z13Bpn.mjs.map → heading-class-Cj0jHgsZ.mjs.map} +1 -1
- package/dist/{heading-class-CDq0WZpR.d.mts → heading-class-DPbs-YiQ.d.mts} +1 -2
- package/dist/hook-flags.d.mts +1 -2
- package/dist/{index-CeVmiNfF.d.mts → index-1-4t9rX2.d.mts} +2 -3
- package/dist/{index-KNezbJnC.d.mts → index-2z0Rr69i.d.mts} +1 -2
- package/dist/{index-ChbPLmqu.d.mts → index-8ZrDzBaY.d.mts} +1 -2
- package/dist/{index-CjUS4pmA.d.mts → index-B9MYxbAp.d.mts} +2 -3
- package/dist/{index-BkZOsFv4.d.mts → index-BhIR7Vrb.d.mts} +1 -2
- package/dist/index-Cz3K0tg_.d.mts +3 -0
- package/dist/index-DJGZKGut.d.mts +5 -0
- package/dist/{index-CLb1-l_c.d.mts → index-DeL_mxdJ.d.mts} +2 -3
- package/dist/index-DgofHxew.d.mts +1 -0
- package/dist/{index-Cb8YSEwo.d.mts → index-DmIMnqv8.d.mts} +1 -2
- package/dist/kestrion/node.d.mts +1 -2
- package/dist/kestrion/npm.d.mts +2 -3
- package/dist/kestrion/npm.mjs +1 -1
- package/dist/kestrion/pnpm.d.mts +2 -3
- package/dist/kestrion/pnpm.mjs +4 -4
- package/dist/kestrion.d.mts +1 -1
- package/dist/kestrion.mjs +1 -1
- package/dist/lapse/sdk.d.mts +1 -2
- package/dist/lapse.d.mts +2 -3
- package/dist/lapse.mjs +1 -1
- package/dist/local-server/node.d.mts +2 -3
- package/dist/local-server/node.mjs +3 -3
- package/dist/local-server/node.mjs.map +1 -1
- package/dist/local-server/serve.d.mts +1 -2
- package/dist/local-server.d.mts +2 -3
- package/dist/local-server.mjs +1 -1
- package/dist/mapped-import/mapper.d.mts +2 -3
- package/dist/mapped-import/vite.d.mts +1 -2
- package/dist/mapped-import/vite.mjs +1 -1
- package/dist/mapped-import.d.mts +1 -1
- package/dist/{media-protocol-CMyatw7A.mjs → media-protocol-Buk1x3Gb.mjs} +1 -1
- package/dist/{media-protocol-CMyatw7A.mjs.map → media-protocol-Buk1x3Gb.mjs.map} +1 -1
- package/dist/model-server/process.mjs +7 -7
- package/dist/model-server/process.mjs.map +1 -1
- package/dist/model-server.d.mts +423 -102
- package/dist/model-server.mjs +1 -1
- package/dist/model-server.mjs.map +1 -1
- package/dist/{node-main-Bwril94o.mjs → node-main-BrhzkUvP.mjs} +1 -1
- package/dist/{node-main-Bwril94o.mjs.map → node-main-BrhzkUvP.mjs.map} +1 -1
- package/dist/node-main.d.mts +2 -3
- package/dist/node-main.mjs +2 -2
- package/dist/{normalize-CogX79EO.mjs → normalize-CboffJzv.mjs} +1 -1
- package/dist/{normalize-CogX79EO.mjs.map → normalize-CboffJzv.mjs.map} +1 -1
- package/dist/{otlp-ohapzeFh.mjs → otlp-DwZqQqjc.mjs} +1 -1
- package/dist/{otlp-ohapzeFh.mjs.map → otlp-DwZqQqjc.mjs.map} +1 -1
- package/dist/{otlp-schema-CDBPGJ5s.mjs → otlp-schema-DcYNaxGn.mjs} +1 -1
- package/dist/{otlp-schema-CDBPGJ5s.mjs.map → otlp-schema-DcYNaxGn.mjs.map} +1 -1
- package/dist/{otlp-spans-D88555DO.mjs → otlp-spans-BF7m_C1W.mjs} +2 -2
- package/dist/{otlp-spans-D88555DO.mjs.map → otlp-spans-BF7m_C1W.mjs.map} +1 -1
- package/dist/{package-json-CYRyaF9U.mjs → package-json-CdnNcBLT.mjs} +1 -1
- package/dist/{package-json-CYRyaF9U.mjs.map → package-json-CdnNcBLT.mjs.map} +1 -1
- package/dist/plugin-kit.d.mts +3 -4
- package/dist/plugin-kit.mjs +1 -1
- package/dist/plugin-kit.mjs.map +1 -1
- package/dist/{portfolio-BQJtJtfK.mjs → portfolio-VMbxOrAS.mjs} +1 -1
- package/dist/{portfolio-BQJtJtfK.mjs.map → portfolio-VMbxOrAS.mjs.map} +1 -1
- package/dist/{process-_W_7DeKe.d.mts → process-BHJEIAWo.d.mts} +1 -2
- package/dist/{process-lKS6nYWh.mjs → process-l69KvwcT.mjs} +1 -1
- package/dist/{process-lKS6nYWh.mjs.map → process-l69KvwcT.mjs.map} +1 -1
- package/dist/process.d.mts +1 -1
- package/dist/process.mjs +1 -1
- package/dist/{receive-S2txZwcV.mjs → receive-o3h4RxCi.mjs} +1 -1
- package/dist/{receive-S2txZwcV.mjs.map → receive-o3h4RxCi.mjs.map} +1 -1
- package/dist/{route-handlers-Cn3O2hmf.mjs → route-handlers-CKVY2bqC.mjs} +1 -1
- package/dist/{route-handlers-Cn3O2hmf.mjs.map → route-handlers-CKVY2bqC.mjs.map} +1 -1
- package/dist/{route-handlers-E2lwhaAf.d.mts → route-handlers-DAmv3iMD.d.mts} +1 -2
- package/dist/{run-D59Owiv1.d.mts → run-C1nPjDih.d.mts} +1 -2
- package/dist/{run-Cc5W9mi8.mjs → run-DKB2KSjp.mjs} +2 -2
- package/dist/{run-Cc5W9mi8.mjs.map → run-DKB2KSjp.mjs.map} +1 -1
- package/dist/{run-main-BD4uT8sr.mjs → run-main-Chtieg-p.mjs} +7 -7
- package/dist/run-main-Chtieg-p.mjs.map +1 -0
- package/dist/security-headers/http.d.mts +2 -3
- package/dist/security-headers/http.mjs +1 -1
- package/dist/security-headers/request.d.mts +1 -2
- package/dist/security-headers/response.d.mts +1 -2
- package/dist/security-headers/response.mjs +1 -1
- package/dist/security-headers/static.d.mts +1 -1
- package/dist/security-headers/static.mjs +1 -1
- package/dist/security-headers/vite.d.mts +1 -1
- package/dist/security-headers/vite.mjs +1 -1
- package/dist/security-headers.d.mts +3 -3
- package/dist/security-headers.mjs +2 -2
- package/dist/skerm.d.mts +1 -2
- package/dist/{socket-port-CTg-qfiP.mjs → socket-port-Cq7YKLFS.mjs} +1 -1
- package/dist/{socket-port-CTg-qfiP.mjs.map → socket-port-Cq7YKLFS.mjs.map} +1 -1
- package/dist/{span-BKjRu617.mjs → span-BK0kTs11.mjs} +2 -2
- package/dist/{span-BKjRu617.mjs.map → span-BK0kTs11.mjs.map} +1 -1
- package/dist/{static-page-headers-_B0WGkew.mjs → static-page-headers-muClDOhu.mjs} +2 -2
- package/dist/{static-page-headers-_B0WGkew.mjs.map → static-page-headers-muClDOhu.mjs.map} +1 -1
- package/dist/{sync-BkyZGGDA.mjs → sync-Ctl9b02O.mjs} +1 -1
- package/dist/{sync-BkyZGGDA.mjs.map → sync-Ctl9b02O.mjs.map} +1 -1
- package/dist/{table-class-BeiCXlFj.d.mts → table-class-B6OCkS3k.d.mts} +1 -2
- package/dist/{table-class-RQvT6MYy.mjs → table-class-Ck9lRrm4.mjs} +1 -1
- package/dist/{table-class-RQvT6MYy.mjs.map → table-class-Ck9lRrm4.mjs.map} +1 -1
- package/dist/{telemetry-BEWIE8tU.d.mts → telemetry-D6lI0_F9.d.mts} +1 -2
- package/dist/ui/backdrop-palette.d.mts +1 -2
- package/dist/ui/badge.d.mts +1 -2
- package/dist/ui/badge.mjs +1 -1
- package/dist/ui/browser-runtime.d.mts +1 -2
- package/dist/ui/browser-runtime.mjs +1 -1
- package/dist/ui/button-variants.d.mts +1 -1
- package/dist/ui/button-variants.mjs +1 -1
- package/dist/ui/button.d.mts +3 -4
- package/dist/ui/button.mjs +1 -1
- package/dist/ui/cn.d.mts +1 -2
- package/dist/ui/cn.mjs +1 -1
- package/dist/ui/color-scheme.d.mts +1 -2
- package/dist/ui/heading-class.d.mts +1 -1
- package/dist/ui/heading-class.mjs +1 -1
- package/dist/ui/heading.d.mts +2 -3
- package/dist/ui/heading.mjs +1 -1
- package/dist/ui/input-class.d.mts +1 -2
- package/dist/ui/native-select-class.d.mts +1 -2
- package/dist/ui/next-page-trigger.d.mts +1 -2
- package/dist/ui/next-page-trigger.mjs +2 -2
- package/dist/ui/page-footer.d.mts +2 -3
- package/dist/ui/page-footer.mjs +1 -1
- package/dist/ui/page-header.d.mts +2 -3
- package/dist/ui/page-header.mjs +1 -1
- package/dist/ui/pointer.d.mts +1 -2
- package/dist/ui/portfolio.d.mts +1 -2
- package/dist/ui/portfolio.mjs +1 -1
- package/dist/ui/table-class.d.mts +1 -1
- package/dist/ui/table-class.mjs +1 -1
- package/dist/ui/table.d.mts +2 -3
- package/dist/ui/table.mjs +2 -2
- package/dist/ui/to-wavy-letters.d.mts +1 -2
- package/dist/ui/web-analytics.d.mts +3 -4
- package/dist/ui/web-analytics.mjs +1 -1
- package/dist/usage-meter/report.d.mts +2 -3
- package/dist/usage-meter/report.mjs +1 -1
- package/dist/{usage-meter-CmCceKx1.mjs → usage-meter-B196tKiM.mjs} +2 -2
- package/dist/{usage-meter-CmCceKx1.mjs.map → usage-meter-B196tKiM.mjs.map} +1 -1
- package/dist/usage-meter.d.mts +3 -4
- package/dist/usage-meter.mjs +2 -2
- package/dist/{usage-tally-C7zVBg75.d.mts → usage-tally-BBhBouif.d.mts} +1 -2
- package/dist/{usage-tally-FiAxcD-H.mjs → usage-tally-BD3f41V8.mjs} +1 -1
- package/dist/{usage-tally-FiAxcD-H.mjs.map → usage-tally-BD3f41V8.mjs.map} +1 -1
- package/dist/vitest-otlp/collector-files.d.mts +3 -4
- package/dist/vitest-otlp/collector-files.mjs +2 -2
- package/dist/vitest-otlp/semconv.d.mts +1 -2
- package/dist/vitest-otlp/semconv.mjs +2 -2
- package/dist/vitest-otlp/setup.mjs +4 -4
- package/dist/vitest-otlp/workers.d.mts +2 -3
- package/dist/vitest-otlp/workers.mjs +1 -1
- package/dist/{vitest-otlp-current-receiver-8c7rIP1N.mjs → vitest-otlp-current-receiver-Bh_4YbhT.mjs} +1 -1
- package/dist/{vitest-otlp-current-receiver-8c7rIP1N.mjs.map → vitest-otlp-current-receiver-Bh_4YbhT.mjs.map} +1 -1
- package/dist/{vitest-otlp-current-receiver-DphmM9Ha.d.mts → vitest-otlp-current-receiver-DSgQ3zo9.d.mts} +3 -4
- package/dist/vitest-otlp.d.mts +4 -5
- package/dist/vitest-otlp.mjs +3 -3
- package/dist/{web-analytics-Bz6nyJmQ.mjs → web-analytics-CondjbtC.mjs} +1 -1
- package/dist/{web-analytics-Bz6nyJmQ.mjs.map → web-analytics-CondjbtC.mjs.map} +1 -1
- package/dist/{web-analytics-BM9LdncT.d.mts → web-analytics-Cvs9PDoh.d.mts} +1 -2
- package/dist/workers-tracing/alchemy.d.mts +3 -4
- package/dist/workers-tracing/alchemy.mjs +3 -3
- package/dist/workers-tracing/browser-logs.d.mts +2 -3
- package/dist/workers-tracing/browser-logs.mjs +2 -2
- package/dist/workers-tracing/browser-spans.d.mts +2 -3
- package/dist/workers-tracing/browser-spans.mjs +2 -2
- package/dist/workers-tracing/effect.browser.d.mts +2 -3
- package/dist/workers-tracing/effect.browser.mjs +1 -1
- package/dist/workers-tracing/effect.d.mts +2 -3
- package/dist/workers-tracing/effect.mjs +3 -3
- package/dist/workers-tracing/elysia.d.mts +2 -3
- package/dist/workers-tracing/elysia.mjs +4 -4
- package/dist/workers-tracing/elysia.node.d.mts +1 -1
- package/dist/workers-tracing/elysia.node.mjs +1 -1
- package/dist/workers-tracing/tanstack-start.browser.d.mts +1 -2
- package/dist/workers-tracing/tanstack-start.d.mts +1 -2
- package/dist/workers-tracing/tanstack-start.mjs +3 -3
- package/dist/workers-tracing/trace-sink-worker.d.mts +1 -2
- package/dist/workers-tracing/trace-sink-worker.mjs +1 -1
- package/dist/workers-tracing/workers-ai.d.mts +1 -2
- package/dist/yohaku-protocol/sync.d.mts +1 -1
- package/dist/yohaku-protocol/sync.mjs +1 -1
- package/dist/yohaku-protocol.d.mts +1 -1
- package/dist/yohaku-protocol.mjs +1 -1
- package/native/desktop-shell/Cargo.toml +38 -0
- package/native/desktop-shell/src/app/builder.rs +39 -0
- package/native/desktop-shell/src/app/mod.rs +3 -0
- package/native/desktop-shell/src/entities/access_token.rs +77 -0
- package/native/desktop-shell/src/entities/mod.rs +1 -0
- package/native/desktop-shell/src/features/mod.rs +4 -0
- package/native/desktop-shell/src/features/record_telemetry/appender.rs +127 -0
- package/native/desktop-shell/src/features/record_telemetry/forwarder.rs +183 -0
- package/native/desktop-shell/src/features/record_telemetry/invoke.rs +80 -0
- package/native/desktop-shell/src/features/record_telemetry/mod.rs +231 -0
- package/native/desktop-shell/src/features/serve_screen/mod.rs +135 -0
- package/native/desktop-shell/src/features/serve_tools/mod.rs +37 -0
- package/native/desktop-shell/src/features/update_app/mod.rs +53 -0
- package/native/desktop-shell/src/lib.rs +17 -0
- package/native/desktop-shell/src/shared/lib/bearer.rs +49 -0
- package/native/desktop-shell/src/shared/lib/host.rs +1 -0
- package/native/desktop-shell/src/shared/lib/mod.rs +5 -0
- package/native/desktop-shell/src/shared/mod.rs +2 -0
- package/native/desktop-shell/src/shared/ui/log.rs +15 -0
- package/native/desktop-shell/src/shared/ui/menu.rs +37 -0
- package/native/desktop-shell/src/shared/ui/mod.rs +7 -0
- package/native/desktop-shell/src/shared/ui/window.rs +49 -0
- package/native/media-notes/Cargo.toml +36 -0
- package/native/media-notes/src/entities/media_file.rs +89 -0
- package/native/media-notes/src/entities/media_notes.rs +31 -0
- package/native/media-notes/src/entities/mod.rs +3 -0
- package/native/media-notes/src/entities/source/credit.rs +129 -0
- package/native/media-notes/src/entities/source/link.rs +194 -0
- package/native/media-notes/src/entities/source/mod.rs +5 -0
- package/native/media-notes/src/features/mod.rs +2 -0
- package/native/media-notes/src/features/open_media/mod.rs +88 -0
- package/native/media-notes/src/features/share_mcp_access.rs +15 -0
- package/native/media-notes/src/lib.rs +12 -0
- package/native/media-notes/src/shared/db/mod.rs +3 -0
- package/native/media-notes/src/shared/db/store.rs +276 -0
- package/native/media-notes/src/shared/lib/failure.rs +55 -0
- package/native/media-notes/src/shared/lib/mcp.rs +34 -0
- package/native/media-notes/src/shared/lib/mod.rs +5 -0
- package/native/media-notes/src/shared/mod.rs +3 -0
- package/native/media-notes/src/shared/protocol.rs +69 -0
- package/package.json +7 -3
- package/skills/build-tauri-app/SKILL.md +4 -2
- package/dist/client-BS-MCJ0I.mjs.map +0 -1
- package/dist/index-BtcxUsGh.d.mts +0 -4
- package/dist/index-CUo4CRam.d.mts +0 -1
- package/dist/index-DudHILTn.d.mts +0 -6
- package/dist/run-main-BD4uT8sr.mjs.map +0 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::path::Path;
|
|
3
|
+
use std::sync::{Arc, Mutex, PoisonError};
|
|
4
|
+
use std::time::{SystemTime, UNIX_EPOCH};
|
|
5
|
+
|
|
6
|
+
use rusqlite::{Connection, OptionalExtension, params};
|
|
7
|
+
use serde::Serialize;
|
|
8
|
+
use serde::de::DeserializeOwned;
|
|
9
|
+
|
|
10
|
+
use crate::shared::lib::Outcome;
|
|
11
|
+
use crate::shared::protocol::Source;
|
|
12
|
+
|
|
13
|
+
const UNSOURCED: &str = "";
|
|
14
|
+
|
|
15
|
+
#[derive(Clone)]
|
|
16
|
+
pub struct Store {
|
|
17
|
+
connection: Arc<Mutex<Connection>>,
|
|
18
|
+
table: &'static str,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#[must_use]
|
|
22
|
+
pub fn now() -> i64 {
|
|
23
|
+
SystemTime::now()
|
|
24
|
+
.duration_since(UNIX_EPOCH)
|
|
25
|
+
.map_or(0, |elapsed| {
|
|
26
|
+
i64::try_from(elapsed.as_millis()).unwrap_or(i64::MAX)
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#[must_use]
|
|
31
|
+
pub fn fresh_id() -> String {
|
|
32
|
+
uuid::Uuid::now_v7().to_string()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[must_use]
|
|
36
|
+
pub fn is_id(text: &str) -> bool {
|
|
37
|
+
uuid::Uuid::try_parse(text).is_ok_and(|id| id.to_string() == text)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pub struct Row<'a, T> {
|
|
41
|
+
pub id: &'a str,
|
|
42
|
+
pub source: &'a Source,
|
|
43
|
+
pub at: i64,
|
|
44
|
+
pub value: &'a T,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fn decoded<T: DeserializeOwned>(rows: &[String]) -> Outcome<Vec<T>> {
|
|
48
|
+
rows.iter()
|
|
49
|
+
.map(|body| Ok(serde_json::from_str(body)?))
|
|
50
|
+
.collect()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
impl Store {
|
|
54
|
+
pub fn open(directory: &Path, file: &str, table: &'static str) -> Outcome<Self> {
|
|
55
|
+
fs::create_dir_all(directory)?;
|
|
56
|
+
Self::prepare(Connection::open(directory.join(file))?, table)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
pub fn in_memory(table: &'static str) -> Outcome<Self> {
|
|
60
|
+
Self::prepare(Connection::open_in_memory()?, table)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn prepare(connection: Connection, table: &'static str) -> Outcome<Self> {
|
|
64
|
+
connection.execute_batch(&format!(
|
|
65
|
+
"CREATE TABLE IF NOT EXISTS {table} (
|
|
66
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
67
|
+
site TEXT NOT NULL,
|
|
68
|
+
source_id TEXT NOT NULL,
|
|
69
|
+
created_at INTEGER NOT NULL,
|
|
70
|
+
body TEXT NOT NULL
|
|
71
|
+
);
|
|
72
|
+
CREATE INDEX IF NOT EXISTS {table}_source ON {table} (site, source_id, created_at);"
|
|
73
|
+
))?;
|
|
74
|
+
Ok(Self {
|
|
75
|
+
connection: Arc::new(Mutex::new(connection)),
|
|
76
|
+
table,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn with<T>(&self, work: impl FnOnce(&Connection) -> Outcome<T>) -> Outcome<T> {
|
|
81
|
+
let connection = self
|
|
82
|
+
.connection
|
|
83
|
+
.lock()
|
|
84
|
+
.unwrap_or_else(PoisonError::into_inner);
|
|
85
|
+
work(&connection)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pub fn list<T: DeserializeOwned>(&self, source: Option<&Source>) -> Outcome<Vec<T>> {
|
|
89
|
+
let table = self.table;
|
|
90
|
+
self.with(|connection| {
|
|
91
|
+
let rows = match source {
|
|
92
|
+
None => connection
|
|
93
|
+
.prepare(&format!(
|
|
94
|
+
"SELECT body FROM {table} ORDER BY created_at DESC, id DESC"
|
|
95
|
+
))?
|
|
96
|
+
.query_map([], |row| row.get(0))?
|
|
97
|
+
.collect::<rusqlite::Result<Vec<String>>>()?,
|
|
98
|
+
Some(source) => connection
|
|
99
|
+
.prepare(&format!(
|
|
100
|
+
"SELECT body FROM {table} WHERE site = ?1 AND source_id = ?2 ORDER BY created_at DESC, id DESC"
|
|
101
|
+
))?
|
|
102
|
+
.query_map(params![source.site.as_str(), source.id], |row| row.get(0))?
|
|
103
|
+
.collect::<rusqlite::Result<Vec<String>>>()?,
|
|
104
|
+
};
|
|
105
|
+
decoded(&rows)
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
pub fn get<T: DeserializeOwned>(&self, id: &str) -> Outcome<Option<T>> {
|
|
110
|
+
let table = self.table;
|
|
111
|
+
let body = self.with(|connection| {
|
|
112
|
+
Ok(connection
|
|
113
|
+
.query_row(
|
|
114
|
+
&format!("SELECT body FROM {table} WHERE id = ?1"),
|
|
115
|
+
params![id],
|
|
116
|
+
|row| row.get::<_, String>(0),
|
|
117
|
+
)
|
|
118
|
+
.optional()?)
|
|
119
|
+
})?;
|
|
120
|
+
body.map(|text| Ok(serde_json::from_str(&text)?))
|
|
121
|
+
.transpose()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
fn insert<T: Serialize>(
|
|
125
|
+
&self,
|
|
126
|
+
id: &str,
|
|
127
|
+
source: (&str, &str),
|
|
128
|
+
at: i64,
|
|
129
|
+
value: &T,
|
|
130
|
+
) -> Outcome<()> {
|
|
131
|
+
let table = self.table;
|
|
132
|
+
let body = serde_json::to_string(value)?;
|
|
133
|
+
self.with(|connection| {
|
|
134
|
+
connection.execute(
|
|
135
|
+
&format!(
|
|
136
|
+
"INSERT OR REPLACE INTO {table} (id, site, source_id, created_at, body) VALUES (?1, ?2, ?3, ?4, ?5)"
|
|
137
|
+
),
|
|
138
|
+
params![id, source.0, source.1, at, body],
|
|
139
|
+
)?;
|
|
140
|
+
Ok(())
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
pub fn put<T: Serialize>(&self, row: &Row<'_, T>) -> Outcome<()> {
|
|
145
|
+
self.insert(
|
|
146
|
+
row.id,
|
|
147
|
+
(row.source.site.as_str(), &row.source.id),
|
|
148
|
+
row.at,
|
|
149
|
+
row.value,
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
pub fn put_unsourced<T: Serialize>(&self, id: &str, at: i64, value: &T) -> Outcome<()> {
|
|
154
|
+
self.insert(id, (UNSOURCED, UNSOURCED), at, value)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
pub fn remove(&self, id: &str) -> Outcome<bool> {
|
|
158
|
+
let table = self.table;
|
|
159
|
+
self.with(|connection| {
|
|
160
|
+
let removed = connection
|
|
161
|
+
.query_row(
|
|
162
|
+
&format!("DELETE FROM {table} WHERE id = ?1 RETURNING id"),
|
|
163
|
+
params![id],
|
|
164
|
+
|row| row.get::<_, String>(0),
|
|
165
|
+
)
|
|
166
|
+
.optional()?;
|
|
167
|
+
Ok(removed.is_some())
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#[cfg(test)]
|
|
173
|
+
mod tests {
|
|
174
|
+
use serde::{Deserialize, Serialize};
|
|
175
|
+
|
|
176
|
+
use super::{Row, Store, fresh_id, is_id};
|
|
177
|
+
use crate::shared::protocol::{Site, Source};
|
|
178
|
+
|
|
179
|
+
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
|
180
|
+
struct Note {
|
|
181
|
+
words: String,
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#[test]
|
|
185
|
+
fn only_ids_in_the_form_the_app_makes_are_ids() {
|
|
186
|
+
assert!(is_id(&fresh_id()));
|
|
187
|
+
let id = fresh_id();
|
|
188
|
+
for other in [
|
|
189
|
+
id.to_uppercase(),
|
|
190
|
+
id.replace('-', ""),
|
|
191
|
+
format!("{{{id}}}"),
|
|
192
|
+
format!("urn:uuid:{id}"),
|
|
193
|
+
format!("../{id}"),
|
|
194
|
+
format!("/{id}"),
|
|
195
|
+
"..".to_owned(),
|
|
196
|
+
String::new(),
|
|
197
|
+
] {
|
|
198
|
+
assert!(!is_id(&other), "{other}");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fn source(id: &str) -> Source {
|
|
203
|
+
Source {
|
|
204
|
+
site: Site::Youtube,
|
|
205
|
+
id: id.to_owned(),
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
fn note(words: &str) -> Note {
|
|
210
|
+
Note {
|
|
211
|
+
words: words.to_owned(),
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
#[test]
|
|
216
|
+
fn keeps_notes_newest_first_per_source() {
|
|
217
|
+
let store = Store::in_memory("notes").expect("store");
|
|
218
|
+
let here = source("aaaaaaaaaaa");
|
|
219
|
+
let there = source("bbbbbbbbbbb");
|
|
220
|
+
for (id, at, place, words) in [
|
|
221
|
+
("1", 1, &here, "first"),
|
|
222
|
+
("2", 2, &here, "second"),
|
|
223
|
+
("3", 3, &there, "elsewhere"),
|
|
224
|
+
] {
|
|
225
|
+
store
|
|
226
|
+
.put(&Row {
|
|
227
|
+
id,
|
|
228
|
+
source: place,
|
|
229
|
+
at,
|
|
230
|
+
value: ¬e(words),
|
|
231
|
+
})
|
|
232
|
+
.expect("saved");
|
|
233
|
+
}
|
|
234
|
+
let notes: Vec<Note> = store.list(Some(&here)).expect("notes here");
|
|
235
|
+
assert_eq!(notes, vec![note("second"), note("first")]);
|
|
236
|
+
assert_eq!(store.list::<Note>(None).expect("every note").len(), 3);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#[test]
|
|
240
|
+
fn replaces_and_removes_a_note() {
|
|
241
|
+
let store = Store::in_memory("notes").expect("store");
|
|
242
|
+
let here = source("aaaaaaaaaaa");
|
|
243
|
+
let row = |value| Row {
|
|
244
|
+
id: "1",
|
|
245
|
+
source: &here,
|
|
246
|
+
at: 1,
|
|
247
|
+
value,
|
|
248
|
+
};
|
|
249
|
+
let draft = note("draft");
|
|
250
|
+
let last = note("final");
|
|
251
|
+
store.put(&row(&draft)).expect("saved");
|
|
252
|
+
store.put(&row(&last)).expect("replaced");
|
|
253
|
+
assert_eq!(store.get::<Note>("1").expect("read"), Some(note("final")));
|
|
254
|
+
assert!(store.remove("1").expect("first removal"));
|
|
255
|
+
assert!(!store.remove("1").expect("second removal"));
|
|
256
|
+
assert_eq!(store.get::<Note>("1").expect("gone"), None);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
#[test]
|
|
260
|
+
fn keeps_a_note_that_belongs_to_no_media() {
|
|
261
|
+
let store = Store::in_memory("notes").expect("store");
|
|
262
|
+
store
|
|
263
|
+
.put_unsourced("1", 1, ¬e("about every song"))
|
|
264
|
+
.expect("saved");
|
|
265
|
+
assert_eq!(
|
|
266
|
+
store.list::<Note>(None).expect("every note"),
|
|
267
|
+
vec![note("about every song")]
|
|
268
|
+
);
|
|
269
|
+
assert_eq!(
|
|
270
|
+
store
|
|
271
|
+
.list::<Note>(Some(&source("aaaaaaaaaaa")))
|
|
272
|
+
.expect("none here"),
|
|
273
|
+
Vec::<Note>::new()
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
use serde::Serialize;
|
|
2
|
+
use specta::Type;
|
|
3
|
+
|
|
4
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Type)]
|
|
5
|
+
pub struct Failure {
|
|
6
|
+
pub message: String,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
impl Failure {
|
|
10
|
+
pub fn new(message: impl Into<String>) -> Self {
|
|
11
|
+
Self {
|
|
12
|
+
message: message.into(),
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
impl std::fmt::Display for Failure {
|
|
18
|
+
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
19
|
+
formatter.write_str(&self.message)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
impl std::error::Error for Failure {}
|
|
24
|
+
|
|
25
|
+
impl From<rusqlite::Error> for Failure {
|
|
26
|
+
fn from(error: rusqlite::Error) -> Self {
|
|
27
|
+
Self::new(error.to_string())
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
impl From<serde_json::Error> for Failure {
|
|
32
|
+
fn from(error: serde_json::Error) -> Self {
|
|
33
|
+
Self::new(error.to_string())
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
impl From<std::io::Error> for Failure {
|
|
38
|
+
fn from(error: std::io::Error) -> Self {
|
|
39
|
+
Self::new(error.to_string())
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
impl From<reqwest::Error> for Failure {
|
|
44
|
+
fn from(error: reqwest::Error) -> Self {
|
|
45
|
+
Self::new(error.to_string())
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl From<tauri::Error> for Failure {
|
|
50
|
+
fn from(error: tauri::Error) -> Self {
|
|
51
|
+
Self::new(error.to_string())
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
pub type Outcome<T> = Result<T, Failure>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
use rmcp::model::{CallToolResult, ContentBlock};
|
|
2
|
+
use serde::Serialize;
|
|
3
|
+
|
|
4
|
+
use crate::shared::lib::Outcome;
|
|
5
|
+
|
|
6
|
+
pub fn answer<T: Serialize>(outcome: Outcome<T>) -> CallToolResult {
|
|
7
|
+
match outcome.and_then(|value| Ok(serde_json::to_value(&value)?)) {
|
|
8
|
+
Ok(value) if value.is_object() => CallToolResult::structured(value),
|
|
9
|
+
Ok(value) => CallToolResult::success(vec![ContentBlock::text(value.to_string())]),
|
|
10
|
+
Err(failure) => CallToolResult::error(vec![ContentBlock::text(failure.message)]),
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[cfg(test)]
|
|
15
|
+
mod tests {
|
|
16
|
+
use serde_json::json;
|
|
17
|
+
|
|
18
|
+
use super::answer;
|
|
19
|
+
use crate::shared::lib::Failure;
|
|
20
|
+
|
|
21
|
+
#[test]
|
|
22
|
+
fn an_object_comes_back_as_structured_content() {
|
|
23
|
+
let result = answer(Ok(json!({ "songs": [] })));
|
|
24
|
+
assert_eq!(result.structured_content, Some(json!({ "songs": [] })));
|
|
25
|
+
assert_eq!(result.is_error, Some(false));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[test]
|
|
29
|
+
fn a_failure_comes_back_as_an_error_without_structure() {
|
|
30
|
+
let result = answer::<()>(Err(Failure::new("nope")));
|
|
31
|
+
assert_eq!(result.structured_content, None);
|
|
32
|
+
assert_eq!(result.is_error, Some(true));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// @generated by libs/masseater-utils/bin/codegen.ts. Do not edit.
|
|
2
|
+
|
|
3
|
+
use schemars::JsonSchema;
|
|
4
|
+
use serde::{Deserialize, Serialize};
|
|
5
|
+
use specta::Type;
|
|
6
|
+
|
|
7
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type, JsonSchema)]
|
|
8
|
+
pub struct McpAccess {
|
|
9
|
+
pub url: String,
|
|
10
|
+
pub token: String,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Type, JsonSchema)]
|
|
14
|
+
#[serde(rename_all = "lowercase")]
|
|
15
|
+
pub enum Site {
|
|
16
|
+
Youtube,
|
|
17
|
+
Niconico,
|
|
18
|
+
Soundcloud,
|
|
19
|
+
File,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
impl Site {
|
|
23
|
+
#[must_use]
|
|
24
|
+
pub const fn as_str(self) -> &'static str {
|
|
25
|
+
match self {
|
|
26
|
+
Self::Youtube => "youtube",
|
|
27
|
+
Self::Niconico => "niconico",
|
|
28
|
+
Self::Soundcloud => "soundcloud",
|
|
29
|
+
Self::File => "file",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#[must_use]
|
|
34
|
+
pub fn parse(value: &str) -> Option<Self> {
|
|
35
|
+
match value {
|
|
36
|
+
"youtube" => Some(Self::Youtube),
|
|
37
|
+
"niconico" => Some(Self::Niconico),
|
|
38
|
+
"soundcloud" => Some(Self::Soundcloud),
|
|
39
|
+
"file" => Some(Self::File),
|
|
40
|
+
_ => None,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type, JsonSchema)]
|
|
46
|
+
pub struct Source {
|
|
47
|
+
pub site: Site,
|
|
48
|
+
pub id: String,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type, JsonSchema)]
|
|
52
|
+
pub struct Media {
|
|
53
|
+
pub source: Source,
|
|
54
|
+
pub title: String,
|
|
55
|
+
pub artist: String,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type, JsonSchema)]
|
|
59
|
+
pub struct Opened {
|
|
60
|
+
pub media: Media,
|
|
61
|
+
pub location: String,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type, JsonSchema)]
|
|
65
|
+
pub struct Saved {
|
|
66
|
+
pub id: String,
|
|
67
|
+
#[specta(type = specta_typescript::Number)]
|
|
68
|
+
pub at: i64,
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/masseater-utils",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "The small shared libraries of masseater's repositories as subpaths of one package: a chip row for React, Claude Code plugin helpers, Effect entry points for Node.js and GitHub Actions, file import mapping, Node package readers, OTLP assertions for Vitest and Cloudflare Workers tracing, and what the Tauri desktop apps share: OpenTelemetry for the screens, Vite settings, the media-notes screens and the release commands.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actions",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"LICENSE",
|
|
38
38
|
"dist",
|
|
39
39
|
"skills",
|
|
40
|
+
"native/desktop-shell/Cargo.toml",
|
|
41
|
+
"native/desktop-shell/src",
|
|
42
|
+
"native/media-notes/Cargo.toml",
|
|
43
|
+
"native/media-notes/src",
|
|
40
44
|
"src/app/browser-test-fonts.conf",
|
|
41
45
|
"src/app/skerm.css",
|
|
42
46
|
"src/app/ui-styles.css",
|
|
@@ -193,7 +197,7 @@
|
|
|
193
197
|
"@types/react": "19.3.3",
|
|
194
198
|
"@types/youtube": "0.3.0",
|
|
195
199
|
"@vitejs/plugin-react": "6.3.0",
|
|
196
|
-
"@vitest/browser-playwright": "5.1.
|
|
200
|
+
"@vitest/browser-playwright": "5.1.2",
|
|
197
201
|
"alchemy": "2.0.0-beta.87",
|
|
198
202
|
"class-variance-authority": "0.7.1",
|
|
199
203
|
"clsx": "2.1.1",
|
|
@@ -215,7 +219,7 @@
|
|
|
215
219
|
"ts-content-mapper": "0.1.1",
|
|
216
220
|
"tw-animate-css": "1.4.0",
|
|
217
221
|
"typescript": "7.1.0-dev.20261129.1",
|
|
218
|
-
"vite-plus": "1.
|
|
222
|
+
"vite-plus": "1.9.0"
|
|
219
223
|
},
|
|
220
224
|
"peerDependencies": {
|
|
221
225
|
"@alchemy.run/cloudflare": "^2.0.0-beta.85",
|
|
@@ -24,13 +24,15 @@ desktop-shell holds what every Tauri app of the owner shares: the window and app
|
|
|
24
24
|
vp add @r_masseater/masseater-utils
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The Rust crates
|
|
27
|
+
The Rust crates ship inside the npm package, so the app's `src-tauri/Cargo.toml` reads them from the app's `node_modules` and they move with the npm version:
|
|
28
28
|
|
|
29
29
|
```toml
|
|
30
30
|
[dependencies]
|
|
31
|
-
desktop-shell = {
|
|
31
|
+
desktop-shell = { path = "../node_modules/@r_masseater/masseater-utils/native/desktop-shell" }
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
The crates take `version`, `edition`, `rust-version`, `repository` and `lints` from the app's workspace, so the root `Cargo.toml` defines `[workspace.package]` and `[workspace.lints]`.
|
|
35
|
+
|
|
34
36
|
Tauri needs the `proc-macro-crate` and `tauri-macros` patches of the root `Cargo.toml` of masseater/ecosystems. A patch applies only from the workspace root, so copy the same `[patch.crates-io]` entries and the patched crates into the app's repository.
|
|
35
37
|
|
|
36
38
|
## Telemetry
|