@simon-says-build/demo-player 0.6.0 → 0.7.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/README.md +2 -0
- package/package.json +1 -1
- package/src/DemoHost.js +2 -2
- package/src/core.js +1 -1
- package/src/signin.js +21 -0
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ Pass the `process.env.EXPO_PUBLIC_*` reads in the app's own code. Expo inlines t
|
|
|
22
22
|
|
|
23
23
|
Without all three it renders its children and nothing else. Elements are found by `testID`, then `accessibilityLabel`, then visible text, by walking React's tree. No component needs wrapping.
|
|
24
24
|
|
|
25
|
+
**0.7.0: the sign-in link opens through the app's router** (`openInApp`), not `Linking.openURL`. The link names app.json's scheme, and a review plays in the dev build, whose scheme can differ (Walk2Gether's is `walk2gether-dev`), so the OS opened the production app or nothing. Without a `router`, the OS opens it as before.
|
|
26
|
+
|
|
25
27
|
**0.6.0: SSB signs the viewer in** on a phone's private, seeded copy (docs/MOBILE-DEMO.md "Sign-in (stage 2: SSB signs in)"). Before each person's part the player asks the demo API for their sign-in link (`POST /api/demo/:id/signin`), opens it with `Linking.openURL`, waits for the app to settle, and starts on the screen the link opened. The walk's own sign-in steps are skipped. The app must handle `<scheme>://auth?token=<custom token>&next=<path>`: sign in with the custom token, then route to `next`. Where there is no link (the app's real backend, no URL scheme, the copy not up), the card says who to sign in as, as before.
|
|
26
28
|
|
|
27
29
|
`npm test` runs the pure half.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simon-says-build/demo-player",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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
|
@@ -16,7 +16,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
16
16
|
import { Linking, Pressable, ScrollView, StyleSheet, Text, TextInput, View, useWindowDimensions } from 'react-native';
|
|
17
17
|
import { cardBox, currentDemo, demoConfig, findTarget, handlerFor, onDemo, phoneSteps, playDemo, releaseOf, reviewChangesOf, scalePoint } from './core.js';
|
|
18
18
|
import { demoApi, tourOf } from './api.js';
|
|
19
|
-
import { signInFirst } from './signin.js';
|
|
19
|
+
import { signInFirst, openInApp } from './signin.js';
|
|
20
20
|
|
|
21
21
|
const h = React.createElement;
|
|
22
22
|
const FIND_FOR_MS = 8000; // a step's element may appear after a navigation settles
|
|
@@ -148,7 +148,7 @@ function Player({ config, router, insets, onClose, children }) {
|
|
|
148
148
|
let live = true;
|
|
149
149
|
const first = steps[index + 1];
|
|
150
150
|
signInFirst({
|
|
151
|
-
api, actorIndex: step.actorIndex, openURL: (url) => Linking.openURL(
|
|
151
|
+
api, actorIndex: step.actorIndex, openURL: (url) => openInApp(url, { router, openURL: (u) => Linking.openURL(u) }),
|
|
152
152
|
settled: () => !live || !first?.target || first.target.point || !!findTarget(fiberOf(rootRef.current), first.target),
|
|
153
153
|
}).then((r) => {
|
|
154
154
|
if (!live) return;
|
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
|
+
export const PLAYER_VERSION = '0.7.0';
|
|
14
14
|
|
|
15
15
|
export const HOST = 5;
|
|
16
16
|
export const TEXT = 6;
|
package/src/signin.js
CHANGED
|
@@ -11,6 +11,27 @@ const POLL_MS = 250;
|
|
|
11
11
|
|
|
12
12
|
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The app path of a link in the app's own deep-link form: `x://auth?token=…`
|
|
16
|
+
* → `/auth?token=…`. The player opens its sign-in through the app's ROUTER
|
|
17
|
+
* (0.7.0), never the OS: the link names the app's scheme as app.json says it,
|
|
18
|
+
* and a review plays in the DEV build, whose scheme differs (walk2gether-dev),
|
|
19
|
+
* so Linking.openURL opened the production app, or nothing (2026-10-31). The
|
|
20
|
+
* router is always the app the player runs in. Pure; null for anything else.
|
|
21
|
+
*/
|
|
22
|
+
export function inAppPath(link) {
|
|
23
|
+
const m = /^[a-z][a-z0-9+.-]*:\/\/(.*)$/i.exec(String(link || ''));
|
|
24
|
+
if (!m || /^https?:/i.test(String(link))) return null;
|
|
25
|
+
return `/${m[1].replace(/^\/+/, '')}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Open a sign-in link in THIS app: its router when it has one, else the OS. */
|
|
29
|
+
export async function openInApp(link, { router, openURL }) {
|
|
30
|
+
const p = inAppPath(link);
|
|
31
|
+
if (p && router?.push) { router.push(p); return; }
|
|
32
|
+
await openURL(link);
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
/** Whether a demo signs its people in itself: a phone's private copy, not a build the viewer is already in. */
|
|
15
36
|
export const signsIn = (demo, { here = false } = {}) => !here && demo?.platform === 'ios' && demo?.backend === 'sandbox';
|
|
16
37
|
|