@mindees/core 0.22.0 → 0.22.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"animation.d.ts","names":[],"sources":["../../src/animation/animation.ts"],"mappings":";;;;KAiBY,WAAA,IAAe,IAA6B,GAAtB,KAAA;;UAGjB,eAAA;EAQA;EANf,IAAA;;WAES,IAAA,EAAM,OAAO;AAAA;;UAIP,aAAA;EAAA;EAOX;EAJJ,GAAA,CAAI,CAAA;EAkCU;EAAA,SAhCL,QAAA;;EAET,IAAA;AAAA;AAyDF;AAAA,iBA3BgB,cAAA,CAAe,GAAuB,EAAlB,WAAW;;iBA2B/B,cAAA,IAAkB,WAAW;AAAA;AAAA,iBAqD7B,OAAA,CAAQ,OAAA,WAAkB,aAAa;;iBAyFvC,MAAA,CACd,EAAA,EAAI,aAAA,EACJ,IAAA;EAAA,SACW,EAAA;EAAA,SACA,QAAA;EAAA,SACA,MAAA,GAAS,MAAA;EAAA,SACT,KAAA;EAAA,SACA,UAAA,IAAc,QAAA;AAAA,IAExB,eAAA;;iBA+Ba,MAAA,CACd,EAAA,EAAI,aAAA,EACJ,IAAA;EAAA,SACW,EAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,QAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;EAAA,SACA,UAAA,IAAc,QAAA;AAAA,IAExB,eAAe;;;;;;iBAiDF,WAAA,CACd,KAAA,gBACA,UAAA,qBACA,WAAA,qBACA,IAAA;EAAA,SAAkB,WAAA;AAAA;;iBAgCJ,cAAA,IAAkB,WAAW;;iBAe7B,iBAAA;EAAuB,MAAA,EAAQ,WAAW;EAAE,IAAA,GAAO,KAAA;AAAA;;iBAcnD,qBAAA;;iBAKA,eAAA"}
1
+ {"version":3,"file":"animation.d.ts","names":[],"sources":["../../src/animation/animation.ts"],"mappings":";;;;KAiBY,WAAA,IAAe,IAA6B,GAAtB,KAAA;;UAGjB,eAAA;EAQA;EANf,IAAA;;WAES,IAAA,EAAM,OAAO;AAAA;;UAIP,aAAA;EAAA;EAOX;EAJJ,GAAA,CAAI,CAAA;EAkCU;EAAA,SAhCL,QAAA;;EAET,IAAA;AAAA;AAyDF;AAAA,iBA3BgB,cAAA,CAAe,GAAuB,EAAlB,WAAW;;iBA2B/B,cAAA,IAAkB,WAAW;AAAA;AAAA,iBA4D7B,OAAA,CAAQ,OAAA,WAAkB,aAAa;;iBAyFvC,MAAA,CACd,EAAA,EAAI,aAAA,EACJ,IAAA;EAAA,SACW,EAAA;EAAA,SACA,QAAA;EAAA,SACA,MAAA,GAAS,MAAA;EAAA,SACT,KAAA;EAAA,SACA,UAAA,IAAc,QAAA;AAAA,IAExB,eAAA;;iBA+Ba,MAAA,CACd,EAAA,EAAI,aAAA,EACJ,IAAA;EAAA,SACW,EAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;EAAA,SACA,QAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;EAAA,SACA,UAAA,IAAc,QAAA;AAAA,IAExB,eAAe;;;;;;iBAiDF,WAAA,CACd,KAAA,gBACA,UAAA,qBACA,WAAA,qBACA,IAAA;EAAA,SAAkB,WAAA;AAAA;;iBAgCJ,cAAA,IAAkB,WAAW;;iBAqB7B,iBAAA;EAAuB,MAAA,EAAQ,WAAW;EAAE,IAAA,GAAO,KAAA;AAAA;;iBAcnD,qBAAA;;iBAKA,eAAA"}
@@ -75,7 +75,9 @@ function onFrame(now) {
75
75
  active.delete(d);
76
76
  const st = internals.get(d.av);
77
77
  if (st) st.driver = null;
78
- d.settle(true);
78
+ try {
79
+ d.settle(true);
80
+ } catch {}
79
81
  }
80
82
  }
81
83
  });
@@ -257,8 +259,11 @@ function rafFrameSource() {
257
259
  const caf = globalThis.cancelAnimationFrame;
258
260
  if (!raf) return () => {};
259
261
  let id = raf(function loop(t) {
260
- tick(t);
261
- id = raf(loop);
262
+ try {
263
+ tick(t);
264
+ } finally {
265
+ id = raf(loop);
266
+ }
262
267
  });
263
268
  return () => caf?.(id);
264
269
  };
@@ -1 +1 @@
1
- {"version":3,"file":"animation.js","names":[],"sources":["../../src/animation/animation.ts"],"sourcesContent":["/**\n * The animation engine — RN `Animated`/Reanimated + Flutter `AnimationController` parity, built\n * entirely on the reactive core. An {@link AnimatedValue} **is a signal**, so reading it inside a\n * `style` accessor re-renders only that node (no renderer surface). One injected {@link FrameSource}\n * (mirroring `setReactiveScheduler`) drives a single loop that ticks every active driver inside one\n * `batch()` per frame — so a style reading several animated values recomputes once (glitch-free).\n *\n * With no frame source (SSR / headless / tests until one is wired) animations **jump to their final\n * value** synchronously: deterministic, never a hang, server output shows the end state.\n *\n * @module\n */\n\nimport { batch, getOwner, onCleanup, type Signal, signal, untrack } from '../reactive'\nimport { type Easing, linear } from './easing'\n\n/** A frame source: subscribe with a per-frame `tick(nowMs)`, get back an unsubscribe. (`requestAnimationFrame` on web, vsync on native, a manual ticker in tests.) */\nexport type FrameSource = (tick: (nowMs: number) => void) => () => void\n\n/** A running animation: stop it, or await natural completion. */\nexport interface AnimationHandle {\n /** Stop now (keeps the current value); `done` resolves `false`. Idempotent. */\n stop(): void\n /** Resolves `true` on natural completion, `false` if interrupted/stopped. Settles exactly once. */\n readonly done: Promise<boolean>\n}\n\n/** A reactive, animatable number. Call to read (tracks); `.set` jumps (untracked, stops any driver). */\nexport interface AnimatedValue {\n (): number\n /** Jump to `v` immediately, cancelling any running driver. */\n set(v: number): void\n /** The current per-frame velocity (units/sec) — seeds spring-interrupts-spring. */\n readonly velocity: () => number\n /** Stop any running driver, keeping the current value. */\n stop(): void\n}\n\ninterface Driver {\n readonly av: AnimatedValue\n /** Target value, used to jump-to-final if the frame source detaches mid-flight. */\n readonly target: number\n /** Advance by this frame; return `true` while still running. */\n tick(nowMs: number, dt: number): boolean\n /** Resolve the handle + fire onComplete exactly once. */\n settle(finished: boolean): void\n}\n\ninterface Internal {\n readonly signal: Signal<number>\n readonly vel: { v: number }\n driver: Driver | null\n}\n\nconst MAX_DT = 0.064 // clamp huge gaps (backgrounded tab / GC / breakpoint) so springs can't explode\nconst SPRING_MAX_FRAMES = 600 // ~10s @60fps: a non-converging spring fails safely instead of forever\nconst DEFAULT_DURATION = 250 // matches Atlas tokens.duration.standard (kept literal to avoid an atlas dep)\n\nconst internals = new WeakMap<AnimatedValue, Internal>()\nconst active = new Set<Driver>()\nlet frameSource: FrameSource | null = null\nlet unsubscribe: (() => void) | null = null\nlet lastNow = -1 // -1 = uninitialized (a real frame can arrive at now=0)\n\n/** Inject (or clear) the frame source that drives animations. `null` (default) → jump-to-final. */\nexport function setFrameSource(src: FrameSource | null): void {\n if (src === frameSource) return\n // Detach the current loop FIRST so any change — including a non-null→non-null swap — can never\n // leak the old subscription (which would keep driving) nor block resubscribing under the new one.\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n frameSource = src\n if (src === null) {\n // Detaching entirely: flush every active driver to its final value so nothing is left frozen\n // (symmetric with the start-time SSR fallback).\n batch(() => {\n for (const d of [...active]) {\n writeValue(d.av, d.target)\n active.delete(d)\n const st = internals.get(d.av)\n if (st) st.driver = null\n d.settle(true)\n }\n })\n } else if (active.size > 0) {\n ensureLoop() // resubscribe in-flight animations under the new source\n }\n}\n\n/** The current frame source, or `null`. */\nexport function getFrameSource(): FrameSource | null {\n return frameSource\n}\n\nfunction writeValue(av: AnimatedValue, v: number): void {\n untrack(() => internals.get(av)?.signal.set(v))\n}\n\nfunction maybeSleep(): void {\n if (active.size === 0 && unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n}\n\nfunction ensureLoop(): void {\n if (unsubscribe === null && frameSource !== null) {\n lastNow = -1\n unsubscribe = frameSource(onFrame)\n }\n}\n\nfunction onFrame(now: number): void {\n if (lastNow < 0) lastNow = now // first frame establishes the baseline (dt = 0, no jump)\n // Clamp to [0, MAX_DT]: never integrate backward on a non-monotonic timestamp, never explode on a\n // huge gap (backgrounded tab / GC / breakpoint).\n const dt = Math.min(Math.max(0, (now - lastNow) / 1000), MAX_DT)\n // One batch per frame: every driver's write coalesces into a single flush, so a style reading\n // multiple animated values recomputes exactly once (glitch-free).\n batch(() => {\n for (const d of [...active]) {\n // A sibling's onComplete this frame may have stopped this driver — don't tick a removed one\n // (would violate stop()'s \"keeps current value\" contract with an extra write).\n if (!active.has(d)) continue\n let running: boolean\n try {\n running = d.tick(now, dt)\n } catch {\n running = false // isolate a throwing driver (mirrors flushEffects' error isolation)\n }\n if (!running) {\n active.delete(d)\n const st = internals.get(d.av)\n if (st) st.driver = null\n d.settle(true)\n }\n }\n })\n lastNow = now\n maybeSleep()\n}\n\n/** Create an {@link AnimatedValue} (a reactive number you can drive with {@link timing}/{@link spring}). */\nexport function animate(initial: number): AnimatedValue {\n const s = signal(initial)\n const state: Internal = { signal: s, vel: { v: 0 }, driver: null }\n const av: AnimatedValue = Object.assign(() => s(), {\n set(v: number): void {\n stopDriver(av) // a manual jump cancels any running animation (RN setValue semantics)\n untrack(() => s.set(v))\n },\n velocity: () => state.vel.v,\n stop(): void {\n stopDriver(av)\n },\n })\n internals.set(av, state)\n return av\n}\n\nfunction stopDriver(av: AnimatedValue): void {\n const st = internals.get(av)\n if (st?.driver) {\n const d = st.driver\n active.delete(d)\n st.driver = null\n d.settle(false)\n maybeSleep()\n }\n}\n\n/** Options shared by drivers. */\ninterface DriverOptions {\n readonly to: number\n readonly onComplete?: (finished: boolean) => void\n}\n\n/**\n * Begin a driver on `av`: settle any prior driver (last-write-wins), capture the current value as\n * the start, and either jump-to-final (no frame source) or join the loop. Returns the handle.\n */\nfunction start(\n av: AnimatedValue,\n opts: DriverOptions,\n build: (from: number, settle: (finished: boolean) => void) => Driver['tick'],\n): AnimationHandle {\n const st = internals.get(av)\n if (!st) throw new TypeError('animation driver: value was not created with animate()')\n stopDriver(av) // last-write-wins: at most one driver per value\n\n let settled = false\n let resolveDone!: (finished: boolean) => void\n const done = new Promise<boolean>((r) => {\n resolveDone = r\n })\n const settle = (finished: boolean): void => {\n if (settled) return\n settled = true\n resolveDone(finished)\n opts.onComplete?.(finished)\n }\n\n const from = untrack(av) // start from the CURRENT rendered value (continuous retarget)\n\n // No frame source → jump to the final value synchronously (SSR / headless / not-yet-wired).\n if (frameSource === null) {\n writeValue(av, opts.to)\n settle(true)\n return { stop: () => settle(false), done }\n }\n\n const tick = build(from, settle)\n const driver: Driver = { av, target: opts.to, tick, settle }\n st.driver = driver\n active.add(driver)\n\n // Auto-stop when the owner that started the animation is disposed (unmount), so the loop never\n // writes a dead signal and never leaks a frame subscription.\n if (getOwner() !== null) {\n onCleanup(() => {\n if (st.driver === driver) stopDriver(av)\n })\n }\n\n ensureLoop()\n return {\n stop: () => stopDriver(av),\n done,\n }\n}\n\n/** Animate `av` to `to` over `duration` ms with `easing` (RN `Animated.timing`). */\nexport function timing(\n av: AnimatedValue,\n opts: {\n readonly to: number\n readonly duration?: number\n readonly easing?: Easing\n readonly delay?: number\n readonly onComplete?: (finished: boolean) => void\n },\n): AnimationHandle {\n // Sanitize: `??` only catches null/undefined, so a NaN/Infinity duration would write NaN forever\n // (permanent under Object.is) — fall back to the default for any non-finite duration.\n const duration = Number.isFinite(opts.duration) ? (opts.duration as number) : DEFAULT_DURATION\n const easing = opts.easing ?? linear\n const delay = Number.isFinite(opts.delay) ? (opts.delay as number) : 0\n return start(av, opts, (from, _settle) => {\n let startTime = -1 // -1 = uninitialized (a real frame can arrive at now=0)\n let prev = from\n const settleAt = (): boolean => {\n internals.get(av)!.vel.v = 0 // at rest: velocity is 0 (so a following spring doesn't inherit phantom momentum)\n writeValue(av, opts.to)\n return false\n }\n return (now, dt) => {\n if (startTime < 0) startTime = now\n const elapsed = now - startTime - delay\n if (elapsed < 0) return true // still in the delay window\n const t = duration <= 0 ? 1 : Math.min(elapsed / duration, 1)\n const next = from + (opts.to - from) * easing(t)\n if (!Number.isFinite(next)) return settleAt() // defensive: never write NaN/Infinity\n if (dt > 0) internals.get(av)!.vel.v = (next - prev) / dt\n prev = next\n if (t >= 1) return settleAt()\n writeValue(av, next)\n return true\n }\n })\n}\n\n/** Animate `av` to `to` with spring physics (RN/Reanimated `withSpring`, Flutter `SpringSimulation`). */\nexport function spring(\n av: AnimatedValue,\n opts: {\n readonly to: number\n readonly stiffness?: number\n readonly damping?: number\n readonly mass?: number\n readonly velocity?: number\n readonly restDelta?: number\n readonly restVelocity?: number\n readonly onComplete?: (finished: boolean) => void\n },\n): AnimationHandle {\n const stiffness = Math.max(0, opts.stiffness ?? 170)\n const damping = Math.max(0, opts.damping ?? 26)\n const mass = Math.max(1e-4, opts.mass ?? 1)\n const restDelta = opts.restDelta ?? 0.01\n const restVelocity = opts.restVelocity ?? 0.01\n const omega = Math.sqrt(stiffness / mass) // natural frequency, for substep stability\n return start(av, opts, (from) => {\n let x = from\n let v = opts.velocity ?? internals.get(av)!.vel.v\n let frames = 0\n return (_now, dt) => {\n frames++\n // Semi-implicit (symplectic) Euler is only conditionally stable (omega·dt < ~2). Stiffness is\n // user-controlled, so SUBSTEP the frame's dt to keep each step well inside the stable region —\n // a stiff spring stays finite instead of diverging to Infinity/NaN.\n const steps = Math.max(1, Math.ceil((dt * omega) / 1.5))\n const sub = dt / steps\n for (let i = 0; i < steps; i++) {\n const a = (-stiffness * (x - opts.to) - damping * v) / mass\n v += a * sub\n x += v * sub\n }\n if (!Number.isFinite(x)) {\n // Defensive: never write NaN/Infinity (permanent under Object.is) — snap to the target.\n internals.get(av)!.vel.v = 0\n writeValue(av, opts.to)\n return false\n }\n internals.get(av)!.vel.v = v\n if (\n (Math.abs(x - opts.to) < restDelta && Math.abs(v) < restVelocity) ||\n frames > SPRING_MAX_FRAMES\n ) {\n internals.get(av)!.vel.v = 0\n writeValue(av, opts.to)\n return false\n }\n writeValue(av, x)\n return true\n }\n })\n}\n\n/**\n * Map an accessor through a piecewise-linear range (RN `Animated.interpolate`). Returns a plain\n * accessor, so it tracks `value` and re-reads inside the consuming style each frame — glitch-free\n * for free. `inputRange` must be monotonically increasing and match `outputRange` length (≥2).\n */\nexport function interpolate(\n value: () => number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n opts?: { readonly extrapolate?: 'clamp' | 'extend' },\n): () => number {\n if (inputRange.length !== outputRange.length || inputRange.length < 2) {\n throw new RangeError('interpolate: inputRange and outputRange must be the same length (>= 2)')\n }\n const extrapolate = opts?.extrapolate ?? 'clamp'\n const n = inputRange.length\n return () => {\n const x = value()\n if (Number.isNaN(x)) return outputRange[0] as number // a NaN source maps to the first output, not the last\n const lerp = (i: number): number => {\n const x0 = inputRange[i] as number\n const x1 = inputRange[i + 1] as number\n const y0 = outputRange[i] as number\n const y1 = outputRange[i + 1] as number\n if (x1 === x0) return y0 // zero-width segment → avoid divide-by-zero\n return y0 + ((y1 - y0) * (x - x0)) / (x1 - x0)\n }\n if (x <= (inputRange[0] as number)) {\n return extrapolate === 'extend' ? lerp(0) : (outputRange[0] as number)\n }\n if (x >= (inputRange[n - 1] as number)) {\n return extrapolate === 'extend' ? lerp(n - 2) : (outputRange[n - 1] as number)\n }\n for (let i = 0; i < n - 1; i++) {\n if (x >= (inputRange[i] as number) && x <= (inputRange[i + 1] as number)) return lerp(i)\n }\n return outputRange[n - 1] as number // unreachable for monotonic input\n }\n}\n\n/** A `requestAnimationFrame`-backed {@link FrameSource} for the web (the host wires this at startup). */\nexport function rafFrameSource(): FrameSource {\n return (tick) => {\n const raf = (globalThis as { requestAnimationFrame?: (cb: (t: number) => void) => number })\n .requestAnimationFrame\n const caf = (globalThis as { cancelAnimationFrame?: (id: number) => void }).cancelAnimationFrame\n if (!raf) return () => {} // no rAF (non-browser) → caller already degrades to jump-to-final\n let id = raf(function loop(t: number) {\n tick(t)\n id = raf(loop)\n })\n return () => caf?.(id)\n }\n}\n\n/** A manually-driven {@link FrameSource} for deterministic tests: call `tick(nowMs)` to advance. */\nexport function manualFrameSource(): { source: FrameSource; tick: (nowMs: number) => void } {\n let cb: ((nowMs: number) => void) | null = null\n return {\n source: (t) => {\n cb = t\n return () => {\n cb = null\n }\n },\n tick: (nowMs) => cb?.(nowMs),\n }\n}\n\n/** @internal Test-only: number of running animations. */\nexport function _activeAnimationCount(): number {\n return active.size\n}\n\n/** @internal Test-only: reset all engine state between tests. */\nexport function _resetAnimation(): void {\n if (unsubscribe) unsubscribe()\n unsubscribe = null\n active.clear()\n frameSource = null\n lastNow = -1\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAM,SAAS;AACf,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AAEzB,MAAM,4BAAY,IAAI,QAAiC;AACvD,MAAM,yBAAS,IAAI,IAAY;AAC/B,IAAI,cAAkC;AACtC,IAAI,cAAmC;AACvC,IAAI,UAAU;;AAGd,SAAgB,eAAe,KAA+B;CAC5D,IAAI,QAAQ,aAAa;CAGzB,IAAI,aAAa;EACf,YAAY;EACZ,cAAc;CAChB;CACA,cAAc;CACd,IAAI,QAAQ,MAGV,YAAY;EACV,KAAK,MAAM,KAAK,CAAC,GAAG,MAAM,GAAG;GAC3B,WAAW,EAAE,IAAI,EAAE,MAAM;GACzB,OAAO,OAAO,CAAC;GACf,MAAM,KAAK,UAAU,IAAI,EAAE,EAAE;GAC7B,IAAI,IAAI,GAAG,SAAS;GACpB,EAAE,OAAO,IAAI;EACf;CACF,CAAC;MACI,IAAI,OAAO,OAAO,GACvB,WAAW;AAEf;;AAGA,SAAgB,iBAAqC;CACnD,OAAO;AACT;AAEA,SAAS,WAAW,IAAmB,GAAiB;CACtD,cAAc,UAAU,IAAI,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC;AAChD;AAEA,SAAS,aAAmB;CAC1B,IAAI,OAAO,SAAS,KAAK,aAAa;EACpC,YAAY;EACZ,cAAc;CAChB;AACF;AAEA,SAAS,aAAmB;CAC1B,IAAI,gBAAgB,QAAQ,gBAAgB,MAAM;EAChD,UAAU;EACV,cAAc,YAAY,OAAO;CACnC;AACF;AAEA,SAAS,QAAQ,KAA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B,oBAA4E;CAC1F,IAAI,KAAuC;CAC3C,OAAO;EACL,SAAS,MAAM;GACb,KAAK;GACL,aAAa;IACX,KAAK;GACP;EACF;EACA,OAAO,UAAU,KAAK,KAAK;CAC7B;AACF;;AAGA,SAAgB,wBAAgC;CAC9C,OAAO,OAAO;AAChB;;AAGA,SAAgB,kBAAwB;CACtC,IAAI,aAAa,YAAY;CAC7B,cAAc;CACd,OAAO,MAAM;CACb,cAAc;CACd,UAAU;AACZ"}
1
+ {"version":3,"file":"animation.js","names":[],"sources":["../../src/animation/animation.ts"],"sourcesContent":["/**\n * The animation engine — RN `Animated`/Reanimated + Flutter `AnimationController` parity, built\n * entirely on the reactive core. An {@link AnimatedValue} **is a signal**, so reading it inside a\n * `style` accessor re-renders only that node (no renderer surface). One injected {@link FrameSource}\n * (mirroring `setReactiveScheduler`) drives a single loop that ticks every active driver inside one\n * `batch()` per frame — so a style reading several animated values recomputes once (glitch-free).\n *\n * With no frame source (SSR / headless / tests until one is wired) animations **jump to their final\n * value** synchronously: deterministic, never a hang, server output shows the end state.\n *\n * @module\n */\n\nimport { batch, getOwner, onCleanup, type Signal, signal, untrack } from '../reactive'\nimport { type Easing, linear } from './easing'\n\n/** A frame source: subscribe with a per-frame `tick(nowMs)`, get back an unsubscribe. (`requestAnimationFrame` on web, vsync on native, a manual ticker in tests.) */\nexport type FrameSource = (tick: (nowMs: number) => void) => () => void\n\n/** A running animation: stop it, or await natural completion. */\nexport interface AnimationHandle {\n /** Stop now (keeps the current value); `done` resolves `false`. Idempotent. */\n stop(): void\n /** Resolves `true` on natural completion, `false` if interrupted/stopped. Settles exactly once. */\n readonly done: Promise<boolean>\n}\n\n/** A reactive, animatable number. Call to read (tracks); `.set` jumps (untracked, stops any driver). */\nexport interface AnimatedValue {\n (): number\n /** Jump to `v` immediately, cancelling any running driver. */\n set(v: number): void\n /** The current per-frame velocity (units/sec) — seeds spring-interrupts-spring. */\n readonly velocity: () => number\n /** Stop any running driver, keeping the current value. */\n stop(): void\n}\n\ninterface Driver {\n readonly av: AnimatedValue\n /** Target value, used to jump-to-final if the frame source detaches mid-flight. */\n readonly target: number\n /** Advance by this frame; return `true` while still running. */\n tick(nowMs: number, dt: number): boolean\n /** Resolve the handle + fire onComplete exactly once. */\n settle(finished: boolean): void\n}\n\ninterface Internal {\n readonly signal: Signal<number>\n readonly vel: { v: number }\n driver: Driver | null\n}\n\nconst MAX_DT = 0.064 // clamp huge gaps (backgrounded tab / GC / breakpoint) so springs can't explode\nconst SPRING_MAX_FRAMES = 600 // ~10s @60fps: a non-converging spring fails safely instead of forever\nconst DEFAULT_DURATION = 250 // matches Atlas tokens.duration.standard (kept literal to avoid an atlas dep)\n\nconst internals = new WeakMap<AnimatedValue, Internal>()\nconst active = new Set<Driver>()\nlet frameSource: FrameSource | null = null\nlet unsubscribe: (() => void) | null = null\nlet lastNow = -1 // -1 = uninitialized (a real frame can arrive at now=0)\n\n/** Inject (or clear) the frame source that drives animations. `null` (default) → jump-to-final. */\nexport function setFrameSource(src: FrameSource | null): void {\n if (src === frameSource) return\n // Detach the current loop FIRST so any change — including a non-null→non-null swap — can never\n // leak the old subscription (which would keep driving) nor block resubscribing under the new one.\n if (unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n frameSource = src\n if (src === null) {\n // Detaching entirely: flush every active driver to its final value so nothing is left frozen\n // (symmetric with the start-time SSR fallback).\n batch(() => {\n for (const d of [...active]) {\n writeValue(d.av, d.target)\n active.delete(d)\n const st = internals.get(d.av)\n if (st) st.driver = null\n d.settle(true)\n }\n })\n } else if (active.size > 0) {\n ensureLoop() // resubscribe in-flight animations under the new source\n }\n}\n\n/** The current frame source, or `null`. */\nexport function getFrameSource(): FrameSource | null {\n return frameSource\n}\n\nfunction writeValue(av: AnimatedValue, v: number): void {\n untrack(() => internals.get(av)?.signal.set(v))\n}\n\nfunction maybeSleep(): void {\n if (active.size === 0 && unsubscribe) {\n unsubscribe()\n unsubscribe = null\n }\n}\n\nfunction ensureLoop(): void {\n if (unsubscribe === null && frameSource !== null) {\n lastNow = -1\n unsubscribe = frameSource(onFrame)\n }\n}\n\nfunction onFrame(now: number): void {\n if (lastNow < 0) lastNow = now // first frame establishes the baseline (dt = 0, no jump)\n // Clamp to [0, MAX_DT]: never integrate backward on a non-monotonic timestamp, never explode on a\n // huge gap (backgrounded tab / GC / breakpoint).\n const dt = Math.min(Math.max(0, (now - lastNow) / 1000), MAX_DT)\n // One batch per frame: every driver's write coalesces into a single flush, so a style reading\n // multiple animated values recomputes exactly once (glitch-free).\n batch(() => {\n for (const d of [...active]) {\n // A sibling's onComplete this frame may have stopped this driver — don't tick a removed one\n // (would violate stop()'s \"keeps current value\" contract with an extra write).\n if (!active.has(d)) continue\n let running: boolean\n try {\n running = d.tick(now, dt)\n } catch {\n running = false // isolate a throwing driver (mirrors flushEffects' error isolation)\n }\n if (!running) {\n active.delete(d)\n const st = internals.get(d.av)\n if (st) st.driver = null\n // Isolate a throwing onComplete: settle() invokes the user's onComplete, and this runs on the\n // SHARED frame loop — one bad callback must not propagate out and leave the rAF chain un-rearmed\n // (which would freeze EVERY animation in the app).\n try {\n d.settle(true)\n } catch {\n // swallow: a faulty completion callback can't be allowed to kill the loop\n }\n }\n }\n })\n lastNow = now\n maybeSleep()\n}\n\n/** Create an {@link AnimatedValue} (a reactive number you can drive with {@link timing}/{@link spring}). */\nexport function animate(initial: number): AnimatedValue {\n const s = signal(initial)\n const state: Internal = { signal: s, vel: { v: 0 }, driver: null }\n const av: AnimatedValue = Object.assign(() => s(), {\n set(v: number): void {\n stopDriver(av) // a manual jump cancels any running animation (RN setValue semantics)\n untrack(() => s.set(v))\n },\n velocity: () => state.vel.v,\n stop(): void {\n stopDriver(av)\n },\n })\n internals.set(av, state)\n return av\n}\n\nfunction stopDriver(av: AnimatedValue): void {\n const st = internals.get(av)\n if (st?.driver) {\n const d = st.driver\n active.delete(d)\n st.driver = null\n d.settle(false)\n maybeSleep()\n }\n}\n\n/** Options shared by drivers. */\ninterface DriverOptions {\n readonly to: number\n readonly onComplete?: (finished: boolean) => void\n}\n\n/**\n * Begin a driver on `av`: settle any prior driver (last-write-wins), capture the current value as\n * the start, and either jump-to-final (no frame source) or join the loop. Returns the handle.\n */\nfunction start(\n av: AnimatedValue,\n opts: DriverOptions,\n build: (from: number, settle: (finished: boolean) => void) => Driver['tick'],\n): AnimationHandle {\n const st = internals.get(av)\n if (!st) throw new TypeError('animation driver: value was not created with animate()')\n stopDriver(av) // last-write-wins: at most one driver per value\n\n let settled = false\n let resolveDone!: (finished: boolean) => void\n const done = new Promise<boolean>((r) => {\n resolveDone = r\n })\n const settle = (finished: boolean): void => {\n if (settled) return\n settled = true\n resolveDone(finished)\n opts.onComplete?.(finished)\n }\n\n const from = untrack(av) // start from the CURRENT rendered value (continuous retarget)\n\n // No frame source → jump to the final value synchronously (SSR / headless / not-yet-wired).\n if (frameSource === null) {\n writeValue(av, opts.to)\n settle(true)\n return { stop: () => settle(false), done }\n }\n\n const tick = build(from, settle)\n const driver: Driver = { av, target: opts.to, tick, settle }\n st.driver = driver\n active.add(driver)\n\n // Auto-stop when the owner that started the animation is disposed (unmount), so the loop never\n // writes a dead signal and never leaks a frame subscription.\n if (getOwner() !== null) {\n onCleanup(() => {\n if (st.driver === driver) stopDriver(av)\n })\n }\n\n ensureLoop()\n return {\n stop: () => stopDriver(av),\n done,\n }\n}\n\n/** Animate `av` to `to` over `duration` ms with `easing` (RN `Animated.timing`). */\nexport function timing(\n av: AnimatedValue,\n opts: {\n readonly to: number\n readonly duration?: number\n readonly easing?: Easing\n readonly delay?: number\n readonly onComplete?: (finished: boolean) => void\n },\n): AnimationHandle {\n // Sanitize: `??` only catches null/undefined, so a NaN/Infinity duration would write NaN forever\n // (permanent under Object.is) — fall back to the default for any non-finite duration.\n const duration = Number.isFinite(opts.duration) ? (opts.duration as number) : DEFAULT_DURATION\n const easing = opts.easing ?? linear\n const delay = Number.isFinite(opts.delay) ? (opts.delay as number) : 0\n return start(av, opts, (from, _settle) => {\n let startTime = -1 // -1 = uninitialized (a real frame can arrive at now=0)\n let prev = from\n const settleAt = (): boolean => {\n internals.get(av)!.vel.v = 0 // at rest: velocity is 0 (so a following spring doesn't inherit phantom momentum)\n writeValue(av, opts.to)\n return false\n }\n return (now, dt) => {\n if (startTime < 0) startTime = now\n const elapsed = now - startTime - delay\n if (elapsed < 0) return true // still in the delay window\n const t = duration <= 0 ? 1 : Math.min(elapsed / duration, 1)\n const next = from + (opts.to - from) * easing(t)\n if (!Number.isFinite(next)) return settleAt() // defensive: never write NaN/Infinity\n if (dt > 0) internals.get(av)!.vel.v = (next - prev) / dt\n prev = next\n if (t >= 1) return settleAt()\n writeValue(av, next)\n return true\n }\n })\n}\n\n/** Animate `av` to `to` with spring physics (RN/Reanimated `withSpring`, Flutter `SpringSimulation`). */\nexport function spring(\n av: AnimatedValue,\n opts: {\n readonly to: number\n readonly stiffness?: number\n readonly damping?: number\n readonly mass?: number\n readonly velocity?: number\n readonly restDelta?: number\n readonly restVelocity?: number\n readonly onComplete?: (finished: boolean) => void\n },\n): AnimationHandle {\n const stiffness = Math.max(0, opts.stiffness ?? 170)\n const damping = Math.max(0, opts.damping ?? 26)\n const mass = Math.max(1e-4, opts.mass ?? 1)\n const restDelta = opts.restDelta ?? 0.01\n const restVelocity = opts.restVelocity ?? 0.01\n const omega = Math.sqrt(stiffness / mass) // natural frequency, for substep stability\n return start(av, opts, (from) => {\n let x = from\n let v = opts.velocity ?? internals.get(av)!.vel.v\n let frames = 0\n return (_now, dt) => {\n frames++\n // Semi-implicit (symplectic) Euler is only conditionally stable (omega·dt < ~2). Stiffness is\n // user-controlled, so SUBSTEP the frame's dt to keep each step well inside the stable region —\n // a stiff spring stays finite instead of diverging to Infinity/NaN.\n const steps = Math.max(1, Math.ceil((dt * omega) / 1.5))\n const sub = dt / steps\n for (let i = 0; i < steps; i++) {\n const a = (-stiffness * (x - opts.to) - damping * v) / mass\n v += a * sub\n x += v * sub\n }\n if (!Number.isFinite(x)) {\n // Defensive: never write NaN/Infinity (permanent under Object.is) — snap to the target.\n internals.get(av)!.vel.v = 0\n writeValue(av, opts.to)\n return false\n }\n internals.get(av)!.vel.v = v\n if (\n (Math.abs(x - opts.to) < restDelta && Math.abs(v) < restVelocity) ||\n frames > SPRING_MAX_FRAMES\n ) {\n internals.get(av)!.vel.v = 0\n writeValue(av, opts.to)\n return false\n }\n writeValue(av, x)\n return true\n }\n })\n}\n\n/**\n * Map an accessor through a piecewise-linear range (RN `Animated.interpolate`). Returns a plain\n * accessor, so it tracks `value` and re-reads inside the consuming style each frame — glitch-free\n * for free. `inputRange` must be monotonically increasing and match `outputRange` length (≥2).\n */\nexport function interpolate(\n value: () => number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n opts?: { readonly extrapolate?: 'clamp' | 'extend' },\n): () => number {\n if (inputRange.length !== outputRange.length || inputRange.length < 2) {\n throw new RangeError('interpolate: inputRange and outputRange must be the same length (>= 2)')\n }\n const extrapolate = opts?.extrapolate ?? 'clamp'\n const n = inputRange.length\n return () => {\n const x = value()\n if (Number.isNaN(x)) return outputRange[0] as number // a NaN source maps to the first output, not the last\n const lerp = (i: number): number => {\n const x0 = inputRange[i] as number\n const x1 = inputRange[i + 1] as number\n const y0 = outputRange[i] as number\n const y1 = outputRange[i + 1] as number\n if (x1 === x0) return y0 // zero-width segment → avoid divide-by-zero\n return y0 + ((y1 - y0) * (x - x0)) / (x1 - x0)\n }\n if (x <= (inputRange[0] as number)) {\n return extrapolate === 'extend' ? lerp(0) : (outputRange[0] as number)\n }\n if (x >= (inputRange[n - 1] as number)) {\n return extrapolate === 'extend' ? lerp(n - 2) : (outputRange[n - 1] as number)\n }\n for (let i = 0; i < n - 1; i++) {\n if (x >= (inputRange[i] as number) && x <= (inputRange[i + 1] as number)) return lerp(i)\n }\n return outputRange[n - 1] as number // unreachable for monotonic input\n }\n}\n\n/** A `requestAnimationFrame`-backed {@link FrameSource} for the web (the host wires this at startup). */\nexport function rafFrameSource(): FrameSource {\n return (tick) => {\n const raf = (globalThis as { requestAnimationFrame?: (cb: (t: number) => void) => number })\n .requestAnimationFrame\n const caf = (globalThis as { cancelAnimationFrame?: (id: number) => void }).cancelAnimationFrame\n if (!raf) return () => {} // no rAF (non-browser) → caller already degrades to jump-to-final\n let id = raf(function loop(t: number) {\n // Always re-arm the chain, even if `tick` throws — a single bad frame must never permanently\n // freeze the shared loop. (onFrame already isolates driver ticks + completion callbacks; this is\n // belt-and-suspenders for any other thrown error.)\n try {\n tick(t)\n } finally {\n id = raf(loop)\n }\n })\n return () => caf?.(id)\n }\n}\n\n/** A manually-driven {@link FrameSource} for deterministic tests: call `tick(nowMs)` to advance. */\nexport function manualFrameSource(): { source: FrameSource; tick: (nowMs: number) => void } {\n let cb: ((nowMs: number) => void) | null = null\n return {\n source: (t) => {\n cb = t\n return () => {\n cb = null\n }\n },\n tick: (nowMs) => cb?.(nowMs),\n }\n}\n\n/** @internal Test-only: number of running animations. */\nexport function _activeAnimationCount(): number {\n return active.size\n}\n\n/** @internal Test-only: reset all engine state between tests. */\nexport function _resetAnimation(): void {\n if (unsubscribe) unsubscribe()\n unsubscribe = null\n active.clear()\n frameSource = null\n lastNow = -1\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsDA,MAAM,SAAS;AACf,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AAEzB,MAAM,4BAAY,IAAI,QAAiC;AACvD,MAAM,yBAAS,IAAI,IAAY;AAC/B,IAAI,cAAkC;AACtC,IAAI,cAAmC;AACvC,IAAI,UAAU;;AAGd,SAAgB,eAAe,KAA+B;CAC5D,IAAI,QAAQ,aAAa;CAGzB,IAAI,aAAa;EACf,YAAY;EACZ,cAAc;CAChB;CACA,cAAc;CACd,IAAI,QAAQ,MAGV,YAAY;EACV,KAAK,MAAM,KAAK,CAAC,GAAG,MAAM,GAAG;GAC3B,WAAW,EAAE,IAAI,EAAE,MAAM;GACzB,OAAO,OAAO,CAAC;GACf,MAAM,KAAK,UAAU,IAAI,EAAE,EA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AAA,EAC3B,KAAA,IAAS,MAAA,oBAA0B,YAAA,aAChC,QAAA,EAAU,WAAA,KACZ,cAAA;;iBAuBa,SAAA,CAAU,KAAA,YAAiB,KAAA,IAAS,cAAc;;KAatD,cAAA,OAAqB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC;;UAG1B,OAAA;EA/HS;EAAA,SAiIf,EAAA;EA/HA;EAAA,SAiIA,YAAA,EAAc,CAAC;AAAA;;;;;UAOT,eAAA;EAtIU;EAwIzB,GAAA,CAAI,KAAA,EAAO,CAAA;EAtIe;EAwI1B,IAAA,IAAQ,CAAA;EAxI6B;AAIvC;;;;EA0IE,MAAA,IAAU,QAAA,GAAW,KAAA,EAAO,CAAA,KAAM,CAAA,EAAG,MAAA,GAAS,cAAA,CAAe,CAAA,UAAW,CAAA;AAAA;;iBAI1D,aAAA,IAAiB,YAAA,EAAc,CAAA,GAAI,OAAA,CAAQ,CAAA;;;;;;;;;AA9IkB;AAa7E;iBA+IgB,cAAA,IAAkB,OAAA,EAAS,OAAA,CAAQ,CAAA,GAAI,OAAA,GAAU,CAAA,GAAI,eAAA,CAAgB,CAAA;;;;;;;AA/IlB;AASnE;;iBAkKgB,eAAA,IACd,SAAA,EAAW,SAAA,CAAU,CAAA,GACrB,KAAA,EAAO,CAAA;EACJ,IAAA,EAAM,WAAA;EAAa,OAAA;AAAA;;iBAqBR,QAAA"}
@@ -63,7 +63,7 @@ function isPortal(value) {
63
63
  */
64
64
  function createElement(type, props, ...children) {
65
65
  const { key = null, children: propsChildren, ...rest } = props ?? {};
66
- const resolved = children.length > 0 ? children : propsChildren !== void 0 ? [propsChildren] : [];
66
+ const resolved = children.length > 0 ? children : propsChildren === void 0 ? [] : Array.isArray(propsChildren) ? propsChildren : [propsChildren];
67
67
  return {
68
68
  $$typeof: ELEMENT_TYPE,
69
69
  type,
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","names":[],"sources":["../../src/component/component.ts"],"sourcesContent":["/**\n * MindeesNative component model — a minimal, renderer-agnostic element tree plus\n * **selector-based, re-render-isolated context**.\n *\n * The element tree (`createElement` / `Fragment`) is a plain data structure: a\n * component is a function of `props` returning elements. It carries no rendering\n * logic itself — the Helix renderer (Phase 3) turns this tree into host nodes.\n *\n * The context system is the important primitive: a `createContext` value is read\n * through a **selector**, and a consumer only re-runs when its *selected slice*\n * actually changes — not on every context update. This is the re-render\n * isolation the Quantum Router (Phase 6) builds on. It is implemented on the\n * Phase 1 signals, so selection participates in normal reactivity.\n *\n * @module\n */\n\nimport { computed, createRoot, getOwner, signal } from '../reactive'\n\n// ---------------------------------------------------------------------------\n// Element tree\n// ---------------------------------------------------------------------------\n\n/** A component: a function from props to a renderable node. */\nexport type Component<P = Record<string, unknown>> = (props: P) => MindeesNode\n\n/**\n * Anything that can appear in the tree.\n *\n * Includes an **accessor** form `() => MindeesNode`: a function child (or\n * function prop value) is a *reactive region* — the renderer subscribes to it\n * and patches exactly that region when its signals change (the fine-grained\n * update model, à la SolidJS). Static trees never need it; reactive UIs do.\n */\nexport type MindeesNode =\n | MindeesElement\n // A node may hold a keyed region of ANY item type. KeyedRegion is invariant in T (its\n // mapFn/key take T), so `KeyedRegion<unknown>` would reject `KeyedRegion<Row>`; `any` is\n // the correct \"some item type\" here.\n // biome-ignore lint/suspicious/noExplicitAny: see above — invariant T at a node boundary.\n | KeyedRegion<any>\n | PortalRegion\n | string\n | number\n | boolean\n | null\n | undefined\n | (() => MindeesNode)\n | MindeesNode[]\n\n/** The tag of an element: a host string (e.g. `\"view\"`) or a component function. */\nexport type ElementType = string | Component<never>\n\n/** A virtual element: a tag, its props, and its children. */\nexport interface MindeesElement {\n readonly $$typeof: typeof ELEMENT_TYPE\n readonly type: ElementType\n readonly props: Readonly<Record<string, unknown>>\n readonly children: readonly MindeesNode[]\n readonly key: string | number | null\n}\n\n/** Brand so a renderer can reliably distinguish elements from plain objects. */\nexport const ELEMENT_TYPE: unique symbol = Symbol.for('mindees.element')\n\n/** Marker tag for a fragment (children with no wrapper host node). */\nexport const Fragment: unique symbol = Symbol.for('mindees.fragment')\n\n/** Brand identifying a keyed list region (reconciled by key, not full-rebuilt). */\nexport const KEYED_REGION: unique symbol = Symbol.for('mindees.keyed-region')\n\n/**\n * A keyed list region: a reactive item list + a per-item render function, reconciled by key\n * so rows keep their identity (host node, focus, caret, scroll) across reorders instead of\n * being torn down and rebuilt. This is a serializable *description* (no rendering logic); the\n * renderer materializes it (`bindKeyedChild`). Build one with {@link keyedRegion}.\n */\nexport interface KeyedRegion<T = unknown> {\n readonly $$keyed: typeof KEYED_REGION\n /** The items, as a reactive accessor. */\n readonly each: () => readonly T[]\n /** Render one row from reactive `item`/`index` accessors (consume them lazily to patch in place). */\n readonly mapFn: (item: () => T, index: () => number) => MindeesNode\n /** Stable key per item (when omitted, the row is keyed by item identity). */\n readonly key: ((item: T, index: number) => unknown) | undefined\n /** Rendered when the list is empty. */\n readonly fallback: (() => MindeesNode) | undefined\n}\n\n/** Options for {@link keyedRegion}. */\nexport interface KeyedRegionOptions<T> {\n /** The items, static or reactive. */\n readonly each: readonly T[] | (() => readonly T[])\n /** Render one row from reactive `item`/`index` accessors. */\n readonly children: (item: () => T, index: () => number) => MindeesNode\n /** Stable key per item (defaults to item identity). */\n readonly key?: (item: T, index: number) => unknown\n /** Rendered when the list is empty. */\n readonly fallback?: () => MindeesNode\n}\n\n/** Build a {@link KeyedRegion} — a keyed, identity-preserving list node. */\nexport function keyedRegion<T>(options: KeyedRegionOptions<T>): KeyedRegion<T> {\n const each: () => readonly T[] =\n typeof options.each === 'function' ? options.each : () => options.each as readonly T[]\n return {\n $$keyed: KEYED_REGION,\n each,\n mapFn: options.children,\n key: options.key,\n fallback: options.fallback,\n }\n}\n\n/** Type guard: is `value` a {@link KeyedRegion}? */\nexport function isKeyedRegion(value: unknown): value is KeyedRegion {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$keyed?: unknown }).$$keyed === KEYED_REGION\n )\n}\n\n/** Brand identifying a portal region (children relocated to an overlay target above the tree). */\nexport const PORTAL: unique symbol = Symbol.for('mindees.portal')\n\n/**\n * A portal: its children render into a different host parent (an overlay/root layer) than their\n * position in the tree, while staying owned by the logical owner so reactive disposal + unmount\n * still work. The renderer materializes it (`bindPortalChild`); build one with {@link portal}.\n */\nexport interface PortalRegion {\n readonly $$portal: typeof PORTAL\n /** Children to relocate, normalized to a (reactive) accessor. */\n readonly children: () => MindeesNode\n /** Optional explicit host target (an `N`); else the backend's overlay root; else the local parent. Opaque to core. */\n readonly mount: unknown\n}\n\n/**\n * Build a {@link PortalRegion} — relocate `children` to an overlay target. Pass `opts.mount` to\n * override the target host node; otherwise the renderer uses the backend's overlay root (or, with\n * no overlay, mounts in place — the SSR-correct default).\n */\nexport function portal(\n children: MindeesNode | (() => MindeesNode),\n opts?: { readonly mount?: unknown },\n): PortalRegion {\n return {\n $$portal: PORTAL,\n children: typeof children === 'function' ? (children as () => MindeesNode) : () => children,\n mount: opts?.mount,\n }\n}\n\n/** Type guard: is `value` a {@link PortalRegion}? */\nexport function isPortal(value: unknown): value is PortalRegion {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$portal?: unknown }).$$portal === PORTAL\n )\n}\n\ninterface PropsWithKey {\n key?: string | number | null\n children?: MindeesNode\n}\n\n/**\n * Create a virtual element. `type` is a host-component string or a component\n * function; `Fragment` groups children without a wrapper.\n *\n * @example\n * createElement('view', { id: 'root' }, createElement('text', null, 'hi'))\n */\nexport function createElement(\n type: ElementType | typeof Fragment,\n props?: (Record<string, unknown> & PropsWithKey) | null,\n ...children: MindeesNode[]\n): MindeesElement {\n const { key = null, children: propsChildren, ...rest } = props ?? {}\n // Children passed as args win over a `children` prop; otherwise fall back to it.\n const resolved: MindeesNode[] =\n children.length > 0 ? children : propsChildren !== undefined ? [propsChildren] : []\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as ElementType,\n props: Object.freeze({ ...rest }),\n children: Object.freeze(resolved),\n key,\n }\n}\n\n/** Type guard: is `value` a MindeesElement? */\nexport function isElement(value: unknown): value is MindeesElement {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === ELEMENT_TYPE\n )\n}\n\n// ---------------------------------------------------------------------------\n// Selector-based, re-render-isolated context\n// ---------------------------------------------------------------------------\n\n/** Equality used by context selectors. Defaults to `Object.is`. */\nexport type SelectorEquals<S> = (a: S, b: S) => boolean\n\n/** A context handle created by {@link createContext}. */\nexport interface Context<T> {\n /** Provide a value to a subtree (conceptually); returns a scoped reader set. */\n readonly id: symbol\n /** The default value used when no provider is present. */\n readonly defaultValue: T\n}\n\n/**\n * A live provider instance: holds the current value and lets consumers subscribe\n * to a derived slice with re-render isolation.\n */\nexport interface ContextProvider<T> {\n /** Replace the provided value (notifies only consumers whose slice changed). */\n set(value: T): void\n /** Read the current value without subscribing. */\n peek(): T\n /**\n * Subscribe to a selected slice. The returned accessor is a memo that only\n * changes — and thus only re-runs its observers — when `selector(value)`\n * changes under `equals` (default `Object.is`).\n */\n select<S>(selector: (value: T) => S, equals?: SelectorEquals<S>): () => S\n}\n\n/** Create a context with a default value. */\nexport function createContext<T>(defaultValue: T): Context<T> {\n return { id: Symbol('mindees.context'), defaultValue }\n}\n\n/**\n * Create a provider instance for `context`. Built on a signal, so selected\n * slices are memos: a consumer that selects `c => c.user.name` does not re-run\n * when an unrelated field changes.\n *\n * @example\n * const Theme = createContext({ mode: 'light', accent: 'blue' })\n * const p = createProvider(Theme, { mode: 'light', accent: 'blue' })\n * const mode = p.select((t) => t.mode) // only re-runs when `mode` changes\n */\nexport function createProvider<T>(context: Context<T>, initial?: T): ContextProvider<T> {\n // equals:false at the root — every set() re-evaluates selectors, but each\n // selector memo applies its own equality to isolate re-renders.\n const source = signal<T>(initial ?? context.defaultValue, { equals: false })\n return {\n set: (value: T) => {\n source.set(value)\n },\n peek: () => source.peek(),\n select<S>(selector: (value: T) => S, equals: SelectorEquals<S> = Object.is): () => S {\n return computed(() => selector(source()), { equals })\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Rendering a component subtree under an owner (so it can be disposed)\n// ---------------------------------------------------------------------------\n\n/**\n * Invoke a component within a reactive ownership scope, so every effect, memo,\n * and `onCleanup` it registers is torn down together when `dispose` is called.\n * Returns the produced node and that disposer.\n *\n * Built on the Phase 1 {@link createRoot}, so disposal reuses the same\n * leak-free teardown the reactivity tests cover. This is a renderer building\n * block; it does not touch any host.\n */\nexport function renderComponent<P>(\n component: Component<P>,\n props: P,\n): { node: MindeesNode; dispose: () => void } {\n let node!: MindeesNode\n // Capture the disposer eagerly: createRoot hands it to the callback synchronously\n // *before* the component runs, so if the component throws mid-render we can still\n // tear down anything it registered before the throw (effects, subscriptions,\n // timers). Without this, createRoot re-throws without disposing and the caller\n // never receives a disposer — the partial scope would leak forever.\n let dispose!: () => void\n try {\n createRoot((d) => {\n dispose = d\n node = component(props)\n })\n } catch (error) {\n dispose?.()\n throw error\n }\n return { node, dispose }\n}\n\n/** Whether code is currently running inside a reactive ownership scope. */\nexport function hasOwner(): boolean {\n return getOwner() !== null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+DA,MAAa,eAA8B,OAAO,IAAI,iBAAiB;;AAGvE,MAAa,WAA0B,OAAO,IAAI,kBAAkB;;AAGpE,MAAa,eAA8B,OAAO,IAAI,sBAAsB;;AAiC5E,SAAgB,YAAe,SAAgD;CAG7E,OAAO;EACL,SAAS;EACT,MAHA,OAAO,QAAQ,SAAS,aAAa,QAAQ,aAAa,QAAQ;EAIlE,OAAO,QAAQ;EACf,KAAK,QAAQ;EACb,UAAU,QAAQ;CACpB;AACF;;AAGA,SAAgB,cAAc,OAAsC;CAClE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAgC,YAAY;AAEjD;;AAGA,MAAa,SAAwB,OAAO,IAAI,gBAAgB;;;;;;AAoBhE,SAAgB,OACd,UACA,MACc;CACd,OAAO;EACL,UAAU;EACV,UAAU,OAAO,aAAa,aAAc,iBAAuC;EACnF,OAAO,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/component/component.ts"],"sourcesContent":["/**\n * MindeesNative component model — a minimal, renderer-agnostic element tree plus\n * **selector-based, re-render-isolated context**.\n *\n * The element tree (`createElement` / `Fragment`) is a plain data structure: a\n * component is a function of `props` returning elements. It carries no rendering\n * logic itself — the Helix renderer (Phase 3) turns this tree into host nodes.\n *\n * The context system is the important primitive: a `createContext` value is read\n * through a **selector**, and a consumer only re-runs when its *selected slice*\n * actually changes — not on every context update. This is the re-render\n * isolation the Quantum Router (Phase 6) builds on. It is implemented on the\n * Phase 1 signals, so selection participates in normal reactivity.\n *\n * @module\n */\n\nimport { computed, createRoot, getOwner, signal } from '../reactive'\n\n// ---------------------------------------------------------------------------\n// Element tree\n// ---------------------------------------------------------------------------\n\n/** A component: a function from props to a renderable node. */\nexport type Component<P = Record<string, unknown>> = (props: P) => MindeesNode\n\n/**\n * Anything that can appear in the tree.\n *\n * Includes an **accessor** form `() => MindeesNode`: a function child (or\n * function prop value) is a *reactive region* — the renderer subscribes to it\n * and patches exactly that region when its signals change (the fine-grained\n * update model, à la SolidJS). Static trees never need it; reactive UIs do.\n */\nexport type MindeesNode =\n | MindeesElement\n // A node may hold a keyed region of ANY item type. KeyedRegion is invariant in T (its\n // mapFn/key take T), so `KeyedRegion<unknown>` would reject `KeyedRegion<Row>`; `any` is\n // the correct \"some item type\" here.\n // biome-ignore lint/suspicious/noExplicitAny: see above — invariant T at a node boundary.\n | KeyedRegion<any>\n | PortalRegion\n | string\n | number\n | boolean\n | null\n | undefined\n | (() => MindeesNode)\n | MindeesNode[]\n\n/** The tag of an element: a host string (e.g. `\"view\"`) or a component function. */\nexport type ElementType = string | Component<never>\n\n/** A virtual element: a tag, its props, and its children. */\nexport interface MindeesElement {\n readonly $$typeof: typeof ELEMENT_TYPE\n readonly type: ElementType\n readonly props: Readonly<Record<string, unknown>>\n readonly children: readonly MindeesNode[]\n readonly key: string | number | null\n}\n\n/** Brand so a renderer can reliably distinguish elements from plain objects. */\nexport const ELEMENT_TYPE: unique symbol = Symbol.for('mindees.element')\n\n/** Marker tag for a fragment (children with no wrapper host node). */\nexport const Fragment: unique symbol = Symbol.for('mindees.fragment')\n\n/** Brand identifying a keyed list region (reconciled by key, not full-rebuilt). */\nexport const KEYED_REGION: unique symbol = Symbol.for('mindees.keyed-region')\n\n/**\n * A keyed list region: a reactive item list + a per-item render function, reconciled by key\n * so rows keep their identity (host node, focus, caret, scroll) across reorders instead of\n * being torn down and rebuilt. This is a serializable *description* (no rendering logic); the\n * renderer materializes it (`bindKeyedChild`). Build one with {@link keyedRegion}.\n */\nexport interface KeyedRegion<T = unknown> {\n readonly $$keyed: typeof KEYED_REGION\n /** The items, as a reactive accessor. */\n readonly each: () => readonly T[]\n /** Render one row from reactive `item`/`index` accessors (consume them lazily to patch in place). */\n readonly mapFn: (item: () => T, index: () => number) => MindeesNode\n /** Stable key per item (when omitted, the row is keyed by item identity). */\n readonly key: ((item: T, index: number) => unknown) | undefined\n /** Rendered when the list is empty. */\n readonly fallback: (() => MindeesNode) | undefined\n}\n\n/** Options for {@link keyedRegion}. */\nexport interface KeyedRegionOptions<T> {\n /** The items, static or reactive. */\n readonly each: readonly T[] | (() => readonly T[])\n /** Render one row from reactive `item`/`index` accessors. */\n readonly children: (item: () => T, index: () => number) => MindeesNode\n /** Stable key per item (defaults to item identity). */\n readonly key?: (item: T, index: number) => unknown\n /** Rendered when the list is empty. */\n readonly fallback?: () => MindeesNode\n}\n\n/** Build a {@link KeyedRegion} — a keyed, identity-preserving list node. */\nexport function keyedRegion<T>(options: KeyedRegionOptions<T>): KeyedRegion<T> {\n const each: () => readonly T[] =\n typeof options.each === 'function' ? options.each : () => options.each as readonly T[]\n return {\n $$keyed: KEYED_REGION,\n each,\n mapFn: options.children,\n key: options.key,\n fallback: options.fallback,\n }\n}\n\n/** Type guard: is `value` a {@link KeyedRegion}? */\nexport function isKeyedRegion(value: unknown): value is KeyedRegion {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$keyed?: unknown }).$$keyed === KEYED_REGION\n )\n}\n\n/** Brand identifying a portal region (children relocated to an overlay target above the tree). */\nexport const PORTAL: unique symbol = Symbol.for('mindees.portal')\n\n/**\n * A portal: its children render into a different host parent (an overlay/root layer) than their\n * position in the tree, while staying owned by the logical owner so reactive disposal + unmount\n * still work. The renderer materializes it (`bindPortalChild`); build one with {@link portal}.\n */\nexport interface PortalRegion {\n readonly $$portal: typeof PORTAL\n /** Children to relocate, normalized to a (reactive) accessor. */\n readonly children: () => MindeesNode\n /** Optional explicit host target (an `N`); else the backend's overlay root; else the local parent. Opaque to core. */\n readonly mount: unknown\n}\n\n/**\n * Build a {@link PortalRegion} — relocate `children` to an overlay target. Pass `opts.mount` to\n * override the target host node; otherwise the renderer uses the backend's overlay root (or, with\n * no overlay, mounts in place — the SSR-correct default).\n */\nexport function portal(\n children: MindeesNode | (() => MindeesNode),\n opts?: { readonly mount?: unknown },\n): PortalRegion {\n return {\n $$portal: PORTAL,\n children: typeof children === 'function' ? (children as () => MindeesNode) : () => children,\n mount: opts?.mount,\n }\n}\n\n/** Type guard: is `value` a {@link PortalRegion}? */\nexport function isPortal(value: unknown): value is PortalRegion {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$portal?: unknown }).$$portal === PORTAL\n )\n}\n\ninterface PropsWithKey {\n key?: string | number | null\n children?: MindeesNode\n}\n\n/**\n * Create a virtual element. `type` is a host-component string or a component\n * function; `Fragment` groups children without a wrapper.\n *\n * @example\n * createElement('view', { id: 'root' }, createElement('text', null, 'hi'))\n */\nexport function createElement(\n type: ElementType | typeof Fragment,\n props?: (Record<string, unknown> & PropsWithKey) | null,\n ...children: MindeesNode[]\n): MindeesElement {\n const { key = null, children: propsChildren, ...rest } = props ?? {}\n // Children passed as args win over a `children` prop; otherwise fall back to it. An array `children`\n // prop is used as-is (not re-wrapped), so `element.children` has one consistent shape regardless of\n // how children were supplied — matching the JSX runtime's array-spreading normalization.\n const resolved: MindeesNode[] =\n children.length > 0\n ? children\n : propsChildren === undefined\n ? []\n : Array.isArray(propsChildren)\n ? propsChildren\n : [propsChildren]\n return {\n $$typeof: ELEMENT_TYPE,\n type: type as ElementType,\n props: Object.freeze({ ...rest }),\n children: Object.freeze(resolved),\n key,\n }\n}\n\n/** Type guard: is `value` a MindeesElement? */\nexport function isElement(value: unknown): value is MindeesElement {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === ELEMENT_TYPE\n )\n}\n\n// ---------------------------------------------------------------------------\n// Selector-based, re-render-isolated context\n// ---------------------------------------------------------------------------\n\n/** Equality used by context selectors. Defaults to `Object.is`. */\nexport type SelectorEquals<S> = (a: S, b: S) => boolean\n\n/** A context handle created by {@link createContext}. */\nexport interface Context<T> {\n /** Provide a value to a subtree (conceptually); returns a scoped reader set. */\n readonly id: symbol\n /** The default value used when no provider is present. */\n readonly defaultValue: T\n}\n\n/**\n * A live provider instance: holds the current value and lets consumers subscribe\n * to a derived slice with re-render isolation.\n */\nexport interface ContextProvider<T> {\n /** Replace the provided value (notifies only consumers whose slice changed). */\n set(value: T): void\n /** Read the current value without subscribing. */\n peek(): T\n /**\n * Subscribe to a selected slice. The returned accessor is a memo that only\n * changes — and thus only re-runs its observers — when `selector(value)`\n * changes under `equals` (default `Object.is`).\n */\n select<S>(selector: (value: T) => S, equals?: SelectorEquals<S>): () => S\n}\n\n/** Create a context with a default value. */\nexport function createContext<T>(defaultValue: T): Context<T> {\n return { id: Symbol('mindees.context'), defaultValue }\n}\n\n/**\n * Create a provider instance for `context`. Built on a signal, so selected\n * slices are memos: a consumer that selects `c => c.user.name` does not re-run\n * when an unrelated field changes.\n *\n * @example\n * const Theme = createContext({ mode: 'light', accent: 'blue' })\n * const p = createProvider(Theme, { mode: 'light', accent: 'blue' })\n * const mode = p.select((t) => t.mode) // only re-runs when `mode` changes\n */\nexport function createProvider<T>(context: Context<T>, initial?: T): ContextProvider<T> {\n // equals:false at the root — every set() re-evaluates selectors, but each\n // selector memo applies its own equality to isolate re-renders.\n const source = signal<T>(initial ?? context.defaultValue, { equals: false })\n return {\n set: (value: T) => {\n source.set(value)\n },\n peek: () => source.peek(),\n select<S>(selector: (value: T) => S, equals: SelectorEquals<S> = Object.is): () => S {\n return computed(() => selector(source()), { equals })\n },\n }\n}\n\n// ---------------------------------------------------------------------------\n// Rendering a component subtree under an owner (so it can be disposed)\n// ---------------------------------------------------------------------------\n\n/**\n * Invoke a component within a reactive ownership scope, so every effect, memo,\n * and `onCleanup` it registers is torn down together when `dispose` is called.\n * Returns the produced node and that disposer.\n *\n * Built on the Phase 1 {@link createRoot}, so disposal reuses the same\n * leak-free teardown the reactivity tests cover. This is a renderer building\n * block; it does not touch any host.\n */\nexport function renderComponent<P>(\n component: Component<P>,\n props: P,\n): { node: MindeesNode; dispose: () => void } {\n let node!: MindeesNode\n // Capture the disposer eagerly: createRoot hands it to the callback synchronously\n // *before* the component runs, so if the component throws mid-render we can still\n // tear down anything it registered before the throw (effects, subscriptions,\n // timers). Without this, createRoot re-throws without disposing and the caller\n // never receives a disposer — the partial scope would leak forever.\n let dispose!: () => void\n try {\n createRoot((d) => {\n dispose = d\n node = component(props)\n })\n } catch (error) {\n dispose?.()\n throw error\n }\n return { node, dispose }\n}\n\n/** Whether code is currently running inside a reactive ownership scope. */\nexport function hasOwner(): boolean {\n return getOwner() !== null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+DA,MAAa,eAA8B,OAAO,IAAI,iBAAiB;;AAGvE,MAAa,WAA0B,OAAO,IAAI,kBAAkB;;AAGpE,MAAa,eAA8B,OAAO,IAAI,sBAAsB;;AAiC5E,SAAgB,YAAe,SAAgD;CAG7E,OAAO;EACL,SAAS;EACT,MAHA,OAAO,QAAQ,SAAS,aAAa,QAAQ,aAAa,QAAQ;EAIlE,OAAO,QAAQ;EACf,KAAK,QAAQ;EACb,UAAU,QAAQ;CACpB;AACF;;AAGA,SAAgB,cAAc,OAAsC;CAClE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAgC,YA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AK;EACxB,CAAC;CACH,SAAS,OAAO;EACd,UAAU;EACV,MAAM;CACR;CACA,OAAO;EAAE;EAAM;CAAQ;AACzB;;AAGA,SAAgB,WAAoB;CAClC,OAAO,SAAS,MAAM;AACxB"}
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ import { ThreadPool, WorkerLike, WorkerPoolOptions, createInlineThreadPool, crea
14
14
  /** The npm package name. */
15
15
  declare const name = "@mindees/core";
16
16
  /** The package version. All `@mindees/*` packages share one locked version line. */
17
- declare const VERSION = "0.22.0";
17
+ declare const VERSION = "0.22.2";
18
18
  /**
19
19
  * Current maturity of this package. See the repository `STATUS.md`.
20
20
  *
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { createInlineThreadPool, createNativeThreadPool, createWorkerPool } from
12
12
  /** The npm package name. */
13
13
  const name = "@mindees/core";
14
14
  /** The package version. All `@mindees/*` packages share one locked version line. */
15
- const VERSION = "0.22.0";
15
+ const VERSION = "0.22.2";
16
16
  /**
17
17
  * Current maturity of this package. See the repository `STATUS.md`.
18
18
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Maturity, PackageInfo } from './types'\n\n/**\n * Animation engine: reactive animated values + timing/spring drivers + interpolate, driven by an\n * injected frame source (RN Animated/Reanimated + Flutter AnimationController parity).\n */\nexport {\n _activeAnimationCount,\n _resetAnimation,\n type AnimatedValue,\n type AnimationHandle,\n animate,\n cubicBezier,\n type Easing,\n easeInOutQuad,\n easeInQuad,\n easeOutCubic,\n easeOutQuad,\n type FrameSource,\n getFrameSource,\n interpolate,\n linear,\n manualFrameSource,\n rafFrameSource,\n setFrameSource,\n spring,\n timing,\n} from './animation'\n/**\n * Component model: a renderer-agnostic element tree plus selector-based,\n * re-render-isolated context. (Phase 2)\n */\nexport {\n type Component,\n type Context,\n type ContextProvider,\n createContext,\n createElement,\n createProvider,\n ELEMENT_TYPE,\n type ElementType,\n Fragment,\n hasOwner,\n isElement,\n isKeyedRegion,\n isPortal,\n KEYED_REGION,\n type KeyedRegion,\n type KeyedRegionOptions,\n keyedRegion,\n type MindeesElement,\n type MindeesNode,\n PORTAL,\n type PortalRegion,\n portal,\n renderComponent,\n type SelectorEquals,\n} from './component'\nexport { NotImplementedError } from './errors'\n/**\n * Gesture recognizers: tap/longPress/pan/pinch/swipe → reactive state that drives styles and the\n * animation engine (RN Gesture Handler / Flutter GestureDetector parity).\n */\nexport {\n _setGestureClock,\n composeGestures,\n type GestureHandlers,\n longPress,\n normalizePointer,\n type PanEvent,\n type PanState,\n type PinchEvent,\n type PinchState,\n type PointerSample,\n pan,\n panAnimated,\n pinch,\n type Recognizer,\n type SwipeDirection,\n type SwipeEvent,\n swipe,\n type TapState,\n tap,\n} from './gesture'\nexport { notImplemented } from './not-implemented'\n/**\n * Fine-grained reactivity: signals, computed values, effects, batching, and\n * disposal scopes. This is the reactive core of MindeesNative.\n */\nexport {\n type Accessor,\n batch,\n type ComputedOptions,\n computed,\n createRoot,\n deferred,\n type EffectOptions,\n type EqualsFn,\n effect,\n getOwner,\n type Memo,\n memo,\n type Owner,\n on,\n onCleanup,\n runWithOwner,\n type Signal,\n type SignalOptions,\n setReactiveScheduler,\n signal,\n startTransition,\n untrack,\n} from './reactive'\n/**\n * Priority scheduler: two-lane (sync/normal), microtask-batched, with\n * cancellable and dedupable tasks. (Phase 2)\n */\nexport {\n createScheduler,\n type Priority,\n type ScheduledTask,\n type ScheduleOptions,\n Scheduler,\n type SchedulerOptions,\n type Task,\n} from './scheduler'\n/**\n * Threading abstraction: a {@link ThreadPool} contract with a working Web Worker\n * backend and an inline fallback. Native multi-threading is a research track. (Phase 2)\n */\nexport {\n createInlineThreadPool,\n createNativeThreadPool,\n createWorkerPool,\n type ThreadPool,\n type WorkerLike,\n type WorkerPoolOptions,\n} from './threading'\nexport type { Maturity, PackageInfo } from './types'\n\n/** The npm package name. */\nexport const name = '@mindees/core'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.22.0'\n\n/**\n * Current maturity of this package. See the repository `STATUS.md`.\n *\n * The reactivity layer (signals/computed/effect/batch), the component model with\n * selector-isolated context, the priority scheduler, and the thread-pool\n * abstraction (Web Worker + inline) are all implemented and tested. Native\n * multi-threading remains a research track (throws `NotImplementedError`).\n */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n"],"mappings":";;;;;;;;;;;;AA6IA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;;;;;;;;AAUvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Maturity, PackageInfo } from './types'\n\n/**\n * Animation engine: reactive animated values + timing/spring drivers + interpolate, driven by an\n * injected frame source (RN Animated/Reanimated + Flutter AnimationController parity).\n */\nexport {\n _activeAnimationCount,\n _resetAnimation,\n type AnimatedValue,\n type AnimationHandle,\n animate,\n cubicBezier,\n type Easing,\n easeInOutQuad,\n easeInQuad,\n easeOutCubic,\n easeOutQuad,\n type FrameSource,\n getFrameSource,\n interpolate,\n linear,\n manualFrameSource,\n rafFrameSource,\n setFrameSource,\n spring,\n timing,\n} from './animation'\n/**\n * Component model: a renderer-agnostic element tree plus selector-based,\n * re-render-isolated context. (Phase 2)\n */\nexport {\n type Component,\n type Context,\n type ContextProvider,\n createContext,\n createElement,\n createProvider,\n ELEMENT_TYPE,\n type ElementType,\n Fragment,\n hasOwner,\n isElement,\n isKeyedRegion,\n isPortal,\n KEYED_REGION,\n type KeyedRegion,\n type KeyedRegionOptions,\n keyedRegion,\n type MindeesElement,\n type MindeesNode,\n PORTAL,\n type PortalRegion,\n portal,\n renderComponent,\n type SelectorEquals,\n} from './component'\nexport { NotImplementedError } from './errors'\n/**\n * Gesture recognizers: tap/longPress/pan/pinch/swipe → reactive state that drives styles and the\n * animation engine (RN Gesture Handler / Flutter GestureDetector parity).\n */\nexport {\n _setGestureClock,\n composeGestures,\n type GestureHandlers,\n longPress,\n normalizePointer,\n type PanEvent,\n type PanState,\n type PinchEvent,\n type PinchState,\n type PointerSample,\n pan,\n panAnimated,\n pinch,\n type Recognizer,\n type SwipeDirection,\n type SwipeEvent,\n swipe,\n type TapState,\n tap,\n} from './gesture'\nexport { notImplemented } from './not-implemented'\n/**\n * Fine-grained reactivity: signals, computed values, effects, batching, and\n * disposal scopes. This is the reactive core of MindeesNative.\n */\nexport {\n type Accessor,\n batch,\n type ComputedOptions,\n computed,\n createRoot,\n deferred,\n type EffectOptions,\n type EqualsFn,\n effect,\n getOwner,\n type Memo,\n memo,\n type Owner,\n on,\n onCleanup,\n runWithOwner,\n type Signal,\n type SignalOptions,\n setReactiveScheduler,\n signal,\n startTransition,\n untrack,\n} from './reactive'\n/**\n * Priority scheduler: two-lane (sync/normal), microtask-batched, with\n * cancellable and dedupable tasks. (Phase 2)\n */\nexport {\n createScheduler,\n type Priority,\n type ScheduledTask,\n type ScheduleOptions,\n Scheduler,\n type SchedulerOptions,\n type Task,\n} from './scheduler'\n/**\n * Threading abstraction: a {@link ThreadPool} contract with a working Web Worker\n * backend and an inline fallback. Native multi-threading is a research track. (Phase 2)\n */\nexport {\n createInlineThreadPool,\n createNativeThreadPool,\n createWorkerPool,\n type ThreadPool,\n type WorkerLike,\n type WorkerPoolOptions,\n} from './threading'\nexport type { Maturity, PackageInfo } from './types'\n\n/** The npm package name. */\nexport const name = '@mindees/core'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.22.2'\n\n/**\n * Current maturity of this package. See the repository `STATUS.md`.\n *\n * The reactivity layer (signals/computed/effect/batch), the component model with\n * selector-isolated context, the priority scheduler, and the thread-pool\n * abstraction (Web Worker + inline) are all implemented and tested. Native\n * multi-threading remains a research track (throws `NotImplementedError`).\n */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n"],"mappings":";;;;;;;;;;;;AA6IA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;;;;;;;;AAUvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindees/core",
3
- "version": "0.22.0",
3
+ "version": "0.22.2",
4
4
  "description": "MindeesNative core — fine-grained reactivity (signals/computed/effect/batch), component model with selector-isolated context, priority scheduler, and a thread-pool abstraction (Web Worker + inline; native is a research track).",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",