rvlib-shipkit 2.12.0 → 2.14.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 +75 -21
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/assets/run-assets.ts +2 -2
- package/src/assets/server/studio-server.ts +27 -23
- package/src/check.ts +4 -4
- package/src/checks/SK001-package-json-shape.check.ts +8 -4
- package/src/checks/SK002-contracts-fulfillness.check.ts +2 -2
- package/src/checks/SK003-claude-md-shape.check.ts +20 -13
- package/src/checks/SK004-gitignore-policy.check.ts +45 -6
- package/src/checks/SK005-rvlib-versions.check.ts +2 -2
- package/src/checks/SK006-npm-publish-safety.check.ts +3 -3
- package/src/checks/SK007-github-visibility.check.ts +2 -2
- package/src/checks/SK008-reviewer-agent.check.ts +3 -3
- package/src/checks/SK010-undeclared-unit.check.ts +2 -2
- package/src/checks/SK011-sibling-unit-ranges.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +2 -2
- package/src/checks/SK013-one-way-in-policy.check.ts +2 -2
- package/src/checks/SK015-nested-repo.check.ts +3 -3
- package/src/checks/SK016-legacy-check-shapes.check.ts +2 -2
- package/src/checks/SK017-vscode-hub-task.check.ts +2 -2
- package/src/checks/SK018-test-files-run.check.ts +2 -2
- package/src/checks/SK019-tests-run-in-units.check.ts +2 -2
- package/src/checks/SK020-self-spawning-check.check.ts +2 -2
- package/src/checks/SK022-machine-runs-the-pin.check.ts +2 -2
- package/src/checks/SK024-identity-colors.check.ts +1 -1
- package/src/checks/SK025-release-drift.check.ts +2 -2
- package/src/checks/SK026-asks-autoclose.check.ts +2 -2
- package/src/checks/SK027-agent-wiki-links.check.ts +8 -2
- package/src/checks/SK028-readme.check.ts +2 -2
- package/src/checks/SK029-explicit-check-files.check.ts +3 -3
- package/src/checks/SK030-cache-audit.check.ts +7 -5
- package/src/checks/SK031-trace-audit.check.ts +7 -7
- package/src/checks/SK032-ignored-inputs.check.ts +3 -3
- package/src/checks/SK033-global-contribution.check.ts +11 -4
- package/src/checks/SK034-commit-gates-armed.check.ts +2 -2
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/checks/SK037-keyword-additions.check.ts +43 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Commands.ts +4 -4
- package/src/cli/cmd_ConfigKeys.ts +2 -2
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Init.ts +1 -1
- package/src/cli/cmd_Media.ts +10 -8
- package/src/cli/cmd_Mv.ts +14 -7
- package/src/cli/cmd_Review.ts +6 -4
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +5 -2
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Sound.ts +1 -1
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_TraceAudit.ts +6 -6
- package/src/cli/cmd_Trailer.ts +7 -4
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/cmd_When.ts +2 -2
- package/src/cli/family-pages.ts +19 -16
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +12 -3
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +3 -2
- package/src/collections/tests.ts +19 -8
- package/src/comfy/comfy-panel.ts +2 -2
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/contracts/manifests/discord.contract.ts +1 -1
- package/src/contracts/manifests/identity.contract.ts +1 -1
- package/src/contracts/manifests/itch.contract.ts +1 -1
- package/src/contracts/manifests/steam.contract.ts +1 -1
- package/src/core/agent-dir-at.ts +12 -0
- package/src/core/agent-dir.ts +16 -0
- package/src/core/app-icon.ts +9 -3
- package/src/core/budget.ts +1 -1
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/canonical-scripts.ts +2 -2
- package/src/core/discover-checks.ts +38 -6
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/global-contribution.ts +4 -1
- package/src/core/ignored-block.ts +1 -1
- package/src/core/ignored-inputs.ts +3 -2
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/motherhome.ts +2 -2
- package/src/core/one-way-in-policy.ts +34 -26
- package/src/core/run-ci.ts +9 -11
- package/src/core/run-fixers.ts +9 -9
- package/src/core/runs-matrix.ts +1 -1
- package/src/core/slots.ts +30 -0
- package/src/core/trace-audit.ts +50 -9
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +44 -8
- package/src/home/gui-app/ShipkitGui.swift +91 -2
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +54 -5
- package/src/home/inbox.ts +17 -2
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/pm-config.ts +4 -1
- package/src/home/pm-inputs.ts +2 -0
- package/src/home/resources.ts +7 -2
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +3 -1
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +104 -1
- package/src/hooks/commit-message.ts +29 -20
- package/src/hooks/hook-gates.ts +1 -1
- package/src/hooks/leak-guard.ts +69 -9
- package/src/hooks/run-hooks.ts +18 -22
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +3 -3
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +3 -2
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/content.ts +1 -1
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/db.ts +1 -1
- package/src/media-store/fact.ts +1 -1
- package/src/media-store/hand.ts +1 -1
- package/src/media-store/kind.ts +1 -1
- package/src/media-store/purge.ts +1 -1
- package/src/media-store/put.ts +5 -3
- package/src/media-store/remote.ts +1 -1
- package/src/media-store/space.ts +24 -5
- package/src/mv/mv-md.ts +63 -22
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +319 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +3 -2
- package/src/release/run-release.ts +7 -4
- package/src/repo-config.ts +71 -13
- package/src/review/anim.ts +1 -1
- package/src/review/auto.ts +1 -1
- package/src/review/cells.ts +15 -1
- package/src/review/format.ts +2 -2
- package/src/review/http.ts +16 -2
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +1 -1
- package/src/review/media-read.ts +1 -1
- package/src/review/model.ts +27 -6
- package/src/review/notes.ts +125 -0
- package/src/review/previews.ts +1 -1
- package/src/review/project.ts +7 -39
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +18 -14
- package/src/review/store.ts +42 -2
- package/src/review/threads.ts +1 -1
- package/src/review/trailer-desk.ts +3 -3
- package/src/review/trailer-media.ts +8 -5
- package/src/review/trailer-model.ts +1 -1
- package/src/review/trailer-routes.ts +1 -1
- package/src/review/trailer-shots.ts +22 -5
- package/src/review/unit.ts +2 -2
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/files/tsconfig.json +1 -1
- package/src/scaffold/project-scaffold.ts +6 -5
- package/src/serve/embed.ts +2 -2
- package/src/serve/hub-app/check-words.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +0 -13
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +32 -8
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +51 -7
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +353 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +60 -7
- package/src/serve/hub-app/inbox-view.tsx +49 -7
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/kept-cols.tsx +30 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-svc.ts +1 -1
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +76 -20
- package/src/serve/hub-app/review/review-board.tsx +1 -1
- package/src/serve/hub-app/review/review-cells.tsx +6 -5
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +6 -5
- package/src/serve/hub-app/review/review-st.ts +34 -15
- package/src/serve/hub-app/review/review-thread.tsx +63 -14
- package/src/serve/hub-app/review/review-views.tsx +133 -51
- package/src/serve/hub-app/review/thread-st.ts +80 -37
- package/src/serve/hub-app/review/trailer-page.tsx +7 -5
- package/src/serve/hub-app/review/trailer-st.ts +1 -1
- package/src/serve/hub-app/review.css +26 -9
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +330 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +681 -0
- package/src/serve/hub-app/social/social-st.ts +1014 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +312 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +515 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +20 -11
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +20 -12
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +160 -0
- package/src/shot/browser-slot.ts +74 -0
- package/src/shot/client.ts +42 -7
- package/src/shot/clip-encoder.ts +108 -24
- package/src/shot/film-box.ts +292 -0
- package/src/shot/shooter.ts +71 -17
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/card-drafts.ts +24 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +332 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +37 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +186 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +95 -35
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trace/tracer.ts +12 -5
- package/src/trailer/adapter.ts +5 -1
- package/src/trailer/build.ts +45 -12
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/holes.ts +1 -1
- package/src/trailer/passage.ts +18 -6
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/prune.ts +1 -1
- package/src/trailer/states.ts +1 -1
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/trailer/words.ts +1 -1
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/run-tui.ts +1 -1
- package/src/tui/tui-app.tsx +0 -1
- package/src/tui/tui-store.ts +1 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// the desks' words and pure rules (wiki tools/shipkit/social.md, The desks in the hub): the desk as the hub's route
|
|
2
|
+
// sends it, a draft's angle as cards, the families of the list, a card a heading, the address's query. Pure, no
|
|
3
|
+
// browser, so the rules are pinned headless
|
|
4
|
+
import type { Draft, Desk, DeskAccount, DeskIdentity, Media, SocialPost } from '../../../social/load.ts'
|
|
5
|
+
import type { Family, Timeline } from '../../../social/presence.ts'
|
|
6
|
+
|
|
7
|
+
export type { Draft, DeskAccount, DeskIdentity, Media, SocialPost, Timeline }
|
|
8
|
+
export type Place = DeskAccount['places'][number]
|
|
9
|
+
export type Row = DeskIdentity['rows'][number]
|
|
10
|
+
export type Picture = DeskIdentity['pictures'][number]
|
|
11
|
+
export type Legal = NonNullable<DeskIdentity['legal']>
|
|
12
|
+
|
|
13
|
+
/** `GET api/social/desk.json`: the desk, each speaking identity's calendar, the platforms with free numbers */
|
|
14
|
+
export type DeskJson = Desk & { timelines: Record<string, Timeline>; statsPlatforms: string[]; article: boolean }
|
|
15
|
+
|
|
16
|
+
/** the account's own profile, beside its places */
|
|
17
|
+
export const ME = 'me'
|
|
18
|
+
/** the company card of an identity, never an account's folder name */
|
|
19
|
+
export const LEGAL = '@legal'
|
|
20
|
+
/** YouTube's title, the one title a group heading carries (`## vertical`) */
|
|
21
|
+
export const TITLE_MAX = 100
|
|
22
|
+
|
|
23
|
+
export const STATUS: Readonly<Record<string, string>> = { draft: 'draft', picked: 'picked', posted: 'posted', rejected: 'rejected' }
|
|
24
|
+
|
|
25
|
+
export const AUTOMATION: Readonly<Record<string, { label: string; tone: 'ok' | 'blue' | 'warn' | 'dim' }>> = {
|
|
26
|
+
live: { label: 'automated', tone: 'ok' },
|
|
27
|
+
free: { label: 'possible, free', tone: 'blue' },
|
|
28
|
+
paid: { label: 'paid', tone: 'warn' },
|
|
29
|
+
limited: { label: 'limited', tone: 'warn' },
|
|
30
|
+
none: { label: 'by hand', tone: 'dim' },
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** the field of the platform a message's text goes in (the account's `text`) */
|
|
34
|
+
export const TEXT_FIELD: Readonly<Record<string, string>> = { description: 'Description', comment: 'First comment' }
|
|
35
|
+
|
|
36
|
+
/** the list's families (Fil and Vertical): the word in the address, the family of the accounts */
|
|
37
|
+
export const FAMS = { feed: 'feed', vertical: 'shorts' } as const satisfies Record<string, Family>
|
|
38
|
+
export type Fam = keyof typeof FAMS
|
|
39
|
+
export const famOf = (v: unknown): Fam | null => (v === 'feed' || v === 'vertical' ? v : null)
|
|
40
|
+
export const FAM_LABEL: Readonly<Record<Fam, string>> = { feed: 'Feed', vertical: 'Vertical' }
|
|
41
|
+
|
|
42
|
+
/** what the lists count as waiting: a message not posted, its draft not rejected */
|
|
43
|
+
export const waiting = (p: Pick<SocialPost, 'posted' | 'status'>): boolean => p.posted === '' && p.status !== 'rejected'
|
|
44
|
+
export const draftWaiting = (d: Pick<Draft, 'status' | 'posts'>): boolean => d.status !== 'rejected' && d.posts.some((p) => p.posted === '')
|
|
45
|
+
|
|
46
|
+
/** how far some messages are posted: every one, some, none */
|
|
47
|
+
export const posting = (c: { posted: number; of: number }): 'all' | 'some' | 'none' => (c.of > 0 && c.posted === c.of ? 'all' : c.posted > 0 ? 'some' : 'none')
|
|
48
|
+
export const countsOf = (posts: readonly Pick<SocialPost, 'posted'>[]): { posted: number; of: number } => ({ posted: posts.filter((p) => p.posted !== '').length, of: posts.length })
|
|
49
|
+
|
|
50
|
+
/** the day a draft was made, from its folder name: « 28/10 » */
|
|
51
|
+
export const madeOn = (slug: string): string => `${slug.slice(6, 8)}/${slug.slice(4, 6)}`
|
|
52
|
+
/** a draft's slug without its moment, the words he reads */
|
|
53
|
+
export const topicOf = (slug: string): string => slug.replace(/^\d{8}-\d{6}-/, '')
|
|
54
|
+
|
|
55
|
+
export const isClip = (file: string): boolean => /\.(mp4|webm|mov)$/i.test(file)
|
|
56
|
+
export const isVertical = (file: string): boolean => /-vertical\.mp4$/.test(file)
|
|
57
|
+
export const fileName = (path: string): string => path.split('/').pop() ?? path
|
|
58
|
+
|
|
59
|
+
/** a draft's angle as small cards: a paragraph that opens on bold words starts one, those words its title, the rest
|
|
60
|
+
* of it and the paragraphs after it its body; the words before the first one are « The angle » */
|
|
61
|
+
export function angleCards(angle: string): { title: string; body: string }[] {
|
|
62
|
+
const out: { title: string; body: string[] }[] = []
|
|
63
|
+
for (const block of angle.trim().split(/\n\s*\n/)) {
|
|
64
|
+
const m = /^\*\*(.+?)\*\*[:,.]?\s*([\s\S]*)$/.exec(block)
|
|
65
|
+
if (m) out.push({ title: (m[1] ?? '').replace(/[:.]$/, ''), body: m[2] ? [m[2].charAt(0).toUpperCase() + m[2].slice(1)] : [] })
|
|
66
|
+
else if (out.length) out.at(-1)?.body.push(block)
|
|
67
|
+
else if (block) out.push({ title: 'The angle', body: [block] })
|
|
68
|
+
}
|
|
69
|
+
return out.map((c) => ({ title: c.title, body: c.body.join('\n\n') }))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** a markdown text as one plain line, the top line of a folded card */
|
|
73
|
+
export const plain = (md: string): string =>
|
|
74
|
+
md
|
|
75
|
+
.replace(/^\s*[-+] |[*`#>]/gm, '')
|
|
76
|
+
.replace(/\s+/g, ' ')
|
|
77
|
+
.trim()
|
|
78
|
+
|
|
79
|
+
export type Send = { a: DeskAccount; post: SocialPost }
|
|
80
|
+
|
|
81
|
+
/** a draft's messages as cards: one a heading, the accounts of its group that take its text on the same card, the
|
|
82
|
+
* heading's own account first */
|
|
83
|
+
export function sharing(posts: readonly SocialPost[], accountOf: (p: SocialPost) => DeskAccount | null): Send[][] {
|
|
84
|
+
const cards = new Map<string, Send[]>()
|
|
85
|
+
for (const post of posts) {
|
|
86
|
+
const a = accountOf(post)
|
|
87
|
+
if (a) cards.set(post.from, [...(cards.get(post.from) ?? []), { a, post }])
|
|
88
|
+
}
|
|
89
|
+
return [...cards.values()].map((sends) => [...sends].sort((x, y) => Number(y.post.key === y.post.from) - Number(x.post.key === x.post.from)))
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** the platforms of some messages as stacks: a group's accounts one stack of overlapping logos, the others alone */
|
|
93
|
+
export function logoStacks(platforms: readonly string[], groupOf: (id: string) => string): string[][] {
|
|
94
|
+
const stacks: string[][] = []
|
|
95
|
+
const byGroup = new Map<string, string[]>()
|
|
96
|
+
for (const id of new Set(platforms)) {
|
|
97
|
+
const g = groupOf(id)
|
|
98
|
+
const stack = g === '' ? undefined : byGroup.get(g)
|
|
99
|
+
if (stack) stack.push(id)
|
|
100
|
+
else {
|
|
101
|
+
const fresh = [id]
|
|
102
|
+
if (g !== '') byGroup.set(g, fresh)
|
|
103
|
+
stacks.push(fresh)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return stacks
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** every account online, in its order, a markdown line each: `- X: <https://x.com/…>` */
|
|
110
|
+
export const linksText = (accounts: readonly Pick<DeskAccount, 'name' | 'live'>[]): string =>
|
|
111
|
+
accounts
|
|
112
|
+
.filter((a) => a.live)
|
|
113
|
+
.map((a) => `- ${a.name}: <${a.live}>`)
|
|
114
|
+
.join('\n')
|
|
115
|
+
|
|
116
|
+
/** green once the company is registered: a registry number on file in its private rows */
|
|
117
|
+
export const legalLive = (l: Legal | null): boolean => l?.rows.some((r) => r.private && /siret|siren|registr|company number/i.test(r.field) && r.value !== '') ?? false
|
|
118
|
+
|
|
119
|
+
/** the caption a page with no `{text}` gets on the clipboard: YouTube's title first */
|
|
120
|
+
export const caption = (p: Pick<SocialPost, 'platform' | 'title' | 'text'>): string => (p.platform === 'youtube' && p.title !== '' ? `${p.title}\n\n${p.text}` : p.text)
|
|
121
|
+
|
|
122
|
+
/** a series' messages by name, in the draft's order (two digits lead each name); empty for a single message */
|
|
123
|
+
export function partsOf(d: Pick<Draft, 'posts'>): string[] {
|
|
124
|
+
const names = [...new Set(d.posts.map((p) => p.name).filter((n) => n !== ''))].sort()
|
|
125
|
+
return names.length > 1 ? names : []
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** a kind's hue, a token of the hub: the kinds named, else one by its letters */
|
|
129
|
+
const KIND_TONE: Readonly<Record<string, string>> = { look: 'k3', devlog: 'k2', people: 'warn', puzzle: 'blue', trailer: 'red', announcement: 'k4', hello: 'k1', welcome: 'review', roundup: 'ok', page: 'dim' }
|
|
130
|
+
const SPARE = ['k6', 'k5', 'accent', 'k4']
|
|
131
|
+
export const kindTone = (kind: string): string => `var(--${KIND_TONE[kind] ?? SPARE[[...kind].reduce((n, c) => n + c.charCodeAt(0), 0) % SPARE.length]})`
|
|
132
|
+
|
|
133
|
+
/** the list's view as the address carries it, each key only when it is not the default */
|
|
134
|
+
export type CommsView = { fam: Fam | null; channel: string | null; newestFirst: boolean; who: string | null }
|
|
135
|
+
|
|
136
|
+
export function commsQuery(v: CommsView): string {
|
|
137
|
+
const q = new URLSearchParams()
|
|
138
|
+
if (v.fam) q.set('fam', v.fam)
|
|
139
|
+
if (v.channel) q.set('ch', v.channel)
|
|
140
|
+
if (!v.newestFirst) q.set('order', 'old')
|
|
141
|
+
if (v.who) q.set('who', v.who)
|
|
142
|
+
return q.toString()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** an address's query read back: a key it leaves out keeps what the page remembers */
|
|
146
|
+
export function readCommsQuery(q: string): Partial<CommsView> {
|
|
147
|
+
const p = new URLSearchParams(q)
|
|
148
|
+
const out: Partial<CommsView> = {}
|
|
149
|
+
if (p.has('fam')) out.fam = famOf(p.get('fam'))
|
|
150
|
+
if (p.has('ch')) out.channel = p.get('ch') || null
|
|
151
|
+
if (p.has('order')) out.newestFirst = p.get('order') !== 'old'
|
|
152
|
+
if (p.has('who')) out.who = p.get('who') || null
|
|
153
|
+
return out
|
|
154
|
+
}
|