@tempoxyz/ds 0.3.15 → 0.3.17

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.
Files changed (130) hide show
  1. package/dist/docs/AGENTS.md +10 -6
  2. package/dist/docs/arsenal.md +44 -0
  3. package/dist/docs/marketing.md +703 -4
  4. package/dist/docs/product/components/actions.md +53 -1
  5. package/dist/docs/product/components/blockchain.md +147 -3
  6. package/dist/docs/product/components/feedback-and-status.md +137 -7
  7. package/dist/docs/product/components/navigation.md +1 -1
  8. package/dist/docs/product/documents.md +225 -0
  9. package/dist/docs/product/foundations.md +2 -1
  10. package/dist/docs/product/patterns.md +3 -22
  11. package/dist/document/Document.d.ts +46 -0
  12. package/dist/document/Document.d.ts.map +1 -0
  13. package/dist/document/Document.js +190 -0
  14. package/dist/document/Document.js.map +1 -0
  15. package/dist/document/Enhance.d.ts +13 -0
  16. package/dist/document/Enhance.d.ts.map +1 -0
  17. package/dist/document/Enhance.js +421 -0
  18. package/dist/document/Enhance.js.map +1 -0
  19. package/dist/document/bin.d.ts +3 -0
  20. package/dist/document/bin.d.ts.map +1 -0
  21. package/dist/document/bin.js +38 -0
  22. package/dist/document/bin.js.map +1 -0
  23. package/dist/document/document.css +373 -0
  24. package/dist/document/index.d.ts +3 -0
  25. package/dist/document/index.d.ts.map +1 -0
  26. package/dist/document/index.js +3 -0
  27. package/dist/document/index.js.map +1 -0
  28. package/dist/document/internal/Cli.d.ts +43 -0
  29. package/dist/document/internal/Cli.d.ts.map +1 -0
  30. package/dist/document/internal/Cli.js +87 -0
  31. package/dist/document/internal/Cli.js.map +1 -0
  32. package/dist/document/internal/Template.d.ts +21 -0
  33. package/dist/document/internal/Template.d.ts.map +1 -0
  34. package/dist/document/internal/Template.js +15 -0
  35. package/dist/document/internal/Template.js.map +1 -0
  36. package/dist/document/script.d.ts +2 -0
  37. package/dist/document/script.d.ts.map +1 -0
  38. package/dist/document/script.js +379 -0
  39. package/dist/document/templates/brief.html +96 -0
  40. package/dist/document/templates/essay.html +70 -0
  41. package/dist/document/templates/post.html +69 -0
  42. package/dist/marketing/index.js.zyzz.json +1 -1
  43. package/dist/marketing/vars.d.ts +618 -758
  44. package/dist/marketing/vars.d.ts.map +1 -1
  45. package/dist/marketing/vars.js +8 -5
  46. package/dist/marketing/vars.js.map +1 -1
  47. package/dist/marketing/vars.js.zyzz.json +1 -1
  48. package/dist/marketing/zyzz.config.d.ts +3042 -3757
  49. package/dist/marketing/zyzz.config.d.ts.map +1 -1
  50. package/dist/marketing/zyzz.config.js +1 -1
  51. package/dist/marketing/zyzz.config.js.map +1 -1
  52. package/dist/marketing/zyzz.config.js.zyzz.json +1 -1
  53. package/dist/mobile/components/Button.d.ts +115 -15
  54. package/dist/mobile/components/Button.d.ts.map +1 -1
  55. package/dist/mobile/components/Button.js +85 -14
  56. package/dist/mobile/components/Button.js.map +1 -1
  57. package/dist/mobile/components/IconButton.d.ts +129 -40
  58. package/dist/mobile/components/IconButton.d.ts.map +1 -1
  59. package/dist/mobile/components/IconButton.js +97 -28
  60. package/dist/mobile/components/IconButton.js.map +1 -1
  61. package/dist/mobile/components/TextInput.d.ts +132 -11
  62. package/dist/mobile/components/TextInput.d.ts.map +1 -1
  63. package/dist/mobile/components/TextInput.js +115 -14
  64. package/dist/mobile/components/TextInput.js.map +1 -1
  65. package/dist/mobile/index.d.ts +1 -0
  66. package/dist/mobile/index.d.ts.map +1 -1
  67. package/dist/mobile/index.js +1 -0
  68. package/dist/mobile/index.js.map +1 -1
  69. package/dist/mobile/vars.d.ts +103 -0
  70. package/dist/mobile/vars.d.ts.map +1 -1
  71. package/dist/mobile/vars.js +74 -0
  72. package/dist/mobile/vars.js.map +1 -1
  73. package/dist/mobile/zyzz.config.d.ts +408 -0
  74. package/dist/mobile/zyzz.config.d.ts.map +1 -1
  75. package/dist/web/components/AddressCard.js.zyzz.json +1 -1
  76. package/dist/web/components/Amount.css +1 -1
  77. package/dist/web/components/Amount.d.ts +9 -0
  78. package/dist/web/components/Amount.d.ts.map +1 -1
  79. package/dist/web/components/Amount.js +8 -5
  80. package/dist/web/components/Amount.js.map +1 -1
  81. package/dist/web/components/Amount.js.zyzz.json +1 -1
  82. package/dist/web/components/CopyButton.d.ts +6 -0
  83. package/dist/web/components/CopyButton.d.ts.map +1 -1
  84. package/dist/web/components/CopyButton.js +4 -1
  85. package/dist/web/components/CopyButton.js.map +1 -1
  86. package/dist/web/components/CopyButton.js.zyzz.json +1 -1
  87. package/dist/web/components/Hex.css +1 -1
  88. package/dist/web/components/Hex.d.ts +84 -3
  89. package/dist/web/components/Hex.d.ts.map +1 -1
  90. package/dist/web/components/Hex.js +20 -13
  91. package/dist/web/components/Hex.js.map +1 -1
  92. package/dist/web/components/Hex.js.zyzz.json +1 -1
  93. package/dist/web/components/Progress.css +1 -1
  94. package/dist/web/components/Progress.d.ts +12 -2
  95. package/dist/web/components/Progress.d.ts.map +1 -1
  96. package/dist/web/components/Progress.js +9 -5
  97. package/dist/web/components/Progress.js.map +1 -1
  98. package/dist/web/components/Progress.js.zyzz.json +1 -1
  99. package/dist/web/components/SecretValue.js.zyzz.json +1 -1
  100. package/dist/web/components/SidebarMenu.d.ts +4 -4
  101. package/dist/web/components/SidebarMenu.js +6 -6
  102. package/dist/web/components/SidebarMenu.js.map +1 -1
  103. package/dist/web/components/Snippet.js.zyzz.json +1 -1
  104. package/dist/web/index.js.zyzz.json +1 -1
  105. package/package.json +19 -1
  106. package/src/document/Document.ts +277 -0
  107. package/src/document/Enhance.ts +434 -0
  108. package/src/document/bin.ts +38 -0
  109. package/src/document/document.css +373 -0
  110. package/src/document/index.ts +2 -0
  111. package/src/document/internal/Cli.ts +132 -0
  112. package/src/document/internal/Template.ts +25 -0
  113. package/src/document/script.ts +8 -0
  114. package/src/document/templates/brief.html +96 -0
  115. package/src/document/templates/essay.html +70 -0
  116. package/src/document/templates/post.html +69 -0
  117. package/src/marketing/README.md +1 -1
  118. package/src/marketing/vars.ts +526 -604
  119. package/src/marketing/zyzz.config.ts +5 -4
  120. package/src/mobile/README.md +19 -6
  121. package/src/mobile/components/Button.tsx +94 -17
  122. package/src/mobile/components/IconButton.tsx +122 -30
  123. package/src/mobile/components/TextInput.tsx +139 -24
  124. package/src/mobile/index.ts +1 -0
  125. package/src/mobile/vars.ts +74 -0
  126. package/src/web/components/Amount.tsx +37 -3
  127. package/src/web/components/CopyButton.tsx +8 -0
  128. package/src/web/components/Hex.tsx +79 -13
  129. package/src/web/components/Progress.tsx +8 -2
  130. package/src/web/components/SidebarMenu.tsx +6 -6
@@ -0,0 +1,379 @@
1
+ (function() {
2
+ //#region src/document/Enhance.ts
3
+ /** How long a copied state shows before it reverts, in milliseconds. */
4
+ var settle = 1500;
5
+ /**
6
+ * Enhances every document on a page. Safe to call once per page, after the document is parsed.
7
+ *
8
+ * @example
9
+ * Enhance.run(document)
10
+ */
11
+ function run(page) {
12
+ const view = page.defaultView;
13
+ if (!view) return;
14
+ page.documentElement.classList.add("js");
15
+ const live = page.createElement("div");
16
+ live.className = "sr-only";
17
+ live.setAttribute("aria-live", "polite");
18
+ page.body.append(live);
19
+ const announce = (message) => {
20
+ live.textContent = message;
21
+ };
22
+ for (const doc of page.querySelectorAll(".doc")) {
23
+ notes(doc, view);
24
+ anchors(doc, view, announce);
25
+ code(doc, view, announce);
26
+ if (doc.hasAttribute("data-rail")) rail(doc, view);
27
+ }
28
+ for (const nav of page.querySelectorAll(".summary nav")) contents(nav, view);
29
+ for (const axis of page.querySelectorAll("ol.axis")) place(axis, view);
30
+ }
31
+ /** Adds a copy-link anchor to each H2 and H3 that has an id, or gets one from its text. */
32
+ function anchors(doc, view, announce) {
33
+ const page = doc.ownerDocument;
34
+ for (const heading of doc.querySelectorAll(":scope > h2, :scope > h3")) {
35
+ if (heading.querySelector(".h-anchor")) continue;
36
+ const name = (heading.textContent ?? "").trim();
37
+ heading.dataset["name"] = name;
38
+ if (!heading.id) {
39
+ const base = slug(name) || "section";
40
+ let id = base;
41
+ for (let n = 2; page.getElementById(id); n++) id = `${base}-${n}`;
42
+ heading.id = id;
43
+ }
44
+ const anchor = page.createElement("a");
45
+ anchor.className = "h-anchor";
46
+ anchor.href = "#" + heading.id;
47
+ anchor.setAttribute("aria-label", "Copy link to " + name);
48
+ anchor.innerHTML = "<svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\"><path d=\"M3.81309 6.81315C4.00834 6.61819 4.32494 6.61809 4.52012 6.81315C4.71529 7.00833 4.71513 7.32491 4.52012 7.52018L2.77501 9.26628C2.63738 9.40389 2.55452 9.48662 2.49864 9.55241C2.44691 9.61342 2.44701 9.62653 2.45079 9.61491C2.43994 9.64829 2.43997 9.68504 2.45079 9.71843C2.45504 9.72574 2.46795 9.74473 2.49864 9.78093C2.55453 9.84677 2.63719 9.92925 2.77501 10.0671L5.93321 13.2253C6.07102 13.3631 6.15351 13.4448 6.21934 13.5007C6.25519 13.5311 6.27422 13.5441 6.28184 13.5485C6.31522 13.5593 6.35199 13.5603 6.38536 13.5495C6.39329 13.5448 6.41267 13.5305 6.44786 13.5007C6.51365 13.4448 6.5964 13.3629 6.73399 13.2253L8.48008 11.4801C8.67537 11.2851 8.99194 11.285 9.18712 11.4801C9.38206 11.6753 9.38205 11.992 9.18712 12.1872L7.44102 13.9323C7.31499 14.0583 7.19946 14.1749 7.09532 14.2633C7.01381 14.3325 6.92065 14.4014 6.81016 14.4538L6.69395 14.4997C6.45972 14.5758 6.2075 14.5757 5.97325 14.4997C5.80931 14.4465 5.68052 14.3556 5.57188 14.2633C5.4677 14.1749 5.35229 14.0584 5.22618 13.9323L2.06798 10.7741C1.94181 10.6479 1.82539 10.5326 1.73692 10.4284C1.64466 10.3197 1.55286 10.1909 1.49962 10.027C1.42365 9.79294 1.42362 9.54039 1.49962 9.30632C1.55287 9.14262 1.64472 9.01358 1.73692 8.90495C1.82537 8.8008 1.94192 8.6853 2.06798 8.55925L3.81309 6.81315Z\" fill=\"currentColor\"/><path d=\"M9.6461 5.64616C9.84126 5.451 10.1578 5.4512 10.3531 5.64616C10.5484 5.84142 10.5484 6.15793 10.3531 6.35319L6.35313 10.3532C6.15787 10.5485 5.84136 10.5485 5.6461 10.3532C5.45114 10.1579 5.45094 9.84132 5.6461 9.64616L9.6461 5.64616Z\" fill=\"currentColor\"/><path d=\"M9.30626 1.49968C9.54033 1.42368 9.79288 1.42371 10.027 1.49968C10.1908 1.55292 10.3196 1.64472 10.4283 1.73698C10.5325 1.82546 10.6479 1.94187 10.774 2.06804L13.9322 5.22624C14.0583 5.35235 14.1748 5.46776 14.2633 5.57194C14.3555 5.68058 14.4464 5.80937 14.4996 5.97331C14.5566 6.14891 14.5711 6.33463 14.5426 6.5153L14.4996 6.69401C14.4464 6.85774 14.3554 6.98682 14.2633 7.09538C14.1748 7.19952 14.0583 7.31506 13.9322 7.44108L12.1871 9.18718C11.9919 9.38211 11.6753 9.38213 11.4801 9.18718C11.2849 8.992 11.2851 8.67543 11.4801 8.48015L13.2252 6.73405C13.3628 6.59646 13.4447 6.51371 13.5006 6.44792C13.5305 6.41273 13.5438 6.39335 13.5484 6.38542C13.5593 6.35205 13.5602 6.31528 13.5494 6.2819C13.5451 6.27428 13.531 6.25525 13.5006 6.2194C13.4447 6.15357 13.363 6.07108 13.2252 5.93327L10.067 2.77507C9.92919 2.63725 9.84671 2.55459 9.78087 2.4987C9.74467 2.46801 9.72568 2.45511 9.71837 2.45085C9.68498 2.44003 9.64823 2.44 9.61485 2.45085C9.62646 2.44707 9.61336 2.44697 9.55235 2.4987C9.48656 2.55458 9.40383 2.63744 9.26622 2.77507L7.52012 4.52018C7.32485 4.71519 7.00827 4.71535 6.81309 4.52018C6.61803 4.325 6.61813 4.0084 6.81309 3.81315L8.55919 2.06804C8.68524 1.94198 8.80074 1.82543 8.90489 1.73698C9.01352 1.64478 9.14256 1.55293 9.30626 1.49968Z\" fill=\"currentColor\"/></svg><span class=\"tip\" aria-hidden=\"true\">Copy link</span>";
49
+ const last = heading.lastChild;
50
+ const match = last?.nodeType === 3 ? /^([\s\S]*?)(\S+)\s*$/.exec(last.textContent ?? "") : null;
51
+ if (last && match) {
52
+ last.textContent = match[1] ?? "";
53
+ const tail = page.createElement("span");
54
+ tail.className = "h-tail";
55
+ tail.append(match[2] ?? "", anchor);
56
+ heading.append(tail);
57
+ } else heading.append(anchor);
58
+ let timer;
59
+ const tip = anchor.querySelector(".tip");
60
+ anchor.addEventListener("click", (event) => {
61
+ const clipboard = view.navigator.clipboard;
62
+ if (!clipboard) return;
63
+ event.preventDefault();
64
+ const url = view.location.href.split("#")[0] + "#" + heading.id;
65
+ clipboard.writeText(url).then(() => {
66
+ view.history.replaceState(null, "", "#" + heading.id);
67
+ anchor.dataset["copied"] = "";
68
+ if (tip) tip.textContent = "Link copied";
69
+ announce("Link to " + name + " copied");
70
+ clearTimeout(timer);
71
+ timer = setTimeout(() => {
72
+ delete anchor.dataset["copied"];
73
+ if (tip) tip.textContent = "Copy link";
74
+ announce("");
75
+ }, settle);
76
+ }, () => {
77
+ view.location.hash = heading.id;
78
+ });
79
+ });
80
+ }
81
+ }
82
+ /** Wraps each code block with a copy button. */
83
+ function code(doc, view, announce) {
84
+ const page = doc.ownerDocument;
85
+ for (const pre of doc.querySelectorAll(":scope > pre")) {
86
+ const wrap = page.createElement("div");
87
+ wrap.className = ["code-block", ...[...pre.classList].filter((name) => name.startsWith("l-"))].join(" ");
88
+ pre.replaceWith(wrap);
89
+ wrap.append(pre);
90
+ const button = page.createElement("button");
91
+ button.type = "button";
92
+ button.className = "copy";
93
+ button.textContent = "Copy";
94
+ button.setAttribute("aria-label", "Copy code");
95
+ wrap.append(button);
96
+ let timer;
97
+ button.addEventListener("click", async () => {
98
+ const text = (pre.querySelector("code") ?? pre).textContent ?? "";
99
+ try {
100
+ await view.navigator.clipboard.writeText(text);
101
+ } catch {
102
+ return;
103
+ }
104
+ button.textContent = "Copied";
105
+ button.dataset["copied"] = "";
106
+ announce("Copied");
107
+ clearTimeout(timer);
108
+ timer = setTimeout(() => {
109
+ button.textContent = "Copy";
110
+ delete button.dataset["copied"];
111
+ announce("");
112
+ }, settle);
113
+ });
114
+ }
115
+ }
116
+ /** Marks the Brief contents link of the section in view. */
117
+ function contents(nav, view) {
118
+ const page = nav.ownerDocument;
119
+ const links = [...nav.querySelectorAll("a[href^=\"#\"]")];
120
+ const targets = links.flatMap((anchor) => {
121
+ const target = page.getElementById((anchor.getAttribute("href") ?? "").slice(1));
122
+ return target ? [target] : [];
123
+ });
124
+ if (targets.length === 0) return;
125
+ const mark = () => {
126
+ let current = targets[0];
127
+ for (const target of targets) if (target.getBoundingClientRect().top < view.innerHeight * .3) current = target;
128
+ for (const anchor of links) anchor.setAttribute("aria-current", String(anchor.getAttribute("href") === "#" + current?.id));
129
+ };
130
+ mark();
131
+ view.addEventListener("scroll", () => view.requestAnimationFrame(mark), { passive: true });
132
+ }
133
+ /**
134
+ * Turns each `span.sn > small` into a numbered button with a popover, and lists the notes at the
135
+ * end. Escape closes the open note and returns focus to its button.
136
+ */
137
+ function notes(doc, view) {
138
+ const page = doc.ownerDocument;
139
+ const items = [...doc.querySelectorAll(".sn")].flatMap((note) => {
140
+ const small = note.querySelector(":scope > small");
141
+ return small ? [{
142
+ note,
143
+ small
144
+ }] : [];
145
+ });
146
+ if (items.length === 0) return;
147
+ let open;
148
+ const close = () => {
149
+ if (!open) return;
150
+ open.note.classList.remove("open");
151
+ open.button.setAttribute("aria-expanded", "false");
152
+ open = void 0;
153
+ };
154
+ const show = (note, button, small) => {
155
+ if (open && open.note !== note) close();
156
+ note.classList.add("open");
157
+ button.setAttribute("aria-expanded", "true");
158
+ open = {
159
+ button,
160
+ note
161
+ };
162
+ const frame = (small.offsetParent ?? doc).getBoundingClientRect();
163
+ const anchor = button.getBoundingClientRect();
164
+ const width = Math.min(320, view.innerWidth - 40);
165
+ const x = Math.max(20 - frame.left, Math.min(anchor.left - frame.left - 16, view.innerWidth - 20 - width - frame.left));
166
+ note.style.setProperty("--pop-x", x + "px");
167
+ note.style.setProperty("--pop-y", anchor.bottom - frame.top + 8 + "px");
168
+ };
169
+ const list = page.createElement("ol");
170
+ items.forEach((item, index) => {
171
+ const { note, small } = item;
172
+ const number = String(index + 1);
173
+ small.id ||= "note-" + number;
174
+ small.setAttribute("role", "note");
175
+ const button = page.createElement("button");
176
+ button.type = "button";
177
+ button.className = "sn-ref";
178
+ button.textContent = number;
179
+ button.setAttribute("aria-label", "Note " + number);
180
+ button.setAttribute("aria-controls", small.id);
181
+ button.setAttribute("aria-expanded", "false");
182
+ note.insertBefore(button, small);
183
+ button.addEventListener("click", (event) => {
184
+ event.stopPropagation();
185
+ if (note.classList.contains("open")) close();
186
+ else show(note, button, small);
187
+ });
188
+ let timer;
189
+ note.addEventListener("pointerenter", (event) => {
190
+ if (event.pointerType !== "mouse") return;
191
+ clearTimeout(timer);
192
+ timer = setTimeout(() => show(note, button, small), 300);
193
+ });
194
+ note.addEventListener("pointerleave", (event) => {
195
+ if (event.pointerType !== "mouse") return;
196
+ clearTimeout(timer);
197
+ timer = setTimeout(() => open?.note === note && close(), 160);
198
+ });
199
+ const listed = page.createElement("li");
200
+ listed.innerHTML = small.innerHTML;
201
+ list.append(listed);
202
+ });
203
+ page.addEventListener("click", (event) => {
204
+ if (open && !open.note.contains(event.target)) close();
205
+ });
206
+ page.addEventListener("keydown", (event) => {
207
+ if (event.key !== "Escape" || !open) return;
208
+ const { button, note } = open;
209
+ const inside = note.contains(page.activeElement);
210
+ close();
211
+ if (inside) button.focus();
212
+ });
213
+ const section = page.createElement("section");
214
+ section.className = "footnotes";
215
+ section.setAttribute("aria-label", "Notes");
216
+ const heading = page.createElement("h2");
217
+ heading.textContent = "Notes";
218
+ section.append(heading, list);
219
+ doc.append(section);
220
+ }
221
+ /**
222
+ * Lays an Axis timeline out horizontally at 768px and wider, in lanes so labels never overlap.
223
+ * Narrower, it stays a vertical list in date order.
224
+ */
225
+ function place(axis, view) {
226
+ const page = axis.ownerDocument;
227
+ const items = [...axis.children];
228
+ const day = 864e5;
229
+ const start = Date.parse(axis.dataset["start"] ?? "");
230
+ const end = Date.parse(axis.dataset["end"] ?? "");
231
+ if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) return;
232
+ const at = (time) => (time - start) / (end - start);
233
+ for (const item of items) {
234
+ const times = [...item.querySelectorAll("time")].map((time) => Date.parse(time.getAttribute("datetime") ?? ""));
235
+ const first = times[0] ?? start;
236
+ item.style.setProperty("--x", at(first).toFixed(4));
237
+ if (item.classList.contains("phase")) item.style.setProperty("--w", (at(times[1] ?? first) - at(first)).toFixed(4));
238
+ }
239
+ items.map((item, index) => ({
240
+ index,
241
+ item,
242
+ kind: item.classList.contains("phase") ? 0 : 1,
243
+ x: Number(item.style.getPropertyValue("--x"))
244
+ })).sort((a, b) => a.x - b.x || a.kind - b.kind || a.index - b.index).forEach((entry, order) => {
245
+ entry.item.style.order = String(order);
246
+ });
247
+ axis.style.display = "flex";
248
+ axis.style.flexDirection = "column";
249
+ const scale = page.createElement("div");
250
+ scale.className = "axis-scale";
251
+ scale.setAttribute("aria-hidden", "true");
252
+ const marks = [start];
253
+ for (let time = start + 7 * day; time < end - 3 * day; time += 7 * day) marks.push(time);
254
+ marks.push(end);
255
+ for (const mark of marks) {
256
+ const span = page.createElement("span");
257
+ span.style.left = (at(mark) * 100).toFixed(2) + "%";
258
+ span.textContent = new Date(mark).toLocaleDateString("en-US", {
259
+ day: "numeric",
260
+ month: "short",
261
+ timeZone: "UTC"
262
+ });
263
+ scale.append(span);
264
+ }
265
+ axis.after(scale);
266
+ const wide = view.matchMedia("(min-width: 768px)");
267
+ const lanes = () => {
268
+ if (!wide.matches) {
269
+ delete axis.dataset["placed"];
270
+ axis.style.display = "flex";
271
+ return;
272
+ }
273
+ axis.dataset["placed"] = "";
274
+ axis.style.removeProperty("display");
275
+ const width = axis.clientWidth;
276
+ const fill = (list, phase) => {
277
+ const ends = [];
278
+ const placed = [];
279
+ for (const item of list) {
280
+ delete item.dataset["flip"];
281
+ item.style.setProperty("--lane", "0");
282
+ const x = Number(item.style.getPropertyValue("--x")) * width;
283
+ const size = phase ? Math.max(item.scrollWidth, Number(item.style.getPropertyValue("--w")) * width) : item.scrollWidth;
284
+ let left = x;
285
+ let right = x + size;
286
+ if (!phase && right > width) {
287
+ item.dataset["flip"] = "";
288
+ left = x - size;
289
+ right = x;
290
+ }
291
+ let lane;
292
+ if (phase) {
293
+ lane = ends.findIndex((edge) => edge < left - 12);
294
+ if (lane < 0) lane = ends.push(0) - 1;
295
+ ends[lane] = right;
296
+ } else {
297
+ const crossed = (depth) => placed.some((other) => other.lane > depth && other.x >= left - 4 && other.x <= right + 4);
298
+ lane = ends.findIndex((edge, depth) => edge > right + 12 && !crossed(depth));
299
+ if (lane < 0) lane = ends.push(0) - 1;
300
+ ends[lane] = left;
301
+ placed.push({
302
+ lane,
303
+ x: "flip" in item.dataset ? right : left
304
+ });
305
+ }
306
+ item.style.setProperty("--lane", String(lane));
307
+ }
308
+ return Math.max(1, ends.length);
309
+ };
310
+ const phases = items.filter((item) => item.classList.contains("phase"));
311
+ const events = items.filter((item) => !item.classList.contains("phase") && !item.classList.contains("minor")).reverse();
312
+ axis.style.setProperty("--phase-lanes", String(fill(phases, true)));
313
+ axis.style.setProperty("--event-lanes", String(fill(events, false)));
314
+ };
315
+ lanes();
316
+ wide.addEventListener("change", lanes);
317
+ view.addEventListener("resize", lanes);
318
+ page.fonts?.ready.then(lanes);
319
+ }
320
+ /** Adds Essay's reading rail: progress through the page, with a tick for each section. */
321
+ function rail(doc, view) {
322
+ const page = doc.ownerDocument;
323
+ const headings = [...doc.querySelectorAll(":scope > h2[id]")];
324
+ const nav = page.createElement("nav");
325
+ nav.className = "rail";
326
+ nav.setAttribute("aria-label", "Reading progress");
327
+ nav.innerHTML = "<div class=\"rail-track\"></div><div class=\"rail-fill\"></div>";
328
+ const ticks = headings.map((heading) => {
329
+ const anchor = page.createElement("a");
330
+ const name = heading.dataset["name"] ?? heading.textContent ?? "";
331
+ anchor.href = "#" + heading.id;
332
+ anchor.setAttribute("aria-label", "Go to " + name);
333
+ const label = page.createElement("span");
334
+ label.textContent = name;
335
+ anchor.append(label);
336
+ nav.append(anchor);
337
+ return anchor;
338
+ });
339
+ page.body.append(nav);
340
+ const header = doc.querySelector("header");
341
+ let span = 1;
342
+ const measure = () => {
343
+ span = Math.max(1, page.documentElement.scrollHeight - view.innerHeight);
344
+ headings.forEach((heading, index) => {
345
+ const y = heading.getBoundingClientRect().top + view.scrollY - view.innerHeight * .25;
346
+ ticks[index]?.style.setProperty("--at", Math.min(1, Math.max(0, y / span)).toFixed(4));
347
+ });
348
+ };
349
+ const update = () => {
350
+ nav.style.setProperty("--p", Math.min(1, Math.max(0, view.scrollY / span)).toFixed(4));
351
+ const started = header ? header.getBoundingClientRect().bottom < 80 : view.scrollY > 200;
352
+ nav.toggleAttribute("data-on", started);
353
+ };
354
+ measure();
355
+ update();
356
+ view.addEventListener("scroll", () => view.requestAnimationFrame(update), { passive: true });
357
+ view.addEventListener("resize", () => {
358
+ measure();
359
+ update();
360
+ });
361
+ page.fonts?.ready.then(() => {
362
+ measure();
363
+ update();
364
+ });
365
+ }
366
+ /** Returns a URL fragment for a heading's text. */
367
+ function slug(text) {
368
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
369
+ }
370
+ //#endregion
371
+ //#region src/document/script.ts
372
+ /**
373
+ * The document mode script. The build bundles it into one classic script with no imports, so it runs
374
+ * from a CDN and from a page opened as a file. Load it in the head with `<script defer src=".../script.js">`.
375
+ * @module
376
+ */
377
+ run(document);
378
+ //#endregion
379
+ })();
@@ -0,0 +1,96 @@
1
+ <!doctype html>
2
+ <!--
3
+ Brief template for Tempo document mode. Replace every placeholder that a comment marks,
4
+ keep the structure, and run the lint before you publish:
5
+ npx -p @tempoxyz/ds@0.3.17 tempo-document lint brief.html
6
+ -->
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
11
+ <!-- Replace: the document title. -->
12
+ <title>Title of the brief</title>
13
+ <link
14
+ rel="stylesheet"
15
+ href="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/document.css"
16
+ />
17
+ <script
18
+ defer
19
+ src="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/script.js"
20
+ ></script>
21
+ </head>
22
+ <body>
23
+ <div class="brief">
24
+ <header>
25
+ <!-- Replace: the title, what was decided or proposed, the author, and the date. -->
26
+ <h1>Title of the brief</h1>
27
+ <p class="dek">One sentence that states what was decided or proposed.</p>
28
+ <p class="byline">Author name · <time datetime="2026-11-17">Nov 17, 2026</time></p>
29
+ </header>
30
+
31
+ <article class="doc" data-template="brief">
32
+ <!-- Replace: two or three sections. Each H2 id matches a link in the summary contents. -->
33
+ <h2 id="summary">Summary</h2>
34
+
35
+ <p>
36
+ State the decision or the proposal, and why it matters now.<span class="sn"
37
+ ><small
38
+ >A note holds a source or an aside. The script numbers it and lists it at the
39
+ end.</small
40
+ ></span
41
+ >
42
+ </p>
43
+
44
+ <h2 id="plan">Plan</h2>
45
+
46
+ <p>Describe the work in order, and name the owner of each part.</p>
47
+
48
+ <!-- Replace: a figure that supports the plan. The caption states the takeaway, then the source. -->
49
+ <figure>
50
+ <svg viewBox="0 0 640 88" role="img" aria-labelledby="figure-title">
51
+ <title id="figure-title">Two phases drawn as bars, the second twice as long.</title>
52
+ <text class="label" x="0" y="20">Phase 1</text>
53
+ <rect class="fill-ink" x="96" y="8" width="160" height="16" />
54
+ <text class="meta" x="264" y="20">2 weeks</text>
55
+ <text class="label" x="0" y="64">Phase 2</text>
56
+ <rect class="fill-quiet" x="256" y="52" width="320" height="16" />
57
+ <text class="meta" x="584" y="64">4 weeks</text>
58
+ </svg>
59
+ <figcaption>
60
+ The second phase takes twice as long as the first (Source: name the estimate).
61
+ </figcaption>
62
+ </figure>
63
+
64
+ <h2 id="risks">Risks</h2>
65
+
66
+ <p>List what could change the plan, and what you do if it happens.</p>
67
+ </article>
68
+
69
+ <!-- Replace: the facts readers return for, and one contents link per H2. -->
70
+ <aside class="summary" aria-label="Summary">
71
+ <dl class="facts">
72
+ <div>
73
+ <dt>Status</dt>
74
+ <dd>Proposed</dd>
75
+ </div>
76
+ <div>
77
+ <dt>Owner</dt>
78
+ <dd>Owner name</dd>
79
+ </div>
80
+ <div>
81
+ <dt>Next</dt>
82
+ <dd>The next step and its date</dd>
83
+ </div>
84
+ </dl>
85
+ <nav aria-label="Contents">
86
+ <h2>Contents</h2>
87
+ <ol>
88
+ <li><a href="#summary">Summary</a></li>
89
+ <li><a href="#plan">Plan</a></li>
90
+ <li><a href="#risks">Risks</a></li>
91
+ </ol>
92
+ </nav>
93
+ </aside>
94
+ </div>
95
+ </body>
96
+ </html>
@@ -0,0 +1,70 @@
1
+ <!doctype html>
2
+ <!--
3
+ Essay template for Tempo document mode. Replace every placeholder that a comment marks,
4
+ keep the structure, and run the lint before you publish:
5
+ npx -p @tempoxyz/ds@0.3.17 tempo-document lint essay.html
6
+ -->
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
11
+ <!-- Replace: the document title. -->
12
+ <title>Title of the essay</title>
13
+ <link
14
+ rel="stylesheet"
15
+ href="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/document.css"
16
+ />
17
+ <script
18
+ defer
19
+ src="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/script.js"
20
+ ></script>
21
+ </head>
22
+ <body>
23
+ <article class="doc" data-template="essay" data-rail>
24
+ <header>
25
+ <!-- Replace: the title, the dek, the author, and the date. -->
26
+ <h1>Title of the essay</h1>
27
+ <p class="dek">One sentence that states what the reader learns.</p>
28
+ <p class="byline">Author name · <time datetime="2026-11-17">Nov 17, 2026</time></p>
29
+ </header>
30
+
31
+ <!-- Replace: the opening paragraph, which states the argument. -->
32
+ <p>
33
+ State the argument in the first paragraph. The rest of the essay supports it, one section at
34
+ a time.<span class="sn"
35
+ ><small
36
+ >A note holds a source or an aside. The script numbers it and lists it at the
37
+ end.</small
38
+ ></span
39
+ >
40
+ </p>
41
+
42
+ <!-- Replace: two or three sections. Give each H2 an id, which the reading rail links. -->
43
+ <h2 id="evidence">First section</h2>
44
+
45
+ <p>Make one point in each section, and support it with evidence.</p>
46
+
47
+ <!-- Replace: a figure that shows the evidence. The caption states the takeaway, then the source. -->
48
+ <figure>
49
+ <svg viewBox="0 0 640 88" role="img" aria-labelledby="figure-title">
50
+ <title id="figure-title">Two values drawn as bars, the second twice the first.</title>
51
+ <text class="label" x="0" y="20">Before</text>
52
+ <rect class="fill-quiet" x="96" y="8" width="240" height="16" />
53
+ <text class="meta" x="344" y="20">240</text>
54
+ <text class="label" x="0" y="64">After</text>
55
+ <rect class="fill-ink" x="96" y="52" width="480" height="16" />
56
+ <text class="meta" x="584" y="64">480</text>
57
+ </svg>
58
+ <figcaption>The second value is twice the first (Source: name the data).</figcaption>
59
+ </figure>
60
+
61
+ <h2 id="consequence">Second section</h2>
62
+
63
+ <p>Explain what the evidence means and what follows from it.</p>
64
+
65
+ <h2 id="conclusion">Conclusion</h2>
66
+
67
+ <p>Restate the argument in light of the evidence, and say what the reader can do with it.</p>
68
+ </article>
69
+ </body>
70
+ </html>
@@ -0,0 +1,69 @@
1
+ <!doctype html>
2
+ <!--
3
+ Post template for Tempo document mode. Replace every placeholder that a comment marks,
4
+ keep the structure, and run the lint before you publish:
5
+ npx -p @tempoxyz/ds@0.3.17 tempo-document lint post.html
6
+ -->
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
11
+ <!-- Replace: the document title. -->
12
+ <title>Title of the post</title>
13
+ <link
14
+ rel="stylesheet"
15
+ href="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/document.css"
16
+ />
17
+ <script
18
+ defer
19
+ src="https://cdn.jsdelivr.net/npm/@tempoxyz/ds@0.3.17/dist/document/script.js"
20
+ ></script>
21
+ </head>
22
+ <body>
23
+ <article class="doc" data-template="post">
24
+ <header>
25
+ <!-- Replace: the title, the dek, the authors, and the date. -->
26
+ <h1>Title of the post</h1>
27
+ <p class="dek">One sentence that states what the reader can do after reading.</p>
28
+ <p class="byline">By author name · <time datetime="2026-11-17">Nov 17, 2026</time></p>
29
+ </header>
30
+
31
+ <!-- Replace: the opening paragraph, which states who the post is for. -->
32
+ <p>
33
+ State who the post is for and what it covers.<span class="sn"
34
+ ><small
35
+ >A note holds a source or an aside. The script numbers it and lists it at the
36
+ end.</small
37
+ ></span
38
+ >
39
+ </p>
40
+
41
+ <!-- Replace: two or three sections. Number the steps of a procedure with ol.steps. -->
42
+ <h2 id="steps">Steps</h2>
43
+
44
+ <ol class="steps">
45
+ <li>Write the first step as an instruction.</li>
46
+ <li>Write the second step, and name the result the reader sees.</li>
47
+ <li>Write the last step, and say how the reader knows it worked.</li>
48
+ </ol>
49
+
50
+ <!-- Replace: a figure that shows the result. The caption states the takeaway, then the source. -->
51
+ <figure>
52
+ <svg viewBox="0 0 640 88" role="img" aria-labelledby="figure-title">
53
+ <title id="figure-title">Two values drawn as bars, the second twice the first.</title>
54
+ <text class="label" x="0" y="20">Before</text>
55
+ <rect class="fill-quiet" x="96" y="8" width="240" height="16" />
56
+ <text class="meta" x="344" y="20">240</text>
57
+ <text class="label" x="0" y="64">After</text>
58
+ <rect class="fill-ink" x="96" y="52" width="480" height="16" />
59
+ <text class="meta" x="584" y="64">480</text>
60
+ </svg>
61
+ <figcaption>The steps double the result (Source: name the data).</figcaption>
62
+ </figure>
63
+
64
+ <h2 id="next">Next steps</h2>
65
+
66
+ <p>Link what the reader can read or do next.</p>
67
+ </article>
68
+ </body>
69
+ </html>