@simon-says-build/demo-player 0.13.2 → 0.14.0

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.2",
3
+ "version": "0.14.0",
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.2';
13
+ export const PLAYER_VERSION = '0.14.0';
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
  }
@@ -210,7 +221,11 @@ let tuck = null;
210
221
  let overlayHere = false;
211
222
  export function setTuckedDemo(resume) { tuck = typeof resume === 'function' ? resume : null; }
212
223
  export const tuckedDemo = () => tuck;
213
- export function announceOverlay() { overlayHere = true; }
224
+ // `on` (0.13.3): the overlay says so only while its button is DRAWN — it draws
225
+ // none for a login SSB does not show it to (a review copy's cast), and a
226
+ // collapsed review with no button and no pill could not be brought back
227
+ // (Connie Ho's review on SSB's simulator, 2026-11-06).
228
+ export function announceOverlay(on = true) { overlayHere = !!on; }
214
229
  export const overlayAnnounced = () => overlayHere;
215
230
 
216
231
  // A DEMO STARTED AT RUN TIME (2026-10-20, the in-app overlay's ▶ Demo, "Ready