@trpc/server 11.0.0-rc.621 → 11.0.0-rc.632

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 (133) hide show
  1. package/dist/@trpc/server/http.d.ts +1 -1
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/adapters/aws-lambda/getPlanner.js +2 -2
  4. package/dist/adapters/aws-lambda/getPlanner.mjs +2 -2
  5. package/dist/adapters/aws-lambda/index.js +2 -0
  6. package/dist/adapters/aws-lambda/index.mjs +2 -0
  7. package/dist/adapters/express.js +2 -0
  8. package/dist/adapters/express.mjs +2 -0
  9. package/dist/adapters/fastify/fastifyRequestHandler.js +3 -1
  10. package/dist/adapters/fastify/fastifyRequestHandler.mjs +3 -1
  11. package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -1
  12. package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -1
  13. package/dist/adapters/fetch/fetchRequestHandler.js +8 -6
  14. package/dist/adapters/fetch/fetchRequestHandler.mjs +8 -6
  15. package/dist/adapters/next-app-dir/nextAppDirCaller.js +6 -4
  16. package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +6 -4
  17. package/dist/adapters/next-app-dir/notFound.js +2 -0
  18. package/dist/adapters/next-app-dir/notFound.mjs +2 -0
  19. package/dist/adapters/next-app-dir/redirect.js +4 -1
  20. package/dist/adapters/next-app-dir/redirect.mjs +4 -1
  21. package/dist/adapters/next-app-dir/rethrowNextErrors.js +1 -1
  22. package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +1 -1
  23. package/dist/adapters/next.js +2 -0
  24. package/dist/adapters/next.mjs +2 -0
  25. package/dist/adapters/node-http/incomingMessageToRequest.d.ts +1 -1
  26. package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
  27. package/dist/adapters/node-http/incomingMessageToRequest.js +8 -5
  28. package/dist/adapters/node-http/incomingMessageToRequest.mjs +8 -5
  29. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  30. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +11 -43
  31. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +11 -43
  32. package/dist/adapters/node-http/writeResponse.d.ts +18 -0
  33. package/dist/adapters/node-http/writeResponse.d.ts.map +1 -0
  34. package/dist/adapters/node-http/writeResponse.js +85 -0
  35. package/dist/adapters/node-http/writeResponse.mjs +82 -0
  36. package/dist/adapters/standalone.js +2 -0
  37. package/dist/adapters/standalone.mjs +2 -0
  38. package/dist/adapters/ws.js +11 -10
  39. package/dist/adapters/ws.mjs +11 -10
  40. package/dist/bundle-analysis.json +230 -186
  41. package/dist/http.js +2 -2
  42. package/dist/http.mjs +2 -1
  43. package/dist/index.js +2 -0
  44. package/dist/index.mjs +2 -0
  45. package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js +11 -0
  46. package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs +9 -0
  47. package/dist/observable/observable.js +1 -1
  48. package/dist/observable/observable.mjs +1 -1
  49. package/dist/rpc.js +2 -0
  50. package/dist/rpc.mjs +2 -0
  51. package/dist/shared.js +2 -0
  52. package/dist/shared.mjs +2 -0
  53. package/dist/unstable-core-do-not-import/createProxy.js +1 -1
  54. package/dist/unstable-core-do-not-import/createProxy.mjs +1 -1
  55. package/dist/unstable-core-do-not-import/error/TRPCError.js +4 -1
  56. package/dist/unstable-core-do-not-import/error/TRPCError.mjs +4 -1
  57. package/dist/unstable-core-do-not-import/error/formatter.js +1 -1
  58. package/dist/unstable-core-do-not-import/error/formatter.mjs +1 -1
  59. package/dist/unstable-core-do-not-import/error/getErrorShape.js +2 -2
  60. package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +2 -2
  61. package/dist/unstable-core-do-not-import/http/contentType.js +3 -3
  62. package/dist/unstable-core-do-not-import/http/contentType.mjs +3 -3
  63. package/dist/unstable-core-do-not-import/http/isAbortError.d.ts +4 -0
  64. package/dist/unstable-core-do-not-import/http/isAbortError.d.ts.map +1 -0
  65. package/dist/unstable-core-do-not-import/http/isAbortError.js +9 -0
  66. package/dist/unstable-core-do-not-import/http/isAbortError.mjs +7 -0
  67. package/dist/unstable-core-do-not-import/http/resolveResponse.js +24 -24
  68. package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +24 -24
  69. package/dist/unstable-core-do-not-import/middleware.js +1 -1
  70. package/dist/unstable-core-do-not-import/middleware.mjs +1 -1
  71. package/dist/unstable-core-do-not-import/procedureBuilder.js +1 -1
  72. package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -1
  73. package/dist/unstable-core-do-not-import/router.js +2 -2
  74. package/dist/unstable-core-do-not-import/router.mjs +2 -2
  75. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +2 -2
  76. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +2 -2
  77. package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +6 -9
  78. package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
  79. package/dist/unstable-core-do-not-import/stream/jsonl.js +86 -136
  80. package/dist/unstable-core-do-not-import/stream/jsonl.mjs +87 -137
  81. package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
  82. package/dist/unstable-core-do-not-import/stream/sse.js +27 -23
  83. package/dist/unstable-core-do-not-import/stream/sse.mjs +28 -24
  84. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +10 -10
  85. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +1 -1
  86. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +47 -34
  87. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +47 -34
  88. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts +0 -4
  89. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts.map +1 -1
  90. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.js +0 -11
  91. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.mjs +1 -11
  92. package/dist/unstable-core-do-not-import/stream/utils/disposablePromiseTimer.d.ts +6 -0
  93. package/dist/unstable-core-do-not-import/stream/utils/disposablePromiseTimer.d.ts.map +1 -0
  94. package/dist/unstable-core-do-not-import/stream/utils/disposablePromiseTimer.js +28 -0
  95. package/dist/unstable-core-do-not-import/stream/utils/disposablePromiseTimer.mjs +25 -0
  96. package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts.map +1 -1
  97. package/dist/unstable-core-do-not-import/stream/utils/withPing.js +17 -17
  98. package/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +17 -17
  99. package/dist/unstable-core-do-not-import/stream/utils/withRefCount.d.ts +17 -0
  100. package/dist/unstable-core-do-not-import/stream/utils/withRefCount.d.ts.map +1 -0
  101. package/dist/unstable-core-do-not-import/stream/utils/withRefCount.js +59 -0
  102. package/dist/unstable-core-do-not-import/stream/utils/withRefCount.mjs +57 -0
  103. package/dist/unstable-core-do-not-import.d.ts +2 -2
  104. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  105. package/dist/unstable-core-do-not-import.js +2 -2
  106. package/dist/unstable-core-do-not-import.mjs +1 -1
  107. package/dist/vendor/unpromise/unpromise.js +21 -16
  108. package/dist/vendor/unpromise/unpromise.mjs +21 -16
  109. package/package.json +12 -5
  110. package/src/@trpc/server/http.ts +0 -1
  111. package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
  112. package/src/adapters/node-http/incomingMessageToRequest.ts +8 -4
  113. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +8 -46
  114. package/src/adapters/node-http/writeResponse.ts +96 -0
  115. package/src/unstable-core-do-not-import/http/isAbortError.ts +7 -0
  116. package/src/unstable-core-do-not-import/stream/jsonl.ts +85 -154
  117. package/src/unstable-core-do-not-import/stream/sse.ts +24 -25
  118. package/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts +58 -37
  119. package/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts +0 -13
  120. package/src/unstable-core-do-not-import/stream/utils/disposablePromiseTimer.ts +27 -0
  121. package/src/unstable-core-do-not-import/stream/utils/withPing.ts +31 -19
  122. package/src/unstable-core-do-not-import/stream/utils/withRefCount.ts +93 -0
  123. package/src/unstable-core-do-not-import.ts +2 -2
  124. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
  125. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
  126. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +0 -32
  127. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +0 -30
  128. package/dist/unstable-core-do-not-import/stream/utils/promiseTimer.d.ts +0 -8
  129. package/dist/unstable-core-do-not-import/stream/utils/promiseTimer.d.ts.map +0 -1
  130. package/dist/unstable-core-do-not-import/stream/utils/promiseTimer.js +0 -38
  131. package/dist/unstable-core-do-not-import/stream/utils/promiseTimer.mjs +0 -36
  132. package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
  133. package/src/unstable-core-do-not-import/stream/utils/promiseTimer.ts +0 -40
@@ -1,40 +1,47 @@
1
1
  import { Unpromise } from '../../../vendor/unpromise';
2
- import { noop } from '../../utils';
3
- import { createPromiseTimer } from './promiseTimer';
2
+ import {
3
+ disposablePromiseTimer,
4
+ disposablePromiseTimerResult,
5
+ } from './disposablePromiseTimer';
4
6
 
5
7
  /**
6
- * Derives a new {@link AsyncGenerator} based of {@link iterable}, that automatically stops with the
7
- * passed {@link cancel} promise.
8
+ * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically stops after the specified duration.
8
9
  */
9
- export async function* withCancel<T>(
10
+ export async function* withMaxDuration<T>(
10
11
  iterable: AsyncIterable<T>,
11
- cancel: Promise<unknown>,
12
+ opts: { maxDurationMs: number; abortCtrl: AbortController },
12
13
  ): AsyncGenerator<T> {
13
- const cancelPromise = cancel.then(noop);
14
14
  const iterator = iterable[Symbol.asyncIterator]();
15
- // declaration outside the loop for garbage collection reasons
16
- let result: null | IteratorResult<T> | void;
17
- while (true) {
18
- result = await Unpromise.race([iterator.next(), cancelPromise]);
19
- if (result == null) {
20
- await iterator.return?.();
21
- break;
22
- }
23
- if (result.done) {
24
- break;
15
+
16
+ const timer = disposablePromiseTimer(opts.maxDurationMs);
17
+ try {
18
+ const timerPromise = timer.start();
19
+
20
+ // declaration outside the loop for garbage collection reasons
21
+ let result: null | IteratorResult<T> | typeof disposablePromiseTimerResult;
22
+
23
+ while (true) {
24
+ result = await Unpromise.race([iterator.next(), timerPromise]);
25
+ if (result === disposablePromiseTimerResult) {
26
+ // cancelled due to timeout
27
+ opts.abortCtrl.abort();
28
+ const res = await iterator.return?.();
29
+ return res?.value;
30
+ }
31
+ if (result.done) {
32
+ return result;
33
+ }
34
+ yield result.value;
35
+ // free up reference for garbage collection
36
+ result = null;
25
37
  }
26
- yield result.value;
27
- // free up reference for garbage collection
28
- result = null;
38
+ } finally {
39
+ // dispose timer
40
+ // Shouldn't be needed, but build breaks with `using` keyword
41
+ timer[Symbol.dispose]();
29
42
  }
30
43
  }
31
44
 
32
- interface TakeWithGraceOptions {
33
- count: number;
34
- gracePeriodMs: number;
35
- onCancel: () => void;
36
- }
37
-
38
45
  /**
39
46
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
40
47
  * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
@@ -42,31 +49,45 @@ interface TakeWithGraceOptions {
42
49
  */
43
50
  export async function* takeWithGrace<T>(
44
51
  iterable: AsyncIterable<T>,
45
- { count, gracePeriodMs, onCancel }: TakeWithGraceOptions,
52
+ opts: {
53
+ count: number;
54
+ gracePeriodMs: number;
55
+ abortCtrl: AbortController;
56
+ },
46
57
  ): AsyncGenerator<T> {
47
58
  const iterator = iterable[Symbol.asyncIterator]();
48
- const timer = createPromiseTimer(gracePeriodMs);
59
+
60
+ // declaration outside the loop for garbage collection reasons
61
+ let result: null | IteratorResult<T> | typeof disposablePromiseTimerResult;
62
+
63
+ const timer = disposablePromiseTimer(opts.gracePeriodMs);
49
64
  try {
50
- // declaration outside the loop for garbage collection reasons
51
- let result: null | IteratorResult<T> | void;
65
+ let count = opts.count;
66
+
67
+ let timerPromise = new Promise<typeof disposablePromiseTimerResult>(() => {
68
+ // never resolves
69
+ });
70
+
52
71
  while (true) {
53
- result = await Unpromise.race([iterator.next(), timer.promise]);
54
- if (result == null) {
72
+ result = await Unpromise.race([iterator.next(), timerPromise]);
73
+ if (result === disposablePromiseTimerResult) {
55
74
  // cancelled
56
- await iterator.return?.();
57
- break;
75
+ const res = await iterator.return?.();
76
+ return res?.value;
58
77
  }
59
78
  if (result.done) {
60
- break;
79
+ return result.value;
61
80
  }
62
81
  yield result.value;
63
82
  if (--count === 0) {
64
- timer.start().promise.then(onCancel, noop);
83
+ timerPromise = timer.start();
84
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
85
+ timerPromise.then(() => opts.abortCtrl.abort());
65
86
  }
66
87
  // free up reference for garbage collection
67
88
  result = null;
68
89
  }
69
90
  } finally {
70
- timer.clear();
91
+ timer[Symbol.dispose]();
71
92
  }
72
93
  }
@@ -1,8 +1,3 @@
1
- import { createDeferred } from './createDeferred';
2
-
3
- // ---------- utils
4
-
5
- const cancelledStreamSymbol = Symbol();
6
1
  /**
7
2
  * One-off readable stream
8
3
  */
@@ -10,14 +5,12 @@ export function createReadableStream<TValue = unknown>() {
10
5
  let controller: ReadableStreamDefaultController<TValue> =
11
6
  null as unknown as ReadableStreamDefaultController<TValue>;
12
7
 
13
- const deferred = createDeferred<typeof cancelledStreamSymbol>();
14
8
  let cancelled = false;
15
9
  const readable = new ReadableStream<TValue>({
16
10
  start(c) {
17
11
  controller = c;
18
12
  },
19
13
  cancel() {
20
- deferred.resolve(cancelledStreamSymbol);
21
14
  cancelled = true;
22
15
  },
23
16
  });
@@ -25,14 +18,8 @@ export function createReadableStream<TValue = unknown>() {
25
18
  return {
26
19
  readable,
27
20
  controller,
28
- cancelledPromise: deferred.promise,
29
21
  cancelled() {
30
22
  return cancelled;
31
23
  },
32
24
  } as const;
33
25
  }
34
- export function isCancelledStreamResult(
35
- v: unknown,
36
- ): v is typeof cancelledStreamSymbol {
37
- return v === cancelledStreamSymbol;
38
- }
@@ -0,0 +1,27 @@
1
+ // @ts-expect-error polyfill
2
+ Symbol.dispose ??= Symbol();
3
+
4
+ export const disposablePromiseTimerResult = Symbol();
5
+ export function disposablePromiseTimer(ms: number) {
6
+ let timer: ReturnType<typeof setTimeout> | null = null;
7
+
8
+ return {
9
+ start() {
10
+ if (timer) {
11
+ throw new Error('Timer already started');
12
+ }
13
+
14
+ const promise = new Promise<typeof disposablePromiseTimerResult>(
15
+ (resolve) => {
16
+ timer = setTimeout(() => resolve(disposablePromiseTimerResult), ms);
17
+ },
18
+ );
19
+ return promise;
20
+ },
21
+ [Symbol.dispose]: () => {
22
+ if (timer) {
23
+ clearTimeout(timer);
24
+ }
25
+ },
26
+ };
27
+ }
@@ -1,13 +1,11 @@
1
1
  import { Unpromise } from '../../../vendor/unpromise';
2
- import { createPromiseTimer } from './promiseTimer';
2
+ import {
3
+ disposablePromiseTimer,
4
+ disposablePromiseTimerResult,
5
+ } from './disposablePromiseTimer';
3
6
 
4
7
  export const PING_SYM = Symbol('ping');
5
8
 
6
- const PING_RESULT: IteratorResult<typeof PING_SYM> = {
7
- value: PING_SYM,
8
- done: false,
9
- };
10
-
11
9
  /**
12
10
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields {@link PING_SYM}
13
11
  * whenever no value has been yielded for {@link pingIntervalMs}.
@@ -16,24 +14,38 @@ export async function* withPing<TValue>(
16
14
  iterable: AsyncIterable<TValue>,
17
15
  pingIntervalMs: number,
18
16
  ): AsyncGenerator<TValue | typeof PING_SYM> {
19
- const timer = createPromiseTimer(pingIntervalMs);
20
17
  const iterator = iterable[Symbol.asyncIterator]();
21
18
  // declaration outside the loop for garbage collection reasons
22
- let result: null | IteratorResult<TValue | typeof PING_SYM>;
19
+ let result:
20
+ | null
21
+ | IteratorResult<TValue>
22
+ | typeof disposablePromiseTimerResult;
23
+
24
+ let nextPromise = iterator.next();
23
25
  while (true) {
24
- const nextPromise = iterator.next();
25
- const pingPromise = timer.start().promise.then(() => PING_RESULT);
26
+ const pingPromise = disposablePromiseTimer(pingIntervalMs);
27
+
26
28
  try {
27
- result = await Unpromise.race([nextPromise, pingPromise]);
29
+ result = await Unpromise.race([nextPromise, pingPromise.start()]);
30
+
31
+ if (result === disposablePromiseTimerResult) {
32
+ // cancelled
33
+
34
+ yield PING_SYM;
35
+ continue;
36
+ }
37
+
38
+ if (result.done) {
39
+ return result.value;
40
+ }
41
+
42
+ nextPromise = iterator.next();
43
+ yield result.value;
44
+
45
+ // free up reference for garbage collection
46
+ result = null;
28
47
  } finally {
29
- timer.clear();
30
- }
31
- if (result.done) {
32
- return result.value;
48
+ pingPromise[Symbol.dispose]();
33
49
  }
34
- yield result.value;
35
- timer.reset();
36
- // free up reference for garbage collection
37
- result = null;
38
50
  }
39
51
  }
@@ -0,0 +1,93 @@
1
+ // Callback function type that is called when a collection is drained
2
+ type OnDrain = () => void;
3
+
4
+ // Interface for objects that can be activated
5
+ export interface RefCount {
6
+ activate(): void;
7
+ }
8
+
9
+ // Map type that includes ref counting capabilities
10
+ export interface RefCountMap<TKey, TValue>
11
+ extends Map<TKey, TValue>,
12
+ RefCount {}
13
+
14
+ // Set type that includes ref counting capabilities
15
+ export interface RefCountSet<TValue> extends Set<TValue>, RefCount {}
16
+
17
+ /**
18
+ * Adds reference counting capabilities to a Map or Set collection.
19
+ * The collection can be activated, after which it will trigger a drain callback when emptied.
20
+ * Once drained, the collection cannot be modified further.
21
+ */
22
+ export function withRefCount<TKey, TValue>(
23
+ map: Map<TKey, TValue>,
24
+ onDrain: OnDrain,
25
+ ): RefCountMap<TKey, TValue>;
26
+ export function withRefCount<TValue>(
27
+ set: Set<TValue>,
28
+ onDrain: OnDrain,
29
+ ): RefCountSet<TValue>;
30
+ export function withRefCount(
31
+ _obj: Set<any> | Map<any, any>,
32
+ onDrain: OnDrain,
33
+ ): RefCountMap<any, any> & RefCountSet<any> {
34
+ const obj = _obj as any;
35
+
36
+ // Track whether the collection has been drained
37
+ let drained = false;
38
+ // Track whether the collection has been activated
39
+ let active = false;
40
+
41
+ // Check if collection should be drained (empty and active)
42
+ const checkDrain = () => {
43
+ if (!drained && active && obj.size === 0) {
44
+ onDrain();
45
+ drained = true;
46
+ }
47
+ };
48
+
49
+ // Create proxy to intercept collection operations
50
+ return new Proxy(obj, {
51
+ get(_, prop) {
52
+ // Handle activation
53
+ if (prop === 'activate') {
54
+ return () => {
55
+ active = true;
56
+ checkDrain();
57
+ };
58
+ }
59
+
60
+ // Handle adding items - prevent if already drained
61
+ if (prop === 'set' || prop === 'add') {
62
+ return (...args: any[]) => {
63
+ if (drained) {
64
+ throw new Error('Already drained');
65
+ }
66
+
67
+ return obj[prop](...args);
68
+ };
69
+ }
70
+
71
+ // Handle removing items - check if should drain after
72
+ if (prop === 'delete' || prop === 'clear') {
73
+ return (...args: any[]) => {
74
+ try {
75
+ return obj[prop](...args);
76
+ } finally {
77
+ checkDrain();
78
+ }
79
+ };
80
+ }
81
+ // Pass through other method calls
82
+ const target = obj[prop];
83
+ if (typeof target === 'function') {
84
+ return (...args: any[]) => {
85
+ return obj[prop](...args);
86
+ };
87
+ }
88
+
89
+ // Pass through property access
90
+ return target;
91
+ },
92
+ }) as never as RefCountMap<any, any> & RefCountSet<any>;
93
+ }
@@ -15,11 +15,11 @@ export * from './unstable-core-do-not-import/createProxy';
15
15
  export * from './unstable-core-do-not-import/error/formatter';
16
16
  export * from './unstable-core-do-not-import/error/getErrorShape';
17
17
  export * from './unstable-core-do-not-import/error/TRPCError';
18
- export * from './unstable-core-do-not-import/http/batchStreamFormatter';
19
18
  export * from './unstable-core-do-not-import/http/contentType';
20
19
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
21
20
  export * from './unstable-core-do-not-import/http/formDataToObject';
22
21
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
22
+ export * from './unstable-core-do-not-import/http/isAbortError';
23
23
  export * from './unstable-core-do-not-import/http/parseConnectionParams';
24
24
  export * from './unstable-core-do-not-import/http/resolveResponse';
25
25
  export * from './unstable-core-do-not-import/http/types';
@@ -32,8 +32,8 @@ export * from './unstable-core-do-not-import/rootConfig';
32
32
  export * from './unstable-core-do-not-import/router';
33
33
  export * from './unstable-core-do-not-import/rpc';
34
34
  export * from './unstable-core-do-not-import/stream/jsonl';
35
- export * from './unstable-core-do-not-import/stream/sse';
36
35
  export * from './unstable-core-do-not-import/stream/sse.types';
36
+ export * from './unstable-core-do-not-import/stream/sse';
37
37
  export * from './unstable-core-do-not-import/stream/tracked';
38
38
  export * from './unstable-core-do-not-import/stream/utils/createDeferred';
39
39
  export * from './unstable-core-do-not-import/transformer';
@@ -1,24 +0,0 @@
1
- /**
2
- * Format a batch response as a line-delimited JSON stream
3
- * that the `unstable_httpBatchStreamLink` can parse:
4
- *
5
- * @example
6
- * ```ts
7
- * const formatter = getBatchStreamFormatter();
8
- * res.send(formatter(1, 'response #2'));
9
- * res.send(formatter(0, 'response #1'));
10
- * res.send(formatter.end());
11
- * ```
12
- *
13
- * Expected format:
14
- * ```json
15
- * {"1":"response #2"
16
- * ,"0":"response #1"
17
- * }
18
- * ```
19
- */
20
- export declare function getBatchStreamFormatter(): {
21
- (index: number, string: string): string;
22
- end(): string;
23
- };
24
- //# sourceMappingURL=batchStreamFormatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"batchStreamFormatter.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/batchStreamFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB;YAEd,MAAM,UAAU,MAAM;;EAO9C"}
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Format a batch response as a line-delimited JSON stream
5
- * that the `unstable_httpBatchStreamLink` can parse:
6
- *
7
- * @example
8
- * ```ts
9
- * const formatter = getBatchStreamFormatter();
10
- * res.send(formatter(1, 'response #2'));
11
- * res.send(formatter(0, 'response #1'));
12
- * res.send(formatter.end());
13
- * ```
14
- *
15
- * Expected format:
16
- * ```json
17
- * {"1":"response #2"
18
- * ,"0":"response #1"
19
- * }
20
- * ```
21
- */ function getBatchStreamFormatter() {
22
- let first = true;
23
- function format(index, string) {
24
- const prefix = first ? '{' : ',';
25
- first = false;
26
- return `${prefix}"${index}":${string}\n`;
27
- }
28
- format.end = ()=>'}';
29
- return format;
30
- }
31
-
32
- exports.getBatchStreamFormatter = getBatchStreamFormatter;
@@ -1,30 +0,0 @@
1
- /**
2
- * Format a batch response as a line-delimited JSON stream
3
- * that the `unstable_httpBatchStreamLink` can parse:
4
- *
5
- * @example
6
- * ```ts
7
- * const formatter = getBatchStreamFormatter();
8
- * res.send(formatter(1, 'response #2'));
9
- * res.send(formatter(0, 'response #1'));
10
- * res.send(formatter.end());
11
- * ```
12
- *
13
- * Expected format:
14
- * ```json
15
- * {"1":"response #2"
16
- * ,"0":"response #1"
17
- * }
18
- * ```
19
- */ function getBatchStreamFormatter() {
20
- let first = true;
21
- function format(index, string) {
22
- const prefix = first ? '{' : ',';
23
- first = false;
24
- return `${prefix}"${index}":${string}\n`;
25
- }
26
- format.end = ()=>'}';
27
- return format;
28
- }
29
-
30
- export { getBatchStreamFormatter };
@@ -1,8 +0,0 @@
1
- export declare function createPromiseTimer(ms: number): {
2
- readonly promise: Promise<void>;
3
- start: () => PromiseTimer;
4
- reset: () => PromiseTimer;
5
- clear: () => PromiseTimer;
6
- };
7
- export type PromiseTimer = ReturnType<typeof createPromiseTimer>;
8
- //# sourceMappingURL=promiseTimer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"promiseTimer.d.ts","sourceRoot":"","sources":["../../../../src/unstable-core-do-not-import/stream/utils/promiseTimer.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM;;iBAezB,YAAY;iBAQZ,YAAY;iBAMZ,YAAY;EAO/B;AACD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- var createDeferred = require('./createDeferred.js');
4
-
5
- function createPromiseTimer(ms) {
6
- let deferred = createDeferred.createDeferred();
7
- let timeout = null;
8
- const timer = {
9
- get promise () {
10
- return deferred.promise;
11
- },
12
- start,
13
- reset,
14
- clear
15
- };
16
- return timer;
17
- function start() {
18
- if (timeout != null) {
19
- throw new Error('PromiseTimer already started.');
20
- }
21
- timeout = setTimeout(deferred.resolve, ms);
22
- return timer;
23
- }
24
- function reset() {
25
- clear();
26
- deferred = createDeferred.createDeferred();
27
- return timer;
28
- }
29
- function clear() {
30
- if (timeout != null) {
31
- clearTimeout(timeout);
32
- timeout = null;
33
- }
34
- return timer;
35
- }
36
- }
37
-
38
- exports.createPromiseTimer = createPromiseTimer;
@@ -1,36 +0,0 @@
1
- import { createDeferred } from './createDeferred.mjs';
2
-
3
- function createPromiseTimer(ms) {
4
- let deferred = createDeferred();
5
- let timeout = null;
6
- const timer = {
7
- get promise () {
8
- return deferred.promise;
9
- },
10
- start,
11
- reset,
12
- clear
13
- };
14
- return timer;
15
- function start() {
16
- if (timeout != null) {
17
- throw new Error('PromiseTimer already started.');
18
- }
19
- timeout = setTimeout(deferred.resolve, ms);
20
- return timer;
21
- }
22
- function reset() {
23
- clear();
24
- deferred = createDeferred();
25
- return timer;
26
- }
27
- function clear() {
28
- if (timeout != null) {
29
- clearTimeout(timeout);
30
- timeout = null;
31
- }
32
- return timer;
33
- }
34
- }
35
-
36
- export { createPromiseTimer };
@@ -1,29 +0,0 @@
1
- /**
2
- * Format a batch response as a line-delimited JSON stream
3
- * that the `unstable_httpBatchStreamLink` can parse:
4
- *
5
- * @example
6
- * ```ts
7
- * const formatter = getBatchStreamFormatter();
8
- * res.send(formatter(1, 'response #2'));
9
- * res.send(formatter(0, 'response #1'));
10
- * res.send(formatter.end());
11
- * ```
12
- *
13
- * Expected format:
14
- * ```json
15
- * {"1":"response #2"
16
- * ,"0":"response #1"
17
- * }
18
- * ```
19
- */
20
- export function getBatchStreamFormatter() {
21
- let first = true;
22
- function format(index: number, string: string) {
23
- const prefix = first ? '{' : ',';
24
- first = false;
25
- return `${prefix}"${index}":${string}\n`;
26
- }
27
- format.end = () => '}';
28
- return format;
29
- }
@@ -1,40 +0,0 @@
1
- import { createDeferred } from './createDeferred';
2
-
3
- export function createPromiseTimer(ms: number) {
4
- let deferred = createDeferred<void>();
5
- let timeout: ReturnType<typeof setTimeout> | null = null;
6
-
7
- const timer = {
8
- get promise() {
9
- return deferred.promise;
10
- },
11
-
12
- start,
13
- reset,
14
- clear,
15
- };
16
- return timer;
17
-
18
- function start(): PromiseTimer {
19
- if (timeout != null) {
20
- throw new Error('PromiseTimer already started.');
21
- }
22
- timeout = setTimeout(deferred.resolve, ms);
23
- return timer;
24
- }
25
-
26
- function reset(): PromiseTimer {
27
- clear();
28
- deferred = createDeferred();
29
- return timer;
30
- }
31
-
32
- function clear(): PromiseTimer {
33
- if (timeout != null) {
34
- clearTimeout(timeout);
35
- timeout = null;
36
- }
37
- return timer;
38
- }
39
- }
40
- export type PromiseTimer = ReturnType<typeof createPromiseTimer>;