@playcademy/sdk 0.16.1-beta.1 → 0.16.1-beta.11

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
@@ -139,9 +139,24 @@ const completed = await client.timeback.assessments.submit(attempt.attemptId, {
139
139
  })
140
140
  ```
141
141
 
142
- `start()` resumes an unfinished attempt or selects the next live test. Save payloads are
143
- question deltas, but each included question replaces its complete response state; use `null` to
144
- clear an answer. Keep the returned `responseVersion` and send it with the next mutation.
142
+ `start()` resumes a compatible unfinished attempt or selects content for a fixed test or standards
143
+ review. Save payloads merge at both the item and response levels; omitted values remain unchanged,
144
+ and `null` clears one response. Keep the returned `responseVersion` and send it with the next
145
+ mutation.
146
+
147
+ The returned `flow` is authoritative and is derived from `purpose`; callers do not configure
148
+ navigation, feedback, and submission independently:
149
+
150
+ - `attempt-submit` is used for diagnostic and end-of-course attempts. Responses remain editable
151
+ through `save()` until `submit()` finalizes the whole attempt and returns feedback.
152
+ - `item-submit` is used for review and mastery attempts. Submit each item in assessment order with
153
+ `submitItem()`. That operation atomically saves the item's responses, locks them, and returns safe
154
+ immediate feedback. Give each item request its own stable `submissionId` and reuse that ID for an
155
+ ambiguous retry; the returned canonical `itemSubmissions` ledger identifies committed items after
156
+ retry or resume.
157
+
158
+ The host rejects `submitItem()` for attempt-submit flows, rejects `submit()` until every item-submit
159
+ item is committed, and enforces `expectedResponseVersion` for every mutation.
145
160
 
146
161
  For local development, import the current ordered catalog before starting the dev host:
147
162
 
@@ -172,6 +187,46 @@ OAuth provider connections (Discord, Google, etc.).
172
187
  await client.identity.connect({ provider: 'discord' })
173
188
  ```
174
189
 
190
+ ### `client.embed`
191
+
192
+ 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.
193
+
194
+ ```typescript
195
+ const session = client.embed.launch({
196
+ slug: 'math-cakes',
197
+ container: overlayEl,
198
+ intent: { lessonId: 'two-digit-add', eLevel: 'E2' },
199
+ timeback: { activityId: 'two-digit-add-e2', grade: 2, subject: 'Math' },
200
+ })
201
+
202
+ const activity = await session.finished
203
+
204
+ if (activity.status === 'completed') {
205
+ await activity.end({
206
+ correctQuestions: activity.correct,
207
+ totalQuestions: activity.total,
208
+ xpAwarded: 10,
209
+ })
210
+ }
211
+
212
+ await session.closed // iframe unmounted; dismiss surrounding UI
213
+ ```
214
+
215
+ ### `client.parent`
216
+
217
+ 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.
218
+
219
+ ```typescript
220
+ import { isChildLaunched } from '@playcademy/sdk'
221
+
222
+ if (isChildLaunched(client)) {
223
+ const { lessonId, eLevel } = client.parent.intent
224
+ startLesson(lessonId, eLevel)
225
+ // ...later: xpAwarded may be omitted; the parent decides the award
226
+ await client.timeback.endActivity({ correctQuestions, totalQuestions })
227
+ }
228
+ ```
229
+
175
230
  ### `client.demo`
176
231
 
177
232
  Demo mode for anonymous players on the landing page.