@azure/web-pubsub-client-protobuf 1.0.0-beta.2 → 1.0.0-beta.3

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.
Files changed (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +24 -9
  3. package/{types/web-pubsub-client-protobuf.d.ts → dist/browser/index.d.ts} +10 -13
  4. package/dist/browser/index.d.ts.map +1 -0
  5. package/{dist-esm/src → dist/browser}/index.js +3 -3
  6. package/dist/browser/index.js.map +1 -0
  7. package/dist/browser/logger.d.ts +5 -0
  8. package/dist/browser/logger.d.ts.map +1 -0
  9. package/{dist-esm/src → dist/browser}/logger.js +1 -1
  10. package/{dist-esm/src → dist/browser}/logger.js.map +1 -1
  11. package/dist/browser/package.json +3 -0
  12. package/dist/browser/webPubSubProtobufProtocol.d.ts +25 -0
  13. package/dist/browser/webPubSubProtobufProtocol.d.ts.map +1 -0
  14. package/{dist-esm/src → dist/browser}/webPubSubProtobufProtocol.js +10 -12
  15. package/dist/browser/webPubSubProtobufProtocol.js.map +1 -0
  16. package/dist/browser/webPubSubProtobufProtocolBase.d.ts +20 -0
  17. package/dist/browser/webPubSubProtobufProtocolBase.d.ts.map +1 -0
  18. package/{dist-esm/src → dist/browser}/webPubSubProtobufProtocolBase.js +2 -2
  19. package/dist/browser/webPubSubProtobufProtocolBase.js.map +1 -0
  20. package/dist/browser/webPubSubProtobufReliableProtocol.d.ts +25 -0
  21. package/dist/browser/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
  22. package/{dist-esm/src → dist/browser}/webPubSubProtobufReliableProtocol.js +10 -12
  23. package/dist/browser/webPubSubProtobufReliableProtocol.js.map +1 -0
  24. package/dist/{index.js → commonjs/generated/clientProto.js} +192 -3095
  25. package/dist/commonjs/index.d.ts +10 -0
  26. package/dist/commonjs/index.d.ts.map +1 -0
  27. package/dist/commonjs/index.js +22 -0
  28. package/dist/commonjs/index.js.map +1 -0
  29. package/dist/commonjs/logger.d.ts +5 -0
  30. package/dist/commonjs/logger.d.ts.map +1 -0
  31. package/dist/commonjs/logger.js +11 -0
  32. package/dist/commonjs/logger.js.map +1 -0
  33. package/dist/commonjs/package.json +3 -0
  34. package/dist/commonjs/tsdoc-metadata.json +11 -0
  35. package/dist/commonjs/webPubSubProtobufProtocol.d.ts +25 -0
  36. package/dist/commonjs/webPubSubProtobufProtocol.d.ts.map +1 -0
  37. package/dist/commonjs/webPubSubProtobufProtocol.js +35 -0
  38. package/dist/commonjs/webPubSubProtobufProtocol.js.map +1 -0
  39. package/dist/commonjs/webPubSubProtobufProtocolBase.d.ts +20 -0
  40. package/dist/commonjs/webPubSubProtobufProtocolBase.d.ts.map +1 -0
  41. package/dist/commonjs/webPubSubProtobufProtocolBase.js +191 -0
  42. package/dist/commonjs/webPubSubProtobufProtocolBase.js.map +1 -0
  43. package/dist/commonjs/webPubSubProtobufReliableProtocol.d.ts +25 -0
  44. package/dist/commonjs/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
  45. package/dist/commonjs/webPubSubProtobufReliableProtocol.js +35 -0
  46. package/dist/commonjs/webPubSubProtobufReliableProtocol.js.map +1 -0
  47. package/dist/esm/generated/clientProto.d.ts +1668 -0
  48. package/{dist-esm/src → dist/esm}/generated/clientProto.js +45 -15
  49. package/dist/esm/index.d.ts +10 -0
  50. package/dist/esm/index.d.ts.map +1 -0
  51. package/dist/esm/index.js +17 -0
  52. package/dist/esm/index.js.map +1 -0
  53. package/dist/esm/logger.d.ts +5 -0
  54. package/dist/esm/logger.d.ts.map +1 -0
  55. package/dist/esm/logger.js +8 -0
  56. package/dist/esm/logger.js.map +1 -0
  57. package/dist/esm/package.json +3 -0
  58. package/dist/esm/webPubSubProtobufProtocol.d.ts +25 -0
  59. package/dist/esm/webPubSubProtobufProtocol.d.ts.map +1 -0
  60. package/dist/esm/webPubSubProtobufProtocol.js +31 -0
  61. package/dist/esm/webPubSubProtobufProtocol.js.map +1 -0
  62. package/dist/esm/webPubSubProtobufProtocolBase.d.ts +20 -0
  63. package/dist/esm/webPubSubProtobufProtocolBase.d.ts.map +1 -0
  64. package/dist/esm/webPubSubProtobufProtocolBase.js +187 -0
  65. package/dist/esm/webPubSubProtobufProtocolBase.js.map +1 -0
  66. package/dist/esm/webPubSubProtobufReliableProtocol.d.ts +25 -0
  67. package/dist/esm/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
  68. package/dist/esm/webPubSubProtobufReliableProtocol.js +31 -0
  69. package/dist/esm/webPubSubProtobufReliableProtocol.js.map +1 -0
  70. package/dist/react-native/index.d.ts +10 -0
  71. package/dist/react-native/index.d.ts.map +1 -0
  72. package/dist/react-native/index.js +17 -0
  73. package/dist/react-native/index.js.map +1 -0
  74. package/dist/react-native/logger.d.ts +5 -0
  75. package/dist/react-native/logger.d.ts.map +1 -0
  76. package/dist/react-native/logger.js +8 -0
  77. package/dist/react-native/logger.js.map +1 -0
  78. package/dist/react-native/package.json +3 -0
  79. package/dist/react-native/webPubSubProtobufProtocol.d.ts +25 -0
  80. package/dist/react-native/webPubSubProtobufProtocol.d.ts.map +1 -0
  81. package/dist/react-native/webPubSubProtobufProtocol.js +31 -0
  82. package/dist/react-native/webPubSubProtobufProtocol.js.map +1 -0
  83. package/dist/react-native/webPubSubProtobufProtocolBase.d.ts +20 -0
  84. package/dist/react-native/webPubSubProtobufProtocolBase.d.ts.map +1 -0
  85. package/dist/react-native/webPubSubProtobufProtocolBase.js +187 -0
  86. package/dist/react-native/webPubSubProtobufProtocolBase.js.map +1 -0
  87. package/dist/react-native/webPubSubProtobufReliableProtocol.d.ts +25 -0
  88. package/dist/react-native/webPubSubProtobufReliableProtocol.d.ts.map +1 -0
  89. package/dist/react-native/webPubSubProtobufReliableProtocol.js +31 -0
  90. package/dist/react-native/webPubSubProtobufReliableProtocol.js.map +1 -0
  91. package/package.json +88 -90
  92. package/dist/index.js.map +0 -1
  93. package/dist-esm/samples-dev/basicusage.js +0 -63
  94. package/dist-esm/samples-dev/basicusage.js.map +0 -1
  95. package/dist-esm/src/index.js.map +0 -1
  96. package/dist-esm/src/webPubSubProtobufProtocol.js.map +0 -1
  97. package/dist-esm/src/webPubSubProtobufProtocolBase.js.map +0 -1
  98. package/dist-esm/src/webPubSubProtobufReliableProtocol.js.map +0 -1
  99. package/dist-esm/test/client.spec.js +0 -294
  100. package/dist-esm/test/client.spec.js.map +0 -1
@@ -150,12 +150,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
150
150
  * @throws {Error} If the payload is not a reader or valid buffer
151
151
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
152
152
  */
153
- UpstreamMessage.decode = function decode(reader, length) {
153
+ UpstreamMessage.decode = function decode(reader, length, error) {
154
154
  if (!(reader instanceof $Reader))
155
155
  reader = $Reader.create(reader);
156
156
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage();
157
157
  while (reader.pos < end) {
158
158
  let tag = reader.uint32();
159
+ if (tag === error)
160
+ break;
159
161
  switch (tag >>> 3) {
160
162
  case 1: {
161
163
  message.sendToGroupMessage = $root.UpstreamMessage.SendToGroupMessage.decode(reader, reader.uint32());
@@ -514,12 +516,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
514
516
  * @throws {Error} If the payload is not a reader or valid buffer
515
517
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
516
518
  */
517
- SendToGroupMessage.decode = function decode(reader, length) {
519
+ SendToGroupMessage.decode = function decode(reader, length, error) {
518
520
  if (!(reader instanceof $Reader))
519
521
  reader = $Reader.create(reader);
520
522
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.SendToGroupMessage();
521
523
  while (reader.pos < end) {
522
524
  let tag = reader.uint32();
525
+ if (tag === error)
526
+ break;
523
527
  switch (tag >>> 3) {
524
528
  case 1: {
525
529
  message.group = reader.string();
@@ -814,12 +818,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
814
818
  * @throws {Error} If the payload is not a reader or valid buffer
815
819
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
816
820
  */
817
- EventMessage.decode = function decode(reader, length) {
821
+ EventMessage.decode = function decode(reader, length, error) {
818
822
  if (!(reader instanceof $Reader))
819
823
  reader = $Reader.create(reader);
820
824
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.EventMessage();
821
825
  while (reader.pos < end) {
822
826
  let tag = reader.uint32();
827
+ if (tag === error)
828
+ break;
823
829
  switch (tag >>> 3) {
824
830
  case 1: {
825
831
  message.event = reader.string();
@@ -1087,12 +1093,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
1087
1093
  * @throws {Error} If the payload is not a reader or valid buffer
1088
1094
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
1089
1095
  */
1090
- JoinGroupMessage.decode = function decode(reader, length) {
1096
+ JoinGroupMessage.decode = function decode(reader, length, error) {
1091
1097
  if (!(reader instanceof $Reader))
1092
1098
  reader = $Reader.create(reader);
1093
1099
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.JoinGroupMessage();
1094
1100
  while (reader.pos < end) {
1095
1101
  let tag = reader.uint32();
1102
+ if (tag === error)
1103
+ break;
1096
1104
  switch (tag >>> 3) {
1097
1105
  case 1: {
1098
1106
  message.group = reader.string();
@@ -1342,12 +1350,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
1342
1350
  * @throws {Error} If the payload is not a reader or valid buffer
1343
1351
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
1344
1352
  */
1345
- LeaveGroupMessage.decode = function decode(reader, length) {
1353
+ LeaveGroupMessage.decode = function decode(reader, length, error) {
1346
1354
  if (!(reader instanceof $Reader))
1347
1355
  reader = $Reader.create(reader);
1348
1356
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.LeaveGroupMessage();
1349
1357
  while (reader.pos < end) {
1350
1358
  let tag = reader.uint32();
1359
+ if (tag === error)
1360
+ break;
1351
1361
  switch (tag >>> 3) {
1352
1362
  case 1: {
1353
1363
  message.group = reader.string();
@@ -1572,12 +1582,14 @@ export const UpstreamMessage = $root.UpstreamMessage = (() => {
1572
1582
  * @throws {Error} If the payload is not a reader or valid buffer
1573
1583
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
1574
1584
  */
1575
- SequenceAckMessage.decode = function decode(reader, length) {
1585
+ SequenceAckMessage.decode = function decode(reader, length, error) {
1576
1586
  if (!(reader instanceof $Reader))
1577
1587
  reader = $Reader.create(reader);
1578
1588
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UpstreamMessage.SequenceAckMessage();
1579
1589
  while (reader.pos < end) {
1580
1590
  let tag = reader.uint32();
1591
+ if (tag === error)
1592
+ break;
1581
1593
  switch (tag >>> 3) {
1582
1594
  case 1: {
1583
1595
  message.sequenceId = reader.uint64();
@@ -1828,12 +1840,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
1828
1840
  * @throws {Error} If the payload is not a reader or valid buffer
1829
1841
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
1830
1842
  */
1831
- DownstreamMessage.decode = function decode(reader, length) {
1843
+ DownstreamMessage.decode = function decode(reader, length, error) {
1832
1844
  if (!(reader instanceof $Reader))
1833
1845
  reader = $Reader.create(reader);
1834
1846
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage();
1835
1847
  while (reader.pos < end) {
1836
1848
  let tag = reader.uint32();
1849
+ if (tag === error)
1850
+ break;
1837
1851
  switch (tag >>> 3) {
1838
1852
  case 1: {
1839
1853
  message.ackMessage = $root.DownstreamMessage.AckMessage.decode(reader, reader.uint32());
@@ -2122,12 +2136,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
2122
2136
  * @throws {Error} If the payload is not a reader or valid buffer
2123
2137
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
2124
2138
  */
2125
- AckMessage.decode = function decode(reader, length) {
2139
+ AckMessage.decode = function decode(reader, length, error) {
2126
2140
  if (!(reader instanceof $Reader))
2127
2141
  reader = $Reader.create(reader);
2128
2142
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.AckMessage();
2129
2143
  while (reader.pos < end) {
2130
2144
  let tag = reader.uint32();
2145
+ if (tag === error)
2146
+ break;
2131
2147
  switch (tag >>> 3) {
2132
2148
  case 1: {
2133
2149
  message.ackId = reader.uint64();
@@ -2383,12 +2399,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
2383
2399
  * @throws {Error} If the payload is not a reader or valid buffer
2384
2400
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
2385
2401
  */
2386
- ErrorMessage.decode = function decode(reader, length) {
2402
+ ErrorMessage.decode = function decode(reader, length, error) {
2387
2403
  if (!(reader instanceof $Reader))
2388
2404
  reader = $Reader.create(reader);
2389
2405
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.AckMessage.ErrorMessage();
2390
2406
  while (reader.pos < end) {
2391
2407
  let tag = reader.uint32();
2408
+ if (tag === error)
2409
+ break;
2392
2410
  switch (tag >>> 3) {
2393
2411
  case 1: {
2394
2412
  message.name = reader.string();
@@ -2660,12 +2678,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
2660
2678
  * @throws {Error} If the payload is not a reader or valid buffer
2661
2679
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
2662
2680
  */
2663
- DataMessage.decode = function decode(reader, length) {
2681
+ DataMessage.decode = function decode(reader, length, error) {
2664
2682
  if (!(reader instanceof $Reader))
2665
2683
  reader = $Reader.create(reader);
2666
2684
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.DataMessage();
2667
2685
  while (reader.pos < end) {
2668
2686
  let tag = reader.uint32();
2687
+ if (tag === error)
2688
+ break;
2669
2689
  switch (tag >>> 3) {
2670
2690
  case 1: {
2671
2691
  message.from = reader.string();
@@ -2949,12 +2969,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
2949
2969
  * @throws {Error} If the payload is not a reader or valid buffer
2950
2970
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
2951
2971
  */
2952
- SystemMessage.decode = function decode(reader, length) {
2972
+ SystemMessage.decode = function decode(reader, length, error) {
2953
2973
  if (!(reader instanceof $Reader))
2954
2974
  reader = $Reader.create(reader);
2955
2975
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage();
2956
2976
  while (reader.pos < end) {
2957
2977
  let tag = reader.uint32();
2978
+ if (tag === error)
2979
+ break;
2958
2980
  switch (tag >>> 3) {
2959
2981
  case 1: {
2960
2982
  message.connectedMessage = $root.DownstreamMessage.SystemMessage.ConnectedMessage.decode(reader, reader.uint32());
@@ -3205,12 +3227,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
3205
3227
  * @throws {Error} If the payload is not a reader or valid buffer
3206
3228
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
3207
3229
  */
3208
- ConnectedMessage.decode = function decode(reader, length) {
3230
+ ConnectedMessage.decode = function decode(reader, length, error) {
3209
3231
  if (!(reader instanceof $Reader))
3210
3232
  reader = $Reader.create(reader);
3211
3233
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage.ConnectedMessage();
3212
3234
  while (reader.pos < end) {
3213
3235
  let tag = reader.uint32();
3236
+ if (tag === error)
3237
+ break;
3214
3238
  switch (tag >>> 3) {
3215
3239
  case 1: {
3216
3240
  message.connectionId = reader.string();
@@ -3433,12 +3457,14 @@ export const DownstreamMessage = $root.DownstreamMessage = (() => {
3433
3457
  * @throws {Error} If the payload is not a reader or valid buffer
3434
3458
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
3435
3459
  */
3436
- DisconnectedMessage.decode = function decode(reader, length) {
3460
+ DisconnectedMessage.decode = function decode(reader, length, error) {
3437
3461
  if (!(reader instanceof $Reader))
3438
3462
  reader = $Reader.create(reader);
3439
3463
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.DownstreamMessage.SystemMessage.DisconnectedMessage();
3440
3464
  while (reader.pos < end) {
3441
3465
  let tag = reader.uint32();
3466
+ if (tag === error)
3467
+ break;
3442
3468
  switch (tag >>> 3) {
3443
3469
  case 2: {
3444
3470
  message.reason = reader.string();
@@ -3689,12 +3715,14 @@ export const MessageData = $root.MessageData = (() => {
3689
3715
  * @throws {Error} If the payload is not a reader or valid buffer
3690
3716
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
3691
3717
  */
3692
- MessageData.decode = function decode(reader, length) {
3718
+ MessageData.decode = function decode(reader, length, error) {
3693
3719
  if (!(reader instanceof $Reader))
3694
3720
  reader = $Reader.create(reader);
3695
3721
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.MessageData();
3696
3722
  while (reader.pos < end) {
3697
3723
  let tag = reader.uint32();
3724
+ if (tag === error)
3725
+ break;
3698
3726
  switch (tag >>> 3) {
3699
3727
  case 1: {
3700
3728
  message.textData = reader.string();
@@ -3988,12 +4016,14 @@ export const google = $root.google = (() => {
3988
4016
  * @throws {Error} If the payload is not a reader or valid buffer
3989
4017
  * @throws {$protobuf.util.ProtocolError} If required fields are missing
3990
4018
  */
3991
- Any.decode = function decode(reader, length) {
4019
+ Any.decode = function decode(reader, length, error) {
3992
4020
  if (!(reader instanceof $Reader))
3993
4021
  reader = $Reader.create(reader);
3994
4022
  let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any();
3995
4023
  while (reader.pos < end) {
3996
4024
  let tag = reader.uint32();
4025
+ if (tag === error)
4026
+ break;
3997
4027
  switch (tag >>> 3) {
3998
4028
  case 1: {
3999
4029
  message.type_url = reader.string();
@@ -0,0 +1,10 @@
1
+ import type { WebPubSubClientProtocol } from "@azure/web-pubsub-client";
2
+ /**
3
+ * Return the "protobuf.webpubsub.azure.v1" protocol
4
+ */
5
+ export declare const WebPubSubProtobufProtocol: () => WebPubSubClientProtocol;
6
+ /**
7
+ * Return the "protobuf.reliable.webpubsub.azure.v1" protocol
8
+ */
9
+ export declare const WebPubSubProtobufReliableProtocol: () => WebPubSubClientProtocol;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAIxE;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAO,uBAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,QAAO,uBAEpD,CAAC"}
@@ -0,0 +1,17 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { WebPubSubProtobufProtocolImpl } from "./webPubSubProtobufProtocol.js";
4
+ import { WebPubSubProtobufReliableProtocolImpl } from "./webPubSubProtobufReliableProtocol.js";
5
+ /**
6
+ * Return the "protobuf.webpubsub.azure.v1" protocol
7
+ */
8
+ export const WebPubSubProtobufProtocol = () => {
9
+ return new WebPubSubProtobufProtocolImpl();
10
+ };
11
+ /**
12
+ * Return the "protobuf.reliable.webpubsub.azure.v1" protocol
13
+ */
14
+ export const WebPubSubProtobufReliableProtocol = () => {
15
+ return new WebPubSubProtobufReliableProtocolImpl();
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,wCAAwC,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAA4B,EAAE;IACrE,OAAO,IAAI,6BAA6B,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAA4B,EAAE;IAC7E,OAAO,IAAI,qCAAqC,EAAE,CAAC;AACrD,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { WebPubSubClientProtocol } from \"@azure/web-pubsub-client\";\nimport { WebPubSubProtobufProtocolImpl } from \"./webPubSubProtobufProtocol.js\";\nimport { WebPubSubProtobufReliableProtocolImpl } from \"./webPubSubProtobufReliableProtocol.js\";\n\n/**\n * Return the \"protobuf.webpubsub.azure.v1\" protocol\n */\nexport const WebPubSubProtobufProtocol = (): WebPubSubClientProtocol => {\n return new WebPubSubProtobufProtocolImpl();\n};\n\n/**\n * Return the \"protobuf.reliable.webpubsub.azure.v1\" protocol\n */\nexport const WebPubSubProtobufReliableProtocol = (): WebPubSubClientProtocol => {\n return new WebPubSubProtobufReliableProtocolImpl();\n};\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The \@azure\/logger configuration for this package.
3
+ */
4
+ export declare const logger: import("@azure/logger").AzureLogger;
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,MAAM,qCAAmD,CAAC"}
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { createClientLogger } from "@azure/logger";
4
+ /**
5
+ * The \@azure\/logger configuration for this package.
6
+ */
7
+ export const logger = createClientLogger("web-pubsub-client-protobuf");
8
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure\\/logger configuration for this package.\n */\nexport const logger = createClientLogger(\"web-pubsub-client-protobuf\");\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,25 @@
1
+ import type { WebPubSubMessage, WebPubSubClientProtocol } from "@azure/web-pubsub-client";
2
+ /**
3
+ * The "protobuf.reliable.webpubsub.azure.v1" protocol
4
+ */
5
+ export declare class WebPubSubProtobufProtocolImpl implements WebPubSubClientProtocol {
6
+ /**
7
+ * True if the protocol supports reliable features
8
+ */
9
+ readonly isReliableSubProtocol = false;
10
+ /**
11
+ * The name of subprotocol. Name will be used in websocket subprotocol
12
+ */
13
+ readonly name = "protobuf.webpubsub.azure.v1";
14
+ /**
15
+ * Creates WebPubSubMessage objects from the specified serialized representation.
16
+ * @param input - The serialized representation
17
+ */
18
+ parseMessages(input: ArrayBuffer): WebPubSubMessage | null;
19
+ /**
20
+ * Write WebPubSubMessage to string
21
+ * @param message - The message to be written
22
+ */
23
+ writeMessage(message: WebPubSubMessage): ArrayBuffer;
24
+ }
25
+ //# sourceMappingURL=webPubSubProtobufProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufProtocol.d.ts","sourceRoot":"","sources":["../../src/webPubSubProtobufProtocol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAG1F;;GAEG;AACH,qBAAa,6BAA8B,YAAW,uBAAuB;IAC3E;;OAEG;IACH,SAAgB,qBAAqB,SAAS;IAE9C;;OAEG;IACH,SAAgB,IAAI,iCAAiC;IAErD;;;OAGG;IACI,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI;IAIjE;;;OAGG;IACI,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW;CAG5D"}
@@ -0,0 +1,31 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { WebPubSubProtobufProtocolBase } from "./webPubSubProtobufProtocolBase.js";
4
+ /**
5
+ * The "protobuf.reliable.webpubsub.azure.v1" protocol
6
+ */
7
+ export class WebPubSubProtobufProtocolImpl {
8
+ /**
9
+ * True if the protocol supports reliable features
10
+ */
11
+ isReliableSubProtocol = false;
12
+ /**
13
+ * The name of subprotocol. Name will be used in websocket subprotocol
14
+ */
15
+ name = "protobuf.webpubsub.azure.v1";
16
+ /**
17
+ * Creates WebPubSubMessage objects from the specified serialized representation.
18
+ * @param input - The serialized representation
19
+ */
20
+ parseMessages(input) {
21
+ return WebPubSubProtobufProtocolBase.parseMessages(input);
22
+ }
23
+ /**
24
+ * Write WebPubSubMessage to string
25
+ * @param message - The message to be written
26
+ */
27
+ writeMessage(message) {
28
+ return WebPubSubProtobufProtocolBase.writeMessage(message);
29
+ }
30
+ }
31
+ //# sourceMappingURL=webPubSubProtobufProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufProtocol.js","sourceRoot":"","sources":["../../src/webPubSubProtobufProtocol.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,6BAA6B;IACxC;;OAEG;IACa,qBAAqB,GAAG,KAAK,CAAC;IAE9C;;OAEG;IACa,IAAI,GAAG,6BAA6B,CAAC;IAErD;;;OAGG;IACI,aAAa,CAAC,KAAkB;QACrC,OAAO,6BAA6B,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,OAAyB;QAC3C,OAAO,6BAA6B,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { WebPubSubMessage, WebPubSubClientProtocol } from \"@azure/web-pubsub-client\";\nimport { WebPubSubProtobufProtocolBase } from \"./webPubSubProtobufProtocolBase.js\";\n\n/**\n * The \"protobuf.reliable.webpubsub.azure.v1\" protocol\n */\nexport class WebPubSubProtobufProtocolImpl implements WebPubSubClientProtocol {\n /**\n * True if the protocol supports reliable features\n */\n public readonly isReliableSubProtocol = false;\n\n /**\n * The name of subprotocol. Name will be used in websocket subprotocol\n */\n public readonly name = \"protobuf.webpubsub.azure.v1\";\n\n /**\n * Creates WebPubSubMessage objects from the specified serialized representation.\n * @param input - The serialized representation\n */\n public parseMessages(input: ArrayBuffer): WebPubSubMessage | null {\n return WebPubSubProtobufProtocolBase.parseMessages(input);\n }\n\n /**\n * Write WebPubSubMessage to string\n * @param message - The message to be written\n */\n public writeMessage(message: WebPubSubMessage): ArrayBuffer {\n return WebPubSubProtobufProtocolBase.writeMessage(message);\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { WebPubSubMessage } from "@azure/web-pubsub-client";
2
+ /**
3
+ * The "protobuf.reliable.webpubsub.azure.v1" protocol
4
+ */
5
+ export declare class WebPubSubProtobufProtocolBase {
6
+ /**
7
+ * Creates WebPubSubMessage objects from the specified serialized representation.
8
+ * @param input - The serialized representation
9
+ */
10
+ static parseMessages(input: ArrayBuffer): WebPubSubMessage | null;
11
+ /**
12
+ * Write WebPubSubMessage to string
13
+ * @param message - The message to be written
14
+ */
15
+ static writeMessage(message: WebPubSubMessage): ArrayBuffer;
16
+ private static _getIMessageData;
17
+ private static _getNumber;
18
+ private static _isIAny;
19
+ }
20
+ //# sourceMappingURL=webPubSubProtobufProtocolBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufProtocolBase.d.ts","sourceRoot":"","sources":["../../src/webPubSubProtobufProtocolBase.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAQV,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAUlC;;GAEG;AACH,qBAAa,6BAA6B;IACxC;;;OAGG;WACW,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI;IA6ExE;;;OAGG;WACW,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW;IAoDlE,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAgC/B,OAAO,CAAC,MAAM,CAAC,UAAU;IAOzB,OAAO,CAAC,MAAM,CAAC,OAAO;CAGvB"}
@@ -0,0 +1,187 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { DownstreamMessage, MessageData, UpstreamMessage, google, } from "./generated/clientProto.js";
4
+ /**
5
+ * The "protobuf.reliable.webpubsub.azure.v1" protocol
6
+ */
7
+ export class WebPubSubProtobufProtocolBase {
8
+ /**
9
+ * Creates WebPubSubMessage objects from the specified serialized representation.
10
+ * @param input - The serialized representation
11
+ */
12
+ static parseMessages(input) {
13
+ const downstream = DownstreamMessage.decode(new Uint8Array(input));
14
+ if (downstream.ackMessage) {
15
+ const ack = {
16
+ kind: "ack",
17
+ ackId: this._getNumber(downstream.ackMessage.ackId),
18
+ success: downstream.ackMessage.success,
19
+ };
20
+ if (downstream.ackMessage.error) {
21
+ ack.error = {
22
+ name: downstream.ackMessage.error.name,
23
+ message: downstream.ackMessage.error.message,
24
+ };
25
+ }
26
+ return ack;
27
+ }
28
+ else if (downstream.systemMessage) {
29
+ if (downstream.systemMessage.connectedMessage) {
30
+ const msg = downstream.systemMessage.connectedMessage;
31
+ return {
32
+ kind: "connected",
33
+ connectionId: msg.connectionId,
34
+ userId: msg.userId,
35
+ reconnectionToken: msg.reconnectionToken,
36
+ };
37
+ }
38
+ else if (downstream.systemMessage.disconnectedMessage) {
39
+ const msg = downstream.systemMessage.disconnectedMessage;
40
+ return { kind: "disconnected", message: msg.reason };
41
+ }
42
+ else {
43
+ return null;
44
+ }
45
+ }
46
+ else if (downstream.dataMessage) {
47
+ const sequenceId = this._getNumber(downstream.dataMessage.sequenceId);
48
+ const messageData = downstream.dataMessage.data;
49
+ let dataType;
50
+ let data;
51
+ if (messageData.textData) {
52
+ dataType = "text";
53
+ data = messageData.textData;
54
+ }
55
+ else if (messageData.jsonData) {
56
+ dataType = "json";
57
+ data = JSON.parse(messageData.jsonData);
58
+ }
59
+ else if (messageData.binaryData) {
60
+ dataType = "binary";
61
+ data = messageData.binaryData.buffer.slice(messageData.binaryData.byteOffset, messageData.binaryData.byteLength + messageData.binaryData.byteOffset);
62
+ }
63
+ else if (messageData.protobufData) {
64
+ dataType = "protobuf";
65
+ data = messageData.protobufData;
66
+ }
67
+ else {
68
+ return null;
69
+ }
70
+ if (downstream.dataMessage.from === "group") {
71
+ return {
72
+ kind: "groupData",
73
+ dataType: dataType,
74
+ data: data,
75
+ sequenceId: sequenceId,
76
+ group: downstream.dataMessage.group,
77
+ };
78
+ }
79
+ else if (downstream.dataMessage.from === "server") {
80
+ return {
81
+ kind: "serverData",
82
+ dataType: dataType,
83
+ data: data,
84
+ sequenceId: sequenceId,
85
+ };
86
+ }
87
+ else {
88
+ return null;
89
+ }
90
+ }
91
+ else {
92
+ return null;
93
+ }
94
+ }
95
+ /**
96
+ * Write WebPubSubMessage to string
97
+ * @param message - The message to be written
98
+ */
99
+ static writeMessage(message) {
100
+ let upstream;
101
+ switch (message.kind) {
102
+ case "joinGroup": {
103
+ const joinGroup = UpstreamMessage.JoinGroupMessage.create({
104
+ group: message.group,
105
+ ackId: message.ackId,
106
+ });
107
+ upstream = UpstreamMessage.create({ joinGroupMessage: joinGroup });
108
+ break;
109
+ }
110
+ case "leaveGroup": {
111
+ const leaveGroup = UpstreamMessage.LeaveGroupMessage.create({
112
+ group: message.group,
113
+ ackId: message.ackId,
114
+ });
115
+ upstream = UpstreamMessage.create({ leaveGroupMessage: leaveGroup });
116
+ break;
117
+ }
118
+ case "sendToGroup": {
119
+ const sendToGroup = UpstreamMessage.SendToGroupMessage.create({
120
+ group: message.group,
121
+ ackId: message.ackId,
122
+ data: this._getIMessageData(message.data, message.dataType),
123
+ noEcho: message.noEcho,
124
+ });
125
+ upstream = UpstreamMessage.create({ sendToGroupMessage: sendToGroup });
126
+ break;
127
+ }
128
+ case "sendEvent": {
129
+ const sendEvent = UpstreamMessage.EventMessage.create({
130
+ event: message.event,
131
+ ackId: message.ackId,
132
+ data: this._getIMessageData(message.data, message.dataType),
133
+ });
134
+ upstream = UpstreamMessage.create({ eventMessage: sendEvent });
135
+ break;
136
+ }
137
+ case "sequenceAck": {
138
+ const sequenceAck = UpstreamMessage.SequenceAckMessage.create({
139
+ sequenceId: message.sequenceId,
140
+ });
141
+ upstream = UpstreamMessage.create({ sequenceAckMessage: sequenceAck });
142
+ break;
143
+ }
144
+ default:
145
+ throw new TypeError(`kind is not supported: ${message.kind}`);
146
+ }
147
+ return UpstreamMessage.encode(upstream).finish();
148
+ }
149
+ static _getIMessageData(data, dataType) {
150
+ switch (dataType) {
151
+ case "binary":
152
+ if (!(data instanceof ArrayBuffer)) {
153
+ throw new TypeError("Message must be a ArrayBuffer.");
154
+ }
155
+ return MessageData.create({ binaryData: new Uint8Array(data) });
156
+ case "protobuf":
157
+ if (WebPubSubProtobufProtocolBase._isIAny(data)) {
158
+ return MessageData.create({
159
+ protobufData: google.protobuf.Any.create({
160
+ type_url: data.type_url,
161
+ value: new Uint8Array(data.value),
162
+ }),
163
+ });
164
+ }
165
+ throw new TypeError("Message must be a google.protobuf.Any.");
166
+ case "text":
167
+ if (typeof data !== "string") {
168
+ throw new TypeError("Message must be a string.");
169
+ }
170
+ return MessageData.create({ textData: data });
171
+ case "json":
172
+ return MessageData.create({ jsonData: JSON.stringify(data) });
173
+ default:
174
+ throw new TypeError(`dataType is not supported: ${dataType}`);
175
+ }
176
+ }
177
+ static _getNumber(value) {
178
+ if (value === null || value === undefined || typeof value === "number") {
179
+ return value;
180
+ }
181
+ return value.toNumber();
182
+ }
183
+ static _isIAny(obj) {
184
+ return "type_url" in obj && "value" in obj;
185
+ }
186
+ }
187
+ //# sourceMappingURL=webPubSubProtobufProtocolBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufProtocolBase.js","sourceRoot":"","sources":["../../src/webPubSubProtobufProtocolBase.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAclC,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,MAAM,GACP,MAAM,4BAA4B,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,6BAA6B;IACxC;;;OAGG;IACI,MAAM,CAAC,aAAa,CAAC,KAAkB;QAC5C,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG;gBACV,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC;gBACnD,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO;aACzB,CAAC;YAChB,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBAChC,GAAG,CAAC,KAAK,GAAG;oBACV,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI;oBACtC,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO;iBAC1B,CAAC;YACvB,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;aAAM,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;YACpC,IAAI,UAAU,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;gBAC9C,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,gBAAgB,CAAC;gBACtD,OAAO;oBACL,IAAI,EAAE,WAAW;oBACjB,YAAY,EAAE,GAAG,CAAC,YAAY;oBAC9B,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,iBAAiB,EAAE,GAA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CAAC,SAAS,CAAC,IAAI,CAAC,EAAkB,CAAC,CAAC;YAChF;gBACE,MAAM,IAAI,SAAS,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,UAAU,CAAC,KAAuC;QAC/D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvE,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAC,OAAO,CAAC,GAAQ;QAC7B,OAAO,UAAU,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC;IAC7C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AckMessage,\n AckMessageError,\n ConnectedMessage,\n DisconnectedMessage,\n GroupDataMessage,\n ServerDataMessage,\n WebPubSubDataType,\n WebPubSubMessage,\n JSONTypes,\n} from \"@azure/web-pubsub-client\";\nimport type { IMessageData, IUpstreamMessage } from \"./generated/clientProto.js\";\nimport {\n DownstreamMessage,\n MessageData,\n UpstreamMessage,\n google,\n} from \"./generated/clientProto.js\";\nimport type Long from \"long\";\n\n/**\n * The \"protobuf.reliable.webpubsub.azure.v1\" protocol\n */\nexport class WebPubSubProtobufProtocolBase {\n /**\n * Creates WebPubSubMessage objects from the specified serialized representation.\n * @param input - The serialized representation\n */\n public static parseMessages(input: ArrayBuffer): WebPubSubMessage | null {\n const downstream = DownstreamMessage.decode(new Uint8Array(input));\n if (downstream.ackMessage) {\n const ack = {\n kind: \"ack\",\n ackId: this._getNumber(downstream.ackMessage.ackId),\n success: downstream.ackMessage.success,\n } as AckMessage;\n if (downstream.ackMessage.error) {\n ack.error = {\n name: downstream.ackMessage.error.name,\n message: downstream.ackMessage.error.message,\n } as AckMessageError;\n }\n return ack;\n } else if (downstream.systemMessage) {\n if (downstream.systemMessage.connectedMessage) {\n const msg = downstream.systemMessage.connectedMessage;\n return {\n kind: \"connected\",\n connectionId: msg.connectionId,\n userId: msg.userId,\n reconnectionToken: msg.reconnectionToken,\n } as ConnectedMessage;\n } else if (downstream.systemMessage.disconnectedMessage) {\n const msg = downstream.systemMessage.disconnectedMessage;\n return { kind: \"disconnected\", message: msg.reason } as DisconnectedMessage;\n } else {\n return null;\n }\n } else if (downstream.dataMessage) {\n const sequenceId = this._getNumber(downstream.dataMessage.sequenceId);\n const messageData = downstream.dataMessage.data!;\n let dataType: WebPubSubDataType;\n let data: string | ArrayBuffer | object;\n if (messageData.textData) {\n dataType = \"text\";\n data = messageData.textData;\n } else if (messageData.jsonData) {\n dataType = \"json\";\n data = JSON.parse(messageData.jsonData);\n } else if (messageData.binaryData) {\n dataType = \"binary\";\n data = messageData.binaryData.buffer.slice(\n messageData.binaryData.byteOffset,\n messageData.binaryData.byteLength + messageData.binaryData.byteOffset,\n );\n } else if (messageData.protobufData) {\n dataType = \"protobuf\";\n data = messageData.protobufData;\n } else {\n return null;\n }\n\n if (downstream.dataMessage.from === \"group\") {\n return {\n kind: \"groupData\",\n dataType: dataType,\n data: data,\n sequenceId: sequenceId,\n group: downstream.dataMessage.group,\n } as GroupDataMessage;\n } else if (downstream.dataMessage.from === \"server\") {\n return {\n kind: \"serverData\",\n dataType: dataType,\n data: data,\n sequenceId: sequenceId,\n } as ServerDataMessage;\n } else {\n return null;\n }\n } else {\n return null;\n }\n }\n\n /**\n * Write WebPubSubMessage to string\n * @param message - The message to be written\n */\n public static writeMessage(message: WebPubSubMessage): ArrayBuffer {\n let upstream: UpstreamMessage;\n switch (message.kind) {\n case \"joinGroup\": {\n const joinGroup = UpstreamMessage.JoinGroupMessage.create({\n group: message.group,\n ackId: message.ackId,\n } as UpstreamMessage.IJoinGroupMessage);\n upstream = UpstreamMessage.create({ joinGroupMessage: joinGroup } as IUpstreamMessage);\n break;\n }\n case \"leaveGroup\": {\n const leaveGroup = UpstreamMessage.LeaveGroupMessage.create({\n group: message.group,\n ackId: message.ackId,\n } as UpstreamMessage.ILeaveGroupMessage);\n upstream = UpstreamMessage.create({ leaveGroupMessage: leaveGroup } as IUpstreamMessage);\n break;\n }\n case \"sendToGroup\": {\n const sendToGroup = UpstreamMessage.SendToGroupMessage.create({\n group: message.group,\n ackId: message.ackId,\n data: this._getIMessageData(message.data, message.dataType),\n noEcho: message.noEcho,\n } as UpstreamMessage.ISendToGroupMessage);\n upstream = UpstreamMessage.create({ sendToGroupMessage: sendToGroup } as IUpstreamMessage);\n break;\n }\n case \"sendEvent\": {\n const sendEvent = UpstreamMessage.EventMessage.create({\n event: message.event,\n ackId: message.ackId,\n data: this._getIMessageData(message.data, message.dataType),\n } as UpstreamMessage.IEventMessage);\n upstream = UpstreamMessage.create({ eventMessage: sendEvent } as IUpstreamMessage);\n break;\n }\n case \"sequenceAck\": {\n const sequenceAck = UpstreamMessage.SequenceAckMessage.create({\n sequenceId: message.sequenceId,\n } as UpstreamMessage.ISequenceAckMessage);\n upstream = UpstreamMessage.create({ sequenceAckMessage: sequenceAck } as IUpstreamMessage);\n break;\n }\n default:\n throw new TypeError(`kind is not supported: ${message.kind}`);\n }\n\n return UpstreamMessage.encode(upstream).finish();\n }\n\n private static _getIMessageData(\n data: JSONTypes | ArrayBuffer,\n dataType: WebPubSubDataType,\n ): IMessageData {\n switch (dataType) {\n case \"binary\":\n if (!(data instanceof ArrayBuffer)) {\n throw new TypeError(\"Message must be a ArrayBuffer.\");\n }\n return MessageData.create({ binaryData: new Uint8Array(data) } as IMessageData);\n case \"protobuf\":\n if (WebPubSubProtobufProtocolBase._isIAny(data)) {\n return MessageData.create({\n protobufData: google.protobuf.Any.create({\n type_url: data.type_url!,\n value: new Uint8Array(data.value!),\n } as google.protobuf.IAny),\n } as IMessageData);\n }\n throw new TypeError(\"Message must be a google.protobuf.Any.\");\n case \"text\":\n if (typeof data !== \"string\") {\n throw new TypeError(\"Message must be a string.\");\n }\n return MessageData.create({ textData: data } as IMessageData);\n case \"json\":\n return MessageData.create({ jsonData: JSON.stringify(data) } as IMessageData);\n default:\n throw new TypeError(`dataType is not supported: ${dataType}`);\n }\n }\n\n private static _getNumber(value: number | Long | null | undefined): number | null | undefined {\n if (value === null || value === undefined || typeof value === \"number\") {\n return value;\n }\n return value.toNumber();\n }\n\n private static _isIAny(obj: any): obj is google.protobuf.IAny {\n return \"type_url\" in obj && \"value\" in obj;\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { WebPubSubMessage, WebPubSubClientProtocol } from "@azure/web-pubsub-client";
2
+ /**
3
+ * The "protobuf.reliable.webpubsub.azure.v1" protocol
4
+ */
5
+ export declare class WebPubSubProtobufReliableProtocolImpl implements WebPubSubClientProtocol {
6
+ /**
7
+ * True if the protocol supports reliable features
8
+ */
9
+ readonly isReliableSubProtocol = true;
10
+ /**
11
+ * The name of subprotocol. Name will be used in websocket subprotocol
12
+ */
13
+ readonly name = "protobuf.reliable.webpubsub.azure.v1";
14
+ /**
15
+ * Creates WebPubSubMessage objects from the specified serialized representation.
16
+ * @param input - The serialized representation
17
+ */
18
+ parseMessages(input: ArrayBuffer): WebPubSubMessage | null;
19
+ /**
20
+ * Write WebPubSubMessage to string
21
+ * @param message - The message to be written
22
+ */
23
+ writeMessage(message: WebPubSubMessage): ArrayBuffer;
24
+ }
25
+ //# sourceMappingURL=webPubSubProtobufReliableProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufReliableProtocol.d.ts","sourceRoot":"","sources":["../../src/webPubSubProtobufReliableProtocol.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAG1F;;GAEG;AACH,qBAAa,qCAAsC,YAAW,uBAAuB;IACnF;;OAEG;IACH,SAAgB,qBAAqB,QAAQ;IAE7C;;OAEG;IACH,SAAgB,IAAI,0CAA0C;IAE9D;;;OAGG;IACI,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI;IAIjE;;;OAGG;IACI,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW;CAG5D"}