@trpc/server 11.0.0-rc.621 → 11.0.0-rc.630
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/getPlanner.js +2 -2
- package/dist/adapters/aws-lambda/getPlanner.mjs +2 -2
- package/dist/adapters/aws-lambda/index.js +1 -0
- package/dist/adapters/aws-lambda/index.mjs +1 -0
- package/dist/adapters/express.js +1 -0
- package/dist/adapters/express.mjs +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.js +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +7 -6
- package/dist/adapters/fetch/fetchRequestHandler.mjs +7 -6
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +5 -4
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +5 -4
- package/dist/adapters/next-app-dir/notFound.js +1 -0
- package/dist/adapters/next-app-dir/notFound.mjs +1 -0
- package/dist/adapters/next-app-dir/redirect.js +3 -1
- package/dist/adapters/next-app-dir/redirect.mjs +3 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +1 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +1 -1
- package/dist/adapters/next.js +1 -0
- package/dist/adapters/next.mjs +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.js +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +5 -4
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +5 -4
- package/dist/adapters/standalone.js +1 -0
- package/dist/adapters/standalone.mjs +1 -0
- package/dist/adapters/ws.js +9 -9
- package/dist/adapters/ws.mjs +9 -9
- package/dist/bundle-analysis.json +114 -97
- package/dist/http.js +1 -0
- package/dist/http.mjs +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js +11 -0
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs +9 -0
- package/dist/observable/observable.js +1 -1
- package/dist/observable/observable.mjs +1 -1
- package/dist/rpc.js +1 -0
- package/dist/rpc.mjs +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.mjs +1 -0
- package/dist/unstable-core-do-not-import/createProxy.js +1 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +4 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +4 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +1 -1
- package/dist/unstable-core-do-not-import/error/formatter.mjs +1 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +2 -2
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +2 -2
- package/dist/unstable-core-do-not-import/http/contentType.js +3 -3
- package/dist/unstable-core-do-not-import/http/contentType.mjs +3 -3
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +24 -24
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +24 -24
- package/dist/unstable-core-do-not-import/middleware.js +1 -1
- package/dist/unstable-core-do-not-import/middleware.mjs +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -1
- package/dist/unstable-core-do-not-import/router.js +2 -2
- package/dist/unstable-core-do-not-import/router.mjs +2 -2
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +2 -2
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +2 -2
- package/dist/unstable-core-do-not-import/stream/jsonl.js +14 -15
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +14 -15
- package/dist/unstable-core-do-not-import/stream/sse.js +2 -2
- package/dist/unstable-core-do-not-import/stream/sse.mjs +2 -2
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +1 -1
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +1 -1
- package/dist/vendor/unpromise/unpromise.js +21 -16
- package/dist/vendor/unpromise/unpromise.mjs +21 -16
- package/package.json +11 -4
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _define_property } from '../../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs';
|
|
1
2
|
import { Unpromise } from '../../vendor/unpromise/unpromise.mjs';
|
|
2
3
|
import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
|
|
3
4
|
import { isObject, isFunction, isAsyncIterable, run } from '../utils.mjs';
|
|
@@ -17,12 +18,11 @@ function isPromise(value) {
|
|
|
17
18
|
}
|
|
18
19
|
class MaxDepthError extends Error {
|
|
19
20
|
constructor(path){
|
|
20
|
-
super('Max depth reached at path: ' + path.join('.'));
|
|
21
|
-
this.path = path;
|
|
21
|
+
super('Max depth reached at path: ' + path.join('.')), _define_property(this, "path", void 0), this.path = path;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
function createBatchStreamProducer(opts) {
|
|
25
|
-
const { data
|
|
25
|
+
const { data } = opts;
|
|
26
26
|
let counter = 0;
|
|
27
27
|
const placeholder = 0;
|
|
28
28
|
const stream = createReadableStream();
|
|
@@ -229,7 +229,7 @@ function createBatchStreamProducer(opts) {
|
|
|
229
229
|
* @see https://jsonlines.org/
|
|
230
230
|
*/ function jsonlStreamProducer(opts) {
|
|
231
231
|
let [head, stream] = createBatchStreamProducer(opts);
|
|
232
|
-
const { serialize
|
|
232
|
+
const { serialize } = opts;
|
|
233
233
|
if (serialize) {
|
|
234
234
|
head = serialize(head);
|
|
235
235
|
stream = stream.pipeThrough(new TransformStream({
|
|
@@ -258,14 +258,13 @@ class StreamInterruptedError extends Error {
|
|
|
258
258
|
}
|
|
259
259
|
class AsyncError extends Error {
|
|
260
260
|
constructor(data){
|
|
261
|
-
super('Received error from server');
|
|
262
|
-
this.data = data;
|
|
261
|
+
super('Received error from server'), _define_property(this, "data", void 0), this.data = data;
|
|
263
262
|
}
|
|
264
263
|
}
|
|
265
264
|
const nodeJsStreamToReaderEsque = (source)=>{
|
|
266
265
|
return {
|
|
267
266
|
getReader () {
|
|
268
|
-
const { readable
|
|
267
|
+
const { readable, controller } = createReadableStream();
|
|
269
268
|
source.on('data', (chunk)=>{
|
|
270
269
|
controller.enqueue(chunk);
|
|
271
270
|
});
|
|
@@ -284,7 +283,7 @@ function createLineAccumulator(from) {
|
|
|
284
283
|
let lineAggregate = '';
|
|
285
284
|
return new ReadableStream({
|
|
286
285
|
async pull (controller) {
|
|
287
|
-
const { done
|
|
286
|
+
const { done, value } = await reader.read();
|
|
288
287
|
if (done) {
|
|
289
288
|
controller.close();
|
|
290
289
|
} else {
|
|
@@ -325,7 +324,7 @@ function createConsumerStream(from) {
|
|
|
325
324
|
* JSON Lines stream consumer
|
|
326
325
|
* @see https://jsonlines.org/
|
|
327
326
|
*/ async function jsonlStreamConsumer(opts) {
|
|
328
|
-
const { deserialize =(v)=>v
|
|
327
|
+
const { deserialize = (v)=>v } = opts;
|
|
329
328
|
let source = createConsumerStream(opts.from);
|
|
330
329
|
if (deserialize) {
|
|
331
330
|
source = source.pipeThrough(new TransformStream({
|
|
@@ -345,7 +344,7 @@ function createConsumerStream(from) {
|
|
|
345
344
|
};
|
|
346
345
|
function hydrateChunkDefinition(value) {
|
|
347
346
|
const [_path, type, chunkId] = value;
|
|
348
|
-
const { readable
|
|
347
|
+
const { readable, controller } = createReadableStream();
|
|
349
348
|
const wrapper = {
|
|
350
349
|
controller,
|
|
351
350
|
returned: false
|
|
@@ -398,7 +397,7 @@ function createConsumerStream(from) {
|
|
|
398
397
|
const reader = readable.getReader();
|
|
399
398
|
const iterator = {
|
|
400
399
|
next: async ()=>{
|
|
401
|
-
const { done
|
|
400
|
+
const { done, value } = await reader.read();
|
|
402
401
|
if (value instanceof StreamInterruptedError) {
|
|
403
402
|
throw value;
|
|
404
403
|
}
|
|
@@ -449,9 +448,9 @@ function createConsumerStream(from) {
|
|
|
449
448
|
}
|
|
450
449
|
function hydrate(value) {
|
|
451
450
|
const [[data], ...asyncProps] = value;
|
|
452
|
-
for (const
|
|
453
|
-
const [key] =
|
|
454
|
-
const hydrated = hydrateChunkDefinition(
|
|
451
|
+
for (const value of asyncProps){
|
|
452
|
+
const [key] = value;
|
|
453
|
+
const hydrated = hydrateChunkDefinition(value);
|
|
455
454
|
if (key === null) {
|
|
456
455
|
return hydrated;
|
|
457
456
|
}
|
|
@@ -466,7 +465,7 @@ function createConsumerStream(from) {
|
|
|
466
465
|
deferred.reject(error);
|
|
467
466
|
}
|
|
468
467
|
chunkDeferred.clear();
|
|
469
|
-
for (const { controller
|
|
468
|
+
for (const { controller } of controllers.values()){
|
|
470
469
|
controller.enqueue(error);
|
|
471
470
|
controller.close();
|
|
472
471
|
}
|
|
@@ -17,7 +17,7 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
17
17
|
stream.controller.enqueue({
|
|
18
18
|
comment: 'connected'
|
|
19
19
|
});
|
|
20
|
-
const { serialize =utils.identity
|
|
20
|
+
const { serialize = utils.identity } = opts;
|
|
21
21
|
const ping = {
|
|
22
22
|
enabled: opts.ping?.enabled ?? false,
|
|
23
23
|
intervalMs: opts.ping?.intervalMs ?? 1000
|
|
@@ -109,7 +109,7 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
109
109
|
/**
|
|
110
110
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
111
111
|
*/ function sseStreamConsumer(opts) {
|
|
112
|
-
const { deserialize =(v)=>v
|
|
112
|
+
const { deserialize = (v)=>v } = opts;
|
|
113
113
|
const signal = opts.signal;
|
|
114
114
|
let _es = null;
|
|
115
115
|
const stream = new ReadableStream({
|
|
@@ -15,7 +15,7 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
15
15
|
stream.controller.enqueue({
|
|
16
16
|
comment: 'connected'
|
|
17
17
|
});
|
|
18
|
-
const { serialize =identity
|
|
18
|
+
const { serialize = identity } = opts;
|
|
19
19
|
const ping = {
|
|
20
20
|
enabled: opts.ping?.enabled ?? false,
|
|
21
21
|
intervalMs: opts.ping?.intervalMs ?? 1000
|
|
@@ -107,7 +107,7 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
107
107
|
/**
|
|
108
108
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
109
109
|
*/ function sseStreamConsumer(opts) {
|
|
110
|
-
const { deserialize =(v)=>v
|
|
110
|
+
const { deserialize = (v)=>v } = opts;
|
|
111
111
|
const signal = opts.signal;
|
|
112
112
|
let _es = null;
|
|
113
113
|
const stream = new ReadableStream({
|
|
@@ -33,7 +33,7 @@ var promiseTimer = require('./promiseTimer.js');
|
|
|
33
33
|
* Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
|
|
34
34
|
* {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
|
|
35
35
|
* values may still come through. After this period, the generator stops.
|
|
36
|
-
*/ async function* takeWithGrace(iterable, { count
|
|
36
|
+
*/ async function* takeWithGrace(iterable, { count, gracePeriodMs, onCancel }) {
|
|
37
37
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
38
38
|
const timer = promiseTimer.createPromiseTimer(gracePeriodMs);
|
|
39
39
|
try {
|
|
@@ -31,7 +31,7 @@ import { createPromiseTimer } from './promiseTimer.mjs';
|
|
|
31
31
|
* Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
|
|
32
32
|
* {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
|
|
33
33
|
* values may still come through. After this period, the generator stops.
|
|
34
|
-
*/ async function* takeWithGrace(iterable, { count
|
|
34
|
+
*/ async function* takeWithGrace(iterable, { count, gracePeriodMs, onCancel }) {
|
|
35
35
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
36
36
|
const timer = createPromiseTimer(gracePeriodMs);
|
|
37
37
|
try {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _define_property = require('../../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js');
|
|
4
|
+
|
|
5
|
+
var _computedKey;
|
|
6
|
+
/** Memory safe (weakmapped) cache of the ProxyPromise for each Promise,
|
|
4
7
|
* which is retained for the lifetime of the original Promise.
|
|
5
8
|
*/ const subscribableCache = new WeakMap();
|
|
6
9
|
/** A NOOP function allowing a consistent interface for settled
|
|
@@ -8,7 +11,8 @@
|
|
|
8
11
|
* immediately). */ const NOOP = ()=>{
|
|
9
12
|
// noop
|
|
10
13
|
};
|
|
11
|
-
|
|
14
|
+
_computedKey = Symbol.toStringTag;
|
|
15
|
+
let _computedKey1 = _computedKey;
|
|
12
16
|
/**
|
|
13
17
|
* Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
|
|
14
18
|
* created once, cached and reused throughout the lifetime of the Promise. Get a
|
|
@@ -63,7 +67,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
63
67
|
// in all cases we will combine some promise with its unsubscribe function
|
|
64
68
|
let promise;
|
|
65
69
|
let unsubscribe;
|
|
66
|
-
const { settlement
|
|
70
|
+
const { settlement } = this;
|
|
67
71
|
if (settlement === null) {
|
|
68
72
|
// not yet settled - subscribe new promise. Expect eventual settlement
|
|
69
73
|
if (this.subscribers === null) {
|
|
@@ -80,7 +84,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
80
84
|
};
|
|
81
85
|
} else {
|
|
82
86
|
// settled - don't create subscribed promise. Just resolve or reject
|
|
83
|
-
const { status
|
|
87
|
+
const { status } = settlement;
|
|
84
88
|
if (status === "fulfilled") {
|
|
85
89
|
promise = Promise.resolve(settlement.value);
|
|
86
90
|
} else {
|
|
@@ -95,21 +99,21 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
95
99
|
}
|
|
96
100
|
/** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */ then(onfulfilled, onrejected) {
|
|
97
101
|
const subscribed = this.subscribe();
|
|
98
|
-
const { unsubscribe
|
|
102
|
+
const { unsubscribe } = subscribed;
|
|
99
103
|
return Object.assign(subscribed.then(onfulfilled, onrejected), {
|
|
100
104
|
unsubscribe
|
|
101
105
|
});
|
|
102
106
|
}
|
|
103
107
|
catch(onrejected) {
|
|
104
108
|
const subscribed = this.subscribe();
|
|
105
|
-
const { unsubscribe
|
|
109
|
+
const { unsubscribe } = subscribed;
|
|
106
110
|
return Object.assign(subscribed.catch(onrejected), {
|
|
107
111
|
unsubscribe
|
|
108
112
|
});
|
|
109
113
|
}
|
|
110
114
|
finally(onfinally) {
|
|
111
115
|
const subscribed = this.subscribe();
|
|
112
|
-
const { unsubscribe
|
|
116
|
+
const { unsubscribe } = subscribed;
|
|
113
117
|
return Object.assign(subscribed.finally(onfinally), {
|
|
114
118
|
unsubscribe
|
|
115
119
|
});
|
|
@@ -141,7 +145,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
141
145
|
try {
|
|
142
146
|
return await Promise.any(subscribedPromises);
|
|
143
147
|
} finally{
|
|
144
|
-
subscribedPromises.forEach(({ unsubscribe
|
|
148
|
+
subscribedPromises.forEach(({ unsubscribe })=>{
|
|
145
149
|
unsubscribe();
|
|
146
150
|
});
|
|
147
151
|
}
|
|
@@ -154,7 +158,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
154
158
|
try {
|
|
155
159
|
return await Promise.race(subscribedPromises);
|
|
156
160
|
} finally{
|
|
157
|
-
subscribedPromises.forEach(({ unsubscribe
|
|
161
|
+
subscribedPromises.forEach(({ unsubscribe })=>{
|
|
158
162
|
unsubscribe();
|
|
159
163
|
});
|
|
160
164
|
}
|
|
@@ -184,12 +188,13 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
184
188
|
}
|
|
185
189
|
}
|
|
186
190
|
constructor(arg){
|
|
191
|
+
/** INSTANCE IMPLEMENTATION */ /** The promise shadowed by this Unpromise<T> */ _define_property._(this, "promise", void 0);
|
|
187
192
|
/** Promises expecting eventual settlement (unless unsubscribed first). This list is deleted
|
|
188
|
-
* after the original promise settles - no further notifications will be issued. */ this
|
|
193
|
+
* after the original promise settles - no further notifications will be issued. */ _define_property._(this, "subscribers", []);
|
|
189
194
|
/** The Promise's settlement (recorded when it fulfils or rejects). This is consulted when
|
|
190
195
|
* calling .subscribe() .then() .catch() .finally() to see if an immediately-resolving Promise
|
|
191
|
-
* can be returned, and therefore subscription can be bypassed. */ this
|
|
192
|
-
/** TOSTRING SUPPORT */ this
|
|
196
|
+
* can be returned, and therefore subscription can be bypassed. */ _define_property._(this, "settlement", null);
|
|
197
|
+
/** TOSTRING SUPPORT */ _define_property._(this, _computedKey1, "Unpromise");
|
|
193
198
|
// handle either a Promise or a Promise executor function
|
|
194
199
|
if (typeof arg === "function") {
|
|
195
200
|
this.promise = new Promise(arg);
|
|
@@ -200,14 +205,14 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
200
205
|
// handle PromiseLike objects (that at least have .then)
|
|
201
206
|
const thenReturn = this.promise.then((value)=>{
|
|
202
207
|
// atomically record fulfilment and detach subscriber list
|
|
203
|
-
const { subscribers
|
|
208
|
+
const { subscribers } = this;
|
|
204
209
|
this.subscribers = null;
|
|
205
210
|
this.settlement = {
|
|
206
211
|
status: "fulfilled",
|
|
207
212
|
value
|
|
208
213
|
};
|
|
209
214
|
// notify fulfilment to subscriber list
|
|
210
|
-
subscribers?.forEach(({ resolve
|
|
215
|
+
subscribers?.forEach(({ resolve })=>{
|
|
211
216
|
resolve(value);
|
|
212
217
|
});
|
|
213
218
|
});
|
|
@@ -215,14 +220,14 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
215
220
|
if ("catch" in thenReturn) {
|
|
216
221
|
thenReturn.catch((reason)=>{
|
|
217
222
|
// atomically record rejection and detach subscriber list
|
|
218
|
-
const { subscribers
|
|
223
|
+
const { subscribers } = this;
|
|
219
224
|
this.subscribers = null;
|
|
220
225
|
this.settlement = {
|
|
221
226
|
status: "rejected",
|
|
222
227
|
reason
|
|
223
228
|
};
|
|
224
229
|
// notify rejection to subscriber list
|
|
225
|
-
subscribers?.forEach(({ reject
|
|
230
|
+
subscribers?.forEach(({ reject })=>{
|
|
226
231
|
reject(reason);
|
|
227
232
|
});
|
|
228
233
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { _ as _define_property } from '../../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs';
|
|
2
|
+
|
|
3
|
+
var _computedKey;
|
|
4
|
+
/** Memory safe (weakmapped) cache of the ProxyPromise for each Promise,
|
|
2
5
|
* which is retained for the lifetime of the original Promise.
|
|
3
6
|
*/ const subscribableCache = new WeakMap();
|
|
4
7
|
/** A NOOP function allowing a consistent interface for settled
|
|
@@ -6,7 +9,8 @@
|
|
|
6
9
|
* immediately). */ const NOOP = ()=>{
|
|
7
10
|
// noop
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
_computedKey = Symbol.toStringTag;
|
|
13
|
+
let _computedKey1 = _computedKey;
|
|
10
14
|
/**
|
|
11
15
|
* Every `Promise<T>` can be shadowed by a single `ProxyPromise<T>`. It is
|
|
12
16
|
* created once, cached and reused throughout the lifetime of the Promise. Get a
|
|
@@ -61,7 +65,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
61
65
|
// in all cases we will combine some promise with its unsubscribe function
|
|
62
66
|
let promise;
|
|
63
67
|
let unsubscribe;
|
|
64
|
-
const { settlement
|
|
68
|
+
const { settlement } = this;
|
|
65
69
|
if (settlement === null) {
|
|
66
70
|
// not yet settled - subscribe new promise. Expect eventual settlement
|
|
67
71
|
if (this.subscribers === null) {
|
|
@@ -78,7 +82,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
78
82
|
};
|
|
79
83
|
} else {
|
|
80
84
|
// settled - don't create subscribed promise. Just resolve or reject
|
|
81
|
-
const { status
|
|
85
|
+
const { status } = settlement;
|
|
82
86
|
if (status === "fulfilled") {
|
|
83
87
|
promise = Promise.resolve(settlement.value);
|
|
84
88
|
} else {
|
|
@@ -93,21 +97,21 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
93
97
|
}
|
|
94
98
|
/** STANDARD PROMISE METHODS (but returning a SubscribedPromise) */ then(onfulfilled, onrejected) {
|
|
95
99
|
const subscribed = this.subscribe();
|
|
96
|
-
const { unsubscribe
|
|
100
|
+
const { unsubscribe } = subscribed;
|
|
97
101
|
return Object.assign(subscribed.then(onfulfilled, onrejected), {
|
|
98
102
|
unsubscribe
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
catch(onrejected) {
|
|
102
106
|
const subscribed = this.subscribe();
|
|
103
|
-
const { unsubscribe
|
|
107
|
+
const { unsubscribe } = subscribed;
|
|
104
108
|
return Object.assign(subscribed.catch(onrejected), {
|
|
105
109
|
unsubscribe
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
finally(onfinally) {
|
|
109
113
|
const subscribed = this.subscribe();
|
|
110
|
-
const { unsubscribe
|
|
114
|
+
const { unsubscribe } = subscribed;
|
|
111
115
|
return Object.assign(subscribed.finally(onfinally), {
|
|
112
116
|
unsubscribe
|
|
113
117
|
});
|
|
@@ -139,7 +143,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
139
143
|
try {
|
|
140
144
|
return await Promise.any(subscribedPromises);
|
|
141
145
|
} finally{
|
|
142
|
-
subscribedPromises.forEach(({ unsubscribe
|
|
146
|
+
subscribedPromises.forEach(({ unsubscribe })=>{
|
|
143
147
|
unsubscribe();
|
|
144
148
|
});
|
|
145
149
|
}
|
|
@@ -152,7 +156,7 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
152
156
|
try {
|
|
153
157
|
return await Promise.race(subscribedPromises);
|
|
154
158
|
} finally{
|
|
155
|
-
subscribedPromises.forEach(({ unsubscribe
|
|
159
|
+
subscribedPromises.forEach(({ unsubscribe })=>{
|
|
156
160
|
unsubscribe();
|
|
157
161
|
});
|
|
158
162
|
}
|
|
@@ -182,12 +186,13 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
constructor(arg){
|
|
189
|
+
/** INSTANCE IMPLEMENTATION */ /** The promise shadowed by this Unpromise<T> */ _define_property(this, "promise", void 0);
|
|
185
190
|
/** Promises expecting eventual settlement (unless unsubscribed first). This list is deleted
|
|
186
|
-
* after the original promise settles - no further notifications will be issued. */ this
|
|
191
|
+
* after the original promise settles - no further notifications will be issued. */ _define_property(this, "subscribers", []);
|
|
187
192
|
/** The Promise's settlement (recorded when it fulfils or rejects). This is consulted when
|
|
188
193
|
* calling .subscribe() .then() .catch() .finally() to see if an immediately-resolving Promise
|
|
189
|
-
* can be returned, and therefore subscription can be bypassed. */ this
|
|
190
|
-
/** TOSTRING SUPPORT */ this
|
|
194
|
+
* can be returned, and therefore subscription can be bypassed. */ _define_property(this, "settlement", null);
|
|
195
|
+
/** TOSTRING SUPPORT */ _define_property(this, _computedKey1, "Unpromise");
|
|
191
196
|
// handle either a Promise or a Promise executor function
|
|
192
197
|
if (typeof arg === "function") {
|
|
193
198
|
this.promise = new Promise(arg);
|
|
@@ -198,14 +203,14 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
198
203
|
// handle PromiseLike objects (that at least have .then)
|
|
199
204
|
const thenReturn = this.promise.then((value)=>{
|
|
200
205
|
// atomically record fulfilment and detach subscriber list
|
|
201
|
-
const { subscribers
|
|
206
|
+
const { subscribers } = this;
|
|
202
207
|
this.subscribers = null;
|
|
203
208
|
this.settlement = {
|
|
204
209
|
status: "fulfilled",
|
|
205
210
|
value
|
|
206
211
|
};
|
|
207
212
|
// notify fulfilment to subscriber list
|
|
208
|
-
subscribers?.forEach(({ resolve
|
|
213
|
+
subscribers?.forEach(({ resolve })=>{
|
|
209
214
|
resolve(value);
|
|
210
215
|
});
|
|
211
216
|
});
|
|
@@ -213,14 +218,14 @@ let _toStringTag = Symbol.toStringTag;
|
|
|
213
218
|
if ("catch" in thenReturn) {
|
|
214
219
|
thenReturn.catch((reason)=>{
|
|
215
220
|
// atomically record rejection and detach subscriber list
|
|
216
|
-
const { subscribers
|
|
221
|
+
const { subscribers } = this;
|
|
217
222
|
this.subscribers = null;
|
|
218
223
|
this.settlement = {
|
|
219
224
|
status: "rejected",
|
|
220
225
|
reason
|
|
221
226
|
};
|
|
222
227
|
// notify rejection to subscriber list
|
|
223
|
-
subscribers?.forEach(({ reject
|
|
228
|
+
subscribers?.forEach(({ reject })=>{
|
|
224
229
|
reject(reason);
|
|
225
230
|
});
|
|
226
231
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.630+73639524c",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@types/aws-lambda": "^8.10.137",
|
|
122
122
|
"@types/express": "^4.17.17",
|
|
123
123
|
"@types/hash-sum": "^1.0.0",
|
|
124
|
-
"@types/node": "^
|
|
124
|
+
"@types/node": "^22.9.0",
|
|
125
125
|
"@types/react": "^18.3.1",
|
|
126
126
|
"@types/react-dom": "^18.3.0",
|
|
127
127
|
"@types/ws": "^8.2.0",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"next": "^15.0.2",
|
|
136
136
|
"react": "^18.3.1",
|
|
137
137
|
"react-dom": "^18.3.1",
|
|
138
|
-
"rollup": "^4.
|
|
138
|
+
"rollup": "^4.24.4",
|
|
139
139
|
"superjson": "^1.12.4",
|
|
140
140
|
"superstruct": "^2.0.0",
|
|
141
141
|
"tslib": "^2.5.0",
|
|
@@ -149,5 +149,12 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"
|
|
152
|
+
"optionalDependencies": {
|
|
153
|
+
"@types/aws-lambda": "*",
|
|
154
|
+
"express": "*",
|
|
155
|
+
"fastify": "*",
|
|
156
|
+
"next": "*",
|
|
157
|
+
"ws": "*"
|
|
158
|
+
},
|
|
159
|
+
"gitHead": "73639524cd2d8071e4818435a76f7234685ac2af"
|
|
153
160
|
}
|