@supa-media/tex-contract 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +33 -2
- package/package.json +16 -4
- package/texContract/aboutLines.cjs +117 -0
- package/texContract/aboutLines.d.cts +14 -0
- package/texContract/aboutNoteLimits.cjs +41 -0
- package/texContract/aboutNoteLimits.d.cts +5 -0
- package/texContract/actionManual.cjs +104 -0
- package/texContract/activityHint.cjs +40 -0
- package/texContract/activityHint.d.cts +4 -0
- package/texContract/asks.cjs +16 -0
- package/texContract/asks.d.cts +6 -0
- package/texContract/asksToFile.cjs +20 -0
- package/texContract/asksToFile.d.cts +2 -0
- package/texContract/attention.cjs +138 -0
- package/texContract/attention.d.cts +20 -0
- package/texContract/browserHandback.cjs +13 -0
- package/texContract/browserHandback.d.cts +3 -0
- package/texContract/browserOwner.cjs +31 -0
- package/texContract/browserOwner.d.cts +2 -0
- package/texContract/bytes.cjs +12 -0
- package/texContract/capabilities.cjs +47 -0
- package/texContract/capabilities.d.cts +27 -0
- package/texContract/capabilities.generated.json +77 -0
- package/texContract/chatHistoryPath.cjs +38 -0
- package/texContract/chatHistoryPath.d.cts +5 -0
- package/texContract/chatLedger.cjs +91 -0
- package/texContract/chatLedger.d.cts +21 -0
- package/texContract/computerTool.cjs +102 -0
- package/texContract/computerTool.d.cts +16 -0
- package/texContract/consentYes.cjs +22 -0
- package/texContract/consentYes.d.cts +5 -0
- package/texContract/contextGateway.cjs +52 -0
- package/texContract/contextGateway.d.cts +19 -0
- package/texContract/deskEligible.cjs +20 -0
- package/texContract/deskEligible.d.cts +3 -0
- package/texContract/downloads.cjs +129 -0
- package/texContract/downloads.d.cts +15 -0
- package/texContract/egressLedger.cjs +114 -0
- package/texContract/egressLedger.d.cts +14 -0
- package/texContract/emailRead.cjs +38 -0
- package/texContract/emailRead.d.cts +5 -0
- package/texContract/eventWords.cjs +35 -0
- package/texContract/eventWords.d.cts +4 -0
- package/texContract/fileParts.cjs +43 -0
- package/texContract/fileParts.d.cts +6 -0
- package/texContract/fileTables.cjs +243 -0
- package/texContract/fileWords.cjs +169 -0
- package/texContract/folded.cjs +16 -0
- package/texContract/folded.d.cts +3 -0
- package/texContract/googleAiAccess.cjs +12 -0
- package/texContract/googleAiAccess.d.cts +2 -0
- package/texContract/graphWires.cjs +18 -0
- package/texContract/graphWires.d.cts +5 -0
- package/texContract/groupSession.cjs +28 -0
- package/texContract/groupSession.d.cts +7 -0
- package/texContract/guestNames.cjs +136 -0
- package/texContract/guestNames.d.cts +35 -0
- package/texContract/heard.cjs +19 -0
- package/texContract/heard.d.cts +4 -0
- package/texContract/heldOffer.cjs +57 -0
- package/texContract/heldOffer.d.cts +8 -0
- package/texContract/helperCallers.cjs +29 -0
- package/texContract/helperCallers.d.cts +4 -0
- package/texContract/identity.cjs +179 -0
- package/texContract/identity.d.cts +8 -0
- package/texContract/jobLogEntries.cjs +93 -0
- package/texContract/jobLogEntries.d.cts +12 -0
- package/texContract/judgedActions.cjs +20 -0
- package/texContract/judgedActions.d.cts +4 -0
- package/texContract/labSandboxGate.cjs +63 -0
- package/texContract/labSandboxGate.d.cts +9 -0
- package/texContract/ledgerReadChars.cjs +4 -0
- package/texContract/ledgerReadChars.d.cts +3 -0
- package/texContract/mailCheck.cjs +90 -0
- package/texContract/mailCheck.d.cts +12 -0
- package/texContract/mailEntries.cjs +64 -0
- package/texContract/mailEntries.d.cts +13 -0
- package/texContract/mailHealth.cjs +60 -0
- package/texContract/mailHealth.d.cts +10 -0
- package/texContract/notePath.cjs +99 -0
- package/texContract/notePath.d.cts +4 -0
- package/texContract/noteRunFacts.cjs +136 -0
- package/texContract/noteRunFacts.d.cts +32 -0
- package/texContract/objectEtag.cjs +84 -0
- package/texContract/objectEtag.d.cts +4 -0
- package/texContract/objectPlace.cjs +32 -0
- package/texContract/objectPlace.d.cts +5 -0
- package/texContract/pageJobs.cjs +226 -0
- package/texContract/pageJobs.d.cts +13 -0
- package/texContract/pdfLinks.cjs +135 -0
- package/texContract/pdfLinks.d.cts +4 -0
- package/texContract/personHub.cjs +38 -0
- package/texContract/personHub.d.cts +5 -0
- package/texContract/personNameText.cjs +18 -0
- package/texContract/personNameText.d.cts +3 -0
- package/texContract/pinnedContext.cjs +12 -0
- package/texContract/pinnedContext.d.cts +3 -0
- package/texContract/quietHoursWindow.cjs +36 -0
- package/texContract/quietHoursWindow.d.cts +3 -0
- package/texContract/reactEmoji.cjs +79 -0
- package/texContract/reactEmoji.d.cts +2 -0
- package/texContract/scopeClamp.cjs +117 -0
- package/texContract/scopeClamp.d.cts +5 -0
- package/texContract/scopes.cjs +29 -0
- package/texContract/scopes.d.cts +7 -0
- package/texContract/searchSettings.cjs +54 -0
- package/texContract/searchSettings.d.cts +6 -0
- package/texContract/settingHabits.cjs +87 -0
- package/texContract/settingHabits.d.cts +20 -0
- package/texContract/settingsNotes.cjs +217 -0
- package/texContract/settingsNotes.d.cts +26 -0
- package/texContract/shownEmail.cjs +181 -0
- package/texContract/texClients.cjs +53 -0
- package/texContract/texClients.d.cts +12 -0
- package/texContract/texGraph.cjs +593 -0
- package/texContract/texGraph.d.cts +55 -0
- package/texContract/texKeys.cjs +100 -0
- package/texContract/texKeys.d.cts +13 -0
- package/texContract/texNumber.cjs +20 -0
- package/texContract/texNumber.d.cts +3 -0
- package/texContract/texOwnSources.cjs +9 -0
- package/texContract/texOwnSources.d.cts +3 -0
- package/texContract/texSettings.cjs +22 -0
- package/texContract/texSettings.d.cts +20 -0
- package/texContract/texSettings.generated.json +25 -0
- package/texContract/texStateFiles.cjs +22 -0
- package/texContract/texStateFiles.d.cts +9 -0
- package/texContract/texSteps.cjs +27 -0
- package/texContract/texSteps.d.cts +14 -0
- package/texContract/texSteps.generated.json +41 -0
- package/texContract/texStoreNames.cjs +26 -0
- package/texContract/texStoreNames.d.cts +12 -0
- package/texContract/texStoreWire.cjs +306 -0
- package/texContract/texStoreWire.d.cts +32 -0
- package/texContract/threadsFold.cjs +75 -0
- package/texContract/threadsFold.d.cts +22 -0
- package/texContract/toolActions.cjs +253 -0
- package/texContract/toolCatalog.cjs +49 -0
- package/texContract/toolCatalog.generated.json +90 -0
- package/texContract/toolContract.cjs +52 -0
- package/texContract/toolContract.d.cts +12 -0
- package/texContract/toolShapes.cjs +14 -0
- package/texContract/transcription.cjs +101 -0
- package/texContract/transcription.d.cts +3 -0
- package/texContract/treeJobs.cjs +31 -0
- package/texContract/treeJobs.d.cts +3 -0
- package/texContract/turnSession.cjs +90 -0
- package/texContract/turnSession.d.cts +19 -0
- package/texContract/turnWords.cjs +90 -0
- package/texContract/turnWords.d.cts +9 -0
- package/texContract/uploadImages.cjs +131 -0
- package/texContract/uploadImages.d.cts +13 -0
- package/texContract/v2Names.cjs +41 -0
- package/texContract/v2SearchFetch.cjs +316 -0
- package/texContract/v2Translate.cjs +123 -0
- package/texContract/vaultTools.cjs +112 -0
- package/texContract/vaultTools.d.cts +15 -0
- package/texContract/yesWords.cjs +91 -0
- package/texShared/argumentCoercion.cjs +93 -0
- package/texShared/cellComments.cjs +122 -0
- package/texShared/cellComments.d.cts +21 -0
- package/texShared/comments.cjs +586 -0
- package/texShared/comments.d.cts +115 -0
- package/texShared/contentTypes.cjs +85 -0
- package/texShared/fileKinds.cjs +123 -0
- package/texShared/flags.cjs +159 -0
- package/texShared/flags.d.cts +23 -0
- package/texShared/folderJobInfo.cjs +301 -0
- package/texShared/folderJobInfo.d.cts +40 -0
- package/texShared/folderRoles.cjs +512 -0
- package/texShared/folderRoles.d.cts +73 -0
- package/texShared/githubOidc.ts +98 -0
- package/texShared/groupRunQuestions.cjs +98 -0
- package/texShared/groupRunQuestions.d.cts +4 -0
- package/texShared/inboxFolders.cjs +49 -0
- package/texShared/inboxFolders.d.cts +5 -0
- package/texShared/ink/drawing.cjs +474 -0
- package/texShared/ink/texFigure.cjs +252 -0
- package/texShared/ink/texFigure.d.cts +36 -0
- package/texShared/ink/texPoses.cjs +180 -0
- package/texShared/ink/texPoses.d.cts +20 -0
- package/texShared/jobPartEnd.cjs +133 -0
- package/texShared/jobPartEnd.d.cts +13 -0
- package/texShared/jobResume.cjs +31 -0
- package/texShared/jobResume.d.cts +5 -0
- package/texShared/jobSplit.cjs +90 -0
- package/texShared/jobSplit.d.cts +6 -0
- package/texShared/jobStart.cjs +56 -0
- package/texShared/jobStart.d.cts +9 -0
- package/texShared/mail.cjs +400 -0
- package/texShared/mail.d.cts +56 -0
- package/texShared/messageAnchors.cjs +38 -0
- package/texShared/models/aiKeys.cjs +137 -0
- package/texShared/models/aiKeys.d.cts +42 -0
- package/texShared/models/aiKeys.json +56 -0
- package/texShared/models/creditRest.cjs +269 -0
- package/texShared/models/promptBudget.cjs +295 -0
- package/texShared/models/promptSections.cjs +29 -0
- package/texShared/noteAppLink.cjs +23 -0
- package/texShared/notePreview.cjs +219 -0
- package/texShared/notePreview.d.cts +21 -0
- package/texShared/pages/blocks.cjs +215 -0
- package/texShared/pages/cover.cjs +164 -0
- package/texShared/pages/css.cjs +181 -0
- package/texShared/pages/cssBlocks.cjs +264 -0
- package/texShared/pages/draw.cjs +212 -0
- package/texShared/pages/drawRich.cjs +232 -0
- package/texShared/pages/html.cjs +168 -0
- package/texShared/pages/inline.cjs +251 -0
- package/texShared/pages/layout.cjs +76 -0
- package/texShared/pages/parse.cjs +418 -0
- package/texShared/pages/render.cjs +200 -0
- package/texShared/pages/skill.cjs +147 -0
- package/texShared/pages/skill.d.cts +5 -0
- package/texShared/pages/templates.cjs +336 -0
- package/texShared/r2Store.cjs +163 -0
- package/texShared/remoteImage.cjs +177 -0
- package/texShared/routines.cjs +656 -0
- package/texShared/routines.d.cts +86 -0
- package/texShared/servedListing.cjs +250 -0
- package/texShared/servedListing.d.cts +17 -0
- package/texShared/sheetCsv.cjs +566 -0
- package/texShared/sheetCsv.d.cts +91 -0
- package/texShared/storageLayout.cjs +88 -0
- package/texShared/storeKeys.cjs +144 -0
- package/texShared/toolArguments.cjs +323 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tex's geometry: the googly-eyed paper-ink scribble that untangles into the
|
|
3
|
+
* app icon's # as a workspace calms down. Every Tex in the product, the app's
|
|
4
|
+
* chaos score and the homepage's mascot alike, is drawn from here.
|
|
5
|
+
*
|
|
6
|
+
* The owner's pick (2026-10-10), ported faithfully from the board it was
|
|
7
|
+
* chosen on (`texting-assistant-boards/mascots-v7-googly-dots/source/
|
|
8
|
+
* paper3.html`, its `figure()`, `scribble`, `catmull` and `hashStrokes`): the
|
|
9
|
+
* same seeded scribble, split into four strands that each ease onto one
|
|
10
|
+
* stroke of the #, thickening as they go, with a dry second pass beside each.
|
|
11
|
+
* Legs, a waving arm and motion marks fade out on the way.
|
|
12
|
+
*
|
|
13
|
+
* Drawn as Tex was approved on the homepage preview (Dev, 2026-10-11): a
|
|
14
|
+
* heavier brush that thickens less on its way to the #, and googly eyes that
|
|
15
|
+
* stay on even when everything is sorted. The app's chaos score first drew a
|
|
16
|
+
* thinner variant that swapped its eyes for two dots at 0; Dev2 asked
|
|
17
|
+
* (2026-10-12) for the app to use the real Tex, so there is one drawing now.
|
|
18
|
+
*
|
|
19
|
+
* Pure: points and path strings, no React. The app's `Tex.tsx` draws them
|
|
20
|
+
* (through `apps/mobile/features/chaos/figureGeometry.ts`), and the gateway's
|
|
21
|
+
* page drawings put the calm Tex in them (`./drawing.cjs`): one Tex.
|
|
22
|
+
*
|
|
23
|
+
* CommonJS like `../pages/`, so the gateway (plain JavaScript) and the app
|
|
24
|
+
* read one copy.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** The figure's untangling, 0 the full scribble and 1 the calm # (the app's `chaosToT`, `chaosModel.ts`). */
|
|
28
|
+
const chaosToT = (chaos) => (Number.isFinite(chaos) ? 1 - Math.min(100, Math.max(0, chaos)) / 100 : 0);
|
|
29
|
+
/** Paper3's canvas: the figure is drawn about (CX, CY) in a 680 x 820 board. */
|
|
30
|
+
const N = 720;
|
|
31
|
+
const CX = 340;
|
|
32
|
+
const CY = 380;
|
|
33
|
+
/** At this size and under, the figure drops its speckles and motion marks and thickens its strokes. */
|
|
34
|
+
const SMALL_FIGURE = 28;
|
|
35
|
+
/** The part of paper3's board the figure occupies, square. Small drops the speckles' margin. */
|
|
36
|
+
const VIEW_BOX = { x: 30, y: 70, size: 640 };
|
|
37
|
+
const SMALL_VIEW_BOX = { x: 60, y: 140, size: 560 };
|
|
38
|
+
const rng = (seed) => {
|
|
39
|
+
let s = seed;
|
|
40
|
+
return () => (s = s * 16807 % 2147483647) / 2147483647;
|
|
41
|
+
};
|
|
42
|
+
const ease = (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2;
|
|
43
|
+
function catmull(pts, n) {
|
|
44
|
+
const out = [];
|
|
45
|
+
const segs = pts.length - 3;
|
|
46
|
+
for (let i = 0; i < n; i++) {
|
|
47
|
+
const f = i / (n - 1) * segs;
|
|
48
|
+
const s = Math.min(Math.floor(f), segs - 1);
|
|
49
|
+
const u = f - s;
|
|
50
|
+
const [p0, p1, p2, p3] = [pts[s], pts[s + 1], pts[s + 2], pts[s + 3]];
|
|
51
|
+
const c = (a, b, c2, d) => 0.5 * (2 * b + (-a + c2) * u + (2 * a - 5 * b + 4 * c2 - d) * u * u + (-a + 3 * b - 3 * c2 + d) * u * u * u);
|
|
52
|
+
out.push([c(p0[0], p1[0], p2[0], p3[0]), c(p0[1], p1[1], p2[1], p3[1])]);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
const scribbles = new Map();
|
|
57
|
+
|
|
58
|
+
/** The seeded tangle, computed once per seed and kept: every figure with that seed shares it. */
|
|
59
|
+
function scribble(seed, count = 64, radius = 190) {
|
|
60
|
+
const cached = scribbles.get(seed);
|
|
61
|
+
if (cached !== void 0) return cached;
|
|
62
|
+
const r = rng(seed);
|
|
63
|
+
const pts = [];
|
|
64
|
+
for (let i = 0; i < count; i++) {
|
|
65
|
+
const a = r() * Math.PI * 2;
|
|
66
|
+
const d = radius * (0.55 + 0.45 * Math.sqrt(r()));
|
|
67
|
+
pts.push([CX + d * Math.cos(a), CY + d * Math.sin(a) * 0.95]);
|
|
68
|
+
}
|
|
69
|
+
const line = catmull(pts, N);
|
|
70
|
+
scribbles.set(seed, line);
|
|
71
|
+
return line;
|
|
72
|
+
}
|
|
73
|
+
/** The app icon's # (viewBox 100), scaled up about the figure's centre. */
|
|
74
|
+
function hashStrokes() {
|
|
75
|
+
const m = ([x, y]) => [
|
|
76
|
+
CX + (x - 50) * 4.4,
|
|
77
|
+
CY + (y - 50) * 4.4
|
|
78
|
+
];
|
|
79
|
+
const strokes = [
|
|
80
|
+
[
|
|
81
|
+
[40, 7],
|
|
82
|
+
[30, 93]
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
[70, 7],
|
|
86
|
+
[60, 93]
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
[13, 36],
|
|
90
|
+
[93, 36]
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
[7, 66],
|
|
94
|
+
[87, 66]
|
|
95
|
+
]
|
|
96
|
+
];
|
|
97
|
+
return strokes.map(([a, b]) => [m(a), m(b)]);
|
|
98
|
+
}
|
|
99
|
+
/** Where a tugging Tex has hold of its own yarn, and how far round it the tangle follows. */
|
|
100
|
+
const GRAB = [CX + 140, CY + 110];
|
|
101
|
+
const GRAB_REACH = 80;
|
|
102
|
+
/** Tex's brush: a stroke this wide at full chaos, `GROW` wider once it is the #. */
|
|
103
|
+
const TEX_WIDTH = 13;
|
|
104
|
+
const GROW = 16;
|
|
105
|
+
const LIMB_WIDTH = TEX_WIDTH * 1.2;
|
|
106
|
+
const EYE_OUTLINE = TEX_WIDTH * 0.9;
|
|
107
|
+
const pathOf = (pts) => "M" + pts.map((p) => `${p[0].toFixed(1)} ${p[1].toFixed(1)}`).join("L");
|
|
108
|
+
/**
|
|
109
|
+
* Everything Tex draws at `chaos` (0 to 100).
|
|
110
|
+
*
|
|
111
|
+
* `small` drops the speckles and motion marks; `minStroke` (in the board's
|
|
112
|
+
* units) is the thinnest any line may be, so a 20px Tex still reads.
|
|
113
|
+
*
|
|
114
|
+
* `tug` (0 to 1) is Tex stressed, pulling at its own yarn (Dev2, 2026-10-13,
|
|
115
|
+
* for a crowded folder's page). Left out, Tex is exactly as it always was.
|
|
116
|
+
*/
|
|
117
|
+
function figureParts(chaos, {
|
|
118
|
+
small,
|
|
119
|
+
minStroke = 0,
|
|
120
|
+
seed = 7,
|
|
121
|
+
tug
|
|
122
|
+
}) {
|
|
123
|
+
const t = chaosToT(chaos);
|
|
124
|
+
const k = ease(t);
|
|
125
|
+
const src = scribble(seed);
|
|
126
|
+
const pull = tug === void 0 ? null : Math.min(1, Math.max(0, tug));
|
|
127
|
+
const hand = [CX + 225 + 70 * (pull ?? 0), CY + 30 + 20 * (pull ?? 0)];
|
|
128
|
+
// The tangle near the grabbed strand follows the hand, fading with distance.
|
|
129
|
+
const stretch = (p) => {
|
|
130
|
+
if (pull === null || pull === 0) return p;
|
|
131
|
+
const dx = p[0] - GRAB[0];
|
|
132
|
+
const dy = p[1] - GRAB[1];
|
|
133
|
+
const w = Math.exp(-(dx * dx + dy * dy) / (2 * GRAB_REACH * GRAB_REACH));
|
|
134
|
+
const f = 0.32 * pull * w;
|
|
135
|
+
return [p[0] + (hand[0] - GRAB[0]) * f, p[1] + (hand[1] - GRAB[1]) * f];
|
|
136
|
+
};
|
|
137
|
+
const n4 = N / 4;
|
|
138
|
+
const r = rng(seed + 100);
|
|
139
|
+
const strands = hashStrokes().map(([[x0, y0], [x1, y1]], s) => {
|
|
140
|
+
const strand = src.slice(s * n4, (s + 1) * n4).map((p, i) => {
|
|
141
|
+
const u = i / (n4 - 1);
|
|
142
|
+
const wob = 4 * Math.sin(u * 11 + s * 2);
|
|
143
|
+
const tx = x0 + (x1 - x0) * u + (y0 === y1 ? 0 : wob);
|
|
144
|
+
const ty = y0 + (y1 - y0) * u + (y0 === y1 ? wob : 0);
|
|
145
|
+
return stretch([p[0] + (tx - p[0]) * k, p[1] + (ty - p[1]) * k]);
|
|
146
|
+
});
|
|
147
|
+
const w = Math.max(TEX_WIDTH + GROW * k * k * k, minStroke);
|
|
148
|
+
// A dry second pass slightly offset, like a brush going over twice.
|
|
149
|
+
return {
|
|
150
|
+
d: pathOf(strand),
|
|
151
|
+
dry: pathOf(strand.map((p) => [p[0] + 3, p[1] - 2])),
|
|
152
|
+
width: w
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
// Legs and a waving arm fade out as it becomes a #; a tugging Tex keeps them.
|
|
156
|
+
const limbOpacity = pull === null ? 1 - Math.min(1, t / 0.85) : Math.max(0.85, 1 - Math.min(1, t / 0.85));
|
|
157
|
+
const limbWidth = Math.max(LIMB_WIDTH, minStroke);
|
|
158
|
+
const limb = (x0, y0, x1, y1, x2, y2) => ({
|
|
159
|
+
d: `M${x0} ${y0} Q${x1} ${y1} ${x2} ${y2}`,
|
|
160
|
+
width: limbWidth
|
|
161
|
+
});
|
|
162
|
+
const limbs = pull === null ? [
|
|
163
|
+
limb(CX - 60, CY + 175, CX - 70, CY + 230, CX - 95, CY + 285),
|
|
164
|
+
limb(CX + 60, CY + 175, CX + 70, CY + 230, CX + 95, CY + 285),
|
|
165
|
+
limb(CX + 170, CY - 40, CX + 215, CY - 100, CX + 235, CY - 165),
|
|
166
|
+
limb(CX - 175, CY + 10, CX - 230, CY + 60, CX - 245, CY + 110)
|
|
167
|
+
] : [
|
|
168
|
+
// Feet braced apart, leaning back from the pull.
|
|
169
|
+
limb(CX - 60, CY + 175, CX - 85, CY + 230, CX - 125, CY + 280),
|
|
170
|
+
limb(CX + 60, CY + 175, CX + 60, CY + 230, CX + 70, CY + 288),
|
|
171
|
+
// One hand hauling the strand, the other clutching its head.
|
|
172
|
+
limb(CX + 165, CY - 60, (CX + 165 + hand[0]) / 2 + 10, (CY - 60 + hand[1]) / 2 - 12, hand[0], hand[1]),
|
|
173
|
+
limb(CX - 175, CY + 10, CX - 255, CY - 70, CX - 150, CY - 165)
|
|
174
|
+
];
|
|
175
|
+
const yarn = pull === null ? null : (() => {
|
|
176
|
+
const [gx, gy] = stretch(GRAB);
|
|
177
|
+
const sag = 40 * (1 - pull);
|
|
178
|
+
const mx = (gx + hand[0]) / 2;
|
|
179
|
+
const my = (gy + hand[1]) / 2 + sag;
|
|
180
|
+
return {
|
|
181
|
+
d: `M${gx.toFixed(1)} ${gy.toFixed(1)} Q${mx.toFixed(1)} ${my.toFixed(1)} ${hand[0].toFixed(1)} ${hand[1].toFixed(1)}`,
|
|
182
|
+
width: Math.max(TEX_WIDTH * 0.8, minStroke)
|
|
183
|
+
};
|
|
184
|
+
})();
|
|
185
|
+
// Speckles of ink around the figure, drawn from the same stream paper3 used.
|
|
186
|
+
const speckles = [];
|
|
187
|
+
for (let i = 0; i < 26; i++) {
|
|
188
|
+
const a = r() * Math.PI * 2;
|
|
189
|
+
const dd = 200 + r() * 90;
|
|
190
|
+
const cy = CY + 290 + r() * 20 - (i < 12 ? 0 : 300 + dd * Math.sin(a));
|
|
191
|
+
speckles.push({
|
|
192
|
+
cx: CX + dd * Math.cos(a),
|
|
193
|
+
cy,
|
|
194
|
+
r: 1 + r() * 3,
|
|
195
|
+
opacity: (i < 12 ? 0.8 : 0.35) * (1 - k * 0.7)
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Motion marks by the waving side; a tugging Tex has stress marks over its head instead.
|
|
199
|
+
const motionOpacity = (0.4 + 0.6 * limbOpacity) * (1 - k);
|
|
200
|
+
const motion = pull !== null && !small ? {
|
|
201
|
+
d: [
|
|
202
|
+
`M${CX - 95} ${CY - 215} l-10 -34`,
|
|
203
|
+
`M${CX - 50} ${CY - 228} l2 -36`,
|
|
204
|
+
`M${CX - 5} ${CY - 218} l14 -30`
|
|
205
|
+
],
|
|
206
|
+
width: 9,
|
|
207
|
+
opacity: 0.55 + 0.45 * pull
|
|
208
|
+
} : small || motionOpacity <= 0 ? null : {
|
|
209
|
+
d: [
|
|
210
|
+
`M${CX + 250} ${CY - 215} l18 -30`,
|
|
211
|
+
`M${CX + 272} ${CY - 180} l30 -16`,
|
|
212
|
+
`M${CX + 280} ${CY - 145} l32 -2`
|
|
213
|
+
],
|
|
214
|
+
width: 9,
|
|
215
|
+
opacity: motionOpacity
|
|
216
|
+
};
|
|
217
|
+
// Googly, the pupils drifting back to centre as it calms down.
|
|
218
|
+
const j = 1 - k;
|
|
219
|
+
const googly = {
|
|
220
|
+
x: CX,
|
|
221
|
+
y: CY - 10,
|
|
222
|
+
scale: 1 - 0.25 * k,
|
|
223
|
+
outline: Math.max(EYE_OUTLINE, minStroke * 0.6),
|
|
224
|
+
whites: [
|
|
225
|
+
{ cx: -52, cy: 0, rx: 44, ry: 48 },
|
|
226
|
+
{ cx: 50, cy: 4, rx: 36, ry: 40 }
|
|
227
|
+
],
|
|
228
|
+
pupils: pull === null ? [
|
|
229
|
+
{ cx: -52 + 10 * j, cy: 10 * j, r: 17 },
|
|
230
|
+
{ cx: 50 + 8 * j, cy: 4 + 10 * j, r: 14 }
|
|
231
|
+
] : (
|
|
232
|
+
// Eyes on the strand, going wide (pupils shrinking) as it tightens.
|
|
233
|
+
[
|
|
234
|
+
{ cx: -36, cy: 14 + 4 * pull, r: 17 - 4 * pull },
|
|
235
|
+
{ cx: 62, cy: 18 + 4 * pull, r: 14 - 3 * pull }
|
|
236
|
+
]
|
|
237
|
+
)
|
|
238
|
+
};
|
|
239
|
+
const box = small ? SMALL_VIEW_BOX : VIEW_BOX;
|
|
240
|
+
return {
|
|
241
|
+
strands,
|
|
242
|
+
limbs,
|
|
243
|
+
limbOpacity,
|
|
244
|
+
speckles: small ? [] : speckles,
|
|
245
|
+
motion,
|
|
246
|
+
yarn,
|
|
247
|
+
googly,
|
|
248
|
+
viewBox: `${box.x} ${box.y} ${box.size} ${box.size}`
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
module.exports = { figureParts, scribble, SMALL_FIGURE, VIEW_BOX, SMALL_VIEW_BOX, TEX_WIDTH, CX, CY };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Types for `texFigure.cjs`; see that file for Tex's geometry and where it came from. */
|
|
2
|
+
|
|
3
|
+
export type Point = readonly [number, number];
|
|
4
|
+
|
|
5
|
+
export interface FigureParts {
|
|
6
|
+
/** The four strands, each with its dry second pass, at their stroke width. */
|
|
7
|
+
strands: { d: string; dry: string; width: number }[];
|
|
8
|
+
limbs: { d: string; width: number }[];
|
|
9
|
+
limbOpacity: number;
|
|
10
|
+
speckles: { cx: number; cy: number; r: number; opacity: number }[];
|
|
11
|
+
motion: { d: string[]; width: number; opacity: number } | null;
|
|
12
|
+
/** The strand Tex tugs at, from its body to its hand; only in the tugging pose. */
|
|
13
|
+
yarn: { d: string; width: number } | null;
|
|
14
|
+
/** The googly eyes, about (CX, CY - 10) at `scale`. Tex keeps them even when calm. */
|
|
15
|
+
googly: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
scale: number;
|
|
19
|
+
outline: number;
|
|
20
|
+
whites: { cx: number; cy: number; rx: number; ry: number }[];
|
|
21
|
+
pupils: { cx: number; cy: number; r: number }[];
|
|
22
|
+
};
|
|
23
|
+
viewBox: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare const SMALL_FIGURE: number;
|
|
27
|
+
export declare const VIEW_BOX: { readonly x: number; readonly y: number; readonly size: number };
|
|
28
|
+
export declare const SMALL_VIEW_BOX: { readonly x: number; readonly y: number; readonly size: number };
|
|
29
|
+
export declare const TEX_WIDTH: number;
|
|
30
|
+
export declare const CX: number;
|
|
31
|
+
export declare const CY: number;
|
|
32
|
+
export declare function scribble(seed: number, count?: number, radius?: number): readonly Point[];
|
|
33
|
+
export declare function figureParts(
|
|
34
|
+
chaos: number,
|
|
35
|
+
options: { small: boolean; minStroke?: number; seed?: number; tug?: number },
|
|
36
|
+
): FigureParts;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tex doing something: the scribble Tex (`texFigure.cjs` at full chaos) with
|
|
3
|
+
* its arms placed for a pose and one prop in its hands, as an SVG string.
|
|
4
|
+
*
|
|
5
|
+
* Drawn for the picture a note link unfurls with (Dev, 2026-11-23: "see him
|
|
6
|
+
* doing different things based on the title of the note or the type of the
|
|
7
|
+
* note"; `docs/decisions/privacy-and-sharing/note-link-previews.md`), and kept
|
|
8
|
+
* here beside the figure so the app can draw the same poses later.
|
|
9
|
+
*
|
|
10
|
+
* The body, eyes and legs are the figure's own; only the arms and the prop are
|
|
11
|
+
* new. Nothing here draws text: the card renderer rasterises this with no
|
|
12
|
+
* system fonts, so a number or a sign is drawn as strokes.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const { figureParts, CX, CY } = require("./texFigure.cjs");
|
|
16
|
+
|
|
17
|
+
/** Room around the figure for a prop held out or over its head. */
|
|
18
|
+
const VIEW = "-60 -20 800 780";
|
|
19
|
+
const LIMB = 15.6;
|
|
20
|
+
const q = (x0, y0, x1, y1, x2, y2) => `M${x0} ${y0} Q${x1} ${y1} ${x2} ${y2}`;
|
|
21
|
+
|
|
22
|
+
const LEGS = [q(CX - 60, CY + 175, CX - 70, CY + 230, CX - 95, CY + 285), q(CX + 60, CY + 175, CX + 70, CY + 230, CX + 95, CY + 285)];
|
|
23
|
+
const WAVE = q(CX + 170, CY - 40, CX + 215, CY - 100, CX + 235, CY - 165);
|
|
24
|
+
const DOWN = q(CX - 175, CY + 10, CX - 230, CY + 60, CX - 245, CY + 110);
|
|
25
|
+
const WAVE_MARKS = [`M${CX + 250} ${CY - 215} l18 -30`, `M${CX + 272} ${CY - 180} l30 -16`, `M${CX + 280} ${CY - 145} l32 -2`];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Every pose: its arms, where its eyes look, and its prop drawn in the ink,
|
|
29
|
+
* the paper (the prop's fill) and the accent.
|
|
30
|
+
*/
|
|
31
|
+
const POSES = {
|
|
32
|
+
waving: { arms: [WAVE, DOWN], look: [10, 10], marks: WAVE_MARKS, prop: () => "" },
|
|
33
|
+
reading: {
|
|
34
|
+
arms: [q(CX - 170, CY + 60, CX - 200, CY + 150, CX - 120, CY + 190), q(CX + 170, CY + 60, CX + 200, CY + 150, CX + 120, CY + 190)],
|
|
35
|
+
look: [0, 22],
|
|
36
|
+
prop: (ink, paper, accent) =>
|
|
37
|
+
`<g transform="translate(${CX} ${CY + 200}) rotate(-4)">` +
|
|
38
|
+
`<path d="M0 -10 C-60 -40 -130 -30 -165 -10 L-165 95 C-130 75 -60 70 0 100 Z" fill="${paper}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
39
|
+
`<path d="M0 -10 C60 -40 130 -30 165 -10 L165 95 C130 75 60 70 0 100 Z" fill="${paper}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
40
|
+
`<path d="M-135 15 q50 -14 100 4 M-135 42 q50 -14 100 4 M35 19 q50 -18 100 -4 M35 46 q50 -18 100 -4" stroke="${ink}" stroke-width="6" fill="none" stroke-linecap="round" opacity=".55"/>` +
|
|
41
|
+
`<path d="M0 -6 L0 96" stroke="${ink}" stroke-width="8"/>` +
|
|
42
|
+
`<path d="M60 -26 L60 40 L74 28 L88 40 L88 -30" fill="${accent}"/></g>`,
|
|
43
|
+
},
|
|
44
|
+
checklist: {
|
|
45
|
+
arms: [q(CX + 170, CY + 20, CX + 220, CY + 70, CX + 255, CY + 60), DOWN],
|
|
46
|
+
look: [22, 6],
|
|
47
|
+
prop: (ink, paper, accent) =>
|
|
48
|
+
`<g transform="translate(${CX + 300} ${CY - 20}) rotate(8)">` +
|
|
49
|
+
`<rect x="-70" y="-120" width="150" height="200" rx="14" fill="${paper}" stroke="${ink}" stroke-width="12"/>` +
|
|
50
|
+
`<rect x="-28" y="-138" width="66" height="34" rx="8" fill="${ink}"/>` +
|
|
51
|
+
`<path d="M-44 -62 l14 14 l24 -30 M-44 -8 l14 14 l24 -30" stroke="${accent}" stroke-width="11" fill="none" stroke-linecap="round" stroke-linejoin="round"/>` +
|
|
52
|
+
`<rect x="-44" y="34" width="22" height="22" rx="4" fill="none" stroke="${ink}" stroke-width="7"/>` +
|
|
53
|
+
`<path d="M4 -58 h50 M4 -4 h50 M4 46 h50" stroke="${ink}" stroke-width="8" stroke-linecap="round"/></g>`,
|
|
54
|
+
},
|
|
55
|
+
coffee: {
|
|
56
|
+
arms: [q(CX + 170, CY + 30, CX + 230, CY + 60, CX + 250, CY + 10), DOWN],
|
|
57
|
+
look: [16, 0],
|
|
58
|
+
prop: (ink, paper, accent) =>
|
|
59
|
+
`<g transform="translate(${CX + 285} ${CY - 30}) scale(1.5)">` +
|
|
60
|
+
`<path d="M-50 -50 L50 -50 L42 50 Q40 66 24 66 L-24 66 Q-40 66 -42 50 Z" fill="${paper}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
61
|
+
`<path d="M50 -30 q40 0 36 32 q-4 28 -40 26" fill="none" stroke="${ink}" stroke-width="12" stroke-linecap="round"/>` +
|
|
62
|
+
`<rect x="-44" y="-12" width="88" height="26" fill="${accent}"/>` +
|
|
63
|
+
`<path d="M-20 -78 q-14 -22 0 -44 q14 -22 0 -44 M14 -78 q-14 -22 0 -44 q14 -22 0 -44" stroke="${ink}" stroke-width="8" fill="none" stroke-linecap="round" opacity=".5"/></g>`,
|
|
64
|
+
},
|
|
65
|
+
idea: {
|
|
66
|
+
arms: [q(CX + 170, CY - 40, CX + 205, CY - 120, CX + 190, CY - 205), DOWN],
|
|
67
|
+
look: [12, -22],
|
|
68
|
+
prop: (ink, paper, accent) =>
|
|
69
|
+
`<g transform="translate(${CX + 10} ${CY - 300})">` +
|
|
70
|
+
`<path d="M0 -80 C55 -80 82 -40 78 0 C74 30 46 46 40 74 L-40 74 C-46 46 -74 30 -78 0 C-82 -40 -55 -80 0 -80 Z" fill="${accent}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
71
|
+
`<rect x="-36" y="74" width="72" height="34" rx="8" fill="${paper}" stroke="${ink}" stroke-width="10"/>` +
|
|
72
|
+
`<path d="M-18 10 l18 28 l18 -28" fill="none" stroke="${ink}" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/>` +
|
|
73
|
+
`<path d="M-120 -40 l-34 -14 M120 -40 l34 -14 M-110 30 l-36 6 M110 30 l36 6 M0 -110 l0 -34" stroke="${ink}" stroke-width="10" stroke-linecap="round"/></g>`,
|
|
74
|
+
},
|
|
75
|
+
trip: {
|
|
76
|
+
arms: [WAVE, q(CX - 175, CY + 10, CX - 225, CY + 80, CX - 230, CY + 150)],
|
|
77
|
+
look: [10, 10],
|
|
78
|
+
marks: WAVE_MARKS,
|
|
79
|
+
prop: (ink, paper, accent) =>
|
|
80
|
+
`<g transform="translate(${CX - 240} ${CY + 250})">` +
|
|
81
|
+
`<path d="M-30 -98 L-30 -122 Q-30 -132 -20 -132 L20 -132 Q30 -132 30 -122 L30 -98" fill="none" stroke="${ink}" stroke-width="11"/>` +
|
|
82
|
+
`<rect x="-95" y="-100" width="190" height="150" rx="20" fill="${accent}" stroke="${ink}" stroke-width="12"/>` +
|
|
83
|
+
`<path d="M-50 -100 L-50 50 M50 -100 L50 50" stroke="${ink}" stroke-width="9"/>` +
|
|
84
|
+
`<circle cx="-62" cy="64" r="12" fill="${ink}"/><circle cx="62" cy="64" r="12" fill="${ink}"/></g>`,
|
|
85
|
+
},
|
|
86
|
+
painting: {
|
|
87
|
+
arms: [q(CX + 170, CY + 10, CX + 220, CY + 30, CX + 250, CY - 10), DOWN],
|
|
88
|
+
look: [22, 0],
|
|
89
|
+
prop: (ink, paper, accent) =>
|
|
90
|
+
`<g transform="translate(${CX + 300} ${CY - 30}) rotate(-14)">` +
|
|
91
|
+
`<path d="M-110 0 C-110 -80 0 -110 70 -80 C130 -55 120 10 70 10 C30 10 40 60 0 70 C-60 85 -110 50 -110 0 Z" fill="${paper}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
92
|
+
`<circle cx="-60" cy="-30" r="20" fill="${accent}"/><circle cx="-5" cy="-60" r="20" fill="${ink}"/><circle cx="55" cy="-45" r="20" fill="${accent}" opacity=".55"/><circle cx="-60" cy="30" r="20" fill="${ink}" opacity=".55"/>` +
|
|
93
|
+
`<circle cx="10" cy="15" r="18" fill="none" stroke="${ink}" stroke-width="9"/></g>`,
|
|
94
|
+
},
|
|
95
|
+
calendar: {
|
|
96
|
+
arms: [q(CX + 170, CY + 10, CX + 240, CY - 20, CX + 250, CY - 90), DOWN],
|
|
97
|
+
look: [20, -8],
|
|
98
|
+
prop: (ink, paper, accent) =>
|
|
99
|
+
`<g transform="translate(${CX + 300} ${CY - 170}) rotate(10)">` +
|
|
100
|
+
`<rect x="-85" y="-80" width="170" height="160" rx="16" fill="${paper}" stroke="${ink}" stroke-width="12"/>` +
|
|
101
|
+
`<path d="M-85 -64 Q-85 -80 -69 -80 L69 -80 Q85 -80 85 -64 L85 -30 L-85 -30 Z" fill="${accent}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
102
|
+
`<path d="M-40 -100 L-40 -62 M40 -100 L40 -62" stroke="${ink}" stroke-width="12" stroke-linecap="round"/>` +
|
|
103
|
+
// A month's days as dots, one of them ringed: the date.
|
|
104
|
+
[-50, 0, 50].flatMap((x) => [5, 50].map((y) => `<circle cx="${x}" cy="${y}" r="9" fill="${ink}"/>`)).join("") +
|
|
105
|
+
`<circle cx="0" cy="50" r="24" fill="none" stroke="${accent}" stroke-width="9"/></g>`,
|
|
106
|
+
},
|
|
107
|
+
money: {
|
|
108
|
+
arms: [q(CX + 170, CY + 20, CX + 220, CY + 60, CX + 245, CY + 20), DOWN],
|
|
109
|
+
look: [20, 4],
|
|
110
|
+
prop: (ink, paper) =>
|
|
111
|
+
`<g transform="translate(${CX + 300} ${CY - 30}) rotate(-12)">` +
|
|
112
|
+
`<rect x="-120" y="-60" width="230" height="120" rx="14" fill="${paper}" stroke="${ink}" stroke-width="12" transform="rotate(-10) translate(10 -30)"/>` +
|
|
113
|
+
`<rect x="-115" y="-60" width="230" height="120" rx="14" fill="${paper}" stroke="${ink}" stroke-width="12"/>` +
|
|
114
|
+
`<circle r="38" fill="none" stroke="${ink}" stroke-width="10"/>` +
|
|
115
|
+
// A dollar sign in strokes.
|
|
116
|
+
`<path d="M14 -16 C10 -24 -14 -26 -16 -12 C-18 2 16 0 16 14 C14 28 -12 28 -16 18 M0 -30 L0 30" fill="none" stroke="${ink}" stroke-width="8" stroke-linecap="round"/></g>`,
|
|
117
|
+
},
|
|
118
|
+
cooking: {
|
|
119
|
+
arms: [q(CX + 170, CY + 20, CX + 230, CY + 20, CX + 250, CY - 60), DOWN],
|
|
120
|
+
look: [10, 4],
|
|
121
|
+
prop: (ink, paper, accent) =>
|
|
122
|
+
`<g transform="translate(${CX - 5} ${CY - 215})">` +
|
|
123
|
+
`<path d="M-80 0 C-140 -10 -140 -100 -70 -95 C-60 -150 30 -160 50 -110 C120 -140 160 -40 85 0 Z" fill="${paper}" stroke="${ink}" stroke-width="12" stroke-linejoin="round"/>` +
|
|
124
|
+
`<rect x="-82" y="-6" width="166" height="44" rx="6" fill="${paper}" stroke="${ink}" stroke-width="12"/></g>` +
|
|
125
|
+
`<g transform="translate(${CX + 262} ${CY - 90}) rotate(18)">` +
|
|
126
|
+
`<rect x="-8" y="0" width="16" height="140" rx="8" fill="${ink}"/>` +
|
|
127
|
+
`<ellipse cx="0" cy="-36" rx="30" ry="44" fill="${accent}" stroke="${ink}" stroke-width="10"/></g>`,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const POSE_NAMES = Object.freeze(Object.keys(POSES));
|
|
132
|
+
|
|
133
|
+
/** Tex in `pose`, as a standalone SVG document. An unknown pose throws: a caller picks from `POSE_NAMES`. */
|
|
134
|
+
function texPoseSvg(pose, { ink = "#2A45CF", eye = "#FBFAF6", paper = "#FBFAF6", accent = "#2F7BF5" } = {}) {
|
|
135
|
+
const p = POSES[pose];
|
|
136
|
+
if (p === undefined) throw new Error(`no Tex pose "${pose}"`);
|
|
137
|
+
const parts = figureParts(100, { small: false });
|
|
138
|
+
const g = parts.googly;
|
|
139
|
+
const strands = parts.strands
|
|
140
|
+
.map(
|
|
141
|
+
(s) =>
|
|
142
|
+
`<path d="${s.d}" stroke="${ink}" stroke-width="${s.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>` +
|
|
143
|
+
`<path d="${s.dry}" stroke="${ink}" stroke-width="${s.width * 0.45}" fill="none" stroke-linecap="round" opacity=".7"/>`,
|
|
144
|
+
)
|
|
145
|
+
.join("");
|
|
146
|
+
const limbs = [...LEGS, ...p.arms].map((d) => `<path d="${d}" stroke="${ink}" stroke-width="${LIMB}" fill="none" stroke-linecap="round"/>`).join("");
|
|
147
|
+
const marks = (p.marks || []).map((d) => `<path d="${d}" stroke="${ink}" stroke-width="9" stroke-linecap="round" opacity=".9"/>`).join("");
|
|
148
|
+
const [lx, ly] = p.look;
|
|
149
|
+
const eyes =
|
|
150
|
+
`<g transform="translate(${g.x} ${g.y}) scale(${g.scale})">` +
|
|
151
|
+
g.whites.map((w) => `<ellipse cx="${w.cx}" cy="${w.cy}" rx="${w.rx}" ry="${w.ry}" fill="${eye}" stroke="${ink}" stroke-width="${g.outline}"/>`).join("") +
|
|
152
|
+
`<circle cx="${-52 + lx}" cy="${ly}" r="17" fill="${ink}"/><circle cx="${50 + lx * 0.8}" cy="${4 + ly}" r="14" fill="${ink}"/></g>`;
|
|
153
|
+
// The prop sits in front of the body and behind the arms that hold it.
|
|
154
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${VIEW}">${strands}${eyes}${p.prop(ink, paper, accent)}${limbs}${marks}</svg>`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* The app icon's # on its rounded tile, as `apps/mobile/assets/source/tex-mark.mjs`
|
|
159
|
+
* draws `favicon.svg` (Tex at rest, heavier strokes for reading small), in any
|
|
160
|
+
* ground and ink, for a card that shows the # instead of Tex.
|
|
161
|
+
*/
|
|
162
|
+
function hashTileSvg({ ground = "#EDE4D3", ink = "#2A45CF" } = {}) {
|
|
163
|
+
const px = 256;
|
|
164
|
+
const half = 204;
|
|
165
|
+
const pad = 0.12;
|
|
166
|
+
const heavier = 16;
|
|
167
|
+
const scale = px / ((half * 2) / (1 - 2 * pad));
|
|
168
|
+
const at = (n) => +n.toFixed(2);
|
|
169
|
+
const strokes = figureParts(0, { small: false })
|
|
170
|
+
.strands.map((s) => `<path d="${s.d}" stroke-width="${at(s.width + heavier)}"/><path d="${s.dry}" stroke-width="${at((s.width + heavier) * 0.45)}" opacity="0.7"/>`)
|
|
171
|
+
.join("");
|
|
172
|
+
return (
|
|
173
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${px}" height="${px}" viewBox="0 0 ${px} ${px}">` +
|
|
174
|
+
`<rect width="${px}" height="${px}" rx="${at(0.22 * px)}" fill="${ground}"/>` +
|
|
175
|
+
`<g transform="translate(${at(px / 2 - CX * scale)} ${at(px / 2 - CY * scale)}) scale(${+scale.toFixed(5)})">` +
|
|
176
|
+
`<g fill="none" stroke="${ink}" stroke-linecap="round" stroke-linejoin="round">${strokes}</g></g></svg>`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
module.exports = { texPoseSvg, hashTileSvg, POSE_NAMES };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Types for `texPoses.cjs`; see that file for what each pose is for. */
|
|
2
|
+
|
|
3
|
+
export type TexPose =
|
|
4
|
+
| "waving"
|
|
5
|
+
| "reading"
|
|
6
|
+
| "checklist"
|
|
7
|
+
| "coffee"
|
|
8
|
+
| "idea"
|
|
9
|
+
| "trip"
|
|
10
|
+
| "painting"
|
|
11
|
+
| "calendar"
|
|
12
|
+
| "money"
|
|
13
|
+
| "cooking";
|
|
14
|
+
|
|
15
|
+
export declare const POSE_NAMES: readonly TexPose[];
|
|
16
|
+
export declare function texPoseSvg(
|
|
17
|
+
pose: TexPose,
|
|
18
|
+
colors?: { ink?: string; eye?: string; paper?: string; accent?: string },
|
|
19
|
+
): string;
|
|
20
|
+
export declare function hashTileSvg(colors?: { ground?: string; ink?: string }): string;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Part end: what a background job does after one of its parts (Dev2, 2026-11-17, "jobs as config", step 5).
|
|
3
|
+
*
|
|
4
|
+
* A job runs in parts. Until now the choice after each part (start the next one, send the last draft, or end and
|
|
5
|
+
* say how) and the limits behind it (10 parts, 30 minutes; 96 parts and 4 hours on the person's own computer) were
|
|
6
|
+
* code inside the texting Worker's `runJob` (`packages/tex/worker/jobRun.ts`). The timecards job showed what that costs:
|
|
7
|
+
* every part died the same way and the next one was started anyway, ten times, and the answer was never sent. Here the
|
|
8
|
+
* choice is one pure function, the Part end node's code (`packages/tex/gateway/agent/graph/nodes/partEnd.js`), and the limits
|
|
9
|
+
* are that node's config (`limits`), so the Lab shows, tests and changes both.
|
|
10
|
+
*
|
|
11
|
+
* Plain CommonJS with no imports, so the gateway and the texting Worker read the same rules.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The limits a job's parts run under when the config names none: today's numbers, so wiring this changes nothing. */
|
|
15
|
+
const DEFAULT_LIMITS = Object.freeze({ parts: 10, minutes: 30, machineParts: 96, machineMinutes: 240, resumeAfterMinutes: 2, staleParts: 0, sleepMinutes: 120 });
|
|
16
|
+
|
|
17
|
+
/** Why a part ended (`packages/tex/worker/jobProgress.ts` `PartCause`). */
|
|
18
|
+
const CAUSES = Object.freeze(["done", "waiting", "stuck", "check_limit", "timeout", "crash", "model_down", "steps_out", "unfinished", "changed", "stopped", "refused"]);
|
|
19
|
+
|
|
20
|
+
/** Causes that would end the next part the same way: running it again only burns a part, so the last draft goes. */
|
|
21
|
+
const DETERMINISTIC = Object.freeze(["check_limit"]);
|
|
22
|
+
|
|
23
|
+
/** How a part's own check can read its answer (`checked`). */
|
|
24
|
+
const ENDS = Object.freeze(["done", "waiting", "stuck"]);
|
|
25
|
+
|
|
26
|
+
/** Causes where the part broke before it answered. */
|
|
27
|
+
const BROKEN = Object.freeze(["check_limit", "timeout", "crash"]);
|
|
28
|
+
|
|
29
|
+
/** Causes that leave work to do, so a next part picks it up while there is room. */
|
|
30
|
+
const CARRY = Object.freeze(["check_limit", "timeout", "crash", "steps_out", "unfinished", "changed"]);
|
|
31
|
+
|
|
32
|
+
/** Causes where the part answered but was not done, so a next part would go on looking (the `stale` rule). */
|
|
33
|
+
const LOOKING = Object.freeze(["steps_out", "unfinished"]);
|
|
34
|
+
|
|
35
|
+
/** A whole, positive number from config, or the default. */
|
|
36
|
+
const whole = (value, fallback) => (Number.isInteger(value) && value > 0 ? value : fallback);
|
|
37
|
+
|
|
38
|
+
/** The limits a node's config gives, each falling back to today's number. */
|
|
39
|
+
function limitsOf(config) {
|
|
40
|
+
const given = config && typeof config === "object" ? config : {};
|
|
41
|
+
return {
|
|
42
|
+
parts: whole(given.parts, DEFAULT_LIMITS.parts),
|
|
43
|
+
minutes: whole(given.minutes, DEFAULT_LIMITS.minutes),
|
|
44
|
+
machineParts: whole(given.machineParts, DEFAULT_LIMITS.machineParts),
|
|
45
|
+
machineMinutes: whole(given.machineMinutes, DEFAULT_LIMITS.machineMinutes),
|
|
46
|
+
resumeAfterMinutes: whole(given.resumeAfterMinutes, DEFAULT_LIMITS.resumeAfterMinutes),
|
|
47
|
+
staleParts: whole(given.staleParts, DEFAULT_LIMITS.staleParts),
|
|
48
|
+
sleepMinutes: whole(given.sleepMinutes, DEFAULT_LIMITS.sleepMinutes),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The limits a whole config sets on its Part end node: every reader of a job's limits takes them from here. */
|
|
53
|
+
function configLimits(config) {
|
|
54
|
+
const node = Array.isArray(config?.nodes) ? config.nodes.find((n) => n && n.id === "partEnd") : null;
|
|
55
|
+
return limitsOf(node?.limits);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Whether a part may follow this one: under the part count and inside the time, the computer's own when it runs there. */
|
|
59
|
+
function roomLeft({ part, startedAt, now, machine }, limits) {
|
|
60
|
+
const most = machine ? limits.machineParts : limits.parts;
|
|
61
|
+
const minutes = machine ? limits.machineMinutes : limits.minutes;
|
|
62
|
+
return part < most && now - startedAt < minutes * 60_000;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* What follows a part.
|
|
67
|
+
*
|
|
68
|
+
* `to`: "carry" starts the next part; "deliver" sends the last draft the job saved; "end" ends the job as `ended` says;
|
|
69
|
+
* "sleep" keeps a part of a split job (`split`, `jobSplit.cjs`) that ended waiting asleep for `sleepMs`: mail on its
|
|
70
|
+
* note or their text wakes it into its next part, and a sleep that runs out ends it waiting, as "end" would have.
|
|
71
|
+
* `ended` (with "deliver" and "end"): "done", "waiting", "stuck" or "failed".
|
|
72
|
+
*
|
|
73
|
+
* Input: `cause` (above), `part` (this part's number, from 1), `startedAt` and `now` (ms), `machine` (it runs on the
|
|
74
|
+
* person's own computer), `hasDraft` (a draft is saved), `idle` (this part called no tool and wasn't done), `wasIdle`
|
|
75
|
+
* (the part before it was idle too), `split` (it is one part of a split job), `rejected` (turned down before it ran, as opposed to refused for now), `refusal`
|
|
76
|
+
* (why a part was refused for now: "daily_limit" or "no_model"), `fresh` (how many of this part's tool results brought
|
|
77
|
+
* back something no earlier part had), `staleBefore` (how many parts in a row before it brought back nothing new).
|
|
78
|
+
*
|
|
79
|
+
* A job still looking that found nothing new in `staleParts` parts in a row ends (`stale`), its answer sent as it
|
|
80
|
+
* stands: another part would read the same pages again (2026-11-17, a coworking job whose check sent back six parts
|
|
81
|
+
* for day pass prices the spaces' own sites don't publish). 0 turns the rule off.
|
|
82
|
+
*
|
|
83
|
+
* A part refused at today's limit pauses the job: it ends waiting with `resumeAt`, just after the limit resets
|
|
84
|
+
* (counted per UTC day, `apps/convex/functions/lib/jev/meter.ts` `utcDay`), and starts again by itself then
|
|
85
|
+
* (`packages/tex/worker/jobPause.ts`); `resumeAfterMinutes` is how long after the reset.
|
|
86
|
+
*/
|
|
87
|
+
function decidePartEnd(input, config) {
|
|
88
|
+
const limits = limitsOf(config);
|
|
89
|
+
const cause = CAUSES.includes(input?.cause) ? input.cause : "crash";
|
|
90
|
+
const room = roomLeft(
|
|
91
|
+
{ part: Number(input?.part) || 1, startedAt: Number(input?.startedAt) || 0, now: Number(input?.now) || 0, machine: input?.machine === true },
|
|
92
|
+
limits,
|
|
93
|
+
);
|
|
94
|
+
// Two parts in a row that called no tool and still weren't done are going nowhere: it ends stuck (2026-10-31).
|
|
95
|
+
// `idle` already means the part was not done, whatever ended it (out of steps too).
|
|
96
|
+
const spinning = input?.idle === true && input?.wasIdle === true && CARRY.includes(cause) && !BROKEN.includes(cause);
|
|
97
|
+
// A part that broke with a draft saved sends it when the next part would break the same way, or no part is left:
|
|
98
|
+
// never a job that ends with nothing (2026-11-17, the timecards job).
|
|
99
|
+
if (BROKEN.includes(cause) && input?.hasDraft === true && (DETERMINISTIC.includes(cause) || !room)) {
|
|
100
|
+
return { to: "deliver", ended: DETERMINISTIC.includes(cause) ? "done" : "stuck", cause, room };
|
|
101
|
+
}
|
|
102
|
+
const stale = limits.staleParts > 0 && LOOKING.includes(cause) && input?.fresh === 0 && (Number(input?.staleBefore) || 0) + 1 >= limits.staleParts;
|
|
103
|
+
if (CARRY.includes(cause) && room && !spinning && !stale) return { to: "carry", cause, room };
|
|
104
|
+
// A split's part waiting on a partner's mail, or on them, sleeps instead of ending, so the next word wakes it where it
|
|
105
|
+
// was without a restart and without using up parts (2026-11-06: a split's parts each ended or ran out on their own
|
|
106
|
+
// while they waited on each other). Never past the job's own time: it sleeps at most until that runs out.
|
|
107
|
+
if (cause === "waiting" && input?.split === true && room) {
|
|
108
|
+
const most = (input?.machine === true ? limits.machineMinutes : limits.minutes) * 60_000;
|
|
109
|
+
const sleepMs = Math.min(limits.sleepMinutes * 60_000, most - ((Number(input?.now) || 0) - (Number(input?.startedAt) || 0)));
|
|
110
|
+
if (sleepMs > 0) return { to: "sleep", ended: "waiting", cause, room, sleepMs };
|
|
111
|
+
}
|
|
112
|
+
const pause = cause === "refused" && input?.rejected !== true && input?.refusal === "daily_limit" ? { resumeAt: limitResetAt(Number(input?.now) || 0, limits) } : {};
|
|
113
|
+
return { to: "end", ended: endedAs(cause, input?.rejected === true, input?.checked), cause, room, ...(spinning ? { spinning: true } : {}), ...(stale && !spinning ? { stale: true } : {}), ...pause };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** When a job paused at today's limit at `now` starts again: the next midnight UTC, plus `resumeAfterMinutes`. */
|
|
117
|
+
function limitResetAt(now, limits = DEFAULT_LIMITS) {
|
|
118
|
+
const day = new Date(now);
|
|
119
|
+
return Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), day.getUTCDate() + 1) + limits.resumeAfterMinutes * 60_000;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** How a job that ends here ended, by why its last part did. */
|
|
123
|
+
function endedAs(cause, rejected, checked) {
|
|
124
|
+
// Out of steps with no room left, its answer ends as the part's own check said (done unless it was judged short).
|
|
125
|
+
if (cause === "steps_out" && ENDS.includes(checked)) return checked;
|
|
126
|
+
if (cause === "refused") return rejected ? "failed" : "waiting";
|
|
127
|
+
if (cause === "waiting") return "waiting";
|
|
128
|
+
if (cause === "done" || cause === "changed") return "done";
|
|
129
|
+
if (cause === "stuck" || cause === "unfinished" || cause === "steps_out") return "stuck";
|
|
130
|
+
return "failed"; // stopped, a crash or a timeout with nothing saved, a model that stayed down
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = { CAUSES, DEFAULT_LIMITS, DETERMINISTIC, configLimits, decidePartEnd, limitResetAt, limitsOf, roomLeft };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Types for `jobPartEnd.cjs`; see that file for the rules and the reasons. */
|
|
2
|
+
export type PartCause = "done" | "waiting" | "stuck" | "check_limit" | "timeout" | "crash" | "model_down" | "steps_out" | "unfinished" | "changed" | "stopped" | "refused";
|
|
3
|
+
export interface JobLimits { parts: number; minutes: number; machineParts: number; machineMinutes: number; resumeAfterMinutes: number; staleParts: number; sleepMinutes: number }
|
|
4
|
+
export interface PartEndInput { cause: PartCause; part: number; startedAt: number; now: number; machine?: boolean; hasDraft?: boolean; idle?: boolean; wasIdle?: boolean; split?: boolean; rejected?: boolean; refusal?: "daily_limit" | "no_model"; checked?: "done" | "waiting" | "stuck"; fresh?: number; staleBefore?: number }
|
|
5
|
+
export interface PartEndChoice { to: "carry" | "deliver" | "end" | "sleep"; ended?: "done" | "waiting" | "stuck" | "failed"; cause: PartCause; room: boolean; spinning?: true; stale?: true; resumeAt?: number; sleepMs?: number }
|
|
6
|
+
export declare const CAUSES: readonly PartCause[];
|
|
7
|
+
export declare const DETERMINISTIC: readonly PartCause[];
|
|
8
|
+
export declare const DEFAULT_LIMITS: Readonly<JobLimits>;
|
|
9
|
+
export declare function limitsOf(config?: Partial<JobLimits> | null): JobLimits;
|
|
10
|
+
export declare function roomLeft(at: { part: number; startedAt: number; now: number; machine?: boolean }, limits: JobLimits): boolean;
|
|
11
|
+
export declare function limitResetAt(now: number, limits?: JobLimits): number;
|
|
12
|
+
export declare function decidePartEnd(input: PartEndInput, config?: Partial<JobLimits> | null): PartEndChoice;
|
|
13
|
+
export declare function configLimits(config?: { nodes?: readonly { id: string; limits?: unknown }[] } | null): JobLimits;
|