@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
@@ -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 WebPubSubProtobufReliableProtocolImpl {
8
+ /**
9
+ * True if the protocol supports reliable features
10
+ */
11
+ isReliableSubProtocol = true;
12
+ /**
13
+ * The name of subprotocol. Name will be used in websocket subprotocol
14
+ */
15
+ name = "protobuf.reliable.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=webPubSubProtobufReliableProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufReliableProtocol.js","sourceRoot":"","sources":["../../src/webPubSubProtobufReliableProtocol.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAChD;;OAEG;IACa,qBAAqB,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACa,IAAI,GAAG,sCAAsC,CAAC;IAE9D;;;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 WebPubSubProtobufReliableProtocolImpl implements WebPubSubClientProtocol {\n /**\n * True if the protocol supports reliable features\n */\n public readonly isReliableSubProtocol = true;\n\n /**\n * The name of subprotocol. Name will be used in websocket subprotocol\n */\n public readonly name = \"protobuf.reliable.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,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":"AAA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AC;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"}
@@ -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 WebPubSubProtobufReliableProtocolImpl {
8
+ /**
9
+ * True if the protocol supports reliable features
10
+ */
11
+ isReliableSubProtocol = true;
12
+ /**
13
+ * The name of subprotocol. Name will be used in websocket subprotocol
14
+ */
15
+ name = "protobuf.reliable.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=webPubSubProtobufReliableProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webPubSubProtobufReliableProtocol.js","sourceRoot":"","sources":["../../src/webPubSubProtobufReliableProtocol.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAChD;;OAEG;IACa,qBAAqB,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACa,IAAI,GAAG,sCAAsC,CAAC;IAE9D;;;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 WebPubSubProtobufReliableProtocolImpl implements WebPubSubClientProtocol {\n /**\n * True if the protocol supports reliable features\n */\n public readonly isReliableSubProtocol = true;\n\n /**\n * The name of subprotocol. Name will be used in websocket subprotocol\n */\n public readonly name = \"protobuf.reliable.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"]}