@kolkrabbi/kol-component 0.311.2 → 0.311.3
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 +1 -1
- package/src/utilities/AsciiCursor.jsx +23 -15
package/package.json
CHANGED
|
@@ -149,17 +149,23 @@ function Firework({ x, y, type, onDone }) {
|
|
|
149
149
|
const frames = allFrameSets[type]
|
|
150
150
|
|
|
151
151
|
useEffect(() => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
// Advance frames on a clock; report completion from an effect. `onDone` used
|
|
153
|
+
// to be called inside the setFrame updater — React runs updaters during the
|
|
154
|
+
// child's render, so the parent's setFireworks fired mid-render ("Cannot
|
|
155
|
+
// update a component (AsciiCursorOverlay) while rendering Firework") on every
|
|
156
|
+
// burst. The updater also restarted the interval on each parent re-render
|
|
157
|
+
// (onDone is a fresh closure per render), stalling the burst while the
|
|
158
|
+
// cursor moved. (kolkrabbi.io's mobile audit 2026-08-25, lost in the DS copy —
|
|
159
|
+
// AsciiCursorFireworkSetStateInRender 2026-10-29)
|
|
160
|
+
const interval = setInterval(() => setFrame((f) => Math.min(f + 1, frames.length - 1)), 130)
|
|
161
161
|
return () => clearInterval(interval)
|
|
162
|
-
}, [frames
|
|
162
|
+
}, [frames])
|
|
163
|
+
const doneRef = useRef(false)
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (doneRef.current || frame < frames.length - 1) return
|
|
166
|
+
doneRef.current = true
|
|
167
|
+
onDone()
|
|
168
|
+
}, [frame, frames, onDone])
|
|
163
169
|
|
|
164
170
|
return (
|
|
165
171
|
<div
|
|
@@ -387,8 +393,9 @@ function AsciiCrosshair({ overlayRef }) {
|
|
|
387
393
|
</div>
|
|
388
394
|
))
|
|
389
395
|
)}
|
|
390
|
-
{/* Foreground layer
|
|
391
|
-
|
|
396
|
+
{/* Foreground layer — 0.9 in light, 0.5 in dark (kolkrabbi.io's `.ascii-cursor-fg`, carried 2026-10-29): at one 0.5
|
|
397
|
+
* the glyphs washed out on light surfaces */}
|
|
398
|
+
<div className="opacity-90 [:is([data-theme=dark],.dark)_&]:opacity-50" style={{ color: 'var(--kol-surface-on-primary)', position: 'relative' }}>
|
|
392
399
|
{crosshair.map((line, i) => (
|
|
393
400
|
<div key={i}>{line}</div>
|
|
394
401
|
))}
|
|
@@ -460,7 +467,6 @@ function AsciiCursorOverlay({ hideCursor }) {
|
|
|
460
467
|
}
|
|
461
468
|
|
|
462
469
|
const handleContextMenu = (e) => {
|
|
463
|
-
e.preventDefault()
|
|
464
470
|
const now = Date.now()
|
|
465
471
|
if (now - lastInvaderTime.current < 2500) return
|
|
466
472
|
lastInvaderTime.current = now
|
|
@@ -499,8 +505,10 @@ function AsciiCursorOverlay({ hideCursor }) {
|
|
|
499
505
|
* with an ASCII crosshair (diamond variant over interactive elements) and
|
|
500
506
|
* layers ambient effects on top of the page: drifting cursor stars,
|
|
501
507
|
* click-triggered ASCII fireworks, and a right-click Space Invader that
|
|
502
|
-
* drops in, fires, and exits (rate-limited to one per 2.5s
|
|
503
|
-
*
|
|
508
|
+
* drops in, fires, and exits (rate-limited to one per 2.5s). The context menu
|
|
509
|
+
* still opens — the invader is an easter egg, the menu is the browser's
|
|
510
|
+
* (kolkrabbi.io 2026-08-25: swallowing it took copy, open-in-new-tab and
|
|
511
|
+
* inspect off every page).
|
|
504
512
|
*
|
|
505
513
|
* Singleton — mount once at the app root. Portals into `document.body` so
|
|
506
514
|
* it floats above any scroll context. Pure decoration, so it hard-gates:
|