@abraca/junis 2.84.0 → 2.86.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.
Files changed (178) hide show
  1. package/dist/module.d.mts +17 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +270 -22
  4. package/dist/runtime/assets/css/jun.css +1 -1
  5. package/dist/runtime/components/JunBlobBackdrop.client.vue +1 -1
  6. package/dist/runtime/components/JunCampfirePresence.client.vue +75 -10
  7. package/dist/runtime/components/JunCollectionIntro.d.vue.ts +11 -0
  8. package/dist/runtime/components/JunCollectionIntro.vue +45 -0
  9. package/dist/runtime/components/JunCollectionIntro.vue.d.ts +11 -0
  10. package/dist/runtime/components/JunConfigRow.d.vue.ts +43 -0
  11. package/dist/runtime/components/JunConfigRow.vue +34 -0
  12. package/dist/runtime/components/JunConfigRow.vue.d.ts +43 -0
  13. package/dist/runtime/components/JunFooter.vue +1 -1
  14. package/dist/runtime/components/JunHead.vue +37 -5
  15. package/dist/runtime/components/JunHorizontalTimeline.d.vue.ts +30 -0
  16. package/dist/runtime/components/JunHorizontalTimeline.vue.d.ts +30 -0
  17. package/dist/runtime/components/JunLinksRow.d.vue.ts +16 -1
  18. package/dist/runtime/components/JunLinksRow.vue +17 -7
  19. package/dist/runtime/components/JunLinksRow.vue.d.ts +16 -1
  20. package/dist/runtime/components/JunLogo.vue +10 -45
  21. package/dist/runtime/components/JunMedia.client.d.vue.ts +1 -1
  22. package/dist/runtime/components/JunMedia.client.vue.d.ts +1 -1
  23. package/dist/runtime/components/JunNavigation.vue +21 -4
  24. package/dist/runtime/components/JunNoteLinks.d.vue.ts +6 -0
  25. package/dist/runtime/components/JunNoteLinks.vue +57 -0
  26. package/dist/runtime/components/JunNoteLinks.vue.d.ts +6 -0
  27. package/dist/runtime/components/JunPageHero.d.vue.ts +8 -2
  28. package/dist/runtime/components/JunPageHero.vue +15 -3
  29. package/dist/runtime/components/JunPageHero.vue.d.ts +8 -2
  30. package/dist/runtime/components/JunPatternBackdrop.client.vue +1 -1
  31. package/dist/runtime/components/JunReaders.d.vue.ts +11 -0
  32. package/dist/runtime/components/JunReaders.vue +99 -0
  33. package/dist/runtime/components/JunReaders.vue.d.ts +11 -0
  34. package/dist/runtime/components/JunSearch.client.vue +2 -2
  35. package/dist/runtime/components/JunSectionPresence.client.d.vue.ts +17 -0
  36. package/dist/runtime/components/JunSectionPresence.client.vue +99 -0
  37. package/dist/runtime/components/JunSectionPresence.client.vue.d.ts +17 -0
  38. package/dist/runtime/components/JunShaderBackdrop.client.vue +1 -1
  39. package/dist/runtime/components/JunThreadComposer.d.vue.ts +37 -0
  40. package/dist/runtime/components/JunThreadComposer.vue +54 -0
  41. package/dist/runtime/components/JunThreadComposer.vue.d.ts +37 -0
  42. package/dist/runtime/components/JunTravellersChip.vue +35 -5
  43. package/dist/runtime/components/JunVideoEmbed.client.d.vue.ts +1 -1
  44. package/dist/runtime/components/JunVideoEmbed.client.vue.d.ts +1 -1
  45. package/dist/runtime/components/JunViewControl.d.vue.ts +29 -0
  46. package/dist/runtime/components/JunViewControl.vue +340 -0
  47. package/dist/runtime/components/JunViewControl.vue.d.ts +29 -0
  48. package/dist/runtime/components/JunViewControls.d.vue.ts +27 -0
  49. package/dist/runtime/components/JunViewControls.vue +94 -0
  50. package/dist/runtime/components/JunViewControls.vue.d.ts +27 -0
  51. package/dist/runtime/components/renderers/JunAppsRenderer.vue +45 -4
  52. package/dist/runtime/components/renderers/JunCinemaRenderer.vue +42 -4
  53. package/dist/runtime/components/renderers/JunConfigRenderer.vue +362 -239
  54. package/dist/runtime/components/renderers/JunCourseRenderer.d.vue.ts +10 -0
  55. package/dist/runtime/components/renderers/JunCourseRenderer.vue +229 -0
  56. package/dist/runtime/components/renderers/JunCourseRenderer.vue.d.ts +10 -0
  57. package/dist/runtime/components/renderers/JunCvRenderer.vue +44 -6
  58. package/dist/runtime/components/renderers/JunDeckRenderer.d.vue.ts +9 -0
  59. package/dist/runtime/components/renderers/JunDeckRenderer.vue +370 -0
  60. package/dist/runtime/components/renderers/JunDeckRenderer.vue.d.ts +9 -0
  61. package/dist/runtime/components/renderers/JunEntryRenderer.vue +157 -31
  62. package/dist/runtime/components/renderers/JunFestivalRenderer.vue +42 -5
  63. package/dist/runtime/components/renderers/JunGardenRenderer.d.vue.ts +10 -0
  64. package/dist/runtime/components/renderers/JunGardenRenderer.vue +280 -0
  65. package/dist/runtime/components/renderers/JunGardenRenderer.vue.d.ts +10 -0
  66. package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +96 -14
  67. package/dist/runtime/components/renderers/JunHomeRenderer.vue +31 -132
  68. package/dist/runtime/components/renderers/JunItemRenderer.d.vue.ts +10 -0
  69. package/dist/runtime/components/renderers/JunItemRenderer.vue +398 -0
  70. package/dist/runtime/components/renderers/JunItemRenderer.vue.d.ts +10 -0
  71. package/dist/runtime/components/renderers/JunJournalRenderer.vue +141 -11
  72. package/dist/runtime/components/renderers/JunLibraryRenderer.vue +295 -12
  73. package/dist/runtime/components/renderers/JunLinksRenderer.vue +33 -1
  74. package/dist/runtime/components/renderers/JunLiveRenderer.vue +38 -2
  75. package/dist/runtime/components/renderers/JunMosaicRenderer.vue +3 -2
  76. package/dist/runtime/components/renderers/JunMovieRenderer.vue +32 -5
  77. package/dist/runtime/components/renderers/JunNowRenderer.vue +40 -7
  78. package/dist/runtime/components/renderers/JunPollRenderer.d.vue.ts +9 -0
  79. package/dist/runtime/components/renderers/JunPollRenderer.vue +231 -0
  80. package/dist/runtime/components/renderers/JunPollRenderer.vue.d.ts +9 -0
  81. package/dist/runtime/components/renderers/JunProjectRenderer.vue +74 -18
  82. package/dist/runtime/components/renderers/JunServicesRenderer.vue +40 -2
  83. package/dist/runtime/components/renderers/JunStatsRenderer.vue +37 -50
  84. package/dist/runtime/components/renderers/JunThreadRenderer.d.vue.ts +9 -0
  85. package/dist/runtime/components/renderers/JunThreadRenderer.vue +304 -0
  86. package/dist/runtime/components/renderers/JunThreadRenderer.vue.d.ts +9 -0
  87. package/dist/runtime/components/renderers/JunTrackRenderer.vue +32 -4
  88. package/dist/runtime/components/renderers/JunUsesRenderer.vue +57 -13
  89. package/dist/runtime/components/renderers/JunWallRenderer.vue +60 -5
  90. package/dist/runtime/composables/useJunDeck.d.ts +66 -0
  91. package/dist/runtime/composables/useJunDeck.js +61 -0
  92. package/dist/runtime/composables/useJunDocPage.d.ts +14 -11
  93. package/dist/runtime/composables/useJunDocPage.js +67 -3
  94. package/dist/runtime/composables/useJunFollow.d.ts +65 -9
  95. package/dist/runtime/composables/useJunFollow.js +237 -20
  96. package/dist/runtime/composables/useJunGarden.d.ts +67 -0
  97. package/dist/runtime/composables/useJunGarden.js +92 -0
  98. package/dist/runtime/composables/useJunOptions.d.ts +1 -0
  99. package/dist/runtime/composables/useJunPresence.d.ts +26 -0
  100. package/dist/runtime/composables/useJunPresence.js +9 -2
  101. package/dist/runtime/composables/useJunSections.d.ts +73 -0
  102. package/dist/runtime/composables/useJunSections.js +117 -0
  103. package/dist/runtime/composables/useJunSettings.d.ts +1 -1
  104. package/dist/runtime/composables/useJunSettings.js +5 -1
  105. package/dist/runtime/composables/useJunSiteConfig.d.ts +37 -0
  106. package/dist/runtime/composables/useJunTheme.js +49 -50
  107. package/dist/runtime/composables/useJunViewOptions.d.ts +85 -0
  108. package/dist/runtime/composables/useJunViewOptions.js +63 -0
  109. package/dist/runtime/pages/doc.vue +14 -8
  110. package/dist/runtime/plugins/jun-sw.client.d.ts +2 -0
  111. package/dist/runtime/plugins/jun-sw.client.js +36 -0
  112. package/dist/runtime/server/api/health.get.d.ts +19 -0
  113. package/dist/runtime/server/api/health.get.js +40 -0
  114. package/dist/runtime/server/api/links.get.d.ts +19 -0
  115. package/dist/runtime/server/api/links.get.js +37 -0
  116. package/dist/runtime/server/api/resolve/[...slug].get.d.ts +9 -0
  117. package/dist/runtime/server/api/resolve/[...slug].get.js +5 -0
  118. package/dist/runtime/server/api/stats.get.js +2 -1
  119. package/dist/runtime/server/janitor/junJanitorChores.js +8 -0
  120. package/dist/runtime/server/plugins/jun-bootstrap.js +103 -15
  121. package/dist/runtime/server/plugins/jun-doc-cache.js +42 -4
  122. package/dist/runtime/server/plugins/jun-janitor.js +9 -1
  123. package/dist/runtime/server/plugins/jun-rpc.js +293 -0
  124. package/dist/runtime/server/plugins/jun-watchdog.d.ts +2 -0
  125. package/dist/runtime/server/plugins/jun-watchdog.js +54 -0
  126. package/dist/runtime/server/routes/jun-icon.png.get.d.ts +2 -0
  127. package/dist/runtime/server/routes/jun-icon.png.get.js +25 -0
  128. package/dist/runtime/server/routes/jun-icon.svg.get.d.ts +2 -0
  129. package/dist/runtime/server/routes/jun-icon.svg.get.js +9 -0
  130. package/dist/runtime/server/routes/jun-splash.png.get.d.ts +2 -0
  131. package/dist/runtime/server/routes/jun-splash.png.get.js +37 -0
  132. package/dist/runtime/server/routes/jun-sw.js.get.d.ts +2 -0
  133. package/dist/runtime/server/routes/jun-sw.js.get.js +126 -0
  134. package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +24 -0
  135. package/dist/runtime/server/routes/manifest.webmanifest.get.js +51 -0
  136. package/dist/runtime/server/routes/sitemap.xml.get.js +2 -0
  137. package/dist/runtime/server/utils/junBoot.d.ts +1 -0
  138. package/dist/runtime/server/utils/junBoot.js +4 -0
  139. package/dist/runtime/server/utils/junBrand.d.ts +4 -0
  140. package/dist/runtime/server/utils/junBrand.js +9 -0
  141. package/dist/runtime/server/utils/junCache.d.ts +17 -0
  142. package/dist/runtime/server/utils/junCache.js +5 -0
  143. package/dist/runtime/server/utils/junIcon.d.ts +44 -0
  144. package/dist/runtime/server/utils/junIcon.js +374 -0
  145. package/dist/runtime/server/utils/junSeedGate.d.ts +68 -0
  146. package/dist/runtime/server/utils/junSeedGate.js +41 -0
  147. package/dist/runtime/types.d.ts +82 -3
  148. package/dist/runtime/utils/junCourse.d.ts +106 -0
  149. package/dist/runtime/utils/junCourse.js +65 -0
  150. package/dist/runtime/utils/junGarden.d.ts +193 -0
  151. package/dist/runtime/utils/junGarden.js +233 -0
  152. package/dist/runtime/utils/junIdentity.d.ts +121 -0
  153. package/dist/runtime/utils/junIdentity.js +115 -0
  154. package/dist/runtime/utils/junMark.d.ts +254 -0
  155. package/dist/runtime/utils/junMark.js +169 -0
  156. package/dist/runtime/utils/junMetaSchemas.js +8 -1
  157. package/dist/runtime/utils/junModeration.d.ts +67 -0
  158. package/dist/runtime/utils/junModeration.js +20 -0
  159. package/dist/runtime/utils/junMotion.d.ts +26 -0
  160. package/dist/runtime/utils/junMotion.js +31 -0
  161. package/dist/runtime/utils/junPeople.d.ts +43 -0
  162. package/dist/runtime/utils/junPeople.js +9 -0
  163. package/dist/runtime/utils/junPoll.d.ts +79 -0
  164. package/dist/runtime/utils/junPoll.js +82 -0
  165. package/dist/runtime/utils/junReadiness.d.ts +131 -0
  166. package/dist/runtime/utils/junReadiness.js +69 -0
  167. package/dist/runtime/utils/junSections.d.ts +115 -0
  168. package/dist/runtime/utils/junSections.js +45 -0
  169. package/dist/runtime/utils/junSlides.d.ts +66 -0
  170. package/dist/runtime/utils/junSlides.js +47 -0
  171. package/dist/runtime/utils/junThread.d.ts +81 -0
  172. package/dist/runtime/utils/junThread.js +75 -0
  173. package/dist/runtime/utils/junViewSpecs.d.ts +671 -0
  174. package/dist/runtime/utils/junViewSpecs.js +534 -0
  175. package/dist/runtime/utils/junViewValues.d.ts +125 -0
  176. package/dist/runtime/utils/junViewValues.js +104 -0
  177. package/dist/types.d.mts +1 -1
  178. package/package.json +5 -1
@@ -0,0 +1,233 @@
1
+ export const JUN_MATURITIES = [
2
+ { value: "seedling", label: "Seedling", icon: "i-lucide-sprout", hint: "Rough, and says so" },
3
+ { value: "budding", label: "Budding", icon: "i-lucide-flower-2", hint: "Taking shape" },
4
+ { value: "evergreen", label: "Evergreen", icon: "i-lucide-trees", hint: "Tended, and holds up" }
5
+ ];
6
+ const MATURITY_VALUES = JUN_MATURITIES.map((m) => m.value);
7
+ export function junMaturityOf(meta) {
8
+ const raw = meta?.maturity;
9
+ return typeof raw === "string" && MATURITY_VALUES.includes(raw) ? raw : null;
10
+ }
11
+ const HREF_RE = /<a\s[^>]*?href\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;
12
+ const DOC_ID_ATTR_RE = /\bdata-doc-id\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
13
+ const DOC_PATH_RE = /^\/doc\/([\w-]+)/;
14
+ function unescapeAttr(value) {
15
+ return value.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code)));
16
+ }
17
+ export function junScanLinkTargets(html) {
18
+ if (!html) return [];
19
+ const out = [];
20
+ for (const re of [HREF_RE, DOC_ID_ATTR_RE]) {
21
+ re.lastIndex = 0;
22
+ let m;
23
+ while (m = re.exec(html)) {
24
+ const raw = m[1] ?? m[2] ?? m[3] ?? "";
25
+ if (raw) out.push(unescapeAttr(raw).trim());
26
+ }
27
+ }
28
+ return out;
29
+ }
30
+ export function junResolveLinkTarget(target, slugToId, knownIds) {
31
+ const raw = (target ?? "").trim();
32
+ if (!raw) return null;
33
+ if (knownIds.has(raw)) return raw;
34
+ if (/^[a-z][a-z0-9+.-]*:/i.test(raw) || raw.startsWith("//")) return null;
35
+ if (raw.startsWith("#")) return null;
36
+ const path = raw.replace(/[?#].*$/, "");
37
+ const doc = DOC_PATH_RE.exec(path);
38
+ if (doc) return knownIds.has(doc[1]) ? doc[1] : null;
39
+ let slug = path;
40
+ try {
41
+ slug = decodeURIComponent(path);
42
+ } catch {
43
+ }
44
+ slug = slug.replace(/^\/+/, "").replace(/\/+$/, "").toLowerCase();
45
+ const id = slugToId[slug];
46
+ return id && knownIds.has(id) ? id : null;
47
+ }
48
+ export function junGardenEdges(sources, slugToId, knownIds) {
49
+ const edges = [];
50
+ const seen = /* @__PURE__ */ new Map();
51
+ for (const source of sources) {
52
+ if (!source?.id || !knownIds.has(source.id)) continue;
53
+ const targets = source.targets ?? junScanLinkTargets(source.html);
54
+ for (const target of targets) {
55
+ const id = junResolveLinkTarget(target, slugToId, knownIds);
56
+ if (!id || id === source.id) continue;
57
+ const key = `${source.id}\0${id}`;
58
+ const existing = seen.get(key);
59
+ if (existing) {
60
+ existing.weight++;
61
+ continue;
62
+ }
63
+ const edge = { source: source.id, target: id, weight: 1 };
64
+ seen.set(key, edge);
65
+ edges.push(edge);
66
+ }
67
+ }
68
+ return edges;
69
+ }
70
+ export function junGardenNotes(entries, edges, scope) {
71
+ const byId = /* @__PURE__ */ new Map();
72
+ for (const entry of entries) if (entry?.id) byId.set(entry.id, entry);
73
+ const refOf = (id, weight) => {
74
+ const entry = byId.get(id);
75
+ return {
76
+ id,
77
+ label: (entry?.label ?? "").trim() || "Untitled",
78
+ href: entry?.href,
79
+ weight
80
+ };
81
+ };
82
+ const notes = /* @__PURE__ */ new Map();
83
+ for (const id of scope) {
84
+ const entry = byId.get(id);
85
+ if (!entry) continue;
86
+ notes.set(id, {
87
+ id,
88
+ label: (entry.label ?? "").trim() || "Untitled",
89
+ href: entry.href,
90
+ type: entry.type,
91
+ maturity: junMaturityOf(entry.meta),
92
+ updatedAt: entry.updatedAt ?? entry.createdAt ?? 0,
93
+ inbound: [],
94
+ outbound: [],
95
+ degree: 0
96
+ });
97
+ }
98
+ for (const edge of edges) {
99
+ const from = notes.get(edge.source);
100
+ const to = notes.get(edge.target);
101
+ if (from && byId.has(edge.target)) from.outbound.push(refOf(edge.target, edge.weight));
102
+ if (to && byId.has(edge.source)) to.inbound.push(refOf(edge.source, edge.weight));
103
+ }
104
+ for (const note of notes.values()) {
105
+ note.inbound.sort((a, b) => b.weight - a.weight || a.label.localeCompare(b.label));
106
+ note.outbound.sort((a, b) => b.weight - a.weight || a.label.localeCompare(b.label));
107
+ note.degree = note.inbound.length + note.outbound.length;
108
+ }
109
+ return [...notes.values()];
110
+ }
111
+ export function junGardenOrphans(notes) {
112
+ return notes.filter((n) => n.inbound.length === 0);
113
+ }
114
+ export function junGardenSort(notes, key) {
115
+ const byLabel = (a, b) => a.label.localeCompare(b.label);
116
+ const list = [...notes];
117
+ if (key === "alpha") return list.sort(byLabel);
118
+ if (key === "recent") return list.sort((a, b) => b.updatedAt - a.updatedAt || byLabel(a, b));
119
+ return list.sort((a, b) => b.inbound.length - a.inbound.length || b.degree - a.degree || byLabel(a, b));
120
+ }
121
+ export function junGardenCounts(notes) {
122
+ let links = 0;
123
+ let orphans = 0;
124
+ let evergreen = 0;
125
+ for (const note of notes) {
126
+ links += note.outbound.length;
127
+ if (note.inbound.length === 0) orphans++;
128
+ if (note.maturity === "evergreen") evergreen++;
129
+ }
130
+ return { notes: notes.length, links, orphans, evergreen };
131
+ }
132
+ const GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
133
+ const GRAVITY = 0.035;
134
+ export function junGardenLayout(ids, edges, options = {}) {
135
+ const width = options.width ?? 1e3;
136
+ const height = options.height ?? 640;
137
+ const padding = options.padding ?? 28;
138
+ const iterations = options.iterations ?? 240;
139
+ const spread = options.spread ?? 1;
140
+ const n = ids.length;
141
+ if (n === 0) return [];
142
+ if (n === 1) return [{ id: ids[0], x: width / 2, y: height / 2 }];
143
+ const index = /* @__PURE__ */ new Map();
144
+ ids.forEach((id, i) => index.set(id, i));
145
+ const xs = new Float64Array(n);
146
+ const ys = new Float64Array(n);
147
+ for (let i = 0; i < n; i++) {
148
+ const r = 0.5 * Math.sqrt((i + 0.5) / n);
149
+ const a = i * GOLDEN_ANGLE;
150
+ xs[i] = 0.5 + r * Math.cos(a);
151
+ ys[i] = 0.5 + r * Math.sin(a);
152
+ }
153
+ const links = [];
154
+ for (const edge of edges) {
155
+ const a = index.get(edge.source);
156
+ const b = index.get(edge.target);
157
+ if (a === void 0 || b === void 0 || a === b) continue;
158
+ links.push([a, b, Math.min(edge.weight || 1, 4)]);
159
+ }
160
+ const k = spread * Math.sqrt(1 / n);
161
+ const dx = new Float64Array(n);
162
+ const dy = new Float64Array(n);
163
+ for (let step = 0; step < iterations; step++) {
164
+ const temp = 0.1 * (1 - step / iterations);
165
+ dx.fill(0);
166
+ dy.fill(0);
167
+ for (let i = 0; i < n; i++) {
168
+ for (let j = i + 1; j < n; j++) {
169
+ let vx = xs[i] - xs[j];
170
+ let vy = ys[i] - ys[j];
171
+ let dist = Math.sqrt(vx * vx + vy * vy);
172
+ if (dist < 1e-9) {
173
+ vx = ((i * 7 + j * 3) % 11 - 5) * 1e-4 || 1e-4;
174
+ vy = ((i * 5 + j * 9) % 13 - 6) * 1e-4 || 1e-4;
175
+ dist = Math.sqrt(vx * vx + vy * vy);
176
+ }
177
+ const force = k * k / dist;
178
+ const fx = vx / dist * force;
179
+ const fy = vy / dist * force;
180
+ dx[i] += fx;
181
+ dy[i] += fy;
182
+ dx[j] -= fx;
183
+ dy[j] -= fy;
184
+ }
185
+ }
186
+ for (const [a, b, weight] of links) {
187
+ const vx = xs[a] - xs[b];
188
+ const vy = ys[a] - ys[b];
189
+ const dist = Math.max(Math.sqrt(vx * vx + vy * vy), 1e-9);
190
+ const force = dist * dist / k * weight;
191
+ const fx = vx / dist * force;
192
+ const fy = vy / dist * force;
193
+ dx[a] -= fx;
194
+ dy[a] -= fy;
195
+ dx[b] += fx;
196
+ dy[b] += fy;
197
+ }
198
+ for (let i = 0; i < n; i++) {
199
+ dx[i] += (0.5 - xs[i]) * GRAVITY;
200
+ dy[i] += (0.5 - ys[i]) * GRAVITY;
201
+ const len = Math.sqrt(dx[i] * dx[i] + dy[i] * dy[i]);
202
+ if (len > 1e-12) {
203
+ const move = Math.min(len, temp);
204
+ xs[i] += dx[i] / len * move;
205
+ ys[i] += dy[i] / len * move;
206
+ }
207
+ xs[i] = Math.min(1.2, Math.max(-0.2, xs[i]));
208
+ ys[i] = Math.min(1.2, Math.max(-0.2, ys[i]));
209
+ }
210
+ }
211
+ let minX = Infinity;
212
+ let maxX = -Infinity;
213
+ let minY = Infinity;
214
+ let maxY = -Infinity;
215
+ for (let i = 0; i < n; i++) {
216
+ minX = Math.min(minX, xs[i]);
217
+ maxX = Math.max(maxX, xs[i]);
218
+ minY = Math.min(minY, ys[i]);
219
+ maxY = Math.max(maxY, ys[i]);
220
+ }
221
+ const spanX = Math.max(maxX - minX, 1e-6);
222
+ const spanY = Math.max(maxY - minY, 1e-6);
223
+ const boxW = Math.max(width - padding * 2, 1);
224
+ const boxH = Math.max(height - padding * 2, 1);
225
+ return ids.map((id, i) => ({
226
+ id,
227
+ x: round(padding + (xs[i] - minX) / spanX * boxW),
228
+ y: round(padding + (ys[i] - minY) / spanY * boxH)
229
+ }));
230
+ }
231
+ function round(value) {
232
+ return Math.round(value * 100) / 100;
233
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * "What does this site look like?" — the pure answer.
3
+ *
4
+ * Four places need it and none of them may disagree: `<JunHead>` (which writes
5
+ * the `<link>`s), the favicon route, the icon rasteriser and the web manifest.
6
+ * The first runs in the browser and during SSR; the rest run only in Nitro. So
7
+ * the resolution lives here, with **no imports beyond `junMark`**, and each
8
+ * caller supplies its own two inputs — the build-time `jun.brand` options and
9
+ * the Site Config document's meta.
10
+ *
11
+ * The consequence worth stating: the icon URLs carry a `?v=` computed from this
12
+ * identity, and both sides compute it from the same function. If one side ever
13
+ * resolved the brand differently, the head would emit a URL the routes render
14
+ * something else for, and the tab and the home screen would drift apart with
15
+ * nothing failing.
16
+ */
17
+ import type { JunMarkColors, JunMarkName } from './junMark.js';
18
+ export interface JunIdentity {
19
+ name: string;
20
+ /** What a home screen has room for. Launchers truncate rather than wrap. */
21
+ shortName: string;
22
+ description: string;
23
+ mark: JunMarkName;
24
+ light: JunMarkColors;
25
+ dark: JunMarkColors;
26
+ /**
27
+ * The app icon's tile. A home-screen icon is not theme-aware — it sits on
28
+ * whatever wallpaper the person chose — so it commits to ONE colour, and the
29
+ * site's `themeColor` is the colour its app chrome already uses.
30
+ */
31
+ tile: string;
32
+ themeColor: string;
33
+ /**
34
+ * Everything above, as a short stable string, used as the cache-buster on
35
+ * every icon URL. The icon responses are `immutable` for a year; without this
36
+ * an owner changing the accent would keep the old icon until it expired.
37
+ */
38
+ version: string;
39
+ }
40
+ /** The `jun.brand` options this needs. A subset, so the type stays portable. */
41
+ export interface JunIdentityBrand {
42
+ name?: string;
43
+ tagline?: string;
44
+ seoDescription?: string;
45
+ logoMark?: string;
46
+ themeColor?: string;
47
+ iconBackground?: string;
48
+ }
49
+ /**
50
+ * A short, stable, non-cryptographic digest — FNV-1a. A cache key, not a
51
+ * checksum: it has to be identical on both sides of the wire and cheap enough
52
+ * to compute on every render, and it is never compared against anything an
53
+ * attacker supplies.
54
+ */
55
+ export declare function junFingerprint(input: string): string;
56
+ export declare function junIdentity(brand: JunIdentityBrand | undefined, cfg: Record<string, unknown>): JunIdentity;
57
+ /**
58
+ * How much of its box a mark should fill.
59
+ *
60
+ * `sun` IS a disc that meets the edge — insetting it leaves a ring of tile
61
+ * around a shape whose whole job is to BE the tile. The monoline marks are
62
+ * drawn inside a 48-unit box with a margin already, but not enough of one for a
63
+ * launcher's crop.
64
+ *
65
+ * `maskable` is Android's promise that it may crop to any shape inside the
66
+ * central 80%, hence the much deeper inset. Getting this wrong is not subtle:
67
+ * an un-inset maskable icon comes back with its edges sliced off.
68
+ */
69
+ export declare function junIconScale(mark: JunMarkName, maskable?: boolean): number;
70
+ /** The icon URLs, so the head and the manifest cannot spell them differently. */
71
+ export declare function junIconUrls(identity: JunIdentity): {
72
+ favicon: string;
73
+ appleTouch: string;
74
+ png: (size: number, maskable?: boolean) => string;
75
+ splash: (w: number, h: number) => string;
76
+ };
77
+ /**
78
+ * The screens iOS will show a launch image on.
79
+ *
80
+ * ── Why a table at all ──────────────────────────────────────────────────────
81
+ * Android builds its own splash from the manifest (`background_color` + the
82
+ * 512 icon + the name), so everything Android needs is already declared. iOS
83
+ * builds nothing: with no `apple-touch-startup-image` it shows a WHITE screen
84
+ * on every launch, and a white flash in front of a dark site is the second most
85
+ * obvious tell that an installed app is a website — right behind the icon.
86
+ *
87
+ * ── Why it looks like this ──────────────────────────────────────────────────
88
+ * iOS matches on CSS dimensions and DPR, and it matches EXACTLY: a device with
89
+ * no entry gets white, and a near-miss does not letterbox, it is simply not
90
+ * used. So the media query has to name the device. Both orientations, because
91
+ * the query is on `orientation` too and a phone opened in landscape otherwise
92
+ * falls back to white.
93
+ *
94
+ * ── This list AGES, and that is the deal ────────────────────────────────────
95
+ * A device released after this list gets the old behaviour (white), never a
96
+ * broken one. Entries are CSS points at the stated DPR, portrait; the landscape
97
+ * link swaps them. Grouped by hardware generation rather than by marketing
98
+ * name, because several phones share a screen — `375×812@3` is the X, the XS,
99
+ * the 11 Pro, the 12 mini and the 13 mini.
100
+ *
101
+ * The BYTES are the reason this is worth checking before adding to it: 32 link
102
+ * tags is ~5KB of HTML on every page view. They are near-identical strings, so
103
+ * gzip takes them to a few hundred bytes — but that is a property of THIS
104
+ * shape, and a table that grows unboundedly would stop being free.
105
+ */
106
+ export declare const JUN_IOS_SCREENS: {
107
+ w: number;
108
+ h: number;
109
+ dpr: number;
110
+ }[];
111
+ /**
112
+ * The `<link rel="apple-touch-startup-image">` set, both orientations.
113
+ *
114
+ * The `href` is in DEVICE pixels (points × dpr) because that is the image; the
115
+ * media query is in POINTS because that is what iOS matches on.
116
+ */
117
+ export declare function junAppleSplashLinks(identity: JunIdentity): {
118
+ rel: string;
119
+ href: string;
120
+ media: string;
121
+ }[];
@@ -0,0 +1,115 @@
1
+ import { junMarkColorsFor, junMarkName } from "./junMark.js";
2
+ const HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
3
+ const DEFAULT_THEME_COLOR = "#0e0f11";
4
+ const SHORT_NAME_MAX = 12;
5
+ function str(v) {
6
+ return typeof v === "string" && v.trim() ? v.trim() : void 0;
7
+ }
8
+ function hex(v, fallback) {
9
+ const s = str(v);
10
+ return s && HEX_RE.test(s) ? s : fallback;
11
+ }
12
+ export function junFingerprint(input) {
13
+ let h = 2166136261;
14
+ for (let i = 0; i < input.length; i++) {
15
+ h ^= input.charCodeAt(i);
16
+ h = Math.imul(h, 16777619) >>> 0;
17
+ }
18
+ return h.toString(36);
19
+ }
20
+ export function junIdentity(brand, cfg) {
21
+ const name = str(cfg.seoTitle) ?? str(brand?.name) ?? "Jun!s";
22
+ const description = str(cfg.seoDescription) ?? str(brand?.seoDescription) ?? str(brand?.tagline) ?? "";
23
+ const mark = junMarkName(cfg.brandLogo ?? brand?.logoMark, "sun");
24
+ const { light, dark } = junMarkColorsFor(cfg);
25
+ const themeColor = hex(brand?.themeColor, DEFAULT_THEME_COLOR);
26
+ const tile = hex(brand?.iconBackground, themeColor);
27
+ return {
28
+ name,
29
+ shortName: name.length <= SHORT_NAME_MAX ? name : name.slice(0, SHORT_NAME_MAX).trim(),
30
+ description,
31
+ mark,
32
+ light,
33
+ dark,
34
+ tile,
35
+ themeColor,
36
+ version: junFingerprint([
37
+ name,
38
+ mark,
39
+ tile,
40
+ themeColor,
41
+ light.ink,
42
+ light.sunFrom,
43
+ light.sunTo,
44
+ light.sunCore,
45
+ light.sunGlow,
46
+ dark.ink,
47
+ dark.sunFrom,
48
+ dark.sunTo,
49
+ dark.sunCore,
50
+ dark.sunGlow
51
+ ].join("|"))
52
+ };
53
+ }
54
+ export function junIconScale(mark, maskable = false) {
55
+ if (maskable) return mark === "sun" ? 0.72 : 0.56;
56
+ return mark === "sun" ? 1 : 0.8;
57
+ }
58
+ export function junIconUrls(identity) {
59
+ const v = identity.version;
60
+ return {
61
+ favicon: `/jun-icon.svg?v=${v}`,
62
+ appleTouch: `/apple-touch-icon.png?v=${v}`,
63
+ png: (size, maskable = false) => `/jun-icon.png?size=${size}&v=${v}${maskable ? "&maskable=1" : ""}`,
64
+ splash: (w, h) => `/jun-splash.png?w=${w}&h=${h}&v=${v}`
65
+ };
66
+ }
67
+ export const JUN_IOS_SCREENS = [
68
+ { w: 375, h: 667, dpr: 2 },
69
+ // SE (2nd/3rd), 6/7/8
70
+ { w: 414, h: 736, dpr: 3 },
71
+ // 8 Plus
72
+ { w: 375, h: 812, dpr: 3 },
73
+ // X, XS, 11 Pro, 12/13 mini
74
+ { w: 414, h: 896, dpr: 2 },
75
+ // XR, 11
76
+ { w: 414, h: 896, dpr: 3 },
77
+ // XS Max, 11 Pro Max
78
+ { w: 390, h: 844, dpr: 3 },
79
+ // 12, 12 Pro, 13, 13 Pro, 14
80
+ { w: 428, h: 926, dpr: 3 },
81
+ // 12/13 Pro Max, 14 Plus
82
+ { w: 393, h: 852, dpr: 3 },
83
+ // 14 Pro, 15, 15 Pro, 16
84
+ { w: 430, h: 932, dpr: 3 },
85
+ // 14 Pro Max, 15 Plus, 15/16 Pro Max
86
+ { w: 402, h: 874, dpr: 3 },
87
+ // 16 Pro
88
+ { w: 440, h: 956, dpr: 3 },
89
+ // 16 Pro Max
90
+ { w: 768, h: 1024, dpr: 2 },
91
+ // iPad, iPad mini (9.7"/7.9")
92
+ { w: 810, h: 1080, dpr: 2 },
93
+ // iPad 10.2"
94
+ { w: 820, h: 1180, dpr: 2 },
95
+ // iPad Air 10.9"/11"
96
+ { w: 834, h: 1194, dpr: 2 },
97
+ // iPad Pro 11"
98
+ { w: 1024, h: 1366, dpr: 2 }
99
+ // iPad Pro 12.9"/13"
100
+ ];
101
+ export function junAppleSplashLinks(identity) {
102
+ const url = junIconUrls(identity).splash;
103
+ return JUN_IOS_SCREENS.flatMap(({ w, h, dpr }) => [
104
+ {
105
+ rel: "apple-touch-startup-image",
106
+ href: url(w * dpr, h * dpr),
107
+ media: `(device-width:${w}px) and (device-height:${h}px) and (-webkit-device-pixel-ratio:${dpr}) and (orientation:portrait)`
108
+ },
109
+ {
110
+ rel: "apple-touch-startup-image",
111
+ href: url(h * dpr, w * dpr),
112
+ media: `(device-width:${w}px) and (device-height:${h}px) and (-webkit-device-pixel-ratio:${dpr}) and (orientation:landscape)`
113
+ }
114
+ ]);
115
+ }