@simon-says-build/demo-player 0.13.3 → 0.14.1

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": "@simon-says-build/demo-player",
3
- "version": "0.13.3",
3
+ "version": "0.14.1",
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
@@ -15,7 +15,7 @@
15
15
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
16
16
  import { Linking, NativeModules, Platform, Settings, Pressable, ScrollView, StyleSheet, Text, TextInput, View, useWindowDimensions } from 'react-native';
17
17
  import { pageName } from './page-name.js';
18
- import { OVERLAY_ID, cardBox, pinnedBox, setTuckedDemo, overlayAnnounced, tapInside, currentDemo, demoConfig, findTarget, handlerFor, introBody, introOf, onDemo, phoneSteps, playDemo, releaseOf, reviewChangesOf, scalePoint, rescueNote, screenCandidates, stepTitle, targetOfKey } from './core.js';
18
+ import { OVERLAY_ID, 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';
19
19
  import { demoApi, tourOf } from './api.js';
20
20
  import { signInFirst, openInApp } from './signin.js';
21
21
  import { runEvent, fillStep } from './events.js';
@@ -311,6 +311,21 @@ function Player({ config, router, insets, onClose, children }) {
311
311
  actions: signIn ? [{ label: 'Hide', onPress: () => setTucked(true) }, { label: 'Try again', onPress: () => setSignInTry((n) => n + 1), primary: true }] : [],
312
312
  });
313
313
  }
314
+ // A PART'S TITLE CARD (0.14.0): the review moving to a different thing —
315
+ // its title, one line, centred, nothing ringed; Next carries on.
316
+ if (step.kind === 'chapter') {
317
+ const part = chapterOf(steps, index);
318
+ return h(Card, {
319
+ at: null, screen, insets, card, setCard, onCollapse: () => setTucked(true),
320
+ title: part ? `Part ${part.n} of ${part.of} · ${step.title}` : step.title,
321
+ body: step.caption,
322
+ actions: [
323
+ { label: 'Hide', onPress: () => setTucked(true) },
324
+ index > 0 && steps[index - 1].kind !== 'signin' ? { label: 'Back', onPress: () => setIndex(index - 1) } : null,
325
+ { label: index + 1 >= steps.length ? 'Finish' : 'Next', onPress: next, primary: true },
326
+ ].filter(Boolean),
327
+ });
328
+ }
314
329
  if (step.kind === 'try') {
315
330
  return h(React.Fragment, null,
316
331
  rect ? h(View, { pointerEvents: 'none', style: [s.ring, s.tryRing, { left: rect.left - 6, top: rect.top - 6, width: rect.width + 12, height: rect.height + 12 }] }) : null,
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.13.3';
13
+ export const PLAYER_VERSION = '0.14.1';
14
14
 
15
15
  export const HOST = 5;
16
16
  export const TEXT = 6;
@@ -21,7 +21,7 @@ export const RECORDED_SCREEN = { width: 393, height: 852 };
21
21
  // What a phone can perform. `press` (a keyboard key), `select` (a web
22
22
  // <select>) and `run` (a terminal demo) have no phone equivalent. `signin` is
23
23
  // the player's own (tourOf, 0.6.0): sign this person in by link.
24
- const PHONE_KINDS = new Set(['say', 'goto', 'show', 'click', 'fill', 'signin', 'event', 'try']);
24
+ const PHONE_KINDS = new Set(['say', 'goto', 'show', 'click', 'fill', 'signin', 'event', 'try', 'chapter']);
25
25
 
26
26
  const lower = (s) => String(s ?? '').trim().toLowerCase();
27
27
  const hiddenHost = (f) => {
@@ -153,6 +153,17 @@ export function scalePoint(point, screen, from = RECORDED_SCREEN) {
153
153
  }
154
154
 
155
155
  /** A step card's title: where it is in the demo, and whether SSB only set it up (a best-effort step: the state seeded and the screen opened, the change not driven). */
156
+ /**
157
+ * Which part a step belongs to (0.14.0): parts start at each `chapter` step.
158
+ * → { n, of } (1-based) for a chapter step, or null when the tour has none. Pure.
159
+ */
160
+ export function chapterOf(steps = [], index = 0) {
161
+ const at = steps.map((s, i) => (s?.kind === 'chapter' ? i : -1)).filter((i) => i >= 0);
162
+ if (!at.length) return null;
163
+ const n = at.filter((i) => i <= index).length;
164
+ return n ? { n, of: at.length } : null;
165
+ }
166
+
156
167
  export function stepTitle(step, index, total) {
157
168
  return `${index + 1} of ${total}${step?.bestEffort === true ? ' · set up by SSB' : ''}`;
158
169
  }
@@ -183,12 +194,24 @@ export function cardBox(place, at, screen, insets, card) {
183
194
  // pinned to the top by default, but with a collapse button"). The card sits
184
195
  // across the top of the screen; only when it would cover the ringed element
185
196
  // (`at`) does it move to the bottom. Pure.
197
+ // THE DEV CLIENT'S BUTTON (2026-11-07): a review plays in a development build,
198
+ // and expo-dev-menu draws its floating tools button (the gear) in a native
199
+ // window above the app at the top-right. Its touch area is far bigger than the
200
+ // icon — on SSB's iPhone simulator nothing below it got touches from x ≈ 305
201
+ // to the edge, down to y ≈ 165 — so a short card pinned at the top had its
202
+ // right-aligned primary button under it: "Take me there" did nothing for the
203
+ // playback check and for a person alike (Connie Ho's review, demo
204
+ // 16D4S5HqugIonvUSdC5u; mapped by hand-tapping a grid on the simulator). A card
205
+ // pinned at the TOP stays left of it; one pinned at the bottom is full width.
206
+ export const DEV_FAB_CLEAR = 88;
207
+
186
208
  export function pinnedBox(at, screen, insets, card) {
187
- const left = 12, width = screen.width - 24;
209
+ const left = 12, full = screen.width - 24;
188
210
  const top = insets.top + 8;
189
211
  const bottom = screen.height - insets.bottom - card.h - 8;
190
212
  const covers = at && at.top < top + card.h + 8 && at.bottom > top;
191
- return { left, width, top: covers ? Math.max(top, bottom) : top };
213
+ const y = covers ? Math.max(top, bottom) : top;
214
+ return { left, width: y === top ? full - DEV_FAB_CLEAR : full, top: y };
192
215
  }
193
216
 
194
217
  // A TAP ON THE RINGED ELEMENT (0.13.1): a `try` step is done when the viewer's