@simon-says-build/demo-player 0.14.2 → 0.14.4

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/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { DemoHost } from './src/DemoHost.js';
2
- export { demoConfig, findTarget, handlerFor, phoneSteps, scalePoint, playDemo, currentDemo, onDemo, reviewChangesOf, releaseOf, releaseReviewsOf, PLAYER_VERSION, tuckedDemo, announceOverlay } from './src/core.js';
2
+ export { demoConfig, findTarget, handlerFor, phoneSteps, scalePoint, playDemo, currentDemo, onDemo, reviewChangesOf, releaseOf, releaseReviewsOf, PLAYER_VERSION, tuckedDemo, announceOverlay, setCurrentRoute, currentRoute } from './src/core.js';
3
3
  export { navigationRoute, navigationRouter, navigateArgs, pathOfState } from './src/navigation.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simon-says-build/demo-player",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "SimonSays mobile demo player: walks a preview's viewer through a job's change, inside the app. Renders nothing unless the bundle carries a demo.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/DemoHost.js CHANGED
@@ -23,7 +23,7 @@ import { pageName } from './page-name.js';
23
23
  // app (box-none). An app without react-native-screens keeps the in-tree layer.
24
24
  let FullWindowOverlay = null;
25
25
  try { FullWindowOverlay = require('react-native-screens').FullWindowOverlay || null; } catch { FullWindowOverlay = null; }
26
- import { OVERLAY_ID, overlayLayer, chapterOf, cardBox, pinnedBox, setTuckedDemo, overlayAnnounced, tapInside, currentDemo, demoConfig, findTarget, handlerFor, introBody, introOf, onDemo, phoneSteps, playDemo, releaseOf, reviewChangesOf, scalePoint, rescueNote, screenCandidates, stepTitle, targetOfKey } from './core.js';
26
+ import { OVERLAY_ID, overlayLayer, pressableHost, rowBox, alreadyOn, currentRoute, chapterOf, cardBox, pinnedBox, setTuckedDemo, overlayAnnounced, tapInside, currentDemo, demoConfig, findTarget, handlerFor, introBody, introOf, onDemo, phoneSteps, playDemo, releaseOf, reviewChangesOf, scalePoint, rescueNote, screenCandidates, stepTitle, targetOfKey } from './core.js';
27
27
  import { demoApi, tourOf } from './api.js';
28
28
  import { signInFirst, openInApp } from './signin.js';
29
29
  import { runEvent, fillStep } from './events.js';
@@ -157,7 +157,8 @@ function Player({ config, router, insets, onClose, children }) {
157
157
  const started = Date.now();
158
158
  const tick = async () => {
159
159
  const f = findTarget(fiberOf(rootRef.current), target);
160
- const r = f ? await measure(f) : null;
160
+ const host = f ? pressableHost(f) : null;
161
+ const r = f ? rowBox(await measure(f), host !== f ? await measure(host) : null, screen) : null;
161
162
  if (!live) return;
162
163
  setFound(f);
163
164
  setRect(r);
@@ -217,6 +218,16 @@ function Player({ config, router, insets, onClose, children }) {
217
218
  advance();
218
219
  }, [steps, step, router, advance, flash]);
219
220
 
221
+ // A GOTO TO WHERE THE PERSON ALREADY IS (0.14.4) is passed straight over —
222
+ // only when arriving forward, never after Back (Back onto it must stay, or
223
+ // it would bounce forward again).
224
+ const lastIndex = useRef(-1);
225
+ useEffect(() => {
226
+ const forward = index > lastIndex.current;
227
+ lastIndex.current = index;
228
+ if (forward && step?.kind === 'goto' && step.path && !flash && alreadyOn(step.path, currentRoute())) advance();
229
+ }, [index]);
230
+
220
231
  useEffect(() => {
221
232
  if (!tried) return undefined;
222
233
  setFlash('✓ That\'s it');
package/src/core.js CHANGED
@@ -10,7 +10,7 @@ import { bubbleBox } from './step-place.js';
10
10
  // What this player is, said when the app registers for "Ready to see"
11
11
  // (packages/ssb-overlay sends it; functions/in-app-notify.mjs clientOf). Kept
12
12
  // equal to package.json by test/core.test.mjs.
13
- export const PLAYER_VERSION = '0.14.2';
13
+ export const PLAYER_VERSION = '0.14.4';
14
14
 
15
15
  export const HOST = 5;
16
16
  export const TEXT = 6;
@@ -144,6 +144,26 @@ export function handlerFor(f, name) {
144
144
  return null;
145
145
  }
146
146
 
147
+ /**
148
+ * THE THING A PERSON TAPS (0.14.3, 2026-11-07): a target found by its words is
149
+ * often a Text inside a pressable row. Ringing the Text put a small ring on a
150
+ * label at the row's edge, and a tap anywhere else on the row — what a person
151
+ * and SSB's check both do — was not seen as the try: Connie Ho's "Open Yane"
152
+ * opened her profile and the card kept asking (demo 16D4S5HqugIonvUSdC5u).
153
+ * → the first host view of the nearest ancestor with an onPress (the row), or
154
+ * `f` when there is none. Pure (walks fibers: return / child, tag 5 = host).
155
+ */
156
+ export function pressableHost(f) {
157
+ let p = f;
158
+ while (p && typeof p.memoizedProps?.onPress !== 'function') p = p.return;
159
+ if (!p) return f;
160
+ for (let q = p; q; q = q.child) if (q.tag === 5 && q.stateNode) return q;
161
+ return f;
162
+ }
163
+ /** Use the row's box only when it is a row, not a screen-sized wrapper. Pure. */
164
+ export const rowBox = (text, row, screen) =>
165
+ row && text && row.width * row.height <= 0.4 * screen.width * screen.height ? row : text;
166
+
147
167
  /** A recorded point, scaled from the recording screen to `screen`. */
148
168
  export function scalePoint(point, screen, from = RECORDED_SCREEN) {
149
169
  return {
@@ -205,6 +225,21 @@ export function cardBox(place, at, screen, insets, card) {
205
225
  // pinned at the TOP stays left of it; one pinned at the bottom is full width.
206
226
  export const DEV_FAB_CLEAR = 88;
207
227
 
228
+ // THE SCREEN THE PERSON IS ON (0.14.4, 2026-11-07): the in-app overlay knows
229
+ // it (expo-router's usePathname, passed to <SsbHost route>) and tells the
230
+ // player, so a `goto` to where the person already is isn't offered as a
231
+ // destination ("Your walks. Take me there" on the Walks screen — Michael).
232
+ let routeNow = null;
233
+ export const setCurrentRoute = (route) => { routeNow = typeof route === 'string' ? route : null; };
234
+ export const currentRoute = () => routeNow;
235
+ /** "/(app)/(tabs)/walks/" → "/walks": expo-router's groups, a query and trailing slashes are not the screen. Pure. */
236
+ export const screenOf = (path) => {
237
+ const p = String(path || '').split(/[?#]/)[0].split('/').filter((s) => s && !/^\(.*\)$/.test(s)).join('/');
238
+ return `/${p}`;
239
+ };
240
+ /** Is the person already on the screen this path opens? Unknown (no route told) is no. Pure. */
241
+ export const alreadyOn = (path, route) => typeof route === 'string' && !!path && screenOf(path) === screenOf(route);
242
+
208
243
  // Where the overlay draws (0.14.2): iOS with react-native-screens → its own
209
244
  // window above sheets and modals (DemoHost, FullWindowOverlay); else in-tree.
210
245
  export const overlayLayer = (os, fwo) => (os === 'ios' && fwo ? 'window' : 'tree');