@abraca/junis 2.86.0 → 2.88.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 (98) hide show
  1. package/dist/module.d.mts +4 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +82 -8
  4. package/dist/runtime/assets/css/jun.css +2 -2
  5. package/dist/runtime/components/JunDocSurface.d.vue.ts +20 -2
  6. package/dist/runtime/components/JunDocSurface.vue +30 -2
  7. package/dist/runtime/components/JunDocSurface.vue.d.ts +20 -2
  8. package/dist/runtime/components/JunHead.vue +16 -4
  9. package/dist/runtime/components/JunNavDock.d.vue.ts +15 -0
  10. package/dist/runtime/components/JunNavDock.vue +94 -0
  11. package/dist/runtime/components/JunNavDock.vue.d.ts +15 -0
  12. package/dist/runtime/components/JunNavMenu.client.d.vue.ts +15 -0
  13. package/dist/runtime/components/JunNavMenu.client.vue +478 -0
  14. package/dist/runtime/components/JunNavMenu.client.vue.d.ts +15 -0
  15. package/dist/runtime/components/JunNavPreview.d.vue.ts +17 -0
  16. package/dist/runtime/components/JunNavPreview.vue +169 -0
  17. package/dist/runtime/components/JunNavPreview.vue.d.ts +17 -0
  18. package/dist/runtime/components/JunNavigation.d.vue.ts +4 -11
  19. package/dist/runtime/components/JunNavigation.vue +813 -138
  20. package/dist/runtime/components/JunNavigation.vue.d.ts +4 -11
  21. package/dist/runtime/components/JunNoteLinks.vue +1 -1
  22. package/dist/runtime/components/JunPageHero.vue +3 -3
  23. package/dist/runtime/components/JunSectionBar.d.vue.ts +41 -0
  24. package/dist/runtime/components/JunSectionBar.vue +144 -0
  25. package/dist/runtime/components/JunSectionBar.vue.d.ts +41 -0
  26. package/dist/runtime/components/renderers/JunConfigRenderer.vue +486 -6
  27. package/dist/runtime/components/renderers/JunEntryRenderer.vue +48 -0
  28. package/dist/runtime/components/renderers/JunGlobeRenderer.vue +43 -26
  29. package/dist/runtime/composables/useJunCreatePage.js +7 -1
  30. package/dist/runtime/composables/useJunDocPage.d.ts +28 -0
  31. package/dist/runtime/composables/useJunDocPage.js +111 -20
  32. package/dist/runtime/composables/useJunGarden.d.ts +1 -1
  33. package/dist/runtime/composables/useJunGarden.js +3 -2
  34. package/dist/runtime/composables/useJunGestures.d.ts +53 -0
  35. package/dist/runtime/composables/useJunGestures.js +89 -0
  36. package/dist/runtime/composables/useJunMenuState.d.ts +4 -0
  37. package/dist/runtime/composables/useJunMenuState.js +5 -0
  38. package/dist/runtime/composables/useJunNavItems.d.ts +50 -0
  39. package/dist/runtime/composables/useJunNavItems.js +188 -0
  40. package/dist/runtime/composables/useJunNavSettings.d.ts +58 -1
  41. package/dist/runtime/composables/useJunNavSettings.js +110 -8
  42. package/dist/runtime/composables/useJunOptions.d.ts +1 -0
  43. package/dist/runtime/composables/useJunSiblings.d.ts +30 -0
  44. package/dist/runtime/composables/useJunSiblings.js +38 -0
  45. package/dist/runtime/composables/useJunSiteConfig.d.ts +51 -3
  46. package/dist/runtime/composables/useJunTheme.js +4 -1
  47. package/dist/runtime/composables/useJunViewingAccent.js +10 -0
  48. package/dist/runtime/layouts/jun.vue +21 -1
  49. package/dist/runtime/pages/doc.vue +41 -35
  50. package/dist/runtime/pages/index.vue +63 -35
  51. package/dist/runtime/plugins/jun-doc-tree.d.ts +2 -0
  52. package/dist/runtime/plugins/jun-doc-tree.js +26 -0
  53. package/dist/runtime/server/api/health.get.d.ts +15 -0
  54. package/dist/runtime/server/api/health.get.js +7 -2
  55. package/dist/runtime/server/api/links.get.js +27 -3
  56. package/dist/runtime/server/api/resolve/[...slug].get.d.ts +20 -0
  57. package/dist/runtime/server/api/resolve/[...slug].get.js +33 -2
  58. package/dist/runtime/server/api/search.get.d.ts +1 -1
  59. package/dist/runtime/server/api/search.get.js +42 -39
  60. package/dist/runtime/server/api/tree.get.d.ts +9 -0
  61. package/dist/runtime/server/api/tree.get.js +25 -0
  62. package/dist/runtime/server/janitor/junJanitorActor.d.ts +13 -0
  63. package/dist/runtime/server/janitor/junJanitorActor.js +36 -5
  64. package/dist/runtime/server/janitor/junJanitorChores.d.ts +14 -7
  65. package/dist/runtime/server/janitor/junJanitorChores.js +21 -3
  66. package/dist/runtime/server/janitor/junJanitorMachine.js +36 -4
  67. package/dist/runtime/server/janitor/junJanitorPerform.d.ts +15 -1
  68. package/dist/runtime/server/janitor/junJanitorPerform.js +13 -5
  69. package/dist/runtime/server/janitor/junJanitorYText.d.ts +40 -3
  70. package/dist/runtime/server/janitor/junJanitorYText.js +60 -14
  71. package/dist/runtime/server/plugins/jun-janitor.js +132 -81
  72. package/dist/runtime/server/routes/jun-card.png.get.d.ts +2 -0
  73. package/dist/runtime/server/routes/jun-card.png.get.js +40 -0
  74. package/dist/runtime/server/utils/junCard.d.ts +39 -0
  75. package/dist/runtime/server/utils/junCard.js +159 -0
  76. package/dist/runtime/server/utils/junIcon.d.ts +27 -2
  77. package/dist/runtime/server/utils/junIcon.js +5 -5
  78. package/dist/runtime/server/utils/junJanitorStatus.d.ts +59 -0
  79. package/dist/runtime/server/utils/junJanitorStatus.js +27 -0
  80. package/dist/runtime/types.d.ts +225 -0
  81. package/dist/runtime/utils/junAdopt.d.ts +43 -0
  82. package/dist/runtime/utils/junAdopt.js +7 -0
  83. package/dist/runtime/utils/junGesture.d.ts +84 -0
  84. package/dist/runtime/utils/junGesture.js +40 -0
  85. package/dist/runtime/utils/junLetters.d.ts +86 -0
  86. package/dist/runtime/utils/junLetters.js +173 -0
  87. package/dist/runtime/utils/junNavValue.d.ts +56 -0
  88. package/dist/runtime/utils/junNavValue.js +36 -0
  89. package/dist/runtime/utils/junSearchRank.d.ts +79 -0
  90. package/dist/runtime/utils/junSearchRank.js +73 -0
  91. package/dist/runtime/utils/junSocial.d.ts +59 -0
  92. package/dist/runtime/utils/junSocial.js +56 -0
  93. package/dist/runtime/utils/junViewSpecs.d.ts +38 -0
  94. package/dist/runtime/utils/junViewSpecs.js +92 -1
  95. package/package.json +10 -8
  96. /package/dist/runtime/components/{JunSectionPresence.client.d.vue.ts → JunSectionPresence.d.vue.ts} +0 -0
  97. /package/dist/runtime/components/{JunSectionPresence.client.vue → JunSectionPresence.vue} +0 -0
  98. /package/dist/runtime/components/{JunSectionPresence.client.vue.d.ts → JunSectionPresence.vue.d.ts} +0 -0
@@ -0,0 +1,173 @@
1
+ const GLYPHS = {
2
+ "A": "6.4|0,10 3,0 6,10|1.2,7 4.8,7",
3
+ "B": "6.2|0,0 0,10|0,0 4,0 5.4,1.4 5.4,3.6 4,5 0,5|0,5 4.4,5 6,6.6 6,8.4 4.4,10 0,10",
4
+ "C": "6.4|6,2.2 4,0 2,0 0,2.2 0,7.8 2,10 4,10 6,7.8",
5
+ "D": "6.4|0,0 0,10|0,0 3.2,0 5.6,2.4 5.6,7.6 3.2,10 0,10",
6
+ "E": "5.8|5.6,0 0,0 0,10 5.6,10|0,5 4.4,5",
7
+ "F": "5.6|5.6,0 0,0 0,10|0,5 4.4,5",
8
+ "G": "6.6|6,2.2 4,0 2,0 0,2.2 0,7.8 2,10 4.2,10 6,8 6,5.4 3.6,5.4",
9
+ "H": "6.4|0,0 0,10|6,0 6,10|0,5 6,5",
10
+ "I": "2.4|1.2,0 1.2,10",
11
+ "J": "5.6|5,0 5,7.6 3.4,10 1.4,10 0,8",
12
+ "K": "6.2|0,0 0,10|5.6,0 0.6,5.4|2,3.8 6,10",
13
+ "L": "5.4|0,0 0,10 5.2,10",
14
+ "M": "7.6|0,10 0,0 3.6,5.6 7.2,0 7.2,10",
15
+ "N": "6.6|0,10 0,0 6.2,10 6.2,0",
16
+ "O": "6.8|2.2,0 4.2,0 6.4,2.2 6.4,7.8 4.2,10 2.2,10 0,7.8 0,2.2 2.2,0",
17
+ "P": "6.2|0,10 0,0 4,0 6,2 6,4.2 4,6.2 0,6.2",
18
+ "Q": "6.8|2.2,0 4.2,0 6.4,2.2 6.4,7.8 4.2,10 2.2,10 0,7.8 0,2.2 2.2,0|3.8,6.8 6.8,11.4",
19
+ "R": "6.2|0,10 0,0 4,0 6,2 6,4.2 4,6.2 0,6.2|3.4,6.2 6.2,10",
20
+ "S": "6.2|6,2 4.2,0 2,0 0,1.8 0,3.6 2,5 4.2,5 6,6.6 6,8.2 4,10 1.8,10 0,8.2",
21
+ "T": "6|0,0 6,0|3,0 3,10",
22
+ "U": "6.4|0,0 0,7.8 2.2,10 4.2,10 6.4,7.8 6.4,0",
23
+ "V": "6.4|0,0 3.2,10 6.4,0",
24
+ "W": "8.6|0,0 1.9,10 4.3,3.4 6.7,10 8.6,0",
25
+ "X": "6.4|0,0 6.2,10|6.2,0 0,10",
26
+ "Y": "6.2|0,0 3.1,5.2 6.2,0|3.1,5.2 3.1,10",
27
+ "Z": "6.2|0,0 6.2,0 0,10 6.2,10",
28
+ "0": "6.6|2.2,0 4.2,0 6.4,2.2 6.4,7.8 4.2,10 2.2,10 0,7.8 0,2.2 2.2,0|1,8 5.4,2",
29
+ "1": "4|0.6,1.8 2.6,0 2.6,10|0.4,10 4.6,10",
30
+ "2": "6.2|0,2.2 2,0 4.2,0 6.2,2 6.2,3.6 0,10 6.2,10",
31
+ "3": "6.2|0,1.2 2,0 4.4,0 6.2,1.8 6.2,3.6 4.2,5 6.2,6.4 6.2,8.2 4.4,10 2,10 0,8.8",
32
+ "4": "6.4|4.6,10 4.6,0 0,7 6.4,7",
33
+ "5": "6.2|6,0 0.4,0 0,4.6 3.8,4 6.2,5.8 6.2,8.2 4.2,10 1.8,10 0,8.8",
34
+ "6": "6.2|5.6,0.8 3.6,0 1.4,1.4 0,4.4 0,8 2,10 4.2,10 6.2,8.2 6.2,6.6 4.2,5 1.6,5 0,6.6",
35
+ "7": "5.8|0,0 5.8,0 2,10",
36
+ "8": "6.4|2.2,5 0,3.6 0,1.6 2.2,0 4.2,0 6.4,1.6 6.4,3.6 4.2,5 2.2,5|2.2,5 0,6.5 0,8.4 2.2,10 4.2,10 6.4,8.4 6.4,6.5 4.2,5",
37
+ "9": "6.2|0.6,9.2 2.6,10 4.8,8.6 6.2,5.6 6.2,2 4.2,0 2,0 0,1.8 0,3.4 2,5 4.6,5 6.2,3.4",
38
+ " ": "4",
39
+ ".": "2.6|1.1,9.4 1.5,9.4",
40
+ ",": "2.6|1.5,9.2 0.7,11.6",
41
+ ":": "2.6|1.1,3.4 1.5,3.4|1.1,9.4 1.5,9.4",
42
+ ";": "2.6|1.1,3.4 1.5,3.4|1.5,9.2 0.7,11.6",
43
+ "!": "2.6|1.3,0 1.3,7|1.1,9.4 1.5,9.4",
44
+ "?": "5.6|0,2 2,0 3.6,0 5.4,1.8 5.4,3.4 2.7,5.4 2.7,7|2.5,9.4 2.9,9.4",
45
+ "'": "2.4|1.3,0 0.9,2.6",
46
+ '"': "4|1.2,0 0.8,2.6|3.2,0 2.8,2.6",
47
+ "-": "4.6|0.4,5.2 4.2,5.2",
48
+ "\u2013": "6|0,5.2 6,5.2",
49
+ "\u2014": "7.4|0,5.2 7.4,5.2",
50
+ "_": "5.6|0,10.8 5.6,10.8",
51
+ "/": "5|4.6,0 0.4,11",
52
+ "\\": "5|0.4,0 4.6,11",
53
+ "(": "3.6|3.2,0 1,3 1,7 3.2,10",
54
+ ")": "3.6|0.4,0 2.6,3 2.6,7 0.4,10",
55
+ "[": "3.2|3,0 1,0 1,10 3,10",
56
+ "]": "3.2|0.2,0 2.2,0 2.2,10 0.2,10",
57
+ "&": "7|6.8,10 1.6,1.6 3,0 4.4,1.4 0,6.6 0,8.4 1.6,10 3.6,10 6.4,6.6",
58
+ "+": "6|3,2 3,8|0,5 6,5",
59
+ "=": "6|0,3.6 6,3.6|0,6.4 6,6.4",
60
+ "@": "8|5.8,6.8 4.4,6.8 4.4,3.6 5.8,3.6 5.8,7.4 6.8,8 8,6.4 8,3.4 5.6,0 3,0 0.6,1.8 0,5 0.6,8.4 3,10 5.6,10",
61
+ "#": "6.6|1.8,0.6 0.8,9.4|4.6,0.6 3.6,9.4|0,3.4 5.8,3.4|0,6.6 5.8,6.6",
62
+ "%": "7|1.4,0 0,1.4 1.4,2.8 2.8,1.4 1.4,0|6.4,0 0.6,10|5.6,7.2 4.2,8.6 5.6,10 7,8.6 5.6,7.2",
63
+ "\u2026": "6.4|0.6,9.4 1,9.4|3,9.4 3.4,9.4|5.4,9.4 5.8,9.4",
64
+ "\xB7": "2.6|1.1,5 1.5,5",
65
+ "\u2022": "3.4|1.3,4.6 1.9,4.6|1.3,5.4 1.9,5.4",
66
+ "*": "5|2.5,0 2.5,5|0.4,1.4 4.6,3.8|4.6,1.4 0.4,3.8"
67
+ };
68
+ export const JUN_CAP_HEIGHT = 10;
69
+ const TRACKING = 1.4;
70
+ const parsed = /* @__PURE__ */ new Map();
71
+ function glyph(char) {
72
+ const hit = parsed.get(char);
73
+ if (hit) return hit;
74
+ const raw = GLYPHS[char];
75
+ if (!raw) return void 0;
76
+ const [head, ...rest] = raw.split("|");
77
+ const g = {
78
+ advance: Number.parseFloat(head ?? "6") || 6,
79
+ lines: rest.map((line) => line.trim().split(/\s+/).map((pt) => {
80
+ const [x, y] = pt.split(",");
81
+ return [Number.parseFloat(x ?? "0"), Number.parseFloat(y ?? "0")];
82
+ }))
83
+ };
84
+ parsed.set(char, g);
85
+ return g;
86
+ }
87
+ export function junCanDraw(text) {
88
+ for (const char of text.toUpperCase()) {
89
+ if (char.trim() && GLYPHS[char]) return true;
90
+ }
91
+ return false;
92
+ }
93
+ export function junTextWidth(text) {
94
+ const chars = [...text.toUpperCase()];
95
+ let w = 0;
96
+ for (const [i, char] of chars.entries()) {
97
+ const g = glyph(char) ?? glyph(" ");
98
+ w += g.advance + (i < chars.length - 1 ? TRACKING : 0);
99
+ }
100
+ return w;
101
+ }
102
+ export function junWrapText(text, maxWidth, maxLines) {
103
+ return junWrapInfo(text, maxWidth, maxLines).lines;
104
+ }
105
+ export function junWrapInfo(text, maxWidth, maxLines) {
106
+ const words = text.toUpperCase().split(/\s+/).filter(Boolean);
107
+ const lines = [];
108
+ let line = "";
109
+ let dropped = false;
110
+ const pushLine = () => {
111
+ if (line) lines.push(line);
112
+ line = "";
113
+ };
114
+ for (const word of words) {
115
+ const candidate = line ? `${line} ${word}` : word;
116
+ if (junTextWidth(candidate) <= maxWidth) {
117
+ line = candidate;
118
+ continue;
119
+ }
120
+ pushLine();
121
+ if (lines.length >= maxLines) {
122
+ dropped = true;
123
+ break;
124
+ }
125
+ if (junTextWidth(word) > maxWidth) {
126
+ let cut = "";
127
+ for (const char of word) {
128
+ if (junTextWidth(cut + char) > maxWidth) break;
129
+ cut += char;
130
+ }
131
+ line = cut;
132
+ continue;
133
+ }
134
+ line = word;
135
+ }
136
+ pushLine();
137
+ if (dropped || lines.length > maxLines) {
138
+ lines.length = Math.min(lines.length, maxLines);
139
+ let cut = lines[lines.length - 1] ?? "";
140
+ while (cut && junTextWidth(`${cut}\u2026`) > maxWidth) cut = cut.slice(0, -1);
141
+ if (lines.length) lines[lines.length - 1] = `${cut.trimEnd()}\u2026`;
142
+ return { lines, truncated: true };
143
+ }
144
+ return { lines, truncated: false };
145
+ }
146
+ export function junTextStrokes(text, x, y, size) {
147
+ const scale = size / JUN_CAP_HEIGHT;
148
+ const groups = [];
149
+ let penX = x;
150
+ for (const char of text.toUpperCase()) {
151
+ const g = glyph(char);
152
+ if (!g) {
153
+ penX += (glyph(" ").advance + TRACKING) * scale;
154
+ continue;
155
+ }
156
+ const segs = [];
157
+ for (const line of g.lines) {
158
+ for (let i = 1; i < line.length; i++) {
159
+ const a = line[i - 1];
160
+ const b = line[i];
161
+ segs.push([
162
+ penX + a[0] * scale,
163
+ y + (a[1] - JUN_CAP_HEIGHT) * scale,
164
+ penX + b[0] * scale,
165
+ y + (b[1] - JUN_CAP_HEIGHT) * scale
166
+ ]);
167
+ }
168
+ }
169
+ if (segs.length) groups.push(segs);
170
+ penX += (g.advance + TRACKING) * scale;
171
+ }
172
+ return groups;
173
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The navbar's THREE layers, as arithmetic.
3
+ *
4
+ * A navigation setting is answered by whichever of these speaks first:
5
+ *
6
+ * 1. the DOCUMENT being viewed — `meta.junView`, the same place every other
7
+ * per-page display setting lives;
8
+ * 2. the SITE CONFIG document — the owner's live choice;
9
+ * 3. `jun.navigation` — what a fresh site boots with.
10
+ *
11
+ * The rules that make that safe are the ones no page can show you, which is why
12
+ * they are here, with no imports, rather than inline in the composable:
13
+ *
14
+ * - **`inherit` is not a value, it is a refusal to answer.** Every per-document
15
+ * nav option defaults to it, because `useJunViewOptions` resolves to a spec's
16
+ * default when a document stores nothing — so an option whose default were
17
+ * `top` would mean every untouched page overriding the site's placement with
18
+ * `top`, forever.
19
+ * - **An unknown value degrades to the next layer, never to `undefined`.** A
20
+ * config document is CRDT data a NEWER build may have written; a stale client
21
+ * reading `mobileMode: 'carousel'` must fall back, not render nothing.
22
+ * - **…and if the build default is unknown too, the first value in the
23
+ * vocabulary.** That case looks impossible and is what a dev server produces
24
+ * when it hot-reloads a runtime file without re-reading `module.ts`: the
25
+ * navbar concluded a menu had replaced its track and rendered the track
26
+ * `display: none` at every width.
27
+ *
28
+ * `useJunNavSettings` is the reactive wrapper; it cannot load outside a Nuxt
29
+ * app. This is the half that decides, and it is tested.
30
+ */
31
+ /** The document's answer, or `undefined` when it has none. */
32
+ export declare function junNavDocValue(stored: unknown): string | undefined;
33
+ /**
34
+ * Resolve one CHOICE through all three layers.
35
+ *
36
+ * `allowed` is the vocabulary THIS build knows, ordered with the shipped
37
+ * default first — that ordering is what the last fallback relies on.
38
+ */
39
+ export declare function junNavPick<T extends string>(layers: {
40
+ doc?: unknown;
41
+ site?: unknown;
42
+ build: T;
43
+ }, allowed: readonly T[]): T;
44
+ /**
45
+ * Resolve one FLAG through all three layers.
46
+ *
47
+ * The document speaks in `on` / `off` rather than in booleans, because
48
+ * `meta.junView` values are the strings a `select` control stores and a boolean
49
+ * has no way to spell "no opinion".
50
+ */
51
+ export declare function junNavFlag(layers: {
52
+ doc?: unknown;
53
+ site?: unknown;
54
+ build: boolean;
55
+ }): boolean;
56
+ export declare function junNavPreview(raw: unknown): Record<string, string>;
@@ -0,0 +1,36 @@
1
+ export function junNavDocValue(stored) {
2
+ return typeof stored === "string" && stored !== "inherit" ? stored : void 0;
3
+ }
4
+ export function junNavPick(layers, allowed) {
5
+ const doc = junNavDocValue(layers.doc);
6
+ for (const candidate of [doc, layers.site]) {
7
+ if (typeof candidate === "string" && allowed.includes(candidate)) {
8
+ return candidate;
9
+ }
10
+ }
11
+ return allowed.includes(layers.build) ? layers.build : allowed[0];
12
+ }
13
+ export function junNavFlag(layers) {
14
+ const doc = junNavDocValue(layers.doc);
15
+ if (doc === "on") return true;
16
+ if (doc === "off") return false;
17
+ return typeof layers.site === "boolean" ? layers.site : layers.build;
18
+ }
19
+ const PREVIEW_KEYS = {
20
+ mobile: "navMobileMode",
21
+ placement: "navPlacement",
22
+ item: "navItemMode",
23
+ autohide: "navAutoHide",
24
+ section: "navSection"
25
+ };
26
+ export function junNavPreview(raw) {
27
+ const text = Array.isArray(raw) ? raw[0] : raw;
28
+ if (typeof text !== "string" || !text.trim()) return {};
29
+ const out = {};
30
+ for (const pair of text.split(",")) {
31
+ const [key, value] = pair.split(":").map((part) => part.trim().toLowerCase());
32
+ const mapped = key ? PREVIEW_KEYS[key] : void 0;
33
+ if (mapped && value) out[mapped] = value;
34
+ }
35
+ return out;
36
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * What a search query means, and which page answers it best.
3
+ *
4
+ * Zero imports, like `junNavValue` and `junSocial` — the rules here are
5
+ * arithmetic over strings, they decide what a person sees when they type two
6
+ * words, and none of them is visible on a rendered page.
7
+ *
8
+ * ## The bug this replaced
9
+ *
10
+ * Every one of the endpoint's three passes was
11
+ * `haystack.toLowerCase().includes(query)` — the WHOLE query, as one string.
12
+ * So on a site with a page called *Making it look like yours*:
13
+ *
14
+ * "making" → found
15
+ * "look yours" → nothing, because those two words are not adjacent
16
+ * "yours making" → nothing, ever, on any page
17
+ *
18
+ * A person typing two words means "both of these", not "these two, in this
19
+ * order, touching". So: terms, AND, and a score that says which page has more
20
+ * of them and in a better place.
21
+ */
22
+ /** Where a term was found. Higher is a better place to be found. */
23
+ export declare const JUN_FIELD_WEIGHT: {
24
+ readonly label: 100;
25
+ readonly excerpt: 60;
26
+ readonly body: 40;
27
+ };
28
+ export type JunSearchField = keyof typeof JUN_FIELD_WEIGHT;
29
+ export interface JunSearchFields {
30
+ label?: string;
31
+ excerpt?: string;
32
+ body?: string;
33
+ }
34
+ /**
35
+ * The query, as terms.
36
+ *
37
+ * Capped at eight: past that a query is a paste rather than a search, and the
38
+ * scoring loop runs per term per document. Deduped, because "the the" should
39
+ * not double a page's score.
40
+ */
41
+ export declare function junSearchTerms(query: string): string[];
42
+ /**
43
+ * How well a document answers a query. `0` means it does not.
44
+ *
45
+ * Every term must appear SOMEWHERE — that is the AND a person means. Beyond
46
+ * that:
47
+ *
48
+ * - a term is scored by the best field it appears in (a title beats a body);
49
+ * - a term at the very start of the label scores higher than one in the
50
+ * middle, which is the one rule carried over from the old endpoint;
51
+ * - the whole query appearing as a PHRASE is worth a bonus, so an exact title
52
+ * still wins against a page that merely contains the same words apart.
53
+ *
54
+ * The per-term scores are AVERAGED rather than summed, so a two-word query and
55
+ * a five-word one produce comparable numbers and a caller can use one
56
+ * threshold for both.
57
+ */
58
+ export declare function junSearchScore(terms: readonly string[], fields: JunSearchFields): number;
59
+ export interface JunSnippetRange {
60
+ start: number;
61
+ end: number;
62
+ }
63
+ /**
64
+ * The stretch of `text` worth showing, and where the terms are inside it.
65
+ *
66
+ * Centred on the densest WINDOW rather than on the first match. With one term
67
+ * those are the same thing; with two they are not, and a snippet built around
68
+ * the first occurrence of the first term routinely shows neither word in
69
+ * context — which is what the old endpoint did.
70
+ *
71
+ * Returns offsets rather than marked-up text: the caller escapes, because
72
+ * escaping and marking in the same pass is how a search result ends up
73
+ * rendering somebody's `<script>`.
74
+ */
75
+ export declare function junSearchSnippet(text: string, terms: readonly string[], width?: number): {
76
+ start: number;
77
+ end: number;
78
+ marks: JunSnippetRange[];
79
+ };
@@ -0,0 +1,73 @@
1
+ export const JUN_FIELD_WEIGHT = {
2
+ label: 100,
3
+ excerpt: 60,
4
+ body: 40
5
+ };
6
+ export function junSearchTerms(query) {
7
+ const seen = /* @__PURE__ */ new Set();
8
+ for (const raw of query.toLowerCase().split(/\s+/)) {
9
+ const term = raw.trim();
10
+ if (term) seen.add(term);
11
+ if (seen.size >= 8) break;
12
+ }
13
+ return [...seen];
14
+ }
15
+ export function junSearchScore(terms, fields) {
16
+ if (!terms.length) return 0;
17
+ const label = (fields.label ?? "").toLowerCase();
18
+ const excerpt = (fields.excerpt ?? "").toLowerCase();
19
+ const body = (fields.body ?? "").toLowerCase();
20
+ let total = 0;
21
+ for (const term of terms) {
22
+ const inLabel = label.indexOf(term);
23
+ const inExcerpt = excerpt.indexOf(term);
24
+ const inBody = body.indexOf(term);
25
+ if (inLabel < 0 && inExcerpt < 0 && inBody < 0) return 0;
26
+ let best = 0;
27
+ if (inLabel >= 0) best = JUN_FIELD_WEIGHT.label + (inLabel === 0 ? 20 : 0);
28
+ else if (inExcerpt >= 0) best = JUN_FIELD_WEIGHT.excerpt;
29
+ else best = JUN_FIELD_WEIGHT.body;
30
+ total += best;
31
+ }
32
+ let score = total / terms.length;
33
+ if (terms.length > 1) {
34
+ const phrase = terms.join(" ");
35
+ if (label.includes(phrase)) score += 25;
36
+ else if (excerpt.includes(phrase) || body.includes(phrase)) score += 10;
37
+ }
38
+ return score;
39
+ }
40
+ export function junSearchSnippet(text, terms, width = 150) {
41
+ const haystack = text.toLowerCase();
42
+ const hits = [];
43
+ for (const term of terms) {
44
+ let from = 0;
45
+ for (let n = 0; n < 12; n++) {
46
+ const at = haystack.indexOf(term, from);
47
+ if (at < 0) break;
48
+ hits.push({ start: at, end: at + term.length });
49
+ from = at + term.length;
50
+ }
51
+ }
52
+ if (!hits.length) return { start: 0, end: Math.min(width, text.length), marks: [] };
53
+ hits.sort((a, b) => a.start - b.start);
54
+ let best = { start: hits[0].start, count: 0 };
55
+ for (const hit of hits) {
56
+ const windowEnd = hit.start + width;
57
+ const inside = /* @__PURE__ */ new Set();
58
+ for (const other of hits) {
59
+ if (other.start >= hit.start && other.end <= windowEnd) {
60
+ inside.add(haystack.slice(other.start, other.end));
61
+ }
62
+ }
63
+ if (inside.size > best.count) best = { start: hit.start, count: inside.size };
64
+ }
65
+ let start = Math.max(0, best.start - 40);
66
+ while (start > 0 && !/\s/.test(text[start - 1] ?? "")) start--;
67
+ const end = Math.min(text.length, start + width);
68
+ return {
69
+ start,
70
+ end,
71
+ marks: hits.filter((h) => h.start >= start && h.end <= end)
72
+ };
73
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The arithmetic behind a page's link preview.
3
+ *
4
+ * Zero imports on purpose — the same shape as `junNavValue` and
5
+ * `junViewValues`. Every rule here is invisible on a rendered page: what a
6
+ * crawler receives is decided in the `<head>`, which nothing in a browser shows
7
+ * you and no screenshot can catch. So it gets unit tests instead.
8
+ *
9
+ * The starting point was a measurement: `og:title` was the SITE's title on
10
+ * every URL in the site, while `og:description` had been per-page since round
11
+ * five — so a shared journal entry showed the site's name over the entry's own
12
+ * summary, which is worse than either of them being wrong alone.
13
+ */
14
+ export declare function junOgType(schemaType?: unknown): string;
15
+ /**
16
+ * Whether `article:*` tags belong on this page.
17
+ *
18
+ * Only the article family takes them. Emitting `article:published_time` beside
19
+ * `og:type: website` is not harmless — it is the shape a scraper reads to
20
+ * decide a site's pages are one undated blob.
21
+ */
22
+ export declare function junIsArticleOg(ogType: string): boolean;
23
+ /**
24
+ * The first candidate that is a usable absolute origin.
25
+ *
26
+ * Call it with the site's own answer first and the request's last:
27
+ *
28
+ * junOrigin(config.seoSiteUrl, options.siteUrl, requestUrl.origin)
29
+ *
30
+ * Why an owner's setting outranks the request: a site reachable at several
31
+ * addresses (a preview domain, an IP, `www.` and bare) has to name ONE of them
32
+ * canonical, and only its owner knows which. Why the request outranks nothing:
33
+ * a deployment that never set it still emits its real address rather than
34
+ * `http://localhost:3003`, which is the one wrong answer a crawler can neither
35
+ * ignore nor recover from.
36
+ *
37
+ * A trailing slash is stripped so `junAbsoluteUrl` can join with one.
38
+ */
39
+ export declare function junOrigin(...candidates: unknown[]): string;
40
+ /**
41
+ * An absolute URL for a site-relative path.
42
+ *
43
+ * Returns the path unchanged when there is no origin. Deliberate: a relative
44
+ * `og:url` is ignored by every consumer, while an absolute URL built on a
45
+ * guessed origin is FOLLOWED — and points somewhere else. Silence beats a
46
+ * confident wrong answer here.
47
+ */
48
+ export declare function junAbsoluteUrl(origin: string, path: string): string;
49
+ /**
50
+ * An ISO-8601 instant from whatever a document's meta happens to hold.
51
+ *
52
+ * Three shapes reach this and all three are real here: an epoch in
53
+ * milliseconds (`createdAt`), an epoch in SECONDS (seeded content), and a date
54
+ * string an owner typed. The magnitude check is why the second one works —
55
+ * `new Date(1785000000)` is 1970 read as milliseconds and 2026 read as
56
+ * seconds, and the wrong branch dates every post to the Nixon administration
57
+ * without failing anywhere.
58
+ */
59
+ export declare function junIsoTime(value: unknown): string | undefined;
@@ -0,0 +1,56 @@
1
+ const OG_BY_SCHEMA = {
2
+ // The article family — anything read once, from a moment in time.
3
+ Article: "article",
4
+ BlogPosting: "article",
5
+ NewsArticle: "article",
6
+ TechArticle: "article",
7
+ ScholarlyArticle: "article",
8
+ Report: "article",
9
+ DiscussionForumPosting: "article",
10
+ LearningResource: "article",
11
+ Course: "article",
12
+ Recipe: "article",
13
+ // The richer vocabularies Open Graph actually defines.
14
+ Book: "book",
15
+ Movie: "video.movie",
16
+ TVEpisode: "video.episode",
17
+ VideoObject: "video.other",
18
+ MusicRecording: "music.song",
19
+ MusicAlbum: "music.album",
20
+ MusicPlaylist: "music.playlist",
21
+ // A page ABOUT a person, which is what a CV is.
22
+ Person: "profile",
23
+ ProfilePage: "profile"
24
+ };
25
+ export function junOgType(schemaType) {
26
+ if (typeof schemaType !== "string" || !schemaType) return "website";
27
+ return OG_BY_SCHEMA[schemaType] ?? "website";
28
+ }
29
+ export function junIsArticleOg(ogType) {
30
+ return ogType === "article";
31
+ }
32
+ export function junOrigin(...candidates) {
33
+ for (const candidate of candidates) {
34
+ if (typeof candidate !== "string") continue;
35
+ const trimmed = candidate.trim().replace(/\/+$/, "");
36
+ if (/^https?:\/\/\S+$/i.test(trimmed)) return trimmed;
37
+ }
38
+ return "";
39
+ }
40
+ export function junAbsoluteUrl(origin, path) {
41
+ const p = path.startsWith("/") ? path : `/${path}`;
42
+ if (!origin) return p;
43
+ return `${origin}${p === "/" ? "/" : p.replace(/\/+$/, "")}`;
44
+ }
45
+ export function junIsoTime(value) {
46
+ if (typeof value === "number" && Number.isFinite(value)) {
47
+ const ms = value < 1e11 ? value * 1e3 : value;
48
+ const d = new Date(ms);
49
+ return Number.isNaN(d.getTime()) ? void 0 : d.toISOString();
50
+ }
51
+ if (typeof value === "string" && value.trim()) {
52
+ const d = new Date(value.trim());
53
+ return Number.isNaN(d.getTime()) ? void 0 : d.toISOString();
54
+ }
55
+ return void 0;
56
+ }
@@ -669,3 +669,41 @@ export declare function junViewSpecFor(typeKey: string): JunViewOption[];
669
669
  * a hydration mismatch on every page that used one. See `useJunDocPage`.
670
670
  */
671
671
  export declare const JUN_CHROME_OPTIONS: JunViewOption[];
672
+ /**
673
+ * The NAVBAR, per page — appended to every type's spec beside the chrome ones.
674
+ *
675
+ * Hiding the navbar was already a per-document choice; how it LOOKS was not, and
676
+ * the two are the same question asked at different strengths. A deck wants the
677
+ * bar at the bottom and out of the way, a globe wants it to auto-hide over the
678
+ * canvas, and a long article might want that on a site whose owner left it off
679
+ * everywhere else. Turning any of those into a site-wide setting is how a site
680
+ * ends up configured for its most demanding page.
681
+ *
682
+ * **Every one of them defaults to `inherit`, and that is what makes it safe.**
683
+ * `useJunViewOptions` resolves the DOCUMENT, then the site's per-type default,
684
+ * then this — so a plain default of `top` would mean every page overriding the
685
+ * site's own placement with `top`, forever. `inherit` is the value that means
686
+ * "do not answer this question here", and `useJunNavSettings` skips it.
687
+ *
688
+ * They are `select`s rather than toggles for the same reason: a boolean has no
689
+ * way to spell "I have no opinion", and two-thirds of these are booleans in the
690
+ * site config.
691
+ */
692
+ /**
693
+ * How a page WEARS its title.
694
+ *
695
+ * `<JunPageHero>` is the interior header for 26 files and 42 call sites, and it
696
+ * has rendered exactly one shape since it was written: a large headline over a
697
+ * wide-tracked subtitle. That is a good shape and it is not the only one — a
698
+ * reference page wants a quiet line, a photograph wants a band, a wide feed
699
+ * wants the subtitle beside the title rather than under it.
700
+ *
701
+ * Applied as CSS from a `data-jun-hero` attribute on `<html>`, NOT as a prop:
702
+ * the hero is mounted by every renderer and threading a variant through all of
703
+ * them would be 42 edits and a permanent tax on the next one. The attribute is
704
+ * set by `useJunDocPage` in `htmlAttrs`, which is collected after the whole
705
+ * tree has rendered — the same mechanism `data-jun-chrome` uses, for the same
706
+ * reason.
707
+ */
708
+ export declare const JUN_HERO_OPTIONS: JunViewOption[];
709
+ export declare const JUN_NAV_OPTIONS: JunViewOption[];
@@ -525,10 +525,101 @@ export const JUN_VIEW_SPECS = {
525
525
  };
526
526
  export function junViewSpecFor(typeKey) {
527
527
  const own = JUN_VIEW_SPECS[typeKey];
528
- return own ? [...own, ...JUN_CHROME_OPTIONS] : [...JUN_CHROME_OPTIONS];
528
+ const base = own ? [...own, ...JUN_CHROME_OPTIONS] : [...JUN_CHROME_OPTIONS];
529
+ return [...base, ...JUN_HERO_OPTIONS, ...JUN_NAV_OPTIONS];
529
530
  }
530
531
  export const JUN_CHROME_OPTIONS = [
531
532
  { key: "chromeNav", kind: "toggle", label: "Navbar", icon: "i-lucide-navigation", default: true },
532
533
  { key: "chromeFooter", kind: "toggle", label: "Footer", icon: "i-lucide-panel-bottom", default: true },
533
534
  { key: "chromeBackdrop", kind: "toggle", label: "Backdrop", icon: "i-lucide-image", default: true }
534
535
  ];
536
+ export const JUN_HERO_OPTIONS = [
537
+ {
538
+ key: "heroStyle",
539
+ kind: "select",
540
+ label: "Page header",
541
+ icon: "i-lucide-heading-1",
542
+ default: "classic",
543
+ choices: [
544
+ { value: "classic", label: "Classic", hint: "Large headline, subtitle under" },
545
+ { value: "minimal", label: "Minimal", hint: "One quiet line" },
546
+ { value: "banner", label: "Banner", hint: "A band in the accent" },
547
+ { value: "split", label: "Split", hint: "Subtitle beside, on wide screens" }
548
+ ]
549
+ }
550
+ ];
551
+ export const JUN_NAV_OPTIONS = [
552
+ {
553
+ key: "navPlacement",
554
+ kind: "select",
555
+ label: "Navbar placement",
556
+ icon: "i-lucide-navigation",
557
+ default: "inherit",
558
+ choices: [
559
+ { value: "inherit", label: "Site default" },
560
+ { value: "top", label: "Top" },
561
+ { value: "top-bar", label: "Top bar" },
562
+ { value: "bottom", label: "Bottom" },
563
+ { value: "rail-left", label: "Left rail" },
564
+ { value: "rail-right", label: "Right rail" }
565
+ ]
566
+ },
567
+ {
568
+ key: "navItemMode",
569
+ kind: "select",
570
+ label: "Navbar items",
571
+ icon: "i-lucide-type",
572
+ default: "inherit",
573
+ choices: [
574
+ { value: "inherit", label: "Site default" },
575
+ { value: "text", label: "Text" },
576
+ { value: "icon", label: "Icons" },
577
+ { value: "icon-focus", label: "Icon + focus" },
578
+ { value: "icon-text", label: "Icon + title" },
579
+ { value: "icon-stack", label: "Stacked" }
580
+ ]
581
+ },
582
+ {
583
+ key: "navMobileMode",
584
+ kind: "select",
585
+ label: "Navbar on a phone",
586
+ icon: "i-lucide-smartphone",
587
+ default: "inherit",
588
+ choices: [
589
+ { value: "inherit", label: "Site default" },
590
+ { value: "track", label: "Track" },
591
+ { value: "sheet", label: "Sheet" },
592
+ { value: "drawer-left", label: "Drawer left" },
593
+ { value: "drawer-right", label: "Drawer right" },
594
+ { value: "fullscreen", label: "Full screen" },
595
+ { value: "grid", label: "Grid" },
596
+ { value: "dock", label: "Dock" }
597
+ ]
598
+ },
599
+ {
600
+ key: "navSection",
601
+ kind: "select",
602
+ label: "Section bar",
603
+ icon: "i-lucide-rows-3",
604
+ default: "inherit",
605
+ choices: [
606
+ { value: "inherit", label: "Site default" },
607
+ { value: "off", label: "None" },
608
+ { value: "row", label: "Row", hint: "Scrolls, any length" },
609
+ { value: "segmented", label: "Segmented", hint: "Pills \u2014 three or four" },
610
+ { value: "tabs", label: "Tabs", hint: "Underlined, docs-shaped" }
611
+ ]
612
+ },
613
+ {
614
+ key: "navAutoHide",
615
+ kind: "select",
616
+ label: "Navbar auto-hide",
617
+ icon: "i-lucide-eye-off",
618
+ default: "inherit",
619
+ choices: [
620
+ { value: "inherit", label: "Site default" },
621
+ { value: "on", label: "Hide on scroll" },
622
+ { value: "off", label: "Always visible" }
623
+ ]
624
+ }
625
+ ];