anear-js-api 2.2.0 → 2.2.1

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.
@@ -240,15 +240,19 @@ const ActiveEventStatesConfig = {
240
240
  invoke: {
241
241
  src: 'getAttachedCreatorOrHost',
242
242
  input: ({ context, event }) => ({ context, event }),
243
- onDone: {
244
- // v5 note: onDone of a fromPromise actor provides the resolved value on `event.output`.
245
- // event.output.anearParticipant will be null if no presence enter
246
- // was available on actions channel via get(). We must wait for
247
- // the undeferred PARTICIPANT_ENTER instead. But if get() DID
248
- // return the creator presence, register the participant and continue.
249
- actions: ['startNewParticipantSession', 'sendEnterToAppMachine'],
250
- target: '#eventCreated'
251
- },
243
+ onDone: [
244
+ {
245
+ // If actions-channel presence.get() found creator/host, register now.
246
+ guard: 'hasAttachedCreatorOrHost',
247
+ actions: ['startNewParticipantSession', 'sendEnterToAppMachine'],
248
+ target: '#eventCreated'
249
+ },
250
+ {
251
+ // No creator/host found yet via presence.get(); wait for PARTICIPANT_ENTER.
252
+ actions: ['logWaitingForCreatorPresence'],
253
+ target: '#waiting'
254
+ }
255
+ ],
252
256
  onError: {
253
257
  target: '#failure'
254
258
  }
@@ -2143,6 +2147,7 @@ const AnearEventMachineFunctions = ({
2143
2147
  context.coreServiceMachine.send({ type: 'EVENT_MACHINE_EXIT', eventId: context.anearEvent.id })
2144
2148
  },
2145
2149
  logCreatorEnter: ({ event }) => logger.debug("[AEM] got creator PARTICIPANT_ENTER: ", event.data.id),
2150
+ logWaitingForCreatorPresence: ({ context }) => logger.debug(`[AEM] Event ${context.anearEvent.id} creator/host not found via actions presence.get(); waiting for PARTICIPANT_ENTER`),
2146
2151
  logAPMReady: () => logger.debug('[AEM] participant session registered'),
2147
2152
  logInvalidParticipantEnter: ({ context, event }) => logger.info(`[AEM] Event ${context.anearEvent.id} unexpected PARTICIPANT_ENTER participantId=${event.data.id}`),
2148
2153
  logDeferringAppmFinal: ({ context }) => logger.info(`[AEM] Event ${context.anearEvent.id} deferring APPM_FINAL (already transitioning to terminated)`),
@@ -2533,6 +2538,10 @@ const AnearEventMachineFunctions = ({
2533
2538
  })
2534
2539
  },
2535
2540
  guards: {
2541
+ hasAttachedCreatorOrHost: ({ event }) => {
2542
+ const anearParticipant = event?.output?.anearParticipant ?? event?.data?.anearParticipant
2543
+ return !!anearParticipant
2544
+ },
2536
2545
  isReconnectUpdate: ({ context, event }) => {
2537
2546
  // participant exists and event.data.type is undefined
2538
2547
  return context.participants[event.data.id] && !event.data.type
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anear-js-api",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Javascript Developer API for Anear Apps",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {