@kolkrabbi/kol-component 0.330.0 → 0.331.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/kol-component",
3
- "version": "0.330.0",
3
+ "version": "0.331.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,8 +27,8 @@
27
27
  "pdfjs-dist": "^6.3.289",
28
28
  "react-syntax-highlighter": "^16.1.1",
29
29
  "@kolkrabbi/kol-search": "^0.3.0",
30
- "@kolkrabbi/kol-markdown": "^0.2.0",
31
- "@kolkrabbi/kol-growth": "^0.4.0"
30
+ "@kolkrabbi/kol-growth": "^0.4.0",
31
+ "@kolkrabbi/kol-markdown": "^0.2.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@kolkrabbi/kol-icons": ">=0.22.0",
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^18.3.0 || ^19.0.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@kolkrabbi/kol-icons": "^0.57.0"
42
+ "@kolkrabbi/kol-icons": "^0.60.0"
43
43
  },
44
44
  "files": [
45
45
  "src",
package/src/index.js CHANGED
@@ -206,6 +206,9 @@ export { default as FeaturedCarousel } from './organisms/FeaturedCarousel.jsx'
206
206
  export { default as FeaturesCardSection } from './organisms/FeaturesCardSection.jsx'
207
207
  /* the growing line on @kolkrabbi/kol-growth (GrowthLineStage, kol-atlas 2026-10-30) */
208
208
  export { default as GrowthLineStage } from './organisms/GrowthLineStage.jsx'
209
+ /* the app loader's runtime half and its intro claim (LoaderAppIntro, kol-fxr 2026-11-01) — here because GrowthLineStage
210
+ * claims it; kol-framework re-exports it, which stays its documented home */
211
+ export { hideLoaderApp, claimIntro, introClaimed, endIntro, releaseIntro } from './utilities/loaderApp.js'
209
212
  export { default as SectionHero, default as FullBleedHero } from './organisms/SectionHero.jsx'
210
213
  export { default as SectionSplit } from './organisms/SectionSplit.jsx'
211
214
  export { default as SectionCards } from './organisms/SectionCards.jsx'
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useRef } from 'react'
2
2
  import { Growth, densityFrom, mulberry32, orbCanvas, pathCanvas } from '@kolkrabbi/kol-growth'
3
3
  import usePrefersReducedMotion from '../hooks/usePrefersReducedMotion.js'
4
+ import { claimIntro, endIntro, hideLoaderApp, releaseIntro } from '../utilities/loaderApp.js'
4
5
 
5
6
  /* THE GROWING LINE AS A STAGE (GrowthLineStage, kol-atlas 2026-10-30) — kol-fxr's HomeStage sim loop on
6
7
  * @kolkrabbi/kol-growth: one closed line grows into `shape`, packing tighter where it is dark. One <canvas> filling its
@@ -21,9 +22,14 @@ import usePrefersReducedMotion from '../hooks/usePrefersReducedMotion.js'
21
22
  * THE INTRO (`intro`): one line from load to page. It grows on the shape's density (at `fit` 0.5) for 3.8 s, drawn only
22
23
  * through the shape in the emphasis ink; rests 4 s breathing (ink 0.7–1.0 on a 2 s period, growth off after the first
23
24
  * breath); then lets go over 4 s — the density blends shape → orb, `params` take over, every node warms, the stage's ink
24
- * fades up as the shape's fades out, and the pointer waits until it ends. `onIntroEnd` fires then.
25
+ * fades up as the shape's fades out, and the pointer waits until it ends. `onIntroEnd` fires then; `onIntroBreath` fires
26
+ * as the rest begins (HubHome fades its chrome in on it).
25
27
  *
26
- * REDUCED MOTION — no intro (`onIntroEnd` fires at once), no wave, no pointer force: the finished line is grown off
28
+ * THE LOADER IS THE LINE (LoaderAppIntro, kol-fxr 2026-11-01): on a page `loaderApp({ intro })` stamped `kol-intro`, the
29
+ * intro claims it on mount, hides the app loader (its ground only) on its first drawn frame and ends it with the intro.
30
+ * Without the stamp — another route, a SPA return, reduced motion — no loader is involved.
31
+ *
32
+ * REDUCED MOTION — no intro (`onIntroBreath` and `onIntroEnd` fire at once), no wave, no pointer force: the finished line is grown off
27
33
  * screen and drawn once.
28
34
  *
29
35
  * `shape` — 'orb' · an SVG path `d` (centred at `fit` of the box) · `(w, h) => canvas` (dark on light). */
@@ -39,7 +45,7 @@ const shapeCanvas = (shape, w, h, fit, W) => {
39
45
  return pathCanvas(shape, w / h, fit, W)
40
46
  }
41
47
 
42
- export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAMS, cap, pointer = true, seed, wave = WAVE, intro = false, onIntroEnd, className = '' }) {
48
+ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAMS, cap, pointer = true, seed, wave = WAVE, intro = false, onIntroBreath, onIntroEnd, className = '' }) {
43
49
  const ref = useRef(null)
44
50
  const reduced = usePrefersReducedMotion()
45
51
  /* the props are read at (re)start; the effect re-runs when one changes by value */
@@ -48,6 +54,8 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
48
54
  shapeRef.current = shape
49
55
  const endRef = useRef(onIntroEnd)
50
56
  endRef.current = onIntroEnd
57
+ const breathRef = useRef(onIntroBreath)
58
+ breathRef.current = onIntroBreath
51
59
 
52
60
  useEffect(() => {
53
61
  const canvas = ref.current
@@ -56,6 +64,8 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
56
64
  const drift = wave && !reduced ? wave : null
57
65
  const capOf = () => cap ?? Math.round(w * h / 90)
58
66
  let sim = null, raf = 0, w = 0, h = 0, dpr = 1, it = null, orbed = false
67
+ /* the app loader's intro: claimed on mount, handed over ('shown') on the first frame */
68
+ let claim = false
59
69
  let ptr = null, sm = null
60
70
  const force = pointer && !reduced
61
71
  const fitCanvas = () => {
@@ -77,7 +87,7 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
77
87
  it.mask = m
78
88
  it.layer = document.createElement('canvas'); it.layer.width = canvas.width; it.layer.height = canvas.height
79
89
  }
80
- const end = () => { it = null; endRef.current?.() }
90
+ const end = () => { it = null; if (claim) { claim = false; endIntro() } endRef.current?.() }
81
91
  const start = () => {
82
92
  fitCanvas()
83
93
  const src = shapeCanvas(shapeRef.current, w, h, k)
@@ -89,9 +99,10 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
89
99
  const probe = document.createElement('span'); probe.className = 'text-emphasis'; canvas.parentElement.append(probe)
90
100
  it = { t0: 0, ink: 1, out: 0, bright: getComputedStyle(probe).color, mark: sim.density, mix: null }
91
101
  probe.remove(); masks()
102
+ claim = claimIntro()
92
103
  } else {
93
104
  sim.seed()
94
- if (intro) endRef.current?.()
105
+ if (intro) { breathRef.current?.(); endRef.current?.() }
95
106
  }
96
107
  return true
97
108
  }
@@ -129,13 +140,14 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
129
140
  const frame = (now) => {
130
141
  let steps = !sim.full ? 2 : sim.hot > 0 ? 1 : 0
131
142
  if (it) {
132
- if (!it.t0) it.t0 = now
143
+ if (!it.t0) { it.t0 = now; if (claim) { claim = 'shown'; hideLoaderApp({ minMs: 0 }) } }
133
144
  const t = now - it.t0
134
145
  if (t < MARK_MS) steps = 4
135
146
  else if (t < MARK_MS + REST_MS) {
136
147
  /* it keeps filling the shape's far corners through the first breath, then holds */
137
148
  if (!it.rest && t > MARK_MS + BREATH_MS) { it.rest = true; sim.setParams({ growth: 0 }) }
138
149
  it.ink = 0.7 + 0.3 * Math.cos((2 * Math.PI * (t - MARK_MS)) / BREATH_MS)
150
+ if (!it.breath) { it.breath = true; breathRef.current?.() }
139
151
  } else {
140
152
  if (!it.free) { it.free = true; it.ink = 1; release() }
141
153
  const u = Math.min(1, (t - MARK_MS - REST_MS) / RELEASE_MS)
@@ -203,6 +215,8 @@ export default function GrowthLineStage({ shape = 'orb', fit, params = ORB_PARAM
203
215
  mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
204
216
  return () => {
205
217
  cancelAnimationFrame(raf); ro.disconnect(); mo.disconnect()
218
+ /* gone before its first frame (StrictMode's first mount reclaims at once) → the loader's fallback; gone mid-intro → ended */
219
+ if (claim === true) releaseIntro(); else if (claim) endIntro()
206
220
  if (force) {
207
221
  window.removeEventListener('pointermove', onMove)
208
222
  window.removeEventListener('pointerdown', onDown)
@@ -0,0 +1,40 @@
1
+ /**
2
+ * hideLoaderApp — the app loader's other half (`loaderApp()` in `@kolkrabbi/kol-framework/vite` writes it into
3
+ * index.html). Call it once React has committed: two frames later the loader fades (240 ms, none under reduced
4
+ * motion — the CSS drops the transition) and leaves the DOM. Safe to call when there is no loader.
5
+ *
6
+ * `minMs` (default 600, LoaderAppMinimumTime — kol-monitor, user ruling 2026-10-22) holds the loader at least
7
+ * that long from navigation start, which is when the static loader first paints: a fast load flashed the mark
8
+ * for a blink, a slow one waits nothing extra. Reduced motion drops the fade, never the minimum. `minMs: 0` is
9
+ * the old behaviour.
10
+ *
11
+ * THE INTRO (LoaderAppIntro, kol-fxr 2026-11-01 — the loader is the line): `loaderApp({ intro })` stamps `kol-intro`
12
+ * on <html> before paint and the loader shows its ground only. A stage claims it (`claimIntro()`, GrowthLineStage
13
+ * `intro`) and hides the loader on its own first frame; while it is stamped and unclaimed, `hideLoaderApp()` waits a
14
+ * beat (600 ms) and, still unclaimed, ends the intro and goes the plain way — so an app calls it exactly as before.
15
+ *
16
+ * Lives in kol-component because the stage that claims it does (ARCHITECTURE §3, no reverse deps); kol-framework
17
+ * re-exports all of it from `src/loaderApp.js`, its documented home.
18
+ */
19
+ const INTRO_CLASS = 'kol-intro'
20
+ const live = () => typeof document !== 'undefined' && document.documentElement.classList.contains(INTRO_CLASS)
21
+ let claimed = false
22
+
23
+ /* true while the intro is the caller's to play — StrictMode's second mount gets it again */
24
+ export const claimIntro = () => { if (!live()) return false; claimed = true; return true }
25
+ export const introClaimed = () => claimed
26
+ export const endIntro = () => { if (typeof document !== 'undefined') document.documentElement.classList.remove(INTRO_CLASS) }
27
+ /* a claimant that leaves before its first frame lets go — unclaimed a beat later, the plain loader goes */
28
+ export const releaseIntro = () => { claimed = false; fallback() }
29
+ const fallback = () => setTimeout(() => { if (live() && !claimed) { endIntro(); hideLoaderApp({ minMs: 0 }) } }, 600)
30
+
31
+ export function hideLoaderApp({ minMs = 600 } = {}) {
32
+ if (typeof document === 'undefined') return
33
+ if (live() && !claimed) { fallback(); return }
34
+ const el = document.getElementById('kol-loader-app')
35
+ if (!el) return
36
+ setTimeout(() => requestAnimationFrame(() => requestAnimationFrame(() => {
37
+ el.classList.add('is-done')
38
+ setTimeout(() => { el.remove(); document.getElementById('kol-loader-app-css')?.remove() }, 300)
39
+ })), Math.max(0, minMs - performance.now()))
40
+ }