@trpc/client 10.0.0-alpha.15 → 10.0.0-alpha.18

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 (155) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1081 -18
  4. package/dist/index.mjs +1064 -13
  5. package/dist/internals/TRPCClient.d.ts +3 -3
  6. package/dist/internals/TRPCClient.d.ts.map +1 -1
  7. package/dist/links/httpBatchLink.d.ts +1 -1
  8. package/dist/links/httpBatchLink.d.ts.map +1 -1
  9. package/dist/links/httpLink.d.ts +1 -1
  10. package/dist/links/httpLink.d.ts.map +1 -1
  11. package/dist/links/index.d.ts +11 -0
  12. package/dist/links/index.d.ts.map +1 -0
  13. package/dist/links/{httpUtils.d.ts → internals/httpUtils.d.ts} +1 -1
  14. package/dist/links/internals/httpUtils.d.ts.map +1 -0
  15. package/dist/links/transformerLink.d.ts.map +1 -1
  16. package/dist/links/types.d.ts +1 -1
  17. package/dist/links/types.d.ts.map +1 -1
  18. package/dist/links/wsLink.d.ts +1 -1
  19. package/dist/links/wsLink.d.ts.map +1 -1
  20. package/dist/observable/index.d.ts +4 -0
  21. package/dist/observable/index.d.ts.map +1 -0
  22. package/dist/{rx/operators → observable}/index.js +3 -3
  23. package/dist/{rx/operators → observable}/index.mjs +1 -2
  24. package/dist/{rx → observable}/index.ts.js +0 -0
  25. package/dist/{rx/util → observable/internals}/identity.d.ts +0 -0
  26. package/dist/observable/internals/identity.d.ts.map +1 -0
  27. package/dist/{rx/util → observable/internals}/observableToPromise.d.ts +0 -0
  28. package/dist/observable/internals/observableToPromise.d.ts.map +1 -0
  29. package/dist/{rx/util → observable/internals}/pipe.d.ts +0 -0
  30. package/dist/observable/internals/pipe.d.ts.map +1 -0
  31. package/dist/{rx → observable}/observable.d.ts +0 -0
  32. package/dist/observable/observable.d.ts.map +1 -0
  33. package/dist/{rx → observable}/operators/index.d.ts +0 -0
  34. package/dist/observable/operators/index.d.ts.map +1 -0
  35. package/dist/{rx → observable}/operators/map.d.ts +0 -0
  36. package/dist/observable/operators/map.d.ts.map +1 -0
  37. package/dist/{rx → observable}/operators/share.d.ts +0 -0
  38. package/dist/observable/operators/share.d.ts.map +1 -0
  39. package/dist/{rx → observable}/operators/tap.d.ts +0 -0
  40. package/dist/observable/operators/tap.d.ts.map +1 -0
  41. package/dist/{rx → observable}/types.d.ts +0 -0
  42. package/dist/observable/types.d.ts.map +1 -0
  43. package/dist/{share-671b63fa.mjs → tap-4bc60fb0.mjs} +131 -1
  44. package/dist/{share-4d79dc49.js → tap-fcd41ae6.js} +132 -0
  45. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.d.ts +1 -11
  46. package/{dist/links/httpBatchLink.js → links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js} +63 -44
  47. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.js +6 -15
  48. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +214 -0
  49. package/{dist/links/httpBatchLink.mjs → links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js} +62 -43
  50. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.d.ts +1 -11
  51. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +67 -0
  52. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.js +6 -15
  53. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +67 -0
  54. package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +63 -0
  55. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.d.ts +1 -11
  56. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +89 -0
  57. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.js +6 -15
  58. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +89 -0
  59. package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +85 -0
  60. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.d.ts +1 -11
  61. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +19 -0
  62. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.js +6 -15
  63. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +19 -0
  64. package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +15 -0
  65. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.d.ts +1 -11
  66. package/{dist/links/wsLink.js → links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js} +92 -82
  67. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.js +6 -15
  68. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +395 -0
  69. package/{dist/links/wsLink.mjs → links/wsLink/dist/trpc-client-links-wsLink.esm.js} +87 -67
  70. package/package.json +8 -43
  71. package/src/index.ts +1 -1
  72. package/src/internals/TRPCClient.ts +8 -11
  73. package/src/links/dedupeLink.test.ts +1 -1
  74. package/src/links/dedupeLink.ts +5 -5
  75. package/src/links/httpBatchLink.ts +6 -2
  76. package/src/links/httpLink.ts +2 -2
  77. package/src/links/index.ts +10 -0
  78. package/src/links/internals/createChain.test.ts +5 -5
  79. package/src/links/internals/createChain.ts +3 -3
  80. package/src/links/{httpUtils.ts → internals/httpUtils.ts} +1 -1
  81. package/src/links/loggerLink.ts +2 -2
  82. package/src/links/retryLink.ts +2 -2
  83. package/src/links/splitLink.test.ts +3 -3
  84. package/src/links/splitLink.ts +1 -1
  85. package/src/links/transformerLink.ts +9 -5
  86. package/src/links/types.ts +1 -1
  87. package/src/links/wsLink.ts +1 -2
  88. package/src/{rx → observable}/index.ts +1 -0
  89. package/src/{rx/util → observable/internals}/identity.ts +0 -0
  90. package/src/{rx/util → observable/internals}/observableToPromise.ts +0 -0
  91. package/src/{rx/util → observable/internals}/pipe.ts +0 -0
  92. package/src/{rx → observable}/observable.test.ts +21 -1
  93. package/src/{rx → observable}/observable.ts +1 -1
  94. package/src/{rx → observable}/operators/index.ts +0 -0
  95. package/src/{rx → observable}/operators/map.test.ts +0 -0
  96. package/src/{rx → observable}/operators/map.ts +0 -0
  97. package/src/{rx → observable}/operators/share.test.ts +0 -0
  98. package/src/{rx → observable}/operators/share.ts +0 -0
  99. package/src/{rx → observable}/operators/tap.ts +0 -0
  100. package/src/{rx → observable}/types.ts +0 -0
  101. package/dist/TRPCClientError-17b117e1.mjs +0 -81
  102. package/dist/TRPCClientError-ec6bd2ca.js +0 -94
  103. package/dist/createChain-389cc116.mjs +0 -25
  104. package/dist/createChain-864dbb30.js +0 -27
  105. package/dist/httpUtils-1f9e4e3c.js +0 -97
  106. package/dist/httpUtils-c09d7b79.mjs +0 -91
  107. package/dist/links/httpBatchLink.ts.js +0 -1
  108. package/dist/links/httpLink.js +0 -44
  109. package/dist/links/httpLink.mjs +0 -40
  110. package/dist/links/httpLink.ts.js +0 -1
  111. package/dist/links/httpUtils.d.ts.map +0 -1
  112. package/dist/links/loggerLink.js +0 -108
  113. package/dist/links/loggerLink.mjs +0 -99
  114. package/dist/links/loggerLink.ts.js +0 -1
  115. package/dist/links/splitLink.js +0 -32
  116. package/dist/links/splitLink.mjs +0 -28
  117. package/dist/links/splitLink.ts.js +0 -1
  118. package/dist/links/transformerLink.js +0 -75
  119. package/dist/links/transformerLink.mjs +0 -67
  120. package/dist/links/transformerLink.ts.js +0 -1
  121. package/dist/links/wsLink.ts.js +0 -1
  122. package/dist/observable-7e66cb56.mjs +0 -102
  123. package/dist/observable-85669100.js +0 -104
  124. package/dist/rx/index.d.ts +0 -3
  125. package/dist/rx/index.d.ts.map +0 -1
  126. package/dist/rx/index.js +0 -9
  127. package/dist/rx/index.mjs +0 -1
  128. package/dist/rx/observable.d.ts.map +0 -1
  129. package/dist/rx/operators/index.d.ts.map +0 -1
  130. package/dist/rx/operators/index.ts.js +0 -1
  131. package/dist/rx/operators/map.d.ts.map +0 -1
  132. package/dist/rx/operators/share.d.ts.map +0 -1
  133. package/dist/rx/operators/tap.d.ts.map +0 -1
  134. package/dist/rx/types.d.ts.map +0 -1
  135. package/dist/rx/util/identity.d.ts.map +0 -1
  136. package/dist/rx/util/observableToPromise.d.ts.map +0 -1
  137. package/dist/rx/util/pipe.d.ts.map +0 -1
  138. package/dist/tap-538fa07f.mjs +0 -30
  139. package/dist/tap-799a2d33.js +0 -32
  140. package/links/httpBatchLink/index.d.ts +0 -1
  141. package/links/httpBatchLink/index.js +0 -1
  142. package/links/httpLink/index.d.ts +0 -1
  143. package/links/httpLink/index.js +0 -1
  144. package/links/loggerLink/index.d.ts +0 -1
  145. package/links/loggerLink/index.js +0 -1
  146. package/links/splitLink/index.d.ts +0 -1
  147. package/links/splitLink/index.js +0 -1
  148. package/links/transformerLink/index.d.ts +0 -1
  149. package/links/transformerLink/index.js +0 -1
  150. package/links/wsLink/index.d.ts +0 -1
  151. package/links/wsLink/index.js +0 -1
  152. package/rx/index.d.ts +0 -1
  153. package/rx/index.js +0 -1
  154. package/rx/operators/index.d.ts +0 -1
  155. package/rx/operators/index.js +0 -1
@@ -2,35 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
5
6
  var _createClass = require('@babel/runtime/helpers/createClass');
6
7
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
7
8
  var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
8
9
  var _inherits = require('@babel/runtime/helpers/inherits');
9
- var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
10
- var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
10
+ var _createSuper = require('@babel/runtime/helpers/createSuper');
11
11
  var _wrapNativeSuper = require('@babel/runtime/helpers/wrapNativeSuper');
12
- var observable = require('../observable-85669100.js');
13
- var TRPCClientError = require('../TRPCClientError-ec6bd2ca.js');
14
- require('@babel/runtime/helpers/defineProperty');
15
-
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
-
18
- var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
19
- var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
20
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
21
- var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
22
- var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
23
- var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
24
- var _wrapNativeSuper__default = /*#__PURE__*/_interopDefaultLegacy(_wrapNativeSuper);
12
+ var TRPCClientError = require('../../../dist/TRPCClientError-bfee2bf5.cjs.dev.js');
25
13
 
26
14
  /* istanbul ignore next */
27
15
  var retryDelay = function retryDelay(attemptIndex) {
28
16
  return attemptIndex === 0 ? 0 : Math.min(1000 * Math.pow(2, attemptIndex), 30000);
29
17
  };
30
18
 
31
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
32
-
33
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
19
  function createWSClient(opts) {
35
20
  var url = opts.url,
36
21
  _opts$WebSocket = opts.WebSocket,
@@ -163,19 +148,24 @@ function createWSClient(opts) {
163
148
  }
164
149
  };
165
150
 
166
- var handleIncomingResponse = function handleIncomingResponse(data) {
167
- var _req$callbacks$next, _req$callbacks;
151
+ var handleIncomingResponse = function handleIncomingResponse(res) {
152
+ var _req$callbacks$onNext, _req$callbacks2;
168
153
 
169
- var req = data.id !== null && pendingRequests[data.id];
154
+ var req = res.id !== null && pendingRequests[res.id];
170
155
 
171
156
  if (!req) {
172
157
  // do something?
173
158
  return;
174
159
  }
175
160
 
176
- (_req$callbacks$next = (_req$callbacks = req.callbacks).next) === null || _req$callbacks$next === void 0 ? void 0 : _req$callbacks$next.call(_req$callbacks, {
177
- data: data
178
- });
161
+ if ('error' in res) {
162
+ var _req$callbacks$onErro, _req$callbacks;
163
+
164
+ (_req$callbacks$onErro = (_req$callbacks = req.callbacks).onError) === null || _req$callbacks$onErro === void 0 ? void 0 : _req$callbacks$onErro.call(_req$callbacks, res);
165
+ return;
166
+ }
167
+
168
+ (_req$callbacks$onNext = (_req$callbacks2 = req.callbacks).onNext) === null || _req$callbacks$onNext === void 0 ? void 0 : _req$callbacks$onNext.call(_req$callbacks2, res.result);
179
169
 
180
170
  if (req.ws !== activeConnection && conn === activeConnection) {
181
171
  var oldWs = req.ws; // gracefully replace old connection with this
@@ -184,8 +174,10 @@ function createWSClient(opts) {
184
174
  closeIfNoPending(oldWs);
185
175
  }
186
176
 
187
- if ('result' in data && data.result.type === 'stopped' && conn === activeConnection) {
188
- req.callbacks.complete();
177
+ if (res.result.type === 'stopped' && conn === activeConnection) {
178
+ var _req$callbacks$onDone, _req$callbacks3;
179
+
180
+ (_req$callbacks$onDone = (_req$callbacks3 = req.callbacks).onDone) === null || _req$callbacks$onDone === void 0 ? void 0 : _req$callbacks$onDone.call(_req$callbacks3);
189
181
  }
190
182
  };
191
183
 
@@ -211,7 +203,7 @@ function createWSClient(opts) {
211
203
  }
212
204
 
213
205
  for (var key in pendingRequests) {
214
- var _req$callbacks$error, _req$callbacks2;
206
+ var _req$callbacks$onErro2, _req$callbacks4;
215
207
 
216
208
  var req = pendingRequests[key];
217
209
 
@@ -219,13 +211,13 @@ function createWSClient(opts) {
219
211
  continue;
220
212
  }
221
213
 
222
- (_req$callbacks$error = (_req$callbacks2 = req.callbacks).error) === null || _req$callbacks$error === void 0 ? void 0 : _req$callbacks$error.call(_req$callbacks2, TRPCClientError.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
214
+ (_req$callbacks$onErro2 = (_req$callbacks4 = req.callbacks).onError) === null || _req$callbacks$onErro2 === void 0 ? void 0 : _req$callbacks$onErro2.call(_req$callbacks4, TRPCClientError.TRPCClientError.from(new TRPCWebSocketClosedError('WebSocket closed prematurely')));
223
215
 
224
216
  if (req.type !== 'subscription') {
225
- var _req$callbacks$comple, _req$callbacks3;
217
+ var _req$callbacks$onDone2, _req$callbacks5;
226
218
 
227
219
  delete pendingRequests[key];
228
- (_req$callbacks$comple = (_req$callbacks3 = req.callbacks).complete) === null || _req$callbacks$comple === void 0 ? void 0 : _req$callbacks$comple.call(_req$callbacks3);
220
+ (_req$callbacks$onDone2 = (_req$callbacks5 = req.callbacks).onDone) === null || _req$callbacks$onDone2 === void 0 ? void 0 : _req$callbacks$onDone2.call(_req$callbacks5);
229
221
  } else if (state !== 'closed') {
230
222
  // request restart of sub with next connection
231
223
  resumeSubscriptionOnReconnect(req);
@@ -259,14 +251,14 @@ function createWSClient(opts) {
259
251
  outgoing.push(envelope);
260
252
  dispatch();
261
253
  return function () {
262
- var _pendingRequests$id, _callbacks$complete;
254
+ var _pendingRequests$id, _callbacks$onDone;
263
255
 
264
256
  var callbacks = (_pendingRequests$id = pendingRequests[id]) === null || _pendingRequests$id === void 0 ? void 0 : _pendingRequests$id.callbacks;
265
257
  delete pendingRequests[id];
266
258
  outgoing = outgoing.filter(function (msg) {
267
259
  return msg.id !== id;
268
260
  });
269
- callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$complete = callbacks.complete) === null || _callbacks$complete === void 0 ? void 0 : _callbacks$complete.call(callbacks);
261
+ callbacks === null || callbacks === void 0 ? void 0 : (_callbacks$onDone = callbacks.onDone) === null || _callbacks$onDone === void 0 ? void 0 : _callbacks$onDone.call(callbacks);
270
262
 
271
263
  if (op.type === 'subscription') {
272
264
  outgoing.push({
@@ -292,90 +284,108 @@ function createWSClient(opts) {
292
284
  }
293
285
 
294
286
  var TRPCWebSocketClosedError = /*#__PURE__*/function (_Error) {
295
- _inherits__default["default"](TRPCWebSocketClosedError, _Error);
287
+ _inherits(TRPCWebSocketClosedError, _Error);
296
288
 
297
289
  var _super = /*#__PURE__*/_createSuper(TRPCWebSocketClosedError);
298
290
 
299
291
  function TRPCWebSocketClosedError(message) {
300
292
  var _this;
301
293
 
302
- _classCallCheck__default["default"](this, TRPCWebSocketClosedError);
294
+ _classCallCheck(this, TRPCWebSocketClosedError);
303
295
 
304
296
  _this = _super.call(this, message);
305
297
  _this.name = 'TRPCWebSocketClosedError';
306
- Object.setPrototypeOf(_assertThisInitialized__default["default"](_this), TRPCWebSocketClosedError.prototype);
298
+ Object.setPrototypeOf(_assertThisInitialized(_this), TRPCWebSocketClosedError.prototype);
307
299
  return _this;
308
300
  }
309
301
 
310
- return _createClass__default["default"](TRPCWebSocketClosedError);
311
- }( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
302
+ return _createClass(TRPCWebSocketClosedError);
303
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
312
304
 
313
305
  var TRPCSubscriptionEndedError = /*#__PURE__*/function (_Error2) {
314
- _inherits__default["default"](TRPCSubscriptionEndedError, _Error2);
306
+ _inherits(TRPCSubscriptionEndedError, _Error2);
315
307
 
316
308
  var _super2 = /*#__PURE__*/_createSuper(TRPCSubscriptionEndedError);
317
309
 
318
310
  function TRPCSubscriptionEndedError(message) {
319
311
  var _this2;
320
312
 
321
- _classCallCheck__default["default"](this, TRPCSubscriptionEndedError);
313
+ _classCallCheck(this, TRPCSubscriptionEndedError);
322
314
 
323
315
  _this2 = _super2.call(this, message);
324
316
  _this2.name = 'TRPCSubscriptionEndedError';
325
- Object.setPrototypeOf(_assertThisInitialized__default["default"](_this2), TRPCSubscriptionEndedError.prototype);
317
+ Object.setPrototypeOf(_assertThisInitialized(_this2), TRPCSubscriptionEndedError.prototype);
326
318
  return _this2;
327
319
  }
328
320
 
329
- return _createClass__default["default"](TRPCSubscriptionEndedError);
330
- }( /*#__PURE__*/_wrapNativeSuper__default["default"](Error));
321
+ return _createClass(TRPCSubscriptionEndedError);
322
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
331
323
 
332
324
  function wsLink(opts) {
333
- return function () {
325
+ // initialized config
326
+ return function (rt) {
334
327
  var client = opts.client;
335
328
  return function (_ref2) {
336
- var op = _ref2.op;
337
- return observable.observable(function (observer) {
338
- var type = op.type,
339
- input = op.input,
340
- path = op.path,
341
- id = op.id,
342
- context = op.context;
343
- var isDone = false;
344
- var unsub = client.request({
345
- type: type,
346
- path: path,
347
- input: input,
348
- id: id,
349
- context: context
350
- }, {
351
- error: function error(err) {
329
+ var op = _ref2.op,
330
+ prev = _ref2.prev,
331
+ onDestroy = _ref2.onDestroy;
332
+ var type = op.type,
333
+ rawInput = op.input,
334
+ path = op.path,
335
+ id = op.id;
336
+ var input = rt.transformer.serialize(rawInput);
337
+ var isDone = false;
338
+ var unsub = client.request({
339
+ type: type,
340
+ path: path,
341
+ input: input,
342
+ id: id
343
+ }, {
344
+ onNext: function onNext(result) {
345
+ if (isDone) {
346
+ return;
347
+ }
348
+
349
+ if ('data' in result) {
350
+ var data = rt.transformer.deserialize(result.data);
351
+ prev({
352
+ type: 'data',
353
+ data: data
354
+ });
355
+ } else {
356
+ prev(result);
357
+ }
358
+
359
+ if (op.type !== 'subscription') {
360
+ // if it isn't a subscription we don't care about next response
352
361
  isDone = true;
353
- observer.error(err);
354
362
  unsub();
355
- },
356
- complete: function complete() {
357
- if (!isDone) {
358
- isDone = true;
359
- observer.error(TRPCClientError.TRPCClientError.from(new TRPCSubscriptionEndedError('Operation ended prematurely')));
360
- } else {
361
- observer.complete();
362
- }
363
- },
364
- next: function next(result) {
365
- observer.next(result);
366
-
367
- if (op.type !== 'subscription') {
368
- // if it isn't a subscription we don't care about next response
369
- isDone = true;
370
- unsub();
371
- observer.complete();
372
- }
373
363
  }
374
- });
375
- return function () {
364
+ },
365
+ onError: function onError(err) {
366
+ if (isDone) {
367
+ return;
368
+ }
369
+
370
+ prev(err instanceof Error ? err : TRPCClientError.TRPCClientError.from(_objectSpread(_objectSpread({}, err), {}, {
371
+ error: rt.transformer.deserialize(err.error)
372
+ })));
373
+ },
374
+ onDone: function onDone() {
375
+ if (isDone) {
376
+ return;
377
+ }
378
+
379
+ var result = new TRPCSubscriptionEndedError('Operation ended prematurely');
380
+ prev(TRPCClientError.TRPCClientError.from(result, {
381
+ isDone: true
382
+ }));
376
383
  isDone = true;
377
- unsub();
378
- };
384
+ }
385
+ });
386
+ onDestroy(function () {
387
+ isDone = true;
388
+ unsub();
379
389
  });
380
390
  };
381
391
  };
@@ -1,16 +1,7 @@
1
- "use strict";
2
- // this file might look strange and you might be wondering what it's for
3
- // it's lets you import your source files by importing this entrypoint
4
- // as you would import it if it was built with preconstruct build
5
- // this file is slightly different to some others though
6
- // it has a require hook which compiles your code with Babel
7
- // this means that you don't have to set up @babel/register or anything like that
8
- // but you can still require this module and it'll be compiled
1
+ 'use strict';
9
2
 
10
- // this bit of code imports the require hook and registers it
11
- let unregister = require("../../../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
-
13
- // this re-exports the source file
14
- module.exports = require("../../../src/links/wsLink.ts");
15
-
16
- unregister();
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./trpc-client-links-wsLink.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./trpc-client-links-wsLink.cjs.dev.js");
7
+ }