rvlib-shipkit 2.22.1 → 2.23.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/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +3 -0
- package/src/annex/born.ts +464 -0
- package/src/annex/flush.ts +46 -0
- package/src/annex/offload.ts +171 -38
- package/src/annex/snapshots.ts +53 -0
- package/src/annex/tidy.ts +368 -0
- package/src/checks/SK041-annex-links.check.ts +4 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
- package/src/cli/cmd_Annex.ts +60 -9
- package/src/cli/cmd_Home.ts +28 -0
- package/src/cli/cmd_Rec.ts +17 -7
- package/src/cli/cmd_Review.ts +27 -3
- package/src/core/machine-db.ts +8 -0
- package/src/home/claude-temp.ts +139 -0
- package/src/home/daemon-jobs.ts +10 -3
- package/src/home/global-units.ts +3 -0
- package/src/home/machine-stores.ts +27 -3
- package/src/home/pm.ts +4 -1
- package/src/home/run-pm.ts +1 -0
- package/src/identities/identities.ts +92 -24
- package/src/media-store/daemon.ts +2 -2
- package/src/media-store/purge.ts +4 -0
- package/src/recordings/load.ts +3 -3
- package/src/recordings/model.ts +7 -0
- package/src/recordings/open.ts +12 -0
- package/src/recordings/presets.ts +12 -5
- package/src/recordings/recorder-app/Capture.swift +34 -5
- package/src/recordings/recorder-app/Clip.swift +126 -17
- package/src/recordings/recorder-app/Editor.swift +177 -7
- package/src/recordings/recorder-app/Hud.swift +189 -0
- package/src/recordings/recorder-app/Tray.swift +179 -36
- package/src/recordings/recorder-app/icon.svg +16 -0
- package/src/recordings/recorder-app/main.swift +349 -18
- package/src/recordings/recorder-app.ts +8 -4
- package/src/recordings/recorder.shipkit.ts +2 -1
- package/src/recordings/routes.ts +52 -6
- package/src/recordings/run-recorder.ts +2 -1
- package/src/recordings/share.ts +27 -0
- package/src/recordings/take.ts +36 -4
- package/src/recordings/view.ts +11 -0
- package/src/repo-config.ts +9 -1
- package/src/review/model.ts +33 -4
- package/src/serve/hub-app/hub.css +4 -0
- package/src/serve/hub-app/recordings-st.ts +135 -24
- package/src/serve/hub-app/recordings-view.tsx +293 -54
- package/src/serve/hub-app/recordings.css +77 -24
- package/src/shipkit-files.ts +5 -0
- package/src/social/drafts.ts +4 -3
- package/src/social/load.ts +7 -2
- package/src/social/publish/discord.ts +10 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* the Recordings page (recordings-view.tsx): one editor window, the height of the page. The top row (repo, record,
|
|
2
2
|
gallery), the toolbar, the stage that takes all the room left, a video's timeline and transport, the strip */
|
|
3
3
|
.rcapp{display:flex;flex-direction:column;gap:var(--s2);height:100%;box-sizing:border-box;overflow:hidden;padding:var(--s2) var(--s3)}
|
|
4
|
+
.rcapp.rcsolo{gap:var(--s1);padding:var(--s1) var(--s2)}
|
|
4
5
|
.rctop{display:flex;align-items:center;gap:var(--s1);flex-wrap:wrap}
|
|
5
6
|
.rctop .sp,.rctoolbar .sp{flex:1}
|
|
6
7
|
.rcdot{color:var(--red)}
|
|
@@ -9,24 +10,55 @@
|
|
|
9
10
|
.rcapp .acpill.on{color:var(--accent);border-color:var(--accent)}
|
|
10
11
|
|
|
11
12
|
.rced{flex:1;min-height:0;display:flex;flex-direction:column;gap:var(--s1)}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
.
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
.
|
|
13
|
+
/* two rows over the capture: what you do (tools, colours, undo, what ⌘C copies, Save), then what it is and where it
|
|
14
|
+
stands (name, repo, size, then disk, edit, Space, WebP) */
|
|
15
|
+
.rctoolbar,.rcinforow{display:flex;align-items:center;gap:var(--s2);flex-wrap:wrap;row-gap:var(--s1)}
|
|
16
|
+
.rcinforow .sp{flex:1}
|
|
17
|
+
.rcico{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;display:block}
|
|
18
|
+
.rcrename{height:24px;width:170px;max-width:100%;box-sizing:border-box;background:transparent;color:var(--ink);border:1px solid transparent;border-radius:4px;padding:0 var(--s1);font:inherit;font-size:13px;font-weight:650}
|
|
19
|
+
.rcrename:hover{border-color:var(--line)}
|
|
20
|
+
.rcrename:focus{outline:none;border-color:var(--accent);background:var(--bg)}
|
|
21
|
+
.rcrepo{height:24px;max-width:130px;background:var(--bg);color:var(--ink);border:1px solid var(--line);border-radius:4px;font:inherit;font-size:12px}
|
|
22
|
+
.rcgroup{display:inline-flex;align-items:center;gap:var(--s1)}
|
|
23
|
+
/* a run of tools is one bar: no gap, one border, the tool picked filled */
|
|
24
|
+
.rctools{gap:0;border:1px solid var(--line);border-radius:6px;background:var(--bg);overflow:hidden}
|
|
25
|
+
.rctool{display:inline-flex;align-items:center;justify-content:center;width:32px;height:28px;padding:0;border:0;border-radius:0;background:transparent;color:var(--ink);cursor:pointer}
|
|
26
|
+
.rctools .rctool+.rctool{border-left:1px solid var(--line)}
|
|
27
|
+
.rctool:hover:not(:disabled){background:var(--sel)}
|
|
28
|
+
.rctool.on,.rctool.on:hover{background:var(--accent);color:var(--bg)}
|
|
29
|
+
.rctool:disabled{opacity:.35;cursor:default;color:var(--ink)}
|
|
30
|
+
.rctool.rcalone{border:1px solid var(--line);border-radius:6px;background:var(--bg)}
|
|
31
|
+
.rcswatch{width:20px;height:20px;border-radius:50%;border:1px solid var(--hi1);padding:0;cursor:pointer}
|
|
32
|
+
.rcswatch.on{box-shadow:0 0 0 2px var(--bg),0 0 0 4px var(--ink)}
|
|
33
|
+
.rcinfo{font-size:12px;color:var(--dim);font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
34
|
+
.rckey{font-size:11px;font-weight:600;color:var(--dim);font-variant-numeric:tabular-nums}
|
|
35
|
+
.rcsave{display:inline-flex;align-items:center;gap:var(--s1);height:28px;padding:0 var(--s3);border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--ok);font-size:12.5px;font-weight:650;cursor:pointer;white-space:nowrap}
|
|
36
|
+
.rcsave.dirty{background:var(--accent);border-color:var(--accent);color:var(--bg)}
|
|
37
|
+
.rcsave.dirty .rckey{color:var(--bg);opacity:.8}
|
|
38
|
+
.rcsave:disabled{opacity:1;cursor:default;color:var(--dim);border-color:var(--line)}
|
|
24
39
|
.rcapp .ghost.on{color:var(--accent)}
|
|
40
|
+
/* where the capture stands: one chip a step, its light first */
|
|
41
|
+
.rcstanding{display:inline-flex;align-items:center;gap:var(--s1);flex-wrap:wrap}
|
|
42
|
+
.rcchip{display:inline-flex;align-items:center;gap:var(--s1);height:24px;padding:0 var(--s2);border:1px solid var(--line);border-radius:6px;background:var(--bg);font-size:12px;color:var(--ink);white-space:nowrap}
|
|
43
|
+
.rcchip b{font-weight:650;color:var(--dim)}
|
|
44
|
+
.rcchip.act{cursor:pointer}
|
|
45
|
+
.rcchip.act:hover{border-color:var(--accent)}
|
|
46
|
+
.rclight{width:8px;height:8px;border-radius:50%;box-sizing:border-box;flex:none}
|
|
47
|
+
.rcchip.ok .rclight{background:var(--ok)}
|
|
48
|
+
.rcchip.todo .rclight{border:1.5px solid var(--dim)}
|
|
49
|
+
.rcchip.todo>span{color:var(--dim)}
|
|
50
|
+
.rcchip.warn{border-color:var(--warn)}
|
|
51
|
+
.rcchip.warn .rclight{background:var(--warn)}
|
|
52
|
+
.rcchip.warn>span{color:var(--warn);font-weight:600}
|
|
53
|
+
.rcchip .rcspin.sm{border-color:var(--line);border-top-color:var(--accent)}
|
|
54
|
+
.rcver{height:20px;max-width:130px;margin-right:-4px;padding:0 var(--s1);border:1px solid var(--line);border-radius:4px;background:var(--panel2);color:var(--ink);font-size:11px}
|
|
25
55
|
|
|
26
|
-
|
|
56
|
+
/* the capture on its ground: a dark line then a light one around it, so its edge reads on a light capture and on a
|
|
57
|
+
dark one, in either theme */
|
|
58
|
+
.rcstage{flex:1;min-height:120px;display:flex;align-items:center;justify-content:center;background:var(--chk1);border:1px solid var(--line);border-radius:6px;overflow:hidden}
|
|
27
59
|
.rccanvas{position:relative;flex:none}
|
|
28
60
|
.rccanvas.grown{background:repeating-conic-gradient(var(--chk1) 0% 25%,var(--chk2) 0% 50%) 0 0/16px 16px;outline:1px dashed var(--hair)}
|
|
29
|
-
.rcframe{position:absolute;background:var(--solid)}
|
|
61
|
+
.rcframe{position:absolute;background:var(--solid);outline:1px solid var(--ink);box-shadow:0 0 0 2px var(--bg),0 6px 22px 2px var(--shadow)}
|
|
30
62
|
.rcframe video,.rcframe img{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;display:block}
|
|
31
63
|
.rcdraw{position:absolute;inset:0;pointer-events:none}
|
|
32
64
|
.rcstage{touch-action:none}
|
|
@@ -38,14 +70,11 @@
|
|
|
38
70
|
|
|
39
71
|
.rctl{display:flex;flex-direction:column;gap:var(--s0)}
|
|
40
72
|
.rcline{position:relative;height:26px;border:1px solid var(--line);border-radius:4px;background:var(--chk2);cursor:pointer;touch-action:none}
|
|
41
|
-
.rcout{position:absolute;top:0;bottom:0;background:var(--hi2)}
|
|
42
73
|
.rckeep{position:absolute;top:0;bottom:0;background:var(--wash);border-left:1px solid var(--hair);border-right:1px solid var(--hair)}
|
|
43
74
|
.rcspeed{position:absolute;bottom:0;height:10px;background:var(--warn);color:var(--solid);font-size:9px;line-height:10px;text-align:center;opacity:.8}
|
|
44
75
|
.rcsel{position:absolute;top:0;bottom:0;background:var(--hi2);border-left:2px solid var(--accent);border-right:2px solid var(--accent)}
|
|
45
76
|
.rcmark{position:absolute;top:0;bottom:0;width:2px;transform:translateX(-50%);background:var(--accent)}
|
|
46
77
|
.rchead{position:absolute;top:0;bottom:0;width:2px;transform:translateX(-50%);background:var(--red);pointer-events:none}
|
|
47
|
-
.rchandle{position:absolute;top:-2px;bottom:-2px;width:8px;transform:translateX(-100%);background:var(--warn);border-radius:3px 0 0 3px;cursor:ew-resize}
|
|
48
|
-
.rchandle.end{transform:none;border-radius:0 3px 3px 0}
|
|
49
78
|
.rclane{position:relative;height:12px}
|
|
50
79
|
.rcspan{position:absolute;top:2px;bottom:2px;border-radius:3px;opacity:.75;cursor:grab;display:flex;align-items:center;overflow:hidden;touch-action:none}
|
|
51
80
|
.rclane.on .rcspan{opacity:1;outline:2px solid var(--accent)}
|
|
@@ -66,17 +95,41 @@
|
|
|
66
95
|
.rctname i{color:var(--warn);font-style:normal}
|
|
67
96
|
.rctmeta{font-size:10.5px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
68
97
|
.rcacts{display:flex;gap:var(--s0)}
|
|
69
|
-
.rcacts button{flex:1;height:
|
|
98
|
+
.rcacts button{flex:1;display:inline-flex;align-items:center;justify-content:center;height:22px;padding:0;border:1px solid var(--line);border-radius:3px;background:var(--panel2);color:var(--ink);font-size:11px;cursor:pointer}
|
|
99
|
+
.rcacts .rcico{width:13px;height:13px}
|
|
70
100
|
.rcacts button:hover{border-color:var(--accent)}
|
|
71
101
|
.rcacts button.rcarmed{flex:2;background:var(--red);border-color:var(--red);color:var(--bg)}
|
|
72
102
|
.rcgallery{flex:1;min-height:0;overflow:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,240px),1fr));gap:var(--s3);align-content:start}
|
|
73
103
|
.rcthumb.big{width:auto}
|
|
104
|
+
.rcgtitle{font-size:13px;font-weight:650}
|
|
105
|
+
.rcsolo .rcgallery{padding-bottom:var(--s2)}
|
|
74
106
|
.rcsolo{position:fixed;inset:0;background:var(--bg)}
|
|
75
107
|
.rcsolo .rcsaid{position:absolute;right:var(--s3);bottom:var(--s2);z-index:2}
|
|
76
|
-
.rctoolbar .rcacts{flex:none}
|
|
77
|
-
.rctoolbar .rcacts button{flex:none;width:30px;height:24px;font-size:13px}
|
|
78
108
|
/* instant tooltips: the native one waits a second; these show on hover at once */
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
.
|
|
82
|
-
.
|
|
109
|
+
.rctip{position:fixed;left:0;top:0;visibility:hidden;z-index:50;max-width:min(420px,calc(100vw - 12px));padding:var(--s1) var(--s2);border-radius:4px;background:var(--ink);color:var(--bg);font:500 11.5px -apple-system,Helvetica,sans-serif;pointer-events:none}
|
|
110
|
+
/* what ⌘C copies: one bar, each mode a dot of the recorder tray's own colour; the one picked is filled with it */
|
|
111
|
+
.rccopy{display:inline-flex;align-items:center;gap:var(--s1)}
|
|
112
|
+
.rcseg{display:inline-flex;border:1px solid var(--line);border-radius:6px;background:var(--bg);overflow:hidden}
|
|
113
|
+
.rcseg button{display:inline-flex;align-items:center;gap:var(--s1);height:26px;padding:0 var(--s3);border:0;border-radius:0;background:transparent;color:var(--ink);font-size:12px;font-weight:600;cursor:pointer}
|
|
114
|
+
.rcseg button+button{border-left:1px solid var(--line)}
|
|
115
|
+
.rcseg button i{width:8px;height:8px;border-radius:50%;background:var(--mode)}
|
|
116
|
+
.rcseg button:hover:not(:disabled):not(.on){background:var(--sel)}
|
|
117
|
+
.rcseg button.on{background:var(--mode);color:var(--recink)}
|
|
118
|
+
.rcseg button.on i{background:var(--recink)}
|
|
119
|
+
.rcseg button:disabled{opacity:.45;cursor:default;color:var(--ink)}
|
|
120
|
+
.rcseg .rcspin.sm{border-color:var(--mode);border-top-color:transparent}
|
|
121
|
+
.rcseg .on .rcspin.sm{border-color:var(--recink);border-top-color:transparent}
|
|
122
|
+
.rcspin.sm{width:9px;height:9px;border-width:2px;flex:none}
|
|
123
|
+
.rcmode-file{--mode:var(--recfile)}
|
|
124
|
+
.rcmode-webp-hq{--mode:var(--recwebp)}
|
|
125
|
+
.rcmode-link{--mode:var(--reclink)}
|
|
126
|
+
.rccuts{position:relative;height:18px;border:1px dashed var(--hair);border-radius:4px;cursor:crosshair;touch-action:none}
|
|
127
|
+
.rccutsname{position:absolute;left:var(--s1);top:0;bottom:0;display:flex;align-items:center;font-size:10px;font-weight:650;color:var(--dim);pointer-events:none;z-index:1}
|
|
128
|
+
.rccut{position:absolute;top:0;bottom:0;background:var(--red);opacity:.8;border-radius:3px;cursor:pointer}
|
|
129
|
+
.rccut.painting{opacity:.45;pointer-events:none}
|
|
130
|
+
.rccut.restoring{background:var(--ok);opacity:.7;pointer-events:none;z-index:1}
|
|
131
|
+
.rccutshint{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:10.5px;color:var(--dim);pointer-events:none}
|
|
132
|
+
.rcstagebox{position:relative;flex:1;min-height:120px;display:flex}
|
|
133
|
+
.rcexporting{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--s1);background:var(--chk2);opacity:.92;border-radius:4px;font-size:12px;color:var(--ink)}
|
|
134
|
+
.rcspin{width:22px;height:22px;border:3px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:rcspin .8s linear infinite}
|
|
135
|
+
@keyframes rcspin{to{transform:rotate(360deg)}}
|
package/src/shipkit-files.ts
CHANGED
|
@@ -75,6 +75,10 @@ export type GlobalProcessDef = {
|
|
|
75
75
|
/** what its card wears: an emoji, or a repo-relative image path
|
|
76
76
|
* (png, svg, ico, jpg, webp). Absent: the declaring repo's own icon */
|
|
77
77
|
icon?: string
|
|
78
|
+
/** pm starts it when pm itself starts cold (no daemon left to adopt: a login, a reboot, a kill), for a
|
|
79
|
+
* process that is only useful while always up (a hotkey owner). A pm
|
|
80
|
+
* restart in place keeps the owner's switch */
|
|
81
|
+
atLogin?: boolean
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
export type WidgetDef = {
|
|
@@ -117,6 +121,7 @@ export function globalProcessProblem(d: GlobalProcessDef): string | null {
|
|
|
117
121
|
if (d.app !== undefined && (typeof d.app !== 'string' || d.app.trim() === '' || /^\.|[/:]/.test(d.app))) return `${at}: app is a file name: not empty, no leading dot, no / or :`
|
|
118
122
|
if (d.probe != null && !httpUrl(d.probe)) return `${at}: probe must be an http url`
|
|
119
123
|
if (d.down != null && d.probe == null && d.url == null) return `${at}: a bring-up (one with down) needs probe or url, the only truth of whether it is up`
|
|
124
|
+
if (d.atLogin !== undefined && typeof d.atLogin !== 'boolean') return `${at}: atLogin is true or false`
|
|
120
125
|
if (d.icon !== undefined) {
|
|
121
126
|
const why = iconProblem(d.icon)
|
|
122
127
|
if (why != null) return `${at}: ${why}`
|
package/src/social/drafts.ts
CHANGED
|
@@ -8,10 +8,11 @@ import { parseFrontmatter } from './md.ts'
|
|
|
8
8
|
|
|
9
9
|
/** the headings a draft holds besides its platforms */
|
|
10
10
|
const OWN = ['Angle', 'Posted'] as const
|
|
11
|
-
const OPTIONS = ['name', 'place', 'title', 'media', 'rating', 'pin', 'outro', 'mark', 'tags', 'tier'] as const
|
|
11
|
+
const OPTIONS = ['name', 'place', 'title', 'media', 'rating', 'pin', 'embeds', 'outro', 'mark', 'tags', 'tier'] as const
|
|
12
12
|
type Option = (typeof OPTIONS)[number]
|
|
13
|
-
/** the options whose value is one of a few words: a vertical's end and its watermark's corner, words a project reads
|
|
14
|
-
|
|
13
|
+
/** the options whose value is one of a few words: a vertical's end and its watermark's corner, words a project reads;
|
|
14
|
+
* `embeds: none`, no preview card under its links */
|
|
15
|
+
const WORDS: Partial<Record<Option, readonly string[]>> = { outro: ['montage', 'short', 'none'], mark: ['left', 'right'], embeds: ['none'] }
|
|
15
16
|
|
|
16
17
|
const HEADING = /^## (.+?)[ \t]*$/gm
|
|
17
18
|
const PLATFORM = /^([a-z0-9-]+)(?:\s*\((.*)\))?$/
|
package/src/social/load.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
5
5
|
import { join, relative, resolve, sep } from 'node:path'
|
|
6
6
|
import { LAYOUT } from '../core/layout.ts'
|
|
7
|
-
import { speakerOf, type Account, type Identities, type Identity } from '../identities/identities.ts'
|
|
7
|
+
import { filledText, speakerOf, type Account, type Identities, type Identity } from '../identities/identities.ts'
|
|
8
8
|
import { isPostRating, POST_RATINGS, takes, type PostRating } from '../identities/rating.ts'
|
|
9
9
|
import { fileList, groupKeys, mediaNames, parseDraft, renderedTrailer, resolveMedia, tagList, topicList, type Topic } from './drafts.ts'
|
|
10
10
|
import { compose, fillLink, messageLength } from './compose.ts'
|
|
@@ -90,6 +90,8 @@ export type SocialPost = {
|
|
|
90
90
|
/** the account's write page, prefilled when it takes {text}; null when it names none */
|
|
91
91
|
href: string | null
|
|
92
92
|
pin: boolean
|
|
93
|
+
/** the venue draws a preview card under each link (`embeds: none` turns them off: a list of links) */
|
|
94
|
+
embeds: boolean
|
|
93
95
|
/** the key of the heading its text comes from: its own, or its group's (`short`, `short/<name>`) */
|
|
94
96
|
from: string
|
|
95
97
|
/** the links under a vertical message's text, counted and copied with it; empty elsewhere */
|
|
@@ -357,7 +359,9 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
357
359
|
}
|
|
358
360
|
const footer = from.split('/')[0] === VERTICAL ? footerText : ''
|
|
359
361
|
const tags = tagList(s.options.tags)
|
|
360
|
-
|
|
362
|
+
// `[[row]]` is that account's row (its `[[links]]`), so a list the identity keeps never goes stale in a draft
|
|
363
|
+
const filled = filledText(s.text, a.rows, `${file}: ## ${key}`, errors)
|
|
364
|
+
const made = compose(a.id, { text: filled, tags, footer }, { max: a.max, saturday })
|
|
361
365
|
const at = a.places.find((x) => x.id === place)
|
|
362
366
|
// a Discord place is a channel of its server's layout; with no layout, checked when the bot posts
|
|
363
367
|
if (place !== '' && !places.some((x) => x.id === place) && (a.id !== 'discord' || hasLayout(a)))
|
|
@@ -389,6 +393,7 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
389
393
|
href: write === '' ? null : fillLink(write, { url: '', title, text: made.text }),
|
|
390
394
|
prefilled: write.includes('{text}'),
|
|
391
395
|
pin: s.options.pin === 'true',
|
|
396
|
+
embeds: s.options.embeds !== 'none',
|
|
392
397
|
from,
|
|
393
398
|
footer,
|
|
394
399
|
rating,
|
|
@@ -57,21 +57,28 @@ export function discordContent(text: string, channels: readonly Channel[]): stri
|
|
|
57
57
|
return withoutTags(linked)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/** Discord's message flag that drops the preview cards under its links */
|
|
61
|
+
const SUPPRESS_EMBEDS = 1 << 2
|
|
62
|
+
|
|
63
|
+
/** a message as Discord takes it, posted or edited: no mention pings, its links' cards only when `embeds`; an edit
|
|
64
|
+
* sets the flag too, so a draft that changes it changes the posted message */
|
|
65
|
+
export const discordPayload = (content: string, embeds: boolean): Record<string, unknown> => ({ content, allowed_mentions: { parse: [] }, flags: embeds ? 0 : SUPPRESS_EMBEDS })
|
|
66
|
+
|
|
60
67
|
/** posts a message on the identity's Discord server; its link, which the caller records */
|
|
61
68
|
export async function postDiscord(a: Account, post: SocialPost): Promise<string> {
|
|
62
69
|
if (a.guild === '') throw new Error(`${a.file}: no guild, the server's id`)
|
|
63
70
|
if (post.text === '') throw new Error(`${post.slug}: its ## ${post.from} is empty`)
|
|
64
71
|
const channels = await call<Channel[]>(a, 'GET', `/guilds/${a.guild}/channels`)
|
|
65
|
-
const
|
|
72
|
+
const payload = discordPayload(discordContent(post.text, channels), post.embeds)
|
|
66
73
|
if (post.posted) {
|
|
67
74
|
const ids = new RegExp(`^https://discord\\.com/channels/${a.guild}/(\\d+)/(\\d+)$`).exec(post.posted)
|
|
68
75
|
if (ids == null) throw new Error(`${post.slug}: posted "${post.posted}" is no message link of the server`)
|
|
69
|
-
await call(a, 'PATCH', `/channels/${ids[1]}/messages/${ids[2]}`, JSON.stringify(
|
|
76
|
+
await call(a, 'PATCH', `/channels/${ids[1]}/messages/${ids[2]}`, JSON.stringify(payload))
|
|
70
77
|
return post.posted
|
|
71
78
|
}
|
|
72
79
|
const target = channels.find((x) => x.type === TEXT && same(channelKey(x.name), post.place))
|
|
73
80
|
if (target == null) throw new Error(`${post.slug}: place "${post.place}" is no text channel of the server`)
|
|
74
|
-
const msg = await postMessage(a, target.id,
|
|
81
|
+
const msg = await postMessage(a, target.id, payload, post.media?.path ?? null, post.alt)
|
|
75
82
|
if (post.pin) await call(a, 'PUT', `/channels/${target.id}/pins/${msg.id}`)
|
|
76
83
|
return `https://discord.com/channels/${a.guild}/${target.id}/${msg.id}`
|
|
77
84
|
}
|