@webex/internal-media-core 0.0.10-beta → 0.0.12-beta

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/dist/esm/index.js CHANGED
@@ -2430,8 +2430,7 @@ var getErrorDescription = error => {
2430
2430
  };
2431
2431
 
2432
2432
  var NUM$1 = '\\d+';
2433
- var SDP_TOKEN = "[!#$%&'*+\\-.^_`{|}~a-zA-Z0-9]+";
2434
- var ANY_NON_WS = '\\S+';
2433
+ var TOKEN$1 = '\\S+';
2435
2434
  var SP$1 = '\\s';
2436
2435
  var REST$1 = '.+';
2437
2436
  class Line$1 {}
@@ -2525,7 +2524,7 @@ class CandidateLine$1 extends Line$1 {
2525
2524
  }
2526
2525
  _a$4$1 = CandidateLine$1;
2527
2526
  CandidateLine$1.ICE_CHARS = "[a-zA-Z0-9+/]+";
2528
- CandidateLine$1.regex = new RegExp("^candidate:(".concat(_a$4$1.ICE_CHARS, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS, ") (").concat(NUM$1, ") typ (").concat(ANY_NON_WS, ")(?: raddr (").concat(ANY_NON_WS, "))?(?: rport (").concat(NUM$1, "))?(?: (").concat(REST$1, "))?"));
2527
+ CandidateLine$1.regex = new RegExp("^candidate:(".concat(_a$4$1.ICE_CHARS, ") (").concat(NUM$1, ") (").concat(TOKEN$1, ") (").concat(NUM$1, ") (").concat(TOKEN$1, ") (").concat(NUM$1, ") typ (").concat(TOKEN$1, ")(?: raddr (").concat(TOKEN$1, "))?(?: rport (").concat(NUM$1, "))?(?: (").concat(REST$1, "))?"));
2529
2528
  class ConnectionLine$1 extends Line$1 {
2530
2529
  constructor(netType, addrType, ipAddr) {
2531
2530
  super();
@@ -2547,7 +2546,7 @@ class ConnectionLine$1 extends Line$1 {
2547
2546
  return "c=".concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
2548
2547
  }
2549
2548
  }
2550
- ConnectionLine$1.regex = new RegExp("^(".concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ")"));
2549
+ ConnectionLine$1.regex = new RegExp("^(".concat(TOKEN$1, ") (").concat(TOKEN$1, ") (").concat(TOKEN$1, ")"));
2551
2550
  class ContentLine$1 extends Line$1 {
2552
2551
  constructor(values) {
2553
2552
  super();
@@ -2619,7 +2618,7 @@ class ExtMapLine$1 extends Line$1 {
2619
2618
  }
2620
2619
  _a$3$1 = ExtMapLine$1;
2621
2620
  ExtMapLine$1.EXTMAP_DIRECTION = "sendonly|recvonly|sendrecv|inactive";
2622
- ExtMapLine$1.regex = new RegExp("^extmap:(".concat(NUM$1, ")(?:/(").concat(_a$3$1.EXTMAP_DIRECTION, "))? (").concat(ANY_NON_WS, ")(?: (").concat(REST$1, "))?"));
2621
+ ExtMapLine$1.regex = new RegExp("^extmap:(".concat(NUM$1, ")(?:/(").concat(_a$3$1.EXTMAP_DIRECTION, "))? (").concat(TOKEN$1, ")(?: (").concat(REST$1, "))?"));
2623
2622
  class FingerprintLine$1 extends Line$1 {
2624
2623
  constructor(fingerprint) {
2625
2624
  super();
@@ -2693,7 +2692,7 @@ class IcePwdLine$1 extends Line$1 {
2693
2692
  return "a=ice-pwd:".concat(this.pwd);
2694
2693
  }
2695
2694
  }
2696
- IcePwdLine$1.regex = new RegExp("^ice-pwd:(".concat(ANY_NON_WS, ")$"));
2695
+ IcePwdLine$1.regex = new RegExp("^ice-pwd:(".concat(TOKEN$1, ")$"));
2697
2696
  class IceUfragLine$1 extends Line$1 {
2698
2697
  constructor(ufrag) {
2699
2698
  super();
@@ -2711,7 +2710,7 @@ class IceUfragLine$1 extends Line$1 {
2711
2710
  return "a=ice-ufrag:".concat(this.ufrag);
2712
2711
  }
2713
2712
  }
2714
- IceUfragLine$1.regex = new RegExp("^ice-ufrag:(".concat(ANY_NON_WS, ")$"));
2713
+ IceUfragLine$1.regex = new RegExp("^ice-ufrag:(".concat(TOKEN$1, ")$"));
2715
2714
  class MaxMessageSizeLine$1 extends Line$1 {
2716
2715
  constructor(maxMessageSize) {
2717
2716
  super();
@@ -2756,7 +2755,7 @@ class MediaLine$1 extends Line$1 {
2756
2755
  }
2757
2756
  _a$2$1 = MediaLine$1;
2758
2757
  MediaLine$1.MEDIA_TYPE = 'audio|video|application';
2759
- MediaLine$1.regex = new RegExp("^(".concat(_a$2$1.MEDIA_TYPE, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS, ") (").concat(REST$1, ")"));
2758
+ MediaLine$1.regex = new RegExp("^(".concat(_a$2$1.MEDIA_TYPE, ") (").concat(NUM$1, ") (").concat(TOKEN$1, ") (").concat(REST$1, ")"));
2760
2759
  class MidLine$1 extends Line$1 {
2761
2760
  constructor(mid) {
2762
2761
  super();
@@ -2774,7 +2773,7 @@ class MidLine$1 extends Line$1 {
2774
2773
  return "a=mid:".concat(this.mid);
2775
2774
  }
2776
2775
  }
2777
- MidLine$1.regex = new RegExp("^mid:(".concat(ANY_NON_WS, ")$"));
2776
+ MidLine$1.regex = new RegExp("^mid:(".concat(TOKEN$1, ")$"));
2778
2777
  class OriginLine$1 extends Line$1 {
2779
2778
  constructor(username, sessionId, sessionVersion, netType, addrType, ipAddr) {
2780
2779
  super();
@@ -2802,7 +2801,7 @@ class OriginLine$1 extends Line$1 {
2802
2801
  return "o=".concat(this.username, " ").concat(this.sessionId, " ").concat(this.sessionVersion, " ").concat(this.netType, " ").concat(this.addrType, " ").concat(this.ipAddr);
2803
2802
  }
2804
2803
  }
2805
- OriginLine$1.regex = new RegExp("^(".concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(NUM$1, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ") (").concat(ANY_NON_WS, ")"));
2804
+ OriginLine$1.regex = new RegExp("^(".concat(TOKEN$1, ") (").concat(TOKEN$1, ") (").concat(NUM$1, ") (").concat(TOKEN$1, ") (").concat(TOKEN$1, ") (").concat(TOKEN$1, ")"));
2806
2805
  var _a$1$1;
2807
2806
  class RidLine$1 extends Line$1 {
2808
2807
  constructor(id, direction, params) {
@@ -3070,60 +3069,7 @@ class SimulcastLine$1 extends Line$1 {
3070
3069
  return str;
3071
3070
  }
3072
3071
  }
3073
- SimulcastLine$1.regex = new RegExp("^simulcast:(send|recv) (".concat(ANY_NON_WS, ")(?: (send|recv) (").concat(ANY_NON_WS, "))?"));
3074
- class SsrcLine extends Line$1 {
3075
- constructor(ssrcId, attribute) {
3076
- var attributeValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
3077
- var attributeData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
3078
- super();
3079
- this.ssrcId = ssrcId;
3080
- this.attribute = attribute;
3081
- this.attributeValue = attributeValue;
3082
- this.attributeData = attributeData;
3083
- }
3084
- static fromSdpLine(line) {
3085
- if (!SsrcLine.regex.test(line)) {
3086
- return undefined;
3087
- }
3088
- var tokens = line.match(SsrcLine.regex);
3089
- var ssrcId = parseInt(tokens[1], 10);
3090
- var attribute = tokens[2];
3091
- var attributeValue = tokens[3];
3092
- var attributeData = tokens[4];
3093
- return new SsrcLine(ssrcId, attribute, attributeValue, attributeData);
3094
- }
3095
- toSdpLine() {
3096
- var str = "a=ssrc:".concat(this.ssrcId, " ").concat(this.attribute);
3097
- if (this.attributeValue) {
3098
- str += ":".concat(this.attributeValue);
3099
- }
3100
- if (this.attributeData) {
3101
- str += " ".concat(this.attributeData);
3102
- }
3103
- return str;
3104
- }
3105
- }
3106
- SsrcLine.regex = new RegExp("^ssrc:(".concat(NUM$1, ") (").concat(SDP_TOKEN, ")(?::(").concat(SDP_TOKEN, ")?(?: (").concat(ANY_NON_WS, "))?)?$"));
3107
- class SsrcGroupLine extends Line$1 {
3108
- constructor(semantics, ssrcs) {
3109
- super();
3110
- this.semantics = semantics;
3111
- this.ssrcs = ssrcs;
3112
- }
3113
- static fromSdpLine(line) {
3114
- if (!SsrcGroupLine.regex.test(line)) {
3115
- return undefined;
3116
- }
3117
- var tokens = line.match(SsrcGroupLine.regex);
3118
- var semantics = tokens[1];
3119
- var ssrcs = tokens[2].split(' ').map(ssrcStr => parseInt(ssrcStr, 10));
3120
- return new SsrcGroupLine(semantics, ssrcs);
3121
- }
3122
- toSdpLine() {
3123
- return "a=ssrc-group:".concat(this.semantics, " ").concat(this.ssrcs.join(' '));
3124
- }
3125
- }
3126
- SsrcGroupLine.regex = new RegExp("^ssrc-group:(SIM|FID|FEC) ((?:".concat(NUM$1).concat(SP$1, "*)+)"));
3072
+ SimulcastLine$1.regex = new RegExp("^simulcast:(send|recv) (".concat(TOKEN$1, ")(?: (send|recv) (").concat(TOKEN$1, "))?"));
3127
3073
  class TimingLine$1 extends Line$1 {
3128
3074
  constructor(startTime, stopTime) {
3129
3075
  super();
@@ -3360,8 +3306,6 @@ class AvMediaDescription$1 extends MediaDescription$1 {
3360
3306
  this.rids = [];
3361
3307
  this.codecs = new Map();
3362
3308
  this.rtcpMux = false;
3363
- this.ssrcs = [];
3364
- this.ssrcGroups = [];
3365
3309
  this.pts = mediaLine.formats.map(fmt => {
3366
3310
  return parseInt(fmt, 10);
3367
3311
  });
@@ -3401,8 +3345,6 @@ class AvMediaDescription$1 extends MediaDescription$1 {
3401
3345
  lines.push(new DirectionLine$1(this.direction));
3402
3346
  }
3403
3347
  this.codecs.forEach(codec => lines.push(...codec.toLines()));
3404
- lines.push(...this.ssrcs);
3405
- lines.push(...this.ssrcGroups);
3406
3348
  lines.push(...this.otherLines);
3407
3349
  return lines;
3408
3350
  }
@@ -3441,14 +3383,6 @@ class AvMediaDescription$1 extends MediaDescription$1 {
3441
3383
  codec.addLine(line);
3442
3384
  return true;
3443
3385
  }
3444
- if (line instanceof SsrcLine) {
3445
- this.ssrcs.push(line);
3446
- return true;
3447
- }
3448
- if (line instanceof SsrcGroupLine) {
3449
- this.ssrcGroups.push(line);
3450
- return true;
3451
- }
3452
3386
  this.otherLines.push(line);
3453
3387
  return true;
3454
3388
  }
@@ -3593,8 +3527,6 @@ class SdpGrammar$1 extends Grammar$1 {
3593
3527
  this.addParser('a', RidLine$1.fromSdpLine);
3594
3528
  this.addParser('a', CandidateLine$1.fromSdpLine);
3595
3529
  this.addParser('a', SimulcastLine$1.fromSdpLine);
3596
- this.addParser('a', SsrcLine.fromSdpLine);
3597
- this.addParser('a', SsrcGroupLine.fromSdpLine);
3598
3530
  }
3599
3531
  }
3600
3532
  var DefaultSdpGrammar$1 = new SdpGrammar$1();
@@ -3869,6 +3801,11 @@ function mungeLocalSdp(config, sdp) {
3869
3801
  function setStartBitrate(sdp, startBitrate) {
3870
3802
  appendToH264fmtpParams(sdp, "x-google-start-bitrate=".concat(startBitrate));
3871
3803
  }
3804
+ function removeXtlsIceCandidates(sdp) {
3805
+ sdp.media.forEach(media => {
3806
+ media.iceInfo.candidates = media.iceInfo.candidates.filter(candidate => candidate.transport.toLowerCase() !== 'xtls');
3807
+ });
3808
+ }
3872
3809
  function mungeRemoteSdp(config, sdp) {
3873
3810
  var parsedSdp = parse$2(sdp);
3874
3811
  if (config.startBitrate) {
@@ -3877,6 +3814,7 @@ function mungeRemoteSdp(config, sdp) {
3877
3814
  if (config.disableExtmap) {
3878
3815
  disableExtmap(parsedSdp);
3879
3816
  }
3817
+ removeXtlsIceCandidates(parsedSdp);
3880
3818
  return parsedSdp.toString();
3881
3819
  }
3882
3820
 
@@ -4344,13 +4282,13 @@ class MediaConnection$1 extends EventEmitter$3 {
4344
4282
  };
4345
4283
  var doneGatheringIceCandidates = () => {
4346
4284
  if (!done) {
4347
- var miliseconds = performance.now() - startTime;
4285
+ var milliseconds = performance.now() - startTime;
4348
4286
  this.log('waitForIceCandidates()', "checking SDP...");
4349
4287
  if (!isLocalSdpValid()) {
4350
4288
  this.error('waitForIceCandidates()', 'SDP not valid after waiting.');
4351
4289
  reject(new Error('SDP not valid'));
4352
4290
  }
4353
- this.log('waitForIceCandidates()', "It took ".concat(miliseconds, " miliseconds to gather ice candidates"));
4291
+ this.log('waitForIceCandidates()', "It took ".concat(milliseconds, " milliseconds to gather ice candidates"));
4354
4292
  done = true;
4355
4293
  this.pc.onicegatheringstatechange = null;
4356
4294
  this.pc.onicecandidate = null;
@@ -4380,8 +4318,7 @@ class MediaConnection$1 extends EventEmitter$3 {
4380
4318
  }
4381
4319
  };
4382
4320
  this.pc.onicecandidateerror = event => {
4383
- this.error('waitForIceCandidates()', "onicecandidateerror: ".concat(event));
4384
- reject(new Error('Error gathering ICE candidates'));
4321
+ this.warn('waitForIceCandidates()', "onicecandidateerror: ".concat(event));
4385
4322
  };
4386
4323
  });
4387
4324
  }
@@ -6973,29 +6910,6 @@ function shimRTCIceCandidate$1(window) {
6973
6910
  return e;
6974
6911
  });
6975
6912
  }
6976
- function shimRTCIceCandidateRelayProtocol(window) {
6977
- if (!window.RTCIceCandidate || window.RTCIceCandidate && 'relayProtocol' in window.RTCIceCandidate.prototype) {
6978
- return;
6979
- }
6980
-
6981
- // Hook up the augmented candidate in onicecandidate and
6982
- // addEventListener('icecandidate', ...)
6983
- wrapPeerConnectionEvent$1(window, 'icecandidate', e => {
6984
- if (e.candidate) {
6985
- var parsedCandidate = SDPUtils$1.parseCandidate(e.candidate.candidate);
6986
- if (parsedCandidate.type === 'relay') {
6987
- // This is a libwebrtc-specific mapping of local type preference
6988
- // to relayProtocol.
6989
- e.candidate.relayProtocol = {
6990
- 0: 'tls',
6991
- 1: 'tcp',
6992
- 2: 'udp'
6993
- }[parsedCandidate.priority >> 24];
6994
- }
6995
- }
6996
- return e;
6997
- });
6998
- }
6999
6913
  function shimMaxMessageSize$1(window, browserDetails) {
7000
6914
  if (!window.RTCPeerConnection) {
7001
6915
  return;
@@ -7332,7 +7246,6 @@ function shimParameterlessSetLocalDescription$1(window, browserDetails) {
7332
7246
  var commonShim$1 = /*#__PURE__*/Object.freeze({
7333
7247
  __proto__: null,
7334
7248
  shimRTCIceCandidate: shimRTCIceCandidate$1,
7335
- shimRTCIceCandidateRelayProtocol: shimRTCIceCandidateRelayProtocol,
7336
7249
  shimMaxMessageSize: shimMaxMessageSize$1,
7337
7250
  shimSendThrowTypeError: shimSendThrowTypeError$1,
7338
7251
  shimConnectionState: shimConnectionState$1,
@@ -7400,7 +7313,6 @@ function adapterFactory$1() {
7400
7313
  shimSenderReceiverGetStats$1(window);
7401
7314
  fixNegotiationNeeded$1(window, browserDetails);
7402
7315
  shimRTCIceCandidate$1(window);
7403
- shimRTCIceCandidateRelayProtocol(window);
7404
7316
  shimConnectionState$1(window);
7405
7317
  shimMaxMessageSize$1(window, browserDetails);
7406
7318
  shimSendThrowTypeError$1(window);
@@ -7455,7 +7367,6 @@ function adapterFactory$1() {
7455
7367
  shimGetUserMedia$3(window);
7456
7368
  shimAudioContext$1(window);
7457
7369
  shimRTCIceCandidate$1(window);
7458
- shimRTCIceCandidateRelayProtocol(window);
7459
7370
  shimMaxMessageSize$1(window, browserDetails);
7460
7371
  shimSendThrowTypeError$1(window);
7461
7372
  removeExtmapAllowMixed$1(window, browserDetails);
@@ -8374,44 +8285,18 @@ function error(id, data) {
8374
8285
  };
8375
8286
  return eventObject;
8376
8287
  }
8377
- var pluckAssigns = function pluckAssigns(actionBlocks) {
8378
- var e_1, _a;
8379
- var assignActions = [];
8380
- try {
8381
- for (var actionBlocks_1 = __values(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) {
8382
- var block = actionBlocks_1_1.value;
8383
- var i = 0;
8384
- while (i < block.length) {
8385
- if (block[i].type === assign$2) {
8386
- assignActions.push(block[i]);
8387
- block.splice(i, 1);
8388
- continue;
8389
- }
8390
- i++;
8391
- }
8392
- }
8393
- } catch (e_1_1) {
8394
- e_1 = {
8395
- error: e_1_1
8396
- };
8397
- } finally {
8398
- try {
8399
- if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1);
8400
- } finally {
8401
- if (e_1) throw e_1.error;
8402
- }
8403
- }
8404
- return assignActions;
8405
- };
8406
- function resolveActions(machine, currentState, currentContext, _event, actionBlocks, predictableExec, preserveActionOrder) {
8288
+ function resolveActions(machine, currentState, currentContext, _event, actions, predictableExec, preserveActionOrder) {
8407
8289
  if (preserveActionOrder === void 0) {
8408
8290
  preserveActionOrder = false;
8409
8291
  }
8410
- var assignActions = preserveActionOrder ? [] : pluckAssigns(actionBlocks);
8292
+ var _a = __read(preserveActionOrder ? [[], actions] : partition(actions, function (action) {
8293
+ return action.type === assign$2;
8294
+ }), 2),
8295
+ assignActions = _a[0],
8296
+ otherActions = _a[1];
8411
8297
  var updatedContext = assignActions.length ? updateContext(currentContext, _event, assignActions, currentState) : currentContext;
8412
8298
  var preservedContexts = preserveActionOrder ? [currentContext] : undefined;
8413
- var deferredToBlockEnd = [];
8414
- function handleAction(actionObject) {
8299
+ var resolvedActions = flatten(otherActions.map(function (actionObject) {
8415
8300
  var _a;
8416
8301
  switch (actionObject.type) {
8417
8302
  case raise$1:
@@ -8427,8 +8312,8 @@ function resolveActions(machine, currentState, currentContext, _event, actionBlo
8427
8312
  // tslint:disable-next-line:max-line-length
8428
8313
  "No delay reference for delay expression '".concat(actionObject.delay, "' was found on machine '").concat(machine.id, "'"));
8429
8314
  }
8430
- if (predictableExec && sendAction.to !== SpecialTargets.Internal) {
8431
- deferredToBlockEnd.push(sendAction);
8315
+ if (sendAction.to !== SpecialTargets.Internal) {
8316
+ predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(sendAction, updatedContext, _event);
8432
8317
  }
8433
8318
  return sendAction;
8434
8319
  case log$2:
@@ -8447,7 +8332,7 @@ function resolveActions(machine, currentState, currentContext, _event, actionBlo
8447
8332
  if (!matchedActions) {
8448
8333
  return [];
8449
8334
  }
8450
- var _b = __read(resolveActions(machine, currentState, updatedContext, _event, [toActionObjects(toArray(matchedActions), machine.options.actions)], predictableExec, preserveActionOrder), 2),
8335
+ var _b = __read(resolveActions(machine, currentState, updatedContext, _event, toActionObjects(toArray(matchedActions), machine.options.actions), predictableExec, preserveActionOrder), 2),
8451
8336
  resolvedActionsFromChoose = _b[0],
8452
8337
  resolvedContextFromChoose = _b[1];
8453
8338
  updatedContext = resolvedContextFromChoose;
@@ -8460,7 +8345,7 @@ function resolveActions(machine, currentState, currentContext, _event, actionBlo
8460
8345
  if (!matchedActions) {
8461
8346
  return [];
8462
8347
  }
8463
- var _c = __read(resolveActions(machine, currentState, updatedContext, _event, [toActionObjects(toArray(matchedActions), machine.options.actions)], predictableExec, preserveActionOrder), 2),
8348
+ var _c = __read(resolveActions(machine, currentState, updatedContext, _event, toActionObjects(toArray(matchedActions), machine.options.actions), predictableExec, preserveActionOrder), 2),
8464
8349
  resolvedActionsFromPure = _c[0],
8465
8350
  resolvedContext = _c[1];
8466
8351
  updatedContext = resolvedContext;
@@ -8470,7 +8355,7 @@ function resolveActions(machine, currentState, currentContext, _event, actionBlo
8470
8355
  case stop$1:
8471
8356
  {
8472
8357
  var resolved = resolveStop(actionObject, updatedContext, _event);
8473
- predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, currentContext, _event);
8358
+ predictableExec === null || predictableExec === void 0 ? void 0 : predictableExec(resolved, updatedContext, _event);
8474
8359
  return resolved;
8475
8360
  }
8476
8361
  case assign$2:
@@ -8498,36 +8383,9 @@ function resolveActions(machine, currentState, currentContext, _event, actionBlo
8498
8383
  }
8499
8384
  return resolvedActionObject;
8500
8385
  }
8501
- }
8502
- function processBlock(block) {
8503
- var e_2, _a;
8504
- var resolvedActions = [];
8505
- try {
8506
- for (var block_1 = __values(block), block_1_1 = block_1.next(); !block_1_1.done; block_1_1 = block_1.next()) {
8507
- var action = block_1_1.value;
8508
- var resolved = handleAction(action);
8509
- if (resolved) {
8510
- resolvedActions = resolvedActions.concat(resolved);
8511
- }
8512
- }
8513
- } catch (e_2_1) {
8514
- e_2 = {
8515
- error: e_2_1
8516
- };
8517
- } finally {
8518
- try {
8519
- if (block_1_1 && !block_1_1.done && (_a = block_1.return)) _a.call(block_1);
8520
- } finally {
8521
- if (e_2) throw e_2.error;
8522
- }
8523
- }
8524
- deferredToBlockEnd.forEach(function (action) {
8525
- predictableExec(action, updatedContext, _event);
8526
- });
8527
- deferredToBlockEnd.length = 0;
8528
- return resolvedActions;
8529
- }
8530
- var resolvedActions = flatten(actionBlocks.map(processBlock));
8386
+ }).filter(function (a) {
8387
+ return !!a;
8388
+ }));
8531
8389
  return [resolvedActions, updatedContext];
8532
8390
  }
8533
8391
 
@@ -9276,10 +9134,10 @@ function () {
9276
9134
  * @param options Interpreter options
9277
9135
  */
9278
9136
  function Interpreter(machine, options) {
9137
+ var _this = this;
9279
9138
  if (options === void 0) {
9280
9139
  options = Interpreter.defaultOptions;
9281
9140
  }
9282
- var _this = this;
9283
9141
  this.machine = machine;
9284
9142
  this.delayedEventsMap = {};
9285
9143
  this.listeners = new Set();
@@ -9296,7 +9154,6 @@ function () {
9296
9154
  this.status = InterpreterStatus.NotStarted;
9297
9155
  this.children = new Map();
9298
9156
  this.forwardTo = new Set();
9299
- this._outgoingQueue = [];
9300
9157
  /**
9301
9158
  * Alias for Interpreter.prototype.start
9302
9159
  */
@@ -9332,14 +9189,14 @@ function () {
9332
9189
  _this.scheduler.schedule(function () {
9333
9190
  // Forward copy of event to child actors
9334
9191
  _this.forward(_event);
9335
- var nextState = _this._nextState(_event);
9192
+ var nextState = _this.nextState(_event);
9336
9193
  _this.update(nextState, _event);
9337
9194
  });
9338
9195
  return _this._state; // TODO: deprecate (should return void)
9339
9196
  // tslint:disable-next-line:semicolon
9340
9197
  };
9341
9198
 
9342
- this.sendTo = function (event, to, immediate) {
9199
+ this.sendTo = function (event, to) {
9343
9200
  var isParent = _this.parent && (to === SpecialTargets.Parent || _this.parent.id === to);
9344
9201
  var target = isParent ? _this.parent : isString(to) ? _this.children.get(to) || registry.get(to) : isActor$1(to) ? to : undefined;
9345
9202
  if (!target) {
@@ -9359,23 +9216,14 @@ function () {
9359
9216
  // we need to send events to the parent from exit handlers of a machine that reached its final state
9360
9217
  _this.state.done) {
9361
9218
  // Send SCXML events to machines
9362
- var scxmlEvent = _assign(_assign({}, event), {
9219
+ target.send(_assign(_assign({}, event), {
9363
9220
  name: event.name === error$1 ? "".concat(error(_this.id)) : event.name,
9364
9221
  origin: _this.sessionId
9365
- });
9366
- if (!immediate && _this.machine.config.predictableActionArguments) {
9367
- _this._outgoingQueue.push([target, scxmlEvent]);
9368
- } else {
9369
- target.send(scxmlEvent);
9370
- }
9222
+ }));
9371
9223
  }
9372
9224
  } else {
9373
9225
  // Send normal events to other targets
9374
- if (!immediate && _this.machine.config.predictableActionArguments) {
9375
- _this._outgoingQueue.push([target, event.data]);
9376
- } else {
9377
- target.send(event.data);
9378
- }
9226
+ target.send(event.data);
9379
9227
  }
9380
9228
  };
9381
9229
  this._exec = function (action, context, _event, actionFunctionMap) {
@@ -9412,7 +9260,7 @@ function () {
9412
9260
  return;
9413
9261
  } else {
9414
9262
  if (sendAction.to) {
9415
- _this.sendTo(sendAction._event, sendAction.to, _event === initEvent);
9263
+ _this.sendTo(sendAction._event, sendAction.to);
9416
9264
  } else {
9417
9265
  _this.send(sendAction._event);
9418
9266
  }
@@ -9533,9 +9381,6 @@ function () {
9533
9381
  configurable: true
9534
9382
  });
9535
9383
  Object.defineProperty(Interpreter.prototype, "state", {
9536
- /**
9537
- * @deprecated Use `.getSnapshot()` instead.
9538
- */
9539
9384
  get: function get() {
9540
9385
  if (!IS_PRODUCTION) {
9541
9386
  warn(this.status !== InterpreterStatus.NotStarted, "Attempted to read state from uninitialized service '".concat(this.id, "'. Make sure the service is started first."));
@@ -9584,11 +9429,6 @@ function () {
9584
9429
  // we can't just recompute it (and execute actions while doing so) because we try to preserve identity of actors created within initial assigns
9585
9430
  _event === initEvent) && this.options.execute) {
9586
9431
  this.execute(this.state);
9587
- } else {
9588
- var item = void 0;
9589
- while (item = this._outgoingQueue.shift()) {
9590
- item[0].send(item[1]);
9591
- }
9592
9432
  } // Update children
9593
9433
 
9594
9434
  this.children.forEach(function (child) {
@@ -9672,7 +9512,6 @@ function () {
9672
9512
  }
9673
9513
  }
9674
9514
  this._stop();
9675
- this._stopChildren();
9676
9515
  }
9677
9516
  };
9678
9517
  /*
@@ -9808,15 +9647,6 @@ function () {
9808
9647
  });
9809
9648
  return this;
9810
9649
  };
9811
- Interpreter.prototype._stopChildren = function () {
9812
- // TODO: think about converting those to actions
9813
- this.children.forEach(function (child) {
9814
- if (isFunction(child.stop)) {
9815
- child.stop();
9816
- }
9817
- });
9818
- this.children.clear();
9819
- };
9820
9650
  Interpreter.prototype._stop = function () {
9821
9651
  var e_6, _a, e_7, _b, e_8, _c, e_9, _d, e_10, _e;
9822
9652
  try {
@@ -9940,7 +9770,7 @@ function () {
9940
9770
  }).map(function (stateNode) {
9941
9771
  return toActionObjects(stateNode.onExit, _this.machine.options.actions);
9942
9772
  }));
9943
- var _a = __read(resolveActions(_this.machine, _this.state, _this.state.context, _event, [exitActions], _this.machine.config.predictableActionArguments ? _this._exec : undefined, _this.machine.config.predictableActionArguments || _this.machine.config.preserveActionOrder), 2),
9773
+ var _a = __read(resolveActions(_this.machine, _this.state, _this.state.context, _event, exitActions, _this.machine.config.predictableActionArguments ? _this._exec : undefined, _this.machine.config.predictableActionArguments || _this.machine.config.preserveActionOrder), 2),
9944
9774
  resolvedActions = _a[0],
9945
9775
  updatedContext = _a[1];
9946
9776
  var newState = new State({
@@ -9965,8 +9795,15 @@ function () {
9965
9795
  newState.changed = true;
9966
9796
  return newState;
9967
9797
  });
9968
- _this.update(nextState, _event);
9969
- _this._stopChildren();
9798
+ _this.update(nextState, _event); // TODO: think about converting those to actions
9799
+ // Stop all children
9800
+
9801
+ _this.children.forEach(function (child) {
9802
+ if (isFunction(child.stop)) {
9803
+ child.stop();
9804
+ }
9805
+ });
9806
+ _this.children.clear();
9970
9807
  registry.free(_this.sessionId);
9971
9808
  });
9972
9809
  return this;
@@ -9983,10 +9820,6 @@ function () {
9983
9820
  // tslint:disable-next-line:max-line-length
9984
9821
  "".concat(events.length, " event(s) were sent to uninitialized service \"").concat(this.machine.id, "\". Make sure .start() is called for this service, or set { deferEvents: true } in the service options."));
9985
9822
  }
9986
- if (!events.length) {
9987
- return;
9988
- }
9989
- var exec = !!this.machine.config.predictableActionArguments && this._exec;
9990
9823
  this.scheduler.schedule(function () {
9991
9824
  var e_11, _a;
9992
9825
  var nextState = _this.state;
@@ -9996,9 +9829,9 @@ function () {
9996
9829
  var _event = toSCXMLEvent(event_1);
9997
9830
  _this.forward(_event);
9998
9831
  nextState = provide(_this, function () {
9999
- return _this.machine.transition(nextState, _event, undefined, exec || undefined);
9832
+ return _this.machine.transition(nextState, _event);
10000
9833
  });
10001
- batchedActions.push.apply(batchedActions, __spreadArray([], __read(_this.machine.config.predictableActionArguments ? nextState.actions : nextState.actions.map(function (a) {
9834
+ batchedActions.push.apply(batchedActions, __spreadArray([], __read(nextState.actions.map(function (a) {
10002
9835
  return bindActionToState(a, nextState);
10003
9836
  })), false));
10004
9837
  batchChanged = batchChanged || !!nextState.changed;
@@ -10033,11 +9866,8 @@ function () {
10033
9866
  Interpreter.prototype.sender = function (event) {
10034
9867
  return this.send.bind(this, event);
10035
9868
  };
10036
- Interpreter.prototype._nextState = function (event, exec) {
9869
+ Interpreter.prototype._nextState = function (event) {
10037
9870
  var _this = this;
10038
- if (exec === void 0) {
10039
- exec = !!this.machine.config.predictableActionArguments && this._exec;
10040
- }
10041
9871
  var _event = toSCXMLEvent(event);
10042
9872
  if (_event.name.indexOf(errorPlatform) === 0 && !this.state.nextEvents.some(function (nextEvent) {
10043
9873
  return nextEvent.indexOf(errorPlatform) === 0;
@@ -10045,7 +9875,7 @@ function () {
10045
9875
  throw _event.data.data;
10046
9876
  }
10047
9877
  var nextState = provide(this, function () {
10048
- return _this.machine.transition(_this.state, _event, undefined, exec || undefined);
9878
+ return _this.machine.transition(_this.state, _event, undefined, _this.machine.config.predictableActionArguments ? _this._exec : undefined);
10049
9879
  });
10050
9880
  return nextState;
10051
9881
  };
@@ -10058,7 +9888,7 @@ function () {
10058
9888
  */
10059
9889
 
10060
9890
  Interpreter.prototype.nextState = function (event) {
10061
- return this._nextState(event, false);
9891
+ return this._nextState(event);
10062
9892
  };
10063
9893
  Interpreter.prototype.forward = function (event) {
10064
9894
  var e_12, _a;
@@ -10087,7 +9917,7 @@ function () {
10087
9917
  var _this = this;
10088
9918
  this.delayedEventsMap[sendAction.id] = this.clock.setTimeout(function () {
10089
9919
  if (sendAction.to) {
10090
- _this.sendTo(sendAction._event, sendAction.to, true);
9920
+ _this.sendTo(sendAction._event, sendAction.to);
10091
9921
  } else {
10092
9922
  _this.send(sendAction._event);
10093
9923
  }
@@ -10582,10 +10412,10 @@ function () {
10582
10412
  _context,
10583
10413
  // TODO: this is unsafe, but we're removing it in v5 anyway
10584
10414
  _stateInfo) {
10415
+ var _this = this;
10585
10416
  if (_context === void 0) {
10586
10417
  _context = 'context' in config ? config.context : undefined;
10587
10418
  }
10588
- var _this = this;
10589
10419
  var _a;
10590
10420
  this.config = config;
10591
10421
  this._context = _context;
@@ -11124,14 +10954,13 @@ function () {
11124
10954
  nodes.push(possibleAncestor);
11125
10955
  return nodes;
11126
10956
  };
11127
- StateNode.prototype.getActions = function (resolvedConfig, isDone, transition, currentContext, _event, prevState, predictableExec) {
10957
+ StateNode.prototype.getActions = function (resolvedConfig, isDone, transition, currentContext, _event, prevState) {
11128
10958
  var e_4, _a, e_5, _b;
11129
- var _this = this;
11130
10959
  var prevConfig = getConfiguration([], prevState ? this.getStateNodes(prevState.value) : [this]);
11131
10960
  try {
11132
10961
  for (var resolvedConfig_1 = __values(resolvedConfig), resolvedConfig_1_1 = resolvedConfig_1.next(); !resolvedConfig_1_1.done; resolvedConfig_1_1 = resolvedConfig_1.next()) {
11133
10962
  var sn = resolvedConfig_1_1.value;
11134
- if (!has(prevConfig, sn) || has(transition.entrySet, sn.parent) && !has(transition.entrySet, sn)) {
10963
+ if (!has(prevConfig, sn) || has(transition.entrySet, sn.parent)) {
11135
10964
  transition.entrySet.push(sn);
11136
10965
  }
11137
10966
  }
@@ -11194,19 +11023,18 @@ function () {
11194
11023
  });
11195
11024
  var entryStates = new Set(transition.entrySet);
11196
11025
  var exitStates = new Set(transition.exitSet);
11197
- var entryActions = Array.from(entryStates).map(function (stateNode) {
11198
- var entryActions = stateNode.onEntry;
11199
- var invokeActions = stateNode.activities.map(function (activity) {
11200
- return start(activity);
11201
- });
11202
- return toActionObjects(predictableExec ? __spreadArray(__spreadArray([], __read(entryActions), false), __read(invokeActions), false) : __spreadArray(__spreadArray([], __read(invokeActions), false), __read(entryActions), false), _this.machine.options.actions);
11203
- }).concat([doneEvents.map(raise)]);
11204
- var exitActions = Array.from(exitStates).map(function (stateNode) {
11205
- return toActionObjects(__spreadArray(__spreadArray([], __read(stateNode.onExit), false), __read(stateNode.activities.map(function (activity) {
11206
- return stop(activity);
11207
- })), false), _this.machine.options.actions);
11208
- });
11209
- var actions = exitActions.concat([toActionObjects(transition.actions, this.machine.options.actions)]).concat(entryActions);
11026
+ var _c = __read([flatten(Array.from(entryStates).map(function (stateNode) {
11027
+ return __spreadArray(__spreadArray([], __read(stateNode.activities.map(function (activity) {
11028
+ return start(activity);
11029
+ })), false), __read(stateNode.onEntry), false);
11030
+ })).concat(doneEvents.map(raise)), flatten(Array.from(exitStates).map(function (stateNode) {
11031
+ return __spreadArray(__spreadArray([], __read(stateNode.onExit), false), __read(stateNode.activities.map(function (activity) {
11032
+ return stop(activity);
11033
+ })), false);
11034
+ }))], 2),
11035
+ entryActions = _c[0],
11036
+ exitActions = _c[1];
11037
+ var actions = toActionObjects(exitActions.concat(transition.actions).concat(entryActions), this.machine.options.actions);
11210
11038
  if (isDone) {
11211
11039
  var stopActions = toActionObjects(flatten(__spreadArray([], __read(resolvedConfig), false).sort(function (a, b) {
11212
11040
  return b.order - a.order;
@@ -11215,7 +11043,7 @@ function () {
11215
11043
  })), this.machine.options.actions).filter(function (action) {
11216
11044
  return action.type !== raise$1 && (action.type !== send$1 || !!action.to && action.to !== SpecialTargets.Internal);
11217
11045
  });
11218
- return actions.concat([stopActions]);
11046
+ return actions.concat(stopActions);
11219
11047
  }
11220
11048
  return actions;
11221
11049
  };
@@ -11273,7 +11101,7 @@ function () {
11273
11101
  return state;
11274
11102
  };
11275
11103
  StateNode.prototype.resolveTransition = function (stateTransition, currentState, context, predictableExec, _event) {
11276
- var e_6, _a, e_7, _b;
11104
+ var e_6, _a;
11277
11105
  var _this = this;
11278
11106
  if (_event === void 0) {
11279
11107
  _event = initEvent;
@@ -11287,30 +11115,15 @@ function () {
11287
11115
  var isDone = isInFinalState(resolvedConfiguration, this);
11288
11116
  var resolvedStateValue = willTransition ? getValue(this.machine, configuration) : undefined;
11289
11117
  var historyValue = currentState ? currentState.historyValue ? currentState.historyValue : stateTransition.source ? this.machine.historyValue(currentState.value) : undefined : undefined;
11290
- var actionBlocks = this.getActions(new Set(resolvedConfiguration), isDone, stateTransition, context, _event, currentState, predictableExec);
11118
+ var actions = this.getActions(new Set(resolvedConfiguration), isDone, stateTransition, context, _event, currentState);
11291
11119
  var activities = currentState ? _assign({}, currentState.activities) : {};
11292
11120
  try {
11293
- for (var actionBlocks_1 = __values(actionBlocks), actionBlocks_1_1 = actionBlocks_1.next(); !actionBlocks_1_1.done; actionBlocks_1_1 = actionBlocks_1.next()) {
11294
- var block = actionBlocks_1_1.value;
11295
- try {
11296
- for (var block_1 = (e_7 = void 0, __values(block)), block_1_1 = block_1.next(); !block_1_1.done; block_1_1 = block_1.next()) {
11297
- var action = block_1_1.value;
11298
- if (action.type === start$1) {
11299
- activities[action.activity.id || action.activity.type] = action;
11300
- } else if (action.type === stop$1) {
11301
- activities[action.activity.id || action.activity.type] = false;
11302
- }
11303
- }
11304
- } catch (e_7_1) {
11305
- e_7 = {
11306
- error: e_7_1
11307
- };
11308
- } finally {
11309
- try {
11310
- if (block_1_1 && !block_1_1.done && (_b = block_1.return)) _b.call(block_1);
11311
- } finally {
11312
- if (e_7) throw e_7.error;
11313
- }
11121
+ for (var actions_1 = __values(actions), actions_1_1 = actions_1.next(); !actions_1_1.done; actions_1_1 = actions_1.next()) {
11122
+ var action = actions_1_1.value;
11123
+ if (action.type === start$1) {
11124
+ activities[action.activity.id || action.activity.type] = action;
11125
+ } else if (action.type === stop$1) {
11126
+ activities[action.activity.id || action.activity.type] = false;
11314
11127
  }
11315
11128
  }
11316
11129
  } catch (e_6_1) {
@@ -11319,19 +11132,19 @@ function () {
11319
11132
  };
11320
11133
  } finally {
11321
11134
  try {
11322
- if (actionBlocks_1_1 && !actionBlocks_1_1.done && (_a = actionBlocks_1.return)) _a.call(actionBlocks_1);
11135
+ if (actions_1_1 && !actions_1_1.done && (_a = actions_1.return)) _a.call(actions_1);
11323
11136
  } finally {
11324
11137
  if (e_6) throw e_6.error;
11325
11138
  }
11326
11139
  }
11327
- var _c = __read(resolveActions(this, currentState, context, _event, actionBlocks, predictableExec, this.machine.config.predictableActionArguments || this.machine.config.preserveActionOrder), 2),
11328
- resolvedActions = _c[0],
11329
- updatedContext = _c[1];
11330
- var _d = __read(partition(resolvedActions, function (action) {
11140
+ var _b = __read(resolveActions(this, currentState, context, _event, actions, predictableExec, this.machine.config.predictableActionArguments || this.machine.config.preserveActionOrder), 2),
11141
+ resolvedActions = _b[0],
11142
+ updatedContext = _b[1];
11143
+ var _c = __read(partition(resolvedActions, function (action) {
11331
11144
  return action.type === raise$1 || action.type === send$1 && action.to === SpecialTargets.Internal;
11332
11145
  }), 2),
11333
- raisedEvents = _d[0],
11334
- nonRaisedActions = _d[1];
11146
+ raisedEvents = _c[0],
11147
+ nonRaisedActions = _c[1];
11335
11148
  var invokeActions = resolvedActions.filter(function (action) {
11336
11149
  var _a;
11337
11150
  return action.type === start$1 && ((_a = action.activity) === null || _a === void 0 ? void 0 : _a.type) === invoke;
@@ -11539,7 +11352,7 @@ function () {
11539
11352
  var configuration = this.getStateNodes(stateValue);
11540
11353
  return this.resolveTransition({
11541
11354
  configuration: configuration,
11542
- entrySet: configuration,
11355
+ entrySet: __spreadArray([], __read(configuration), false),
11543
11356
  exitSet: [],
11544
11357
  transitions: [],
11545
11358
  source: undefined,
@@ -11705,7 +11518,7 @@ function () {
11705
11518
  * All the event types accepted by this state node and its descendants.
11706
11519
  */
11707
11520
  get: function get() {
11708
- var e_8, _a, e_9, _b;
11521
+ var e_7, _a, e_8, _b;
11709
11522
  if (this.__cache.events) {
11710
11523
  return this.__cache.events;
11711
11524
  }
@@ -11718,32 +11531,32 @@ function () {
11718
11531
  var state = states[stateId];
11719
11532
  if (state.states) {
11720
11533
  try {
11721
- for (var _e = (e_9 = void 0, __values(state.events)), _f = _e.next(); !_f.done; _f = _e.next()) {
11534
+ for (var _e = (e_8 = void 0, __values(state.events)), _f = _e.next(); !_f.done; _f = _e.next()) {
11722
11535
  var event_1 = _f.value;
11723
11536
  events.add("".concat(event_1));
11724
11537
  }
11725
- } catch (e_9_1) {
11726
- e_9 = {
11727
- error: e_9_1
11538
+ } catch (e_8_1) {
11539
+ e_8 = {
11540
+ error: e_8_1
11728
11541
  };
11729
11542
  } finally {
11730
11543
  try {
11731
11544
  if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
11732
11545
  } finally {
11733
- if (e_9) throw e_9.error;
11546
+ if (e_8) throw e_8.error;
11734
11547
  }
11735
11548
  }
11736
11549
  }
11737
11550
  }
11738
- } catch (e_8_1) {
11739
- e_8 = {
11740
- error: e_8_1
11551
+ } catch (e_7_1) {
11552
+ e_7 = {
11553
+ error: e_7_1
11741
11554
  };
11742
11555
  } finally {
11743
11556
  try {
11744
11557
  if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
11745
11558
  } finally {
11746
- if (e_8) throw e_8.error;
11559
+ if (e_7) throw e_7.error;
11747
11560
  }
11748
11561
  }
11749
11562
  }
@@ -11825,7 +11638,7 @@ function () {
11825
11638
  return transition;
11826
11639
  };
11827
11640
  StateNode.prototype.formatTransitions = function () {
11828
- var e_10, _a;
11641
+ var e_9, _a;
11829
11642
  var _this = this;
11830
11643
  var onConfig;
11831
11644
  if (!this.config.on) {
@@ -11875,15 +11688,15 @@ function () {
11875
11688
  var delayedTransition = delayedTransitions_1_1.value;
11876
11689
  formattedTransitions.push(delayedTransition);
11877
11690
  }
11878
- } catch (e_10_1) {
11879
- e_10 = {
11880
- error: e_10_1
11691
+ } catch (e_9_1) {
11692
+ e_9 = {
11693
+ error: e_9_1
11881
11694
  };
11882
11695
  } finally {
11883
11696
  try {
11884
11697
  if (delayedTransitions_1_1 && !delayedTransitions_1_1.done && (_a = delayedTransitions_1.return)) _a.call(delayedTransitions_1);
11885
11698
  } finally {
11886
- if (e_10) throw e_10.error;
11699
+ if (e_9) throw e_9.error;
11887
11700
  }
11888
11701
  }
11889
11702
  return formattedTransitions;