anear-js-api 1.1.6 → 1.1.7

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.
@@ -165,7 +165,8 @@ const ActiveEventStatesConfig = {
165
165
  src: 'getAttachedCreatorOrHost',
166
166
  input: ({ context, event }) => ({ context, event }),
167
167
  onDone: {
168
- // event.data.anearParticipant will be null if no presence enter
168
+ // v5 note: onDone of a fromPromise actor provides the resolved value on `event.output`.
169
+ // event.output.anearParticipant will be null if no presence enter
169
170
  // was available on actions channel via get(). We must wait for
170
171
  // the undeferred PARTICIPANT_ENTER instead. But if get() DID
171
172
  // return the creator presence, then an APM will be created
@@ -201,7 +202,8 @@ const ActiveEventStatesConfig = {
201
202
  src: 'fetchParticipantData',
202
203
  input: ({ context, event }) => ({ context, event }),
203
204
  onDone: {
204
- // event.data.anearParticipant available in actions
205
+ // v5 note: onDone of a fromPromise actor provides the resolved value on `event.output`.
206
+ // event.output.anearParticipant available in actions
205
207
  actions: ['startNewParticipantMachine'],
206
208
  target: '#waiting.creatorStatus'
207
209
  },
@@ -1304,7 +1306,11 @@ const AnearEventMachineFunctions = ({
1304
1306
  }
1305
1307
  }),
1306
1308
  sendSpectatorEnterToAppEventMachine: ({ context, event }) => {
1307
- const spectators = [].concat(event.data || [])
1309
+ // This action is used both for:
1310
+ // - SPECTATOR_ENTER presence events (event.data = a single spectator payload)
1311
+ // - onDone of fromPromise spectators loaders (event.output = an array of members)
1312
+ const spectatorsPayload = event?.output ?? event?.data ?? []
1313
+ const spectators = [].concat(spectatorsPayload || [])
1308
1314
  spectators.forEach(
1309
1315
  // app can trigger a meta display for Spectator
1310
1316
  userJSON => {
@@ -1516,10 +1522,20 @@ const AnearEventMachineFunctions = ({
1516
1522
  processParticipantTimeout: ({ context, event }) =>
1517
1523
  context.appEventMachine.send({ type: 'PARTICIPANT_TIMEOUT', participantId: event.participantId }),
1518
1524
  setupParticipantsTimeout: assign(({ context, event }) => {
1519
- // Only set up a new timeout if one is provided in the event data.
1525
+ // Only set up a new timeout if one is provided by the display render workflow.
1526
+ //
1527
+ // v5 note: `renderDisplay` is implemented as a Promise actor (fromPromise).
1528
+ // The actor's resolved value is delivered on the done event as `event.output`
1529
+ // (v4 invoked services used `event.data`). Keep a fallback to `event.data`
1530
+ // to remain compatible with any legacy paths.
1531
+ const participantsTimeout =
1532
+ (event && event.output && event.output.participantsTimeout) ||
1533
+ (event && event.data && event.data.participantsTimeout) ||
1534
+ null
1535
+
1520
1536
  // This prevents overwriting an existing timeout during a simple re-render.
1521
- if (event.data && event.data.participantsTimeout) {
1522
- const timeoutMsecs = event.data.participantsTimeout.msecs
1537
+ if (participantsTimeout) {
1538
+ const timeoutMsecs = participantsTimeout.msecs
1523
1539
  const allParticipantIds = getPlayingParticipantIds(context)
1524
1540
  logger.debug(`[AEM] Starting participants action timeout for ${timeoutMsecs}ms. Responders: ${allParticipantIds.join(', ')}`)
1525
1541
 
@@ -1811,7 +1827,7 @@ const AnearEventMachineFunctions = ({
1811
1827
 
1812
1828
  if (members.length === 0) return { anearParticipant: null }
1813
1829
 
1814
- // event.data in onDone actions is
1830
+ // v5 note: actor resolution value is available on `event.output` in onDone actions:
1815
1831
  // {
1816
1832
  // anearParticipant
1817
1833
  // }
@@ -1958,7 +1974,12 @@ const AnearEventMachineFunctions = ({
1958
1974
  }
1959
1975
  },
1960
1976
  isParticipantsTimeoutActive: ({ context, event }) => {
1961
- const isStartingNewTimeout = event.data && event.data.participantsTimeout && event.data.participantsTimeout.msecs > 0;
1977
+ const participantsTimeout =
1978
+ (event && event.output && event.output.participantsTimeout) ||
1979
+ (event && event.data && event.data.participantsTimeout) ||
1980
+ null
1981
+
1982
+ const isStartingNewTimeout = participantsTimeout && participantsTimeout.msecs > 0
1962
1983
  const isTimeoutAlreadyRunning = context.participantsActionTimeout !== null;
1963
1984
  return isStartingNewTimeout || isTimeoutAlreadyRunning;
1964
1985
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anear-js-api",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Javascript Developer API for Anear Apps",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {