@lincyaw/host 1.0.0-rc.29 → 1.0.0-rc.30

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": "@lincyaw/host",
3
- "version": "1.0.0-rc.29",
3
+ "version": "1.0.0-rc.30",
4
4
  "description": "Presmium's host interface for plugin components in every form: step state, services, interface text, and the design system (tokens, components, fonts)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -45,8 +45,8 @@
45
45
  "@radix-ui/react-tooltip": "^1.2.8",
46
46
  "react": "18.3.1",
47
47
  "react-dom": "18.3.1",
48
- "@lincyaw/design": "1.0.0-rc.29",
49
- "@lincyaw/kernel": "1.0.0-rc.29"
48
+ "@lincyaw/kernel": "1.0.0-rc.30",
49
+ "@lincyaw/design": "1.0.0-rc.30"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/react": "18.3.28",
package/src/contracts.ts CHANGED
@@ -158,6 +158,11 @@ export interface StepClockDriver {
158
158
  readonly recording?: boolean
159
159
  /** Holds the clock until it is released (a capture of the page): other drivers wait until then. */
160
160
  readonly exclusive?: boolean
161
+ /**
162
+ * How long (ms) the animation of step `step` of slide `slide` may take while this driver plays it: a narrated lecture
163
+ * gives the time from the step's start until its voice ends. Undefined for a step it does not pace.
164
+ */
165
+ readonly stepLength?: (slide: number, step: number) => number | undefined
161
166
  }
162
167
 
163
168
  export interface StepClock {
package/src/index.ts CHANGED
@@ -65,7 +65,7 @@ export { PmApprovals } from './approvals.ts'
65
65
  export { claimFirst } from './claim-first.ts'
66
66
  export { createServerClient, pluginRoutePath, provideServer, useServer, serverClient } from './server.ts'
67
67
  export { PmPresenterPanels } from './panels.ts'
68
- export { useStepTime } from './step-clock.ts'
68
+ export { useDrivenStepLength, useStepTime } from './step-clock.ts'
69
69
  export type { StepTimeOptions } from './step-clock.ts'
70
70
  export { StepScope, useBlockStepRange, useStepScope } from './step-scope.ts'
71
71
  export { useSessionSnapshot } from './session.ts'
package/src/step-clock.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from 'react'
1
+ import { useEffect, useRef, useSyncExternalStore } from 'react'
2
2
  import type { Unsubscribe } from '@lincyaw/kernel/contracts'
3
3
  import type { Navigation, NavigationPosition, StepClock, StepClockDriver } from './contracts.ts'
4
4
  import { useHost, usePrefersReducedMotion } from './host.ts'
@@ -55,3 +55,10 @@ export function useStepTime(options: StepTimeOptions = {}): number {
55
55
  useEffect(() => { const running = () => Number.isFinite(renderedTime.current) && driver.getSnapshot()?.elapsed.getSnapshot() === undefined; live.add(running); ensureTicking(); return () => { live.delete(running) } }, [step, cursor.slide, player, options.until, reduced])
56
56
  return time
57
57
  }
58
+ const unobserved = () => () => {}
59
+ /** While the driver of the clock paces the steps it plays (a narrated lecture), the length it gives a step: `StepClockDriver.stepLength`. */
60
+ export function useDrivenStepLength(): StepClockDriver['stepLength'] {
61
+ const player = useStore(driver)
62
+ const playing = () => player?.elapsed.getSnapshot() !== undefined
63
+ return useSyncExternalStore(player?.elapsed.subscribe ?? unobserved, playing, playing) ? player?.stepLength : undefined
64
+ }