@playcademy/sdk 0.16.1-beta.4 → 0.16.1-beta.5

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 CHANGED
@@ -172,6 +172,46 @@ OAuth provider connections (Discord, Google, etc.).
172
172
  await client.identity.connect({ provider: 'discord' })
173
173
  ```
174
174
 
175
+ ### `client.embed`
176
+
177
+ Launch other Playcademy games as embedded children (platform mode only). With `timeback`, the child's play time and completion are recorded on this game's Timeback course. Interrupted launches resume automatically when the child streams checkpoints; the `resume` option tunes or disables the persistence.
178
+
179
+ ```typescript
180
+ const session = client.embed.launch({
181
+ slug: 'math-cakes',
182
+ container: overlayEl,
183
+ intent: { lessonId: 'two-digit-add', eLevel: 'E2' },
184
+ timeback: { activityId: 'two-digit-add-e2', grade: 2, subject: 'Math' },
185
+ })
186
+
187
+ const activity = await session.finished
188
+
189
+ if (activity.status === 'completed') {
190
+ await activity.end({
191
+ correctQuestions: activity.correct,
192
+ totalQuestions: activity.total,
193
+ xpAwarded: 10,
194
+ })
195
+ }
196
+
197
+ await session.closed // iframe unmounted; dismiss surrounding UI
198
+ ```
199
+
200
+ ### `client.parent`
201
+
202
+ The launch context when this game was launched by a parent game (`mode: 'child'`); `null` in every other mode. In child mode, activity reporting is relayed to the parent automatically, and `xpAwarded` becomes a suggestion the parent may override. Stream `client.parent.checkpoint(state)` to make interrupted launches resumable; the state comes back as `client.parent.resume`. Narrow with `isChildLaunched()` to get the relaxed types.
203
+
204
+ ```typescript
205
+ import { isChildLaunched } from '@playcademy/sdk'
206
+
207
+ if (isChildLaunched(client)) {
208
+ const { lessonId, eLevel } = client.parent.intent
209
+ startLesson(lessonId, eLevel)
210
+ // ...later: xpAwarded may be omitted; the parent decides the award
211
+ await client.timeback.endActivity({ correctQuestions, totalQuestions })
212
+ }
213
+ ```
214
+
175
215
  ### `client.demo`
176
216
 
177
217
  Demo mode for anonymous players on the landing page.