@camstack/core 0.1.14 → 0.1.15
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/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +220 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js.map +1 -0
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +9 -0
- package/dist/builtins/addon-pages-aggregator/index.js +222 -0
- package/dist/builtins/addon-pages-aggregator/index.js.map +1 -0
- package/dist/builtins/addon-pages-aggregator/index.mjs +9 -0
- package/dist/builtins/addon-pages-aggregator/index.mjs.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +200 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +9 -0
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/index.js +202 -0
- package/dist/builtins/addon-widgets-aggregator/index.js.map +1 -0
- package/dist/builtins/addon-widgets-aggregator/index.mjs +9 -0
- package/dist/builtins/addon-widgets-aggregator/index.mjs.map +1 -0
- package/dist/builtins/alerts/alerts.addon.js +443 -0
- package/dist/builtins/alerts/alerts.addon.js.map +1 -0
- package/dist/builtins/alerts/alerts.addon.mjs +9 -0
- package/dist/builtins/alerts/alerts.addon.mjs.map +1 -0
- package/dist/builtins/alerts/index.js +443 -0
- package/dist/builtins/alerts/index.js.map +1 -0
- package/dist/builtins/alerts/index.mjs +8 -0
- package/dist/builtins/alerts/index.mjs.map +1 -0
- package/dist/builtins/console-logging/index.js +242 -0
- package/dist/builtins/console-logging/index.js.map +1 -0
- package/dist/builtins/console-logging/index.mjs +11 -0
- package/dist/builtins/console-logging/index.mjs.map +1 -0
- package/dist/builtins/device-manager/device-manager.addon.js +2155 -0
- package/dist/builtins/device-manager/device-manager.addon.js.map +1 -0
- package/dist/builtins/device-manager/device-manager.addon.mjs +9 -0
- package/dist/builtins/device-manager/device-manager.addon.mjs.map +1 -0
- package/dist/builtins/device-manager/index.js +2157 -0
- package/dist/builtins/device-manager/index.js.map +1 -0
- package/dist/builtins/device-manager/index.mjs +10 -0
- package/dist/builtins/device-manager/index.mjs.map +1 -0
- package/dist/builtins/hub-forwarder/index.js +297 -0
- package/dist/builtins/hub-forwarder/index.js.map +1 -0
- package/dist/builtins/hub-forwarder/index.mjs +11 -0
- package/dist/builtins/hub-forwarder/index.mjs.map +1 -0
- package/dist/builtins/local-auth/index.js +623 -0
- package/dist/builtins/local-auth/index.js.map +1 -0
- package/dist/builtins/local-auth/index.mjs +8 -0
- package/dist/builtins/local-auth/index.mjs.map +1 -0
- package/dist/builtins/local-auth/local-auth.addon.js +623 -0
- package/dist/builtins/local-auth/local-auth.addon.js.map +1 -0
- package/dist/builtins/local-auth/local-auth.addon.mjs +9 -0
- package/dist/builtins/local-auth/local-auth.addon.mjs.map +1 -0
- package/dist/builtins/local-backup/index.js +53 -68
- package/dist/builtins/local-backup/index.js.map +1 -1
- package/dist/builtins/local-backup/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +898 -0
- package/dist/builtins/native-metrics/native-metrics.addon.js.map +1 -0
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +7 -0
- package/dist/builtins/native-metrics/native-metrics.addon.mjs.map +1 -0
- package/dist/builtins/snapshot/index.js +504 -0
- package/dist/builtins/snapshot/index.js.map +1 -0
- package/dist/builtins/snapshot/index.mjs +477 -0
- package/dist/builtins/snapshot/index.mjs.map +1 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +16 -166
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js.map +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +554 -621
- package/dist/builtins/sqlite-storage/index.js.map +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +9 -11
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +368 -130
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js.map +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
- package/dist/builtins/system-config/index.js +189 -0
- package/dist/builtins/system-config/index.js.map +1 -0
- package/dist/builtins/system-config/index.mjs +10 -0
- package/dist/builtins/system-config/index.mjs.map +1 -0
- package/dist/builtins/system-config/system-config.addon.js +187 -0
- package/dist/builtins/system-config/system-config.addon.js.map +1 -0
- package/dist/builtins/system-config/system-config.addon.mjs +9 -0
- package/dist/builtins/system-config/system-config.addon.mjs.map +1 -0
- package/dist/builtins/winston-logging/index.js +185 -65
- package/dist/builtins/winston-logging/index.js.map +1 -1
- package/dist/builtins/winston-logging/index.mjs +2 -1
- package/dist/chunk-2CIYKDRN.mjs +1 -0
- package/dist/chunk-2CIYKDRN.mjs.map +1 -0
- package/dist/chunk-2F76X6NL.mjs +136 -0
- package/dist/chunk-2F76X6NL.mjs.map +1 -0
- package/dist/chunk-2QUFBZ7M.mjs +1 -0
- package/dist/chunk-2QUFBZ7M.mjs.map +1 -0
- package/dist/chunk-3BK2Y7GY.mjs +593 -0
- package/dist/chunk-3BK2Y7GY.mjs.map +1 -0
- package/dist/chunk-4OOHFJHT.mjs +421 -0
- package/dist/chunk-4OOHFJHT.mjs.map +1 -0
- package/dist/chunk-4XHB7IHT.mjs +809 -0
- package/dist/chunk-4XHB7IHT.mjs.map +1 -0
- package/dist/{chunk-2F3XZYRW.mjs → chunk-6M2HSSTQ.mjs} +16 -7
- package/dist/chunk-6M2HSSTQ.mjs.map +1 -0
- package/dist/{chunk-SO4LROOT.mjs → chunk-7FI7SQS7.mjs} +54 -69
- package/dist/chunk-7FI7SQS7.mjs.map +1 -0
- package/dist/chunk-ED57RCQE.mjs +171 -0
- package/dist/chunk-ED57RCQE.mjs.map +1 -0
- package/dist/chunk-FZN56HGQ.mjs +626 -0
- package/dist/chunk-FZN56HGQ.mjs.map +1 -0
- package/dist/chunk-GL4OOB25.mjs +51 -0
- package/dist/chunk-GL4OOB25.mjs.map +1 -0
- package/dist/chunk-KDG2NTDB.mjs +137 -0
- package/dist/chunk-KDG2NTDB.mjs.map +1 -0
- package/dist/chunk-NRBQWBDM.mjs +191 -0
- package/dist/chunk-NRBQWBDM.mjs.map +1 -0
- package/dist/chunk-O4V246GG.mjs +2137 -0
- package/dist/chunk-O4V246GG.mjs.map +1 -0
- package/dist/chunk-QT57H266.mjs +163 -0
- package/dist/chunk-QT57H266.mjs.map +1 -0
- package/dist/chunk-QX4RH25I.mjs +141 -0
- package/dist/chunk-QX4RH25I.mjs.map +1 -0
- package/dist/chunk-TB562PZX.mjs +86 -0
- package/dist/chunk-TB562PZX.mjs.map +1 -0
- package/dist/chunk-TDYPZXK5.mjs +1 -0
- package/dist/chunk-TDYPZXK5.mjs.map +1 -0
- package/dist/chunk-UJI4LN5P.mjs +36 -0
- package/dist/chunk-UJI4LN5P.mjs.map +1 -0
- package/dist/chunk-W6RTHQGP.mjs +1 -0
- package/dist/chunk-W6RTHQGP.mjs.map +1 -0
- package/dist/chunk-ZELBCPDC.mjs +369 -0
- package/dist/chunk-ZELBCPDC.mjs.map +1 -0
- package/dist/index.d.mts +1103 -544
- package/dist/index.d.ts +1103 -544
- package/dist/index.js +7032 -6033
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +568 -2226
- package/dist/index.mjs.map +1 -1
- package/dist/resource-monitor-UZUGPIAU.mjs +9 -0
- package/dist/resource-monitor-UZUGPIAU.mjs.map +1 -0
- package/dist/storage-location-manager-HFNB3PCS.mjs +7 -0
- package/dist/storage-location-manager-HFNB3PCS.mjs.map +1 -0
- package/package.json +123 -2
- package/dist/builtins/local-backup/index.d.mts +0 -42
- package/dist/builtins/local-backup/index.d.ts +0 -42
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.mts +0 -2
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.d.ts +0 -2
- package/dist/builtins/sqlite-storage/index.d.mts +0 -4
- package/dist/builtins/sqlite-storage/index.d.ts +0 -4
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.mts +0 -2
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +0 -2
- package/dist/builtins/winston-logging/index.d.mts +0 -30
- package/dist/builtins/winston-logging/index.d.ts +0 -30
- package/dist/chunk-2F3XZYRW.mjs.map +0 -1
- package/dist/chunk-LQFPAEQF.mjs +0 -147
- package/dist/chunk-LQFPAEQF.mjs.map +0 -1
- package/dist/chunk-R3DIIBBX.mjs +0 -532
- package/dist/chunk-R3DIIBBX.mjs.map +0 -1
- package/dist/chunk-SMNR44VG.mjs +0 -386
- package/dist/chunk-SMNR44VG.mjs.map +0 -1
- package/dist/chunk-SO4LROOT.mjs.map +0 -1
- package/dist/chunk-SPA4JBKN.mjs +0 -175
- package/dist/chunk-SPA4JBKN.mjs.map +0 -1
- package/dist/dist-3BY63UQ5.mjs +0 -2151
- package/dist/dist-3BY63UQ5.mjs.map +0 -1
- package/dist/filesystem-storage.addon-C42r589X.d.mts +0 -57
- package/dist/filesystem-storage.addon-C42r589X.d.ts +0 -57
- package/dist/sql-schema-CKz78rId.d.mts +0 -97
- package/dist/sql-schema-CKz78rId.d.ts +0 -97
- package/dist/sqlite-settings.addon-KwG-uKMP.d.mts +0 -79
- package/dist/sqlite-settings.addon-KwG-uKMP.d.ts +0 -79
- package/dist/storage-location-manager-KKDQNAKA.mjs +0 -7
- /package/dist/{storage-location-manager-KKDQNAKA.mjs.map → builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs.map} +0 -0
package/dist/dist-3BY63UQ5.mjs
DELETED
|
@@ -1,2151 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
-
key = keys[i];
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
-
get: ((k) => from[k]).bind(null, key),
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
26
|
-
function _typeof$2(o) {
|
|
27
|
-
"@babel/helpers - typeof";
|
|
28
|
-
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
29
|
-
return typeof o$1;
|
|
30
|
-
} : function(o$1) {
|
|
31
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
32
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
33
|
-
}
|
|
34
|
-
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
35
|
-
} });
|
|
36
|
-
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
37
|
-
var _typeof$1 = require_typeof()["default"];
|
|
38
|
-
function toPrimitive$1(t, r) {
|
|
39
|
-
if ("object" != _typeof$1(t) || !t) return t;
|
|
40
|
-
var e = t[Symbol.toPrimitive];
|
|
41
|
-
if (void 0 !== e) {
|
|
42
|
-
var i = e.call(t, r || "default");
|
|
43
|
-
if ("object" != _typeof$1(i)) return i;
|
|
44
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
45
|
-
}
|
|
46
|
-
return ("string" === r ? String : Number)(t);
|
|
47
|
-
}
|
|
48
|
-
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
49
|
-
} });
|
|
50
|
-
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
51
|
-
var _typeof = require_typeof()["default"];
|
|
52
|
-
var toPrimitive = require_toPrimitive();
|
|
53
|
-
function toPropertyKey$1(t) {
|
|
54
|
-
var i = toPrimitive(t, "string");
|
|
55
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
56
|
-
}
|
|
57
|
-
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
58
|
-
} });
|
|
59
|
-
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
60
|
-
var toPropertyKey = require_toPropertyKey();
|
|
61
|
-
function _defineProperty(e, r, t) {
|
|
62
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
63
|
-
value: t,
|
|
64
|
-
enumerable: true,
|
|
65
|
-
configurable: true,
|
|
66
|
-
writable: true
|
|
67
|
-
}) : e[r] = t, e;
|
|
68
|
-
}
|
|
69
|
-
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
70
|
-
} });
|
|
71
|
-
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
72
|
-
var defineProperty = require_defineProperty();
|
|
73
|
-
function ownKeys(e, r) {
|
|
74
|
-
var t = Object.keys(e);
|
|
75
|
-
if (Object.getOwnPropertySymbols) {
|
|
76
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
77
|
-
r && (o = o.filter(function(r$1) {
|
|
78
|
-
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
79
|
-
})), t.push.apply(t, o);
|
|
80
|
-
}
|
|
81
|
-
return t;
|
|
82
|
-
}
|
|
83
|
-
function _objectSpread2(e) {
|
|
84
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
85
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
86
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
|
|
87
|
-
defineProperty(e, r$1, t[r$1]);
|
|
88
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
89
|
-
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return e;
|
|
93
|
-
}
|
|
94
|
-
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
95
|
-
} });
|
|
96
|
-
|
|
97
|
-
// ../../node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
|
|
98
|
-
import { observable } from "@trpc/server/observable";
|
|
99
|
-
function createChain(opts) {
|
|
100
|
-
return observable((observer) => {
|
|
101
|
-
function execute(index = 0, op = opts.op) {
|
|
102
|
-
const next = opts.links[index];
|
|
103
|
-
if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
|
|
104
|
-
const subscription = next({
|
|
105
|
-
op,
|
|
106
|
-
next(nextOp) {
|
|
107
|
-
const nextObserver = execute(index + 1, nextOp);
|
|
108
|
-
return nextObserver;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return subscription;
|
|
112
|
-
}
|
|
113
|
-
const obs$ = execute();
|
|
114
|
-
return obs$.subscribe(observer);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function asArray(value) {
|
|
118
|
-
return Array.isArray(value) ? value : [value];
|
|
119
|
-
}
|
|
120
|
-
function splitLink(opts) {
|
|
121
|
-
return (runtime) => {
|
|
122
|
-
const yes = asArray(opts.true).map((link) => link(runtime));
|
|
123
|
-
const no = asArray(opts.false).map((link) => link(runtime));
|
|
124
|
-
return (props) => {
|
|
125
|
-
return observable((observer) => {
|
|
126
|
-
const links = opts.condition(props.op) ? yes : no;
|
|
127
|
-
return createChain({
|
|
128
|
-
op: props.op,
|
|
129
|
-
links
|
|
130
|
-
}).subscribe(observer);
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ../../node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
|
|
137
|
-
import { isObject } from "@trpc/server/unstable-core-do-not-import";
|
|
138
|
-
var import_defineProperty = __toESM(require_defineProperty(), 1);
|
|
139
|
-
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
140
|
-
function isTRPCClientError(cause) {
|
|
141
|
-
return cause instanceof TRPCClientError;
|
|
142
|
-
}
|
|
143
|
-
function isTRPCErrorResponse(obj) {
|
|
144
|
-
return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
|
|
145
|
-
}
|
|
146
|
-
function getMessageFromUnknownError(err, fallback) {
|
|
147
|
-
if (typeof err === "string") return err;
|
|
148
|
-
if (isObject(err) && typeof err["message"] === "string") return err["message"];
|
|
149
|
-
return fallback;
|
|
150
|
-
}
|
|
151
|
-
var TRPCClientError = class TRPCClientError2 extends Error {
|
|
152
|
-
constructor(message, opts) {
|
|
153
|
-
var _opts$result, _opts$result2;
|
|
154
|
-
const cause = opts === null || opts === void 0 ? void 0 : opts.cause;
|
|
155
|
-
super(message, { cause });
|
|
156
|
-
(0, import_defineProperty.default)(this, "cause", void 0);
|
|
157
|
-
(0, import_defineProperty.default)(this, "shape", void 0);
|
|
158
|
-
(0, import_defineProperty.default)(this, "data", void 0);
|
|
159
|
-
(0, import_defineProperty.default)(this, "meta", void 0);
|
|
160
|
-
this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
|
|
161
|
-
this.cause = cause;
|
|
162
|
-
this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
|
|
163
|
-
this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
|
|
164
|
-
this.name = "TRPCClientError";
|
|
165
|
-
Object.setPrototypeOf(this, TRPCClientError2.prototype);
|
|
166
|
-
}
|
|
167
|
-
static from(_cause, opts = {}) {
|
|
168
|
-
const cause = _cause;
|
|
169
|
-
if (isTRPCClientError(cause)) {
|
|
170
|
-
if (opts.meta) cause.meta = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, cause.meta), opts.meta);
|
|
171
|
-
return cause;
|
|
172
|
-
}
|
|
173
|
-
if (isTRPCErrorResponse(cause)) return new TRPCClientError2(cause.error.message, (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
174
|
-
result: cause,
|
|
175
|
-
cause: opts.cause
|
|
176
|
-
}));
|
|
177
|
-
return new TRPCClientError2(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, { cause }));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// ../../node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
|
|
182
|
-
function getTransformer(transformer) {
|
|
183
|
-
const _transformer = transformer;
|
|
184
|
-
if (!_transformer) return {
|
|
185
|
-
input: {
|
|
186
|
-
serialize: (data) => data,
|
|
187
|
-
deserialize: (data) => data
|
|
188
|
-
},
|
|
189
|
-
output: {
|
|
190
|
-
serialize: (data) => data,
|
|
191
|
-
deserialize: (data) => data
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
if ("input" in _transformer) return _transformer;
|
|
195
|
-
return {
|
|
196
|
-
input: _transformer,
|
|
197
|
-
output: _transformer
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ../../node_modules/@trpc/client/dist/httpUtils-pyf5RF99.mjs
|
|
202
|
-
var isFunction = (fn) => typeof fn === "function";
|
|
203
|
-
function getFetch(customFetchImpl) {
|
|
204
|
-
if (customFetchImpl) return customFetchImpl;
|
|
205
|
-
if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
|
|
206
|
-
if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
|
|
207
|
-
throw new Error("No fetch implementation found");
|
|
208
|
-
}
|
|
209
|
-
var import_objectSpread22 = __toESM(require_objectSpread2(), 1);
|
|
210
|
-
function resolveHTTPLinkOptions(opts) {
|
|
211
|
-
return {
|
|
212
|
-
url: opts.url.toString(),
|
|
213
|
-
fetch: opts.fetch,
|
|
214
|
-
transformer: getTransformer(opts.transformer),
|
|
215
|
-
methodOverride: opts.methodOverride
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
function arrayToDict(array) {
|
|
219
|
-
const dict = {};
|
|
220
|
-
for (let index = 0; index < array.length; index++) {
|
|
221
|
-
const element = array[index];
|
|
222
|
-
dict[index] = element;
|
|
223
|
-
}
|
|
224
|
-
return dict;
|
|
225
|
-
}
|
|
226
|
-
var METHOD = {
|
|
227
|
-
query: "GET",
|
|
228
|
-
mutation: "POST",
|
|
229
|
-
subscription: "PATCH"
|
|
230
|
-
};
|
|
231
|
-
function getInput(opts) {
|
|
232
|
-
return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
|
|
233
|
-
}
|
|
234
|
-
var getUrl = (opts) => {
|
|
235
|
-
const parts = opts.url.split("?");
|
|
236
|
-
const base = parts[0].replace(/\/$/, "");
|
|
237
|
-
let url = base + "/" + opts.path;
|
|
238
|
-
const queryParts = [];
|
|
239
|
-
if (parts[1]) queryParts.push(parts[1]);
|
|
240
|
-
if ("inputs" in opts) queryParts.push("batch=1");
|
|
241
|
-
if (opts.type === "query" || opts.type === "subscription") {
|
|
242
|
-
const input = getInput(opts);
|
|
243
|
-
if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
244
|
-
}
|
|
245
|
-
if (queryParts.length) url += "?" + queryParts.join("&");
|
|
246
|
-
return url;
|
|
247
|
-
};
|
|
248
|
-
var getBody = (opts) => {
|
|
249
|
-
if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
|
|
250
|
-
const input = getInput(opts);
|
|
251
|
-
return input !== void 0 ? JSON.stringify(input) : void 0;
|
|
252
|
-
};
|
|
253
|
-
var jsonHttpRequester = (opts) => {
|
|
254
|
-
return httpRequest((0, import_objectSpread22.default)((0, import_objectSpread22.default)({}, opts), {}, {
|
|
255
|
-
contentTypeHeader: "application/json",
|
|
256
|
-
getUrl,
|
|
257
|
-
getBody
|
|
258
|
-
}));
|
|
259
|
-
};
|
|
260
|
-
var AbortError = class extends Error {
|
|
261
|
-
constructor() {
|
|
262
|
-
const name = "AbortError";
|
|
263
|
-
super(name);
|
|
264
|
-
this.name = name;
|
|
265
|
-
this.message = name;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
var throwIfAborted = (signal) => {
|
|
269
|
-
var _signal$throwIfAborte;
|
|
270
|
-
if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return;
|
|
271
|
-
(_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal);
|
|
272
|
-
if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
|
|
273
|
-
throw new AbortError();
|
|
274
|
-
};
|
|
275
|
-
async function fetchHTTPResponse(opts) {
|
|
276
|
-
var _opts$methodOverride, _opts$trpcAcceptHeade;
|
|
277
|
-
throwIfAborted(opts.signal);
|
|
278
|
-
const url = opts.getUrl(opts);
|
|
279
|
-
const body = opts.getBody(opts);
|
|
280
|
-
const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type];
|
|
281
|
-
const resolvedHeaders = await (async () => {
|
|
282
|
-
const heads = await opts.headers();
|
|
283
|
-
if (Symbol.iterator in heads) return Object.fromEntries(heads);
|
|
284
|
-
return heads;
|
|
285
|
-
})();
|
|
286
|
-
const headers = (0, import_objectSpread22.default)((0, import_objectSpread22.default)((0, import_objectSpread22.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
|
|
287
|
-
return getFetch(opts.fetch)(url, {
|
|
288
|
-
method,
|
|
289
|
-
signal: opts.signal,
|
|
290
|
-
body,
|
|
291
|
-
headers
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
async function httpRequest(opts) {
|
|
295
|
-
const meta = {};
|
|
296
|
-
const res = await fetchHTTPResponse(opts);
|
|
297
|
-
meta.response = res;
|
|
298
|
-
const json = await res.json();
|
|
299
|
-
meta.responseJSON = json;
|
|
300
|
-
return {
|
|
301
|
-
json,
|
|
302
|
-
meta
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ../../node_modules/@trpc/client/dist/httpLink-lG_6juPY.mjs
|
|
307
|
-
import { observable as observable2 } from "@trpc/server/observable";
|
|
308
|
-
import { transformResult } from "@trpc/server/unstable-core-do-not-import";
|
|
309
|
-
function isOctetType(input) {
|
|
310
|
-
return input instanceof Uint8Array || input instanceof Blob;
|
|
311
|
-
}
|
|
312
|
-
function isFormData(input) {
|
|
313
|
-
return input instanceof FormData;
|
|
314
|
-
}
|
|
315
|
-
function isNonJsonSerializable(input) {
|
|
316
|
-
return isOctetType(input) || isFormData(input);
|
|
317
|
-
}
|
|
318
|
-
var import_objectSpread23 = __toESM(require_objectSpread2(), 1);
|
|
319
|
-
var universalRequester = (opts) => {
|
|
320
|
-
if ("input" in opts) {
|
|
321
|
-
const { input } = opts;
|
|
322
|
-
if (isFormData(input)) {
|
|
323
|
-
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
|
|
324
|
-
return httpRequest((0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, {
|
|
325
|
-
contentTypeHeader: void 0,
|
|
326
|
-
getUrl,
|
|
327
|
-
getBody: () => input
|
|
328
|
-
}));
|
|
329
|
-
}
|
|
330
|
-
if (isOctetType(input)) {
|
|
331
|
-
if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
|
|
332
|
-
return httpRequest((0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, {
|
|
333
|
-
contentTypeHeader: "application/octet-stream",
|
|
334
|
-
getUrl,
|
|
335
|
-
getBody: () => input
|
|
336
|
-
}));
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return jsonHttpRequester(opts);
|
|
340
|
-
};
|
|
341
|
-
function httpLink(opts) {
|
|
342
|
-
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
343
|
-
return () => {
|
|
344
|
-
return (operationOpts) => {
|
|
345
|
-
const { op } = operationOpts;
|
|
346
|
-
return observable2((observer) => {
|
|
347
|
-
const { path, input, type } = op;
|
|
348
|
-
if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
349
|
-
const request = universalRequester((0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, resolvedOpts), {}, {
|
|
350
|
-
type,
|
|
351
|
-
path,
|
|
352
|
-
input,
|
|
353
|
-
signal: op.signal,
|
|
354
|
-
headers() {
|
|
355
|
-
if (!opts.headers) return {};
|
|
356
|
-
if (typeof opts.headers === "function") return opts.headers({ op });
|
|
357
|
-
return opts.headers;
|
|
358
|
-
}
|
|
359
|
-
}));
|
|
360
|
-
let meta = void 0;
|
|
361
|
-
request.then((res) => {
|
|
362
|
-
meta = res.meta;
|
|
363
|
-
const transformed = transformResult(res.json, resolvedOpts.transformer.output);
|
|
364
|
-
if (!transformed.ok) {
|
|
365
|
-
observer.error(TRPCClientError.from(transformed.error, { meta }));
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
observer.next({
|
|
369
|
-
context: res.meta,
|
|
370
|
-
result: transformed.result
|
|
371
|
-
});
|
|
372
|
-
observer.complete();
|
|
373
|
-
}).catch((cause) => {
|
|
374
|
-
observer.error(TRPCClientError.from(cause, { meta }));
|
|
375
|
-
});
|
|
376
|
-
return () => {
|
|
377
|
-
};
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// ../../node_modules/@trpc/client/dist/httpBatchLink-LhidKAPw.mjs
|
|
384
|
-
import { observable as observable3 } from "@trpc/server/observable";
|
|
385
|
-
import { transformResult as transformResult2 } from "@trpc/server/unstable-core-do-not-import";
|
|
386
|
-
var throwFatalError = () => {
|
|
387
|
-
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
388
|
-
};
|
|
389
|
-
function dataLoader(batchLoader) {
|
|
390
|
-
let pendingItems = null;
|
|
391
|
-
let dispatchTimer = null;
|
|
392
|
-
const destroyTimerAndPendingItems = () => {
|
|
393
|
-
clearTimeout(dispatchTimer);
|
|
394
|
-
dispatchTimer = null;
|
|
395
|
-
pendingItems = null;
|
|
396
|
-
};
|
|
397
|
-
function groupItems(items) {
|
|
398
|
-
const groupedItems = [[]];
|
|
399
|
-
let index = 0;
|
|
400
|
-
while (true) {
|
|
401
|
-
const item = items[index];
|
|
402
|
-
if (!item) break;
|
|
403
|
-
const lastGroup = groupedItems[groupedItems.length - 1];
|
|
404
|
-
if (item.aborted) {
|
|
405
|
-
var _item$reject;
|
|
406
|
-
(_item$reject = item.reject) === null || _item$reject === void 0 || _item$reject.call(item, new Error("Aborted"));
|
|
407
|
-
index++;
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
const isValid = batchLoader.validate(lastGroup.concat(item).map((it) => it.key));
|
|
411
|
-
if (isValid) {
|
|
412
|
-
lastGroup.push(item);
|
|
413
|
-
index++;
|
|
414
|
-
continue;
|
|
415
|
-
}
|
|
416
|
-
if (lastGroup.length === 0) {
|
|
417
|
-
var _item$reject2;
|
|
418
|
-
(_item$reject2 = item.reject) === null || _item$reject2 === void 0 || _item$reject2.call(item, new Error("Input is too big for a single dispatch"));
|
|
419
|
-
index++;
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
groupedItems.push([]);
|
|
423
|
-
}
|
|
424
|
-
return groupedItems;
|
|
425
|
-
}
|
|
426
|
-
function dispatch() {
|
|
427
|
-
const groupedItems = groupItems(pendingItems);
|
|
428
|
-
destroyTimerAndPendingItems();
|
|
429
|
-
for (const items of groupedItems) {
|
|
430
|
-
if (!items.length) continue;
|
|
431
|
-
const batch = { items };
|
|
432
|
-
for (const item of items) item.batch = batch;
|
|
433
|
-
const promise = batchLoader.fetch(batch.items.map((_item) => _item.key));
|
|
434
|
-
promise.then(async (result) => {
|
|
435
|
-
await Promise.all(result.map(async (valueOrPromise, index) => {
|
|
436
|
-
const item = batch.items[index];
|
|
437
|
-
try {
|
|
438
|
-
var _item$resolve;
|
|
439
|
-
const value = await Promise.resolve(valueOrPromise);
|
|
440
|
-
(_item$resolve = item.resolve) === null || _item$resolve === void 0 || _item$resolve.call(item, value);
|
|
441
|
-
} catch (cause) {
|
|
442
|
-
var _item$reject3;
|
|
443
|
-
(_item$reject3 = item.reject) === null || _item$reject3 === void 0 || _item$reject3.call(item, cause);
|
|
444
|
-
}
|
|
445
|
-
item.batch = null;
|
|
446
|
-
item.reject = null;
|
|
447
|
-
item.resolve = null;
|
|
448
|
-
}));
|
|
449
|
-
for (const item of batch.items) {
|
|
450
|
-
var _item$reject4;
|
|
451
|
-
(_item$reject4 = item.reject) === null || _item$reject4 === void 0 || _item$reject4.call(item, new Error("Missing result"));
|
|
452
|
-
item.batch = null;
|
|
453
|
-
}
|
|
454
|
-
}).catch((cause) => {
|
|
455
|
-
for (const item of batch.items) {
|
|
456
|
-
var _item$reject5;
|
|
457
|
-
(_item$reject5 = item.reject) === null || _item$reject5 === void 0 || _item$reject5.call(item, cause);
|
|
458
|
-
item.batch = null;
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
function load(key) {
|
|
464
|
-
var _dispatchTimer;
|
|
465
|
-
const item = {
|
|
466
|
-
aborted: false,
|
|
467
|
-
key,
|
|
468
|
-
batch: null,
|
|
469
|
-
resolve: throwFatalError,
|
|
470
|
-
reject: throwFatalError
|
|
471
|
-
};
|
|
472
|
-
const promise = new Promise((resolve, reject) => {
|
|
473
|
-
var _pendingItems;
|
|
474
|
-
item.reject = reject;
|
|
475
|
-
item.resolve = resolve;
|
|
476
|
-
(_pendingItems = pendingItems) !== null && _pendingItems !== void 0 || (pendingItems = []);
|
|
477
|
-
pendingItems.push(item);
|
|
478
|
-
});
|
|
479
|
-
(_dispatchTimer = dispatchTimer) !== null && _dispatchTimer !== void 0 || (dispatchTimer = setTimeout(dispatch));
|
|
480
|
-
return promise;
|
|
481
|
-
}
|
|
482
|
-
return { load };
|
|
483
|
-
}
|
|
484
|
-
function allAbortSignals(...signals) {
|
|
485
|
-
const ac = new AbortController();
|
|
486
|
-
const count = signals.length;
|
|
487
|
-
let abortedCount = 0;
|
|
488
|
-
const onAbort = () => {
|
|
489
|
-
if (++abortedCount === count) ac.abort();
|
|
490
|
-
};
|
|
491
|
-
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) onAbort();
|
|
492
|
-
else signal === null || signal === void 0 || signal.addEventListener("abort", onAbort, { once: true });
|
|
493
|
-
return ac.signal;
|
|
494
|
-
}
|
|
495
|
-
function raceAbortSignals(...signals) {
|
|
496
|
-
const ac = new AbortController();
|
|
497
|
-
for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) ac.abort();
|
|
498
|
-
else signal === null || signal === void 0 || signal.addEventListener("abort", () => ac.abort(), { once: true });
|
|
499
|
-
return ac.signal;
|
|
500
|
-
}
|
|
501
|
-
function abortSignalToPromise(signal) {
|
|
502
|
-
return new Promise((_, reject) => {
|
|
503
|
-
if (signal.aborted) {
|
|
504
|
-
reject(signal.reason);
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
signal.addEventListener("abort", () => {
|
|
508
|
-
reject(signal.reason);
|
|
509
|
-
}, { once: true });
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
var import_objectSpread24 = __toESM(require_objectSpread2(), 1);
|
|
513
|
-
function httpBatchLink(opts) {
|
|
514
|
-
var _opts$maxURLLength, _opts$maxItems;
|
|
515
|
-
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
516
|
-
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
|
517
|
-
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
|
518
|
-
return () => {
|
|
519
|
-
const batchLoader = (type) => {
|
|
520
|
-
return {
|
|
521
|
-
validate(batchOps) {
|
|
522
|
-
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
|
523
|
-
if (batchOps.length > maxItems) return false;
|
|
524
|
-
const path = batchOps.map((op) => op.path).join(",");
|
|
525
|
-
const inputs = batchOps.map((op) => op.input);
|
|
526
|
-
const url = getUrl((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, resolvedOpts), {}, {
|
|
527
|
-
type,
|
|
528
|
-
path,
|
|
529
|
-
inputs,
|
|
530
|
-
signal: null
|
|
531
|
-
}));
|
|
532
|
-
return url.length <= maxURLLength;
|
|
533
|
-
},
|
|
534
|
-
async fetch(batchOps) {
|
|
535
|
-
const path = batchOps.map((op) => op.path).join(",");
|
|
536
|
-
const inputs = batchOps.map((op) => op.input);
|
|
537
|
-
const signal = allAbortSignals(...batchOps.map((op) => op.signal));
|
|
538
|
-
const res = await jsonHttpRequester((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, resolvedOpts), {}, {
|
|
539
|
-
path,
|
|
540
|
-
inputs,
|
|
541
|
-
type,
|
|
542
|
-
headers() {
|
|
543
|
-
if (!opts.headers) return {};
|
|
544
|
-
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
|
545
|
-
return opts.headers;
|
|
546
|
-
},
|
|
547
|
-
signal
|
|
548
|
-
}));
|
|
549
|
-
const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(() => res.json);
|
|
550
|
-
const result = resJSON.map((item) => ({
|
|
551
|
-
meta: res.meta,
|
|
552
|
-
json: item
|
|
553
|
-
}));
|
|
554
|
-
return result;
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
};
|
|
558
|
-
const query = dataLoader(batchLoader("query"));
|
|
559
|
-
const mutation = dataLoader(batchLoader("mutation"));
|
|
560
|
-
const loaders = {
|
|
561
|
-
query,
|
|
562
|
-
mutation
|
|
563
|
-
};
|
|
564
|
-
return ({ op }) => {
|
|
565
|
-
return observable3((observer) => {
|
|
566
|
-
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
567
|
-
const loader = loaders[op.type];
|
|
568
|
-
const promise = loader.load(op);
|
|
569
|
-
let _res = void 0;
|
|
570
|
-
promise.then((res) => {
|
|
571
|
-
_res = res;
|
|
572
|
-
const transformed = transformResult2(res.json, resolvedOpts.transformer.output);
|
|
573
|
-
if (!transformed.ok) {
|
|
574
|
-
observer.error(TRPCClientError.from(transformed.error, { meta: res.meta }));
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
observer.next({
|
|
578
|
-
context: res.meta,
|
|
579
|
-
result: transformed.result
|
|
580
|
-
});
|
|
581
|
-
observer.complete();
|
|
582
|
-
}).catch((err) => {
|
|
583
|
-
observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
|
584
|
-
});
|
|
585
|
-
return () => {
|
|
586
|
-
};
|
|
587
|
-
});
|
|
588
|
-
};
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// ../../node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
|
|
593
|
-
import { observable as observable4, tap } from "@trpc/server/observable";
|
|
594
|
-
var import_objectSpread25 = __toESM(require_objectSpread2(), 1);
|
|
595
|
-
function isFormData2(value) {
|
|
596
|
-
if (typeof FormData === "undefined") return false;
|
|
597
|
-
return value instanceof FormData;
|
|
598
|
-
}
|
|
599
|
-
var palettes = {
|
|
600
|
-
css: {
|
|
601
|
-
query: ["72e3ff", "3fb0d8"],
|
|
602
|
-
mutation: ["c5a3fc", "904dfc"],
|
|
603
|
-
subscription: ["ff49e1", "d83fbe"]
|
|
604
|
-
},
|
|
605
|
-
ansi: {
|
|
606
|
-
regular: {
|
|
607
|
-
query: ["\x1B[30;46m", "\x1B[97;46m"],
|
|
608
|
-
mutation: ["\x1B[30;45m", "\x1B[97;45m"],
|
|
609
|
-
subscription: ["\x1B[30;42m", "\x1B[97;42m"]
|
|
610
|
-
},
|
|
611
|
-
bold: {
|
|
612
|
-
query: ["\x1B[1;30;46m", "\x1B[1;97;46m"],
|
|
613
|
-
mutation: ["\x1B[1;30;45m", "\x1B[1;97;45m"],
|
|
614
|
-
subscription: ["\x1B[1;30;42m", "\x1B[1;97;42m"]
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
function constructPartsAndArgs(opts) {
|
|
619
|
-
const { direction, type, withContext, path, id, input } = opts;
|
|
620
|
-
const parts = [];
|
|
621
|
-
const args = [];
|
|
622
|
-
if (opts.colorMode === "none") parts.push(direction === "up" ? ">>" : "<<", type, `#${id}`, path);
|
|
623
|
-
else if (opts.colorMode === "ansi") {
|
|
624
|
-
const [lightRegular, darkRegular] = palettes.ansi.regular[type];
|
|
625
|
-
const [lightBold, darkBold] = palettes.ansi.bold[type];
|
|
626
|
-
const reset = "\x1B[0m";
|
|
627
|
-
parts.push(direction === "up" ? lightRegular : darkRegular, direction === "up" ? ">>" : "<<", type, direction === "up" ? lightBold : darkBold, `#${id}`, path, reset);
|
|
628
|
-
} else {
|
|
629
|
-
const [light, dark] = palettes.css[type];
|
|
630
|
-
const css = `
|
|
631
|
-
background-color: #${direction === "up" ? light : dark};
|
|
632
|
-
color: ${direction === "up" ? "black" : "white"};
|
|
633
|
-
padding: 2px;
|
|
634
|
-
`;
|
|
635
|
-
parts.push("%c", direction === "up" ? ">>" : "<<", type, `#${id}`, `%c${path}%c`, "%O");
|
|
636
|
-
args.push(css, `${css}; font-weight: bold;`, `${css}; font-weight: normal;`);
|
|
637
|
-
}
|
|
638
|
-
if (direction === "up") args.push(withContext ? {
|
|
639
|
-
input,
|
|
640
|
-
context: opts.context
|
|
641
|
-
} : { input });
|
|
642
|
-
else args.push((0, import_objectSpread25.default)({
|
|
643
|
-
input,
|
|
644
|
-
result: opts.result,
|
|
645
|
-
elapsedMs: opts.elapsedMs
|
|
646
|
-
}, withContext && { context: opts.context }));
|
|
647
|
-
return {
|
|
648
|
-
parts,
|
|
649
|
-
args
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
var defaultLogger = ({ c = console, colorMode = "css", withContext }) => (props) => {
|
|
653
|
-
const rawInput = props.input;
|
|
654
|
-
const input = isFormData2(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
|
655
|
-
const { parts, args } = constructPartsAndArgs((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, props), {}, {
|
|
656
|
-
colorMode,
|
|
657
|
-
input,
|
|
658
|
-
withContext
|
|
659
|
-
}));
|
|
660
|
-
const fn = props.direction === "down" && props.result && (props.result instanceof Error || "error" in props.result.result && props.result.result.error) ? "error" : "log";
|
|
661
|
-
c[fn].apply(null, [parts.join(" ")].concat(args));
|
|
662
|
-
};
|
|
663
|
-
function loggerLink(opts = {}) {
|
|
664
|
-
var _opts$colorMode, _opts$withContext;
|
|
665
|
-
const { enabled = () => true } = opts;
|
|
666
|
-
const colorMode = (_opts$colorMode = opts.colorMode) !== null && _opts$colorMode !== void 0 ? _opts$colorMode : typeof window === "undefined" ? "ansi" : "css";
|
|
667
|
-
const withContext = (_opts$withContext = opts.withContext) !== null && _opts$withContext !== void 0 ? _opts$withContext : colorMode === "css";
|
|
668
|
-
const { logger = defaultLogger({
|
|
669
|
-
c: opts.console,
|
|
670
|
-
colorMode,
|
|
671
|
-
withContext
|
|
672
|
-
}) } = opts;
|
|
673
|
-
return () => {
|
|
674
|
-
return ({ op, next }) => {
|
|
675
|
-
return observable4((observer) => {
|
|
676
|
-
if (enabled((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, op), {}, { direction: "up" }))) logger((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, op), {}, { direction: "up" }));
|
|
677
|
-
const requestStartTime = Date.now();
|
|
678
|
-
function logResult(result) {
|
|
679
|
-
const elapsedMs = Date.now() - requestStartTime;
|
|
680
|
-
if (enabled((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, op), {}, {
|
|
681
|
-
direction: "down",
|
|
682
|
-
result
|
|
683
|
-
}))) logger((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, op), {}, {
|
|
684
|
-
direction: "down",
|
|
685
|
-
elapsedMs,
|
|
686
|
-
result
|
|
687
|
-
}));
|
|
688
|
-
}
|
|
689
|
-
return next(op).pipe(tap({
|
|
690
|
-
next(result) {
|
|
691
|
-
logResult(result);
|
|
692
|
-
},
|
|
693
|
-
error(result) {
|
|
694
|
-
logResult(result);
|
|
695
|
-
}
|
|
696
|
-
})).subscribe(observer);
|
|
697
|
-
});
|
|
698
|
-
};
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// ../../node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
|
|
703
|
-
import { behaviorSubject, observable as observable5 } from "@trpc/server/observable";
|
|
704
|
-
import { run, sleep, transformResult as transformResult3 } from "@trpc/server/unstable-core-do-not-import";
|
|
705
|
-
var jsonEncoder = {
|
|
706
|
-
encode: (data) => JSON.stringify(data),
|
|
707
|
-
decode: (data) => {
|
|
708
|
-
if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data.");
|
|
709
|
-
return JSON.parse(data);
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
var lazyDefaults = {
|
|
713
|
-
enabled: false,
|
|
714
|
-
closeMs: 0
|
|
715
|
-
};
|
|
716
|
-
var keepAliveDefaults = {
|
|
717
|
-
enabled: false,
|
|
718
|
-
pongTimeoutMs: 1e3,
|
|
719
|
-
intervalMs: 5e3
|
|
720
|
-
};
|
|
721
|
-
var exponentialBackoff = (attemptIndex) => {
|
|
722
|
-
return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
|
|
723
|
-
};
|
|
724
|
-
var resultOf = (value, ...args) => {
|
|
725
|
-
return typeof value === "function" ? value(...args) : value;
|
|
726
|
-
};
|
|
727
|
-
var import_defineProperty$3 = __toESM(require_defineProperty(), 1);
|
|
728
|
-
var TRPCWebSocketClosedError = class TRPCWebSocketClosedError2 extends Error {
|
|
729
|
-
constructor(opts) {
|
|
730
|
-
super(opts.message, { cause: opts.cause });
|
|
731
|
-
this.name = "TRPCWebSocketClosedError";
|
|
732
|
-
Object.setPrototypeOf(this, TRPCWebSocketClosedError2.prototype);
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
var ResettableTimeout = class {
|
|
736
|
-
constructor(onTimeout, timeoutMs) {
|
|
737
|
-
this.onTimeout = onTimeout;
|
|
738
|
-
this.timeoutMs = timeoutMs;
|
|
739
|
-
(0, import_defineProperty$3.default)(this, "timeout", void 0);
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Resets the current timeout, restarting it with the same duration.
|
|
743
|
-
* Does nothing if no timeout is active.
|
|
744
|
-
*/
|
|
745
|
-
reset() {
|
|
746
|
-
if (!this.timeout) return;
|
|
747
|
-
clearTimeout(this.timeout);
|
|
748
|
-
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
749
|
-
}
|
|
750
|
-
start() {
|
|
751
|
-
clearTimeout(this.timeout);
|
|
752
|
-
this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
|
|
753
|
-
}
|
|
754
|
-
stop() {
|
|
755
|
-
clearTimeout(this.timeout);
|
|
756
|
-
this.timeout = void 0;
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
function withResolvers() {
|
|
760
|
-
let resolve;
|
|
761
|
-
let reject;
|
|
762
|
-
const promise = new Promise((res, rej) => {
|
|
763
|
-
resolve = res;
|
|
764
|
-
reject = rej;
|
|
765
|
-
});
|
|
766
|
-
return {
|
|
767
|
-
promise,
|
|
768
|
-
resolve,
|
|
769
|
-
reject
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
async function prepareUrl(urlOptions) {
|
|
773
|
-
const url = await resultOf(urlOptions.url);
|
|
774
|
-
if (!urlOptions.connectionParams) return url;
|
|
775
|
-
const prefix = url.includes("?") ? "&" : "?";
|
|
776
|
-
const connectionParams = `${prefix}connectionParams=1`;
|
|
777
|
-
return url + connectionParams;
|
|
778
|
-
}
|
|
779
|
-
async function buildConnectionMessage(connectionParams, encoder) {
|
|
780
|
-
const message = {
|
|
781
|
-
method: "connectionParams",
|
|
782
|
-
data: await resultOf(connectionParams)
|
|
783
|
-
};
|
|
784
|
-
return encoder.encode(message);
|
|
785
|
-
}
|
|
786
|
-
var import_defineProperty$2 = __toESM(require_defineProperty(), 1);
|
|
787
|
-
var RequestManager = class {
|
|
788
|
-
constructor() {
|
|
789
|
-
(0, import_defineProperty$2.default)(this, "outgoingRequests", new Array());
|
|
790
|
-
(0, import_defineProperty$2.default)(this, "pendingRequests", {});
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Registers a new request by adding it to the outgoing queue and setting up
|
|
794
|
-
* callbacks for lifecycle events such as completion or error.
|
|
795
|
-
*
|
|
796
|
-
* @param message - The outgoing message to be sent.
|
|
797
|
-
* @param callbacks - Callback functions to observe the request's state.
|
|
798
|
-
* @returns A cleanup function to manually remove the request.
|
|
799
|
-
*/
|
|
800
|
-
register(message, callbacks) {
|
|
801
|
-
const { promise: end, resolve } = withResolvers();
|
|
802
|
-
this.outgoingRequests.push({
|
|
803
|
-
id: String(message.id),
|
|
804
|
-
message,
|
|
805
|
-
end,
|
|
806
|
-
callbacks: {
|
|
807
|
-
next: callbacks.next,
|
|
808
|
-
complete: () => {
|
|
809
|
-
callbacks.complete();
|
|
810
|
-
resolve();
|
|
811
|
-
},
|
|
812
|
-
error: (e) => {
|
|
813
|
-
callbacks.error(e);
|
|
814
|
-
resolve();
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
return () => {
|
|
819
|
-
this.delete(message.id);
|
|
820
|
-
callbacks.complete();
|
|
821
|
-
resolve();
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Deletes a request from both the outgoing and pending collections, if it exists.
|
|
826
|
-
*/
|
|
827
|
-
delete(messageId) {
|
|
828
|
-
if (messageId === null) return;
|
|
829
|
-
this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
|
|
830
|
-
delete this.pendingRequests[String(messageId)];
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* Moves all outgoing requests to the pending state and clears the outgoing queue.
|
|
834
|
-
*
|
|
835
|
-
* The caller is expected to handle the actual sending of the requests
|
|
836
|
-
* (e.g., sending them over the network) after this method is called.
|
|
837
|
-
*
|
|
838
|
-
* @returns The list of requests that were transitioned to the pending state.
|
|
839
|
-
*/
|
|
840
|
-
flush() {
|
|
841
|
-
const requests = this.outgoingRequests;
|
|
842
|
-
this.outgoingRequests = [];
|
|
843
|
-
for (const request of requests) this.pendingRequests[request.id] = request;
|
|
844
|
-
return requests;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Retrieves all currently pending requests, which are in flight awaiting responses
|
|
848
|
-
* or handling ongoing subscriptions.
|
|
849
|
-
*/
|
|
850
|
-
getPendingRequests() {
|
|
851
|
-
return Object.values(this.pendingRequests);
|
|
852
|
-
}
|
|
853
|
-
/**
|
|
854
|
-
* Retrieves a specific pending request by its message ID.
|
|
855
|
-
*/
|
|
856
|
-
getPendingRequest(messageId) {
|
|
857
|
-
if (messageId === null) return null;
|
|
858
|
-
return this.pendingRequests[String(messageId)];
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Retrieves all outgoing requests, which are waiting to be sent.
|
|
862
|
-
*/
|
|
863
|
-
getOutgoingRequests() {
|
|
864
|
-
return this.outgoingRequests;
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Retrieves all requests, both outgoing and pending, with their respective states.
|
|
868
|
-
*
|
|
869
|
-
* @returns An array of all requests with their state ("outgoing" or "pending").
|
|
870
|
-
*/
|
|
871
|
-
getRequests() {
|
|
872
|
-
return [...this.getOutgoingRequests().map((request) => ({
|
|
873
|
-
state: "outgoing",
|
|
874
|
-
message: request.message,
|
|
875
|
-
end: request.end,
|
|
876
|
-
callbacks: request.callbacks
|
|
877
|
-
})), ...this.getPendingRequests().map((request) => ({
|
|
878
|
-
state: "pending",
|
|
879
|
-
message: request.message,
|
|
880
|
-
end: request.end,
|
|
881
|
-
callbacks: request.callbacks
|
|
882
|
-
}))];
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Checks if there are any pending requests, including ongoing subscriptions.
|
|
886
|
-
*/
|
|
887
|
-
hasPendingRequests() {
|
|
888
|
-
return this.getPendingRequests().length > 0;
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Checks if there are any pending subscriptions
|
|
892
|
-
*/
|
|
893
|
-
hasPendingSubscriptions() {
|
|
894
|
-
return this.getPendingRequests().some((request) => request.message.method === "subscription");
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Checks if there are any outgoing requests waiting to be sent.
|
|
898
|
-
*/
|
|
899
|
-
hasOutgoingRequests() {
|
|
900
|
-
return this.outgoingRequests.length > 0;
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
var import_defineProperty$1 = __toESM(require_defineProperty(), 1);
|
|
904
|
-
function asyncWsOpen(ws) {
|
|
905
|
-
const { promise, resolve, reject } = withResolvers();
|
|
906
|
-
ws.addEventListener("open", () => {
|
|
907
|
-
ws.removeEventListener("error", reject);
|
|
908
|
-
resolve();
|
|
909
|
-
});
|
|
910
|
-
ws.addEventListener("error", reject);
|
|
911
|
-
return promise;
|
|
912
|
-
}
|
|
913
|
-
function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
|
|
914
|
-
let pingTimeout;
|
|
915
|
-
let pongTimeout;
|
|
916
|
-
function start() {
|
|
917
|
-
pingTimeout = setTimeout(() => {
|
|
918
|
-
ws.send("PING");
|
|
919
|
-
pongTimeout = setTimeout(() => {
|
|
920
|
-
ws.close();
|
|
921
|
-
}, pongTimeoutMs);
|
|
922
|
-
}, intervalMs);
|
|
923
|
-
}
|
|
924
|
-
function reset() {
|
|
925
|
-
clearTimeout(pingTimeout);
|
|
926
|
-
start();
|
|
927
|
-
}
|
|
928
|
-
function pong() {
|
|
929
|
-
clearTimeout(pongTimeout);
|
|
930
|
-
reset();
|
|
931
|
-
}
|
|
932
|
-
ws.addEventListener("open", start);
|
|
933
|
-
ws.addEventListener("message", ({ data }) => {
|
|
934
|
-
clearTimeout(pingTimeout);
|
|
935
|
-
start();
|
|
936
|
-
if (data === "PONG") pong();
|
|
937
|
-
});
|
|
938
|
-
ws.addEventListener("close", () => {
|
|
939
|
-
clearTimeout(pingTimeout);
|
|
940
|
-
clearTimeout(pongTimeout);
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
var WsConnection = class WsConnection2 {
|
|
944
|
-
constructor(opts) {
|
|
945
|
-
var _opts$WebSocketPonyfi;
|
|
946
|
-
(0, import_defineProperty$1.default)(this, "id", ++WsConnection2.connectCount);
|
|
947
|
-
(0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
|
|
948
|
-
(0, import_defineProperty$1.default)(this, "urlOptions", void 0);
|
|
949
|
-
(0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
|
|
950
|
-
(0, import_defineProperty$1.default)(this, "encoder", void 0);
|
|
951
|
-
(0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null));
|
|
952
|
-
(0, import_defineProperty$1.default)(this, "openPromise", null);
|
|
953
|
-
this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
|
|
954
|
-
if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
|
955
|
-
this.urlOptions = opts.urlOptions;
|
|
956
|
-
this.keepAliveOpts = opts.keepAlive;
|
|
957
|
-
this.encoder = opts.encoder;
|
|
958
|
-
}
|
|
959
|
-
get ws() {
|
|
960
|
-
return this.wsObservable.get();
|
|
961
|
-
}
|
|
962
|
-
set ws(ws) {
|
|
963
|
-
this.wsObservable.next(ws);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Checks if the WebSocket connection is open and ready to communicate.
|
|
967
|
-
*/
|
|
968
|
-
isOpen() {
|
|
969
|
-
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Checks if the WebSocket connection is closed or in the process of closing.
|
|
973
|
-
*/
|
|
974
|
-
isClosed() {
|
|
975
|
-
return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
|
|
976
|
-
}
|
|
977
|
-
async open() {
|
|
978
|
-
var _this = this;
|
|
979
|
-
if (_this.openPromise) return _this.openPromise;
|
|
980
|
-
_this.id = ++WsConnection2.connectCount;
|
|
981
|
-
const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
|
|
982
|
-
_this.openPromise = wsPromise.then(async (ws) => {
|
|
983
|
-
_this.ws = ws;
|
|
984
|
-
ws.binaryType = "arraybuffer";
|
|
985
|
-
ws.addEventListener("message", function({ data }) {
|
|
986
|
-
if (data === "PING") this.send("PONG");
|
|
987
|
-
});
|
|
988
|
-
if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
|
|
989
|
-
ws.addEventListener("close", () => {
|
|
990
|
-
if (_this.ws === ws) _this.ws = null;
|
|
991
|
-
});
|
|
992
|
-
await asyncWsOpen(ws);
|
|
993
|
-
if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
|
|
994
|
-
});
|
|
995
|
-
try {
|
|
996
|
-
await _this.openPromise;
|
|
997
|
-
} finally {
|
|
998
|
-
_this.openPromise = null;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Closes the WebSocket connection gracefully.
|
|
1003
|
-
* Waits for any ongoing open operation to complete before closing.
|
|
1004
|
-
*/
|
|
1005
|
-
async close() {
|
|
1006
|
-
var _this2 = this;
|
|
1007
|
-
try {
|
|
1008
|
-
await _this2.openPromise;
|
|
1009
|
-
} finally {
|
|
1010
|
-
var _this$ws;
|
|
1011
|
-
(_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
};
|
|
1015
|
-
(0, import_defineProperty$1.default)(WsConnection, "connectCount", 0);
|
|
1016
|
-
function backwardCompatibility(connection) {
|
|
1017
|
-
if (connection.isOpen()) return {
|
|
1018
|
-
id: connection.id,
|
|
1019
|
-
state: "open",
|
|
1020
|
-
ws: connection.ws
|
|
1021
|
-
};
|
|
1022
|
-
if (connection.isClosed()) return {
|
|
1023
|
-
id: connection.id,
|
|
1024
|
-
state: "closed",
|
|
1025
|
-
ws: connection.ws
|
|
1026
|
-
};
|
|
1027
|
-
if (!connection.ws) return null;
|
|
1028
|
-
return {
|
|
1029
|
-
id: connection.id,
|
|
1030
|
-
state: "connecting",
|
|
1031
|
-
ws: connection.ws
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
var import_defineProperty2 = __toESM(require_defineProperty(), 1);
|
|
1035
|
-
var import_objectSpread26 = __toESM(require_objectSpread2(), 1);
|
|
1036
|
-
var WsClient = class {
|
|
1037
|
-
constructor(opts) {
|
|
1038
|
-
var _opts$experimental_en, _opts$retryDelayMs;
|
|
1039
|
-
(0, import_defineProperty2.default)(this, "connectionState", void 0);
|
|
1040
|
-
(0, import_defineProperty2.default)(this, "allowReconnect", false);
|
|
1041
|
-
(0, import_defineProperty2.default)(this, "requestManager", new RequestManager());
|
|
1042
|
-
(0, import_defineProperty2.default)(this, "activeConnection", void 0);
|
|
1043
|
-
(0, import_defineProperty2.default)(this, "reconnectRetryDelay", void 0);
|
|
1044
|
-
(0, import_defineProperty2.default)(this, "inactivityTimeout", void 0);
|
|
1045
|
-
(0, import_defineProperty2.default)(this, "callbacks", void 0);
|
|
1046
|
-
(0, import_defineProperty2.default)(this, "lazyMode", void 0);
|
|
1047
|
-
(0, import_defineProperty2.default)(this, "encoder", void 0);
|
|
1048
|
-
(0, import_defineProperty2.default)(this, "reconnecting", null);
|
|
1049
|
-
this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder;
|
|
1050
|
-
this.callbacks = {
|
|
1051
|
-
onOpen: opts.onOpen,
|
|
1052
|
-
onClose: opts.onClose,
|
|
1053
|
-
onError: opts.onError
|
|
1054
|
-
};
|
|
1055
|
-
const lazyOptions = (0, import_objectSpread26.default)((0, import_objectSpread26.default)({}, lazyDefaults), opts.lazy);
|
|
1056
|
-
this.inactivityTimeout = new ResettableTimeout(() => {
|
|
1057
|
-
if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) {
|
|
1058
|
-
this.inactivityTimeout.reset();
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
this.close().catch(() => null);
|
|
1062
|
-
}, lazyOptions.closeMs);
|
|
1063
|
-
this.activeConnection = new WsConnection({
|
|
1064
|
-
WebSocketPonyfill: opts.WebSocket,
|
|
1065
|
-
urlOptions: opts,
|
|
1066
|
-
keepAlive: (0, import_objectSpread26.default)((0, import_objectSpread26.default)({}, keepAliveDefaults), opts.keepAlive),
|
|
1067
|
-
encoder: this.encoder
|
|
1068
|
-
});
|
|
1069
|
-
this.activeConnection.wsObservable.subscribe({ next: (ws) => {
|
|
1070
|
-
if (!ws) return;
|
|
1071
|
-
this.setupWebSocketListeners(ws);
|
|
1072
|
-
} });
|
|
1073
|
-
this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff;
|
|
1074
|
-
this.lazyMode = lazyOptions.enabled;
|
|
1075
|
-
this.connectionState = behaviorSubject({
|
|
1076
|
-
type: "state",
|
|
1077
|
-
state: lazyOptions.enabled ? "idle" : "connecting",
|
|
1078
|
-
error: null
|
|
1079
|
-
});
|
|
1080
|
-
if (!this.lazyMode) this.open().catch(() => null);
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* Opens the WebSocket connection. Handles reconnection attempts and updates
|
|
1084
|
-
* the connection state accordingly.
|
|
1085
|
-
*/
|
|
1086
|
-
async open() {
|
|
1087
|
-
var _this = this;
|
|
1088
|
-
_this.allowReconnect = true;
|
|
1089
|
-
if (_this.connectionState.get().state === "idle") _this.connectionState.next({
|
|
1090
|
-
type: "state",
|
|
1091
|
-
state: "connecting",
|
|
1092
|
-
error: null
|
|
1093
|
-
});
|
|
1094
|
-
try {
|
|
1095
|
-
await _this.activeConnection.open();
|
|
1096
|
-
} catch (error) {
|
|
1097
|
-
_this.reconnect(new TRPCWebSocketClosedError({
|
|
1098
|
-
message: "Initialization error",
|
|
1099
|
-
cause: error
|
|
1100
|
-
}));
|
|
1101
|
-
return _this.reconnecting;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Closes the WebSocket connection and stops managing requests.
|
|
1106
|
-
* Ensures all outgoing and pending requests are properly finalized.
|
|
1107
|
-
*/
|
|
1108
|
-
async close() {
|
|
1109
|
-
var _this2 = this;
|
|
1110
|
-
_this2.allowReconnect = false;
|
|
1111
|
-
_this2.inactivityTimeout.stop();
|
|
1112
|
-
const requestsToAwait = [];
|
|
1113
|
-
for (const request of _this2.requestManager.getRequests()) if (request.message.method === "subscription") request.callbacks.complete();
|
|
1114
|
-
else if (request.state === "outgoing") request.callbacks.error(TRPCClientError.from(new TRPCWebSocketClosedError({ message: "Closed before connection was established" })));
|
|
1115
|
-
else requestsToAwait.push(request.end);
|
|
1116
|
-
await Promise.all(requestsToAwait).catch(() => null);
|
|
1117
|
-
await _this2.activeConnection.close().catch(() => null);
|
|
1118
|
-
_this2.connectionState.next({
|
|
1119
|
-
type: "state",
|
|
1120
|
-
state: "idle",
|
|
1121
|
-
error: null
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
/**
|
|
1125
|
-
* Method to request the server.
|
|
1126
|
-
* Handles data transformation, batching of requests, and subscription lifecycle.
|
|
1127
|
-
*
|
|
1128
|
-
* @param op - The operation details including id, type, path, input and signal
|
|
1129
|
-
* @param transformer - Data transformer for serializing requests and deserializing responses
|
|
1130
|
-
* @param lastEventId - Optional ID of the last received event for subscriptions
|
|
1131
|
-
*
|
|
1132
|
-
* @returns An observable that emits operation results and handles cleanup
|
|
1133
|
-
*/
|
|
1134
|
-
request({ op: { id, type, path, input, signal }, transformer, lastEventId }) {
|
|
1135
|
-
return observable5((observer) => {
|
|
1136
|
-
const abort = this.batchSend({
|
|
1137
|
-
id,
|
|
1138
|
-
method: type,
|
|
1139
|
-
params: {
|
|
1140
|
-
input: transformer.input.serialize(input),
|
|
1141
|
-
path,
|
|
1142
|
-
lastEventId
|
|
1143
|
-
}
|
|
1144
|
-
}, (0, import_objectSpread26.default)((0, import_objectSpread26.default)({}, observer), {}, { next(event) {
|
|
1145
|
-
const transformed = transformResult3(event, transformer.output);
|
|
1146
|
-
if (!transformed.ok) {
|
|
1147
|
-
observer.error(TRPCClientError.from(transformed.error));
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
observer.next({ result: transformed.result });
|
|
1151
|
-
} }));
|
|
1152
|
-
return () => {
|
|
1153
|
-
abort();
|
|
1154
|
-
if (type === "subscription" && this.activeConnection.isOpen()) this.send({
|
|
1155
|
-
id,
|
|
1156
|
-
method: "subscription.stop"
|
|
1157
|
-
});
|
|
1158
|
-
signal === null || signal === void 0 || signal.removeEventListener("abort", abort);
|
|
1159
|
-
};
|
|
1160
|
-
});
|
|
1161
|
-
}
|
|
1162
|
-
get connection() {
|
|
1163
|
-
return backwardCompatibility(this.activeConnection);
|
|
1164
|
-
}
|
|
1165
|
-
reconnect(closedError) {
|
|
1166
|
-
var _this3 = this;
|
|
1167
|
-
this.connectionState.next({
|
|
1168
|
-
type: "state",
|
|
1169
|
-
state: "connecting",
|
|
1170
|
-
error: TRPCClientError.from(closedError)
|
|
1171
|
-
});
|
|
1172
|
-
if (this.reconnecting) return;
|
|
1173
|
-
const tryReconnect = async (attemptIndex) => {
|
|
1174
|
-
try {
|
|
1175
|
-
await sleep(_this3.reconnectRetryDelay(attemptIndex));
|
|
1176
|
-
if (_this3.allowReconnect) {
|
|
1177
|
-
await _this3.activeConnection.close();
|
|
1178
|
-
await _this3.activeConnection.open();
|
|
1179
|
-
if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message));
|
|
1180
|
-
}
|
|
1181
|
-
_this3.reconnecting = null;
|
|
1182
|
-
} catch (_unused) {
|
|
1183
|
-
await tryReconnect(attemptIndex + 1);
|
|
1184
|
-
}
|
|
1185
|
-
};
|
|
1186
|
-
this.reconnecting = tryReconnect(0);
|
|
1187
|
-
}
|
|
1188
|
-
setupWebSocketListeners(ws) {
|
|
1189
|
-
var _this4 = this;
|
|
1190
|
-
const handleCloseOrError = (cause) => {
|
|
1191
|
-
const reqs = this.requestManager.getPendingRequests();
|
|
1192
|
-
for (const { message, callbacks } of reqs) {
|
|
1193
|
-
if (message.method === "subscription") continue;
|
|
1194
|
-
callbacks.error(TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({
|
|
1195
|
-
message: "WebSocket closed",
|
|
1196
|
-
cause
|
|
1197
|
-
})));
|
|
1198
|
-
this.requestManager.delete(message.id);
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
ws.addEventListener("open", () => {
|
|
1202
|
-
run(async () => {
|
|
1203
|
-
var _this$callbacks$onOpe, _this$callbacks;
|
|
1204
|
-
if (_this4.lazyMode) _this4.inactivityTimeout.start();
|
|
1205
|
-
(_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks);
|
|
1206
|
-
_this4.connectionState.next({
|
|
1207
|
-
type: "state",
|
|
1208
|
-
state: "pending",
|
|
1209
|
-
error: null
|
|
1210
|
-
});
|
|
1211
|
-
}).catch((error) => {
|
|
1212
|
-
ws.close(3e3);
|
|
1213
|
-
handleCloseOrError(error);
|
|
1214
|
-
});
|
|
1215
|
-
});
|
|
1216
|
-
ws.addEventListener("message", ({ data }) => {
|
|
1217
|
-
this.inactivityTimeout.reset();
|
|
1218
|
-
if (["PING", "PONG"].includes(data)) return;
|
|
1219
|
-
const incomingMessage = this.encoder.decode(data);
|
|
1220
|
-
if ("method" in incomingMessage) {
|
|
1221
|
-
this.handleIncomingRequest(incomingMessage);
|
|
1222
|
-
return;
|
|
1223
|
-
}
|
|
1224
|
-
this.handleResponseMessage(incomingMessage);
|
|
1225
|
-
});
|
|
1226
|
-
ws.addEventListener("close", (event) => {
|
|
1227
|
-
var _this$callbacks$onClo, _this$callbacks2;
|
|
1228
|
-
handleCloseOrError(event);
|
|
1229
|
-
(_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event);
|
|
1230
|
-
if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({
|
|
1231
|
-
message: "WebSocket closed",
|
|
1232
|
-
cause: event
|
|
1233
|
-
}));
|
|
1234
|
-
});
|
|
1235
|
-
ws.addEventListener("error", (event) => {
|
|
1236
|
-
var _this$callbacks$onErr, _this$callbacks3;
|
|
1237
|
-
handleCloseOrError(event);
|
|
1238
|
-
(_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event);
|
|
1239
|
-
this.reconnect(new TRPCWebSocketClosedError({
|
|
1240
|
-
message: "WebSocket closed",
|
|
1241
|
-
cause: event
|
|
1242
|
-
}));
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
handleResponseMessage(message) {
|
|
1246
|
-
const request = this.requestManager.getPendingRequest(message.id);
|
|
1247
|
-
if (!request) return;
|
|
1248
|
-
request.callbacks.next(message);
|
|
1249
|
-
let completed = true;
|
|
1250
|
-
if ("result" in message && request.message.method === "subscription") {
|
|
1251
|
-
if (message.result.type === "data") request.message.params.lastEventId = message.result.id;
|
|
1252
|
-
if (message.result.type !== "stopped") completed = false;
|
|
1253
|
-
}
|
|
1254
|
-
if (completed) {
|
|
1255
|
-
request.callbacks.complete();
|
|
1256
|
-
this.requestManager.delete(message.id);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
handleIncomingRequest(message) {
|
|
1260
|
-
if (message.method === "reconnect") this.reconnect(new TRPCWebSocketClosedError({ message: "Server requested reconnect" }));
|
|
1261
|
-
}
|
|
1262
|
-
/**
|
|
1263
|
-
* Sends a message or batch of messages directly to the server.
|
|
1264
|
-
*/
|
|
1265
|
-
send(messageOrMessages) {
|
|
1266
|
-
if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open");
|
|
1267
|
-
const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages];
|
|
1268
|
-
this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages));
|
|
1269
|
-
}
|
|
1270
|
-
/**
|
|
1271
|
-
* Groups requests for batch sending.
|
|
1272
|
-
*
|
|
1273
|
-
* @returns A function to abort the batched request.
|
|
1274
|
-
*/
|
|
1275
|
-
batchSend(message, callbacks) {
|
|
1276
|
-
var _this5 = this;
|
|
1277
|
-
this.inactivityTimeout.reset();
|
|
1278
|
-
run(async () => {
|
|
1279
|
-
if (!_this5.activeConnection.isOpen()) await _this5.open();
|
|
1280
|
-
await sleep(0);
|
|
1281
|
-
if (!_this5.requestManager.hasOutgoingRequests()) return;
|
|
1282
|
-
_this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1));
|
|
1283
|
-
}).catch((err) => {
|
|
1284
|
-
this.requestManager.delete(message.id);
|
|
1285
|
-
callbacks.error(TRPCClientError.from(err));
|
|
1286
|
-
});
|
|
1287
|
-
return this.requestManager.register(message, callbacks);
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
function createWSClient(opts) {
|
|
1291
|
-
return new WsClient(opts);
|
|
1292
|
-
}
|
|
1293
|
-
function wsLink(opts) {
|
|
1294
|
-
const { client } = opts;
|
|
1295
|
-
const transformer = getTransformer(opts.transformer);
|
|
1296
|
-
return () => {
|
|
1297
|
-
return ({ op }) => {
|
|
1298
|
-
return observable5((observer) => {
|
|
1299
|
-
const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) {
|
|
1300
|
-
observer.next({
|
|
1301
|
-
result,
|
|
1302
|
-
context: op.context
|
|
1303
|
-
});
|
|
1304
|
-
} }) : null;
|
|
1305
|
-
const requestSubscription = client.request({
|
|
1306
|
-
op,
|
|
1307
|
-
transformer
|
|
1308
|
-
}).subscribe(observer);
|
|
1309
|
-
return () => {
|
|
1310
|
-
requestSubscription.unsubscribe();
|
|
1311
|
-
connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe();
|
|
1312
|
-
};
|
|
1313
|
-
});
|
|
1314
|
-
};
|
|
1315
|
-
};
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// ../../node_modules/@trpc/client/dist/index.mjs
|
|
1319
|
-
import { behaviorSubject as behaviorSubject2, observable as observable6, observableToPromise, share } from "@trpc/server/observable";
|
|
1320
|
-
import { callProcedure, createFlatProxy, createRecursiveProxy, isAbortError, isAsyncIterable, iteratorResource, jsonlStreamConsumer, makeResource, retryableRpcCodes, run as run2, sseStreamConsumer } from "@trpc/server/unstable-core-do-not-import";
|
|
1321
|
-
import { getTRPCErrorFromUnknown, getTRPCErrorShape, isTrackedEnvelope } from "@trpc/server";
|
|
1322
|
-
import { TRPC_ERROR_CODES_BY_KEY } from "@trpc/server/rpc";
|
|
1323
|
-
var import_defineProperty3 = __toESM(require_defineProperty(), 1);
|
|
1324
|
-
var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
|
|
1325
|
-
var TRPCUntypedClient = class {
|
|
1326
|
-
constructor(opts) {
|
|
1327
|
-
(0, import_defineProperty3.default)(this, "links", void 0);
|
|
1328
|
-
(0, import_defineProperty3.default)(this, "runtime", void 0);
|
|
1329
|
-
(0, import_defineProperty3.default)(this, "requestId", void 0);
|
|
1330
|
-
this.requestId = 0;
|
|
1331
|
-
this.runtime = {};
|
|
1332
|
-
this.links = opts.links.map((link) => link(this.runtime));
|
|
1333
|
-
}
|
|
1334
|
-
$request(opts) {
|
|
1335
|
-
var _opts$context;
|
|
1336
|
-
const chain$ = createChain({
|
|
1337
|
-
links: this.links,
|
|
1338
|
-
op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
|
|
1339
|
-
context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
|
|
1340
|
-
id: ++this.requestId
|
|
1341
|
-
})
|
|
1342
|
-
});
|
|
1343
|
-
return chain$.pipe(share());
|
|
1344
|
-
}
|
|
1345
|
-
async requestAsPromise(opts) {
|
|
1346
|
-
var _this = this;
|
|
1347
|
-
try {
|
|
1348
|
-
const req$ = _this.$request(opts);
|
|
1349
|
-
const envelope = await observableToPromise(req$);
|
|
1350
|
-
const data = envelope.result.data;
|
|
1351
|
-
return data;
|
|
1352
|
-
} catch (err) {
|
|
1353
|
-
throw TRPCClientError.from(err);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
query(path, input, opts) {
|
|
1357
|
-
return this.requestAsPromise({
|
|
1358
|
-
type: "query",
|
|
1359
|
-
path,
|
|
1360
|
-
input,
|
|
1361
|
-
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1362
|
-
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
mutation(path, input, opts) {
|
|
1366
|
-
return this.requestAsPromise({
|
|
1367
|
-
type: "mutation",
|
|
1368
|
-
path,
|
|
1369
|
-
input,
|
|
1370
|
-
context: opts === null || opts === void 0 ? void 0 : opts.context,
|
|
1371
|
-
signal: opts === null || opts === void 0 ? void 0 : opts.signal
|
|
1372
|
-
});
|
|
1373
|
-
}
|
|
1374
|
-
subscription(path, input, opts) {
|
|
1375
|
-
const observable$ = this.$request({
|
|
1376
|
-
type: "subscription",
|
|
1377
|
-
path,
|
|
1378
|
-
input,
|
|
1379
|
-
context: opts.context,
|
|
1380
|
-
signal: opts.signal
|
|
1381
|
-
});
|
|
1382
|
-
return observable$.subscribe({
|
|
1383
|
-
next(envelope) {
|
|
1384
|
-
switch (envelope.result.type) {
|
|
1385
|
-
case "state": {
|
|
1386
|
-
var _opts$onConnectionSta;
|
|
1387
|
-
(_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
|
|
1388
|
-
break;
|
|
1389
|
-
}
|
|
1390
|
-
case "started": {
|
|
1391
|
-
var _opts$onStarted;
|
|
1392
|
-
(_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
|
|
1393
|
-
break;
|
|
1394
|
-
}
|
|
1395
|
-
case "stopped": {
|
|
1396
|
-
var _opts$onStopped;
|
|
1397
|
-
(_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
|
|
1398
|
-
break;
|
|
1399
|
-
}
|
|
1400
|
-
case "data":
|
|
1401
|
-
case void 0: {
|
|
1402
|
-
var _opts$onData;
|
|
1403
|
-
(_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
|
|
1404
|
-
break;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
},
|
|
1408
|
-
error(err) {
|
|
1409
|
-
var _opts$onError;
|
|
1410
|
-
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
|
|
1411
|
-
},
|
|
1412
|
-
complete() {
|
|
1413
|
-
var _opts$onComplete;
|
|
1414
|
-
(_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
function createTRPCUntypedClient(opts) {
|
|
1420
|
-
return new TRPCUntypedClient(opts);
|
|
1421
|
-
}
|
|
1422
|
-
var untypedClientSymbol = /* @__PURE__ */ Symbol.for("trpc_untypedClient");
|
|
1423
|
-
var clientCallTypeMap = {
|
|
1424
|
-
query: "query",
|
|
1425
|
-
mutate: "mutation",
|
|
1426
|
-
subscribe: "subscription"
|
|
1427
|
-
};
|
|
1428
|
-
var clientCallTypeToProcedureType = (clientCallType) => {
|
|
1429
|
-
return clientCallTypeMap[clientCallType];
|
|
1430
|
-
};
|
|
1431
|
-
function createTRPCClientProxy(client) {
|
|
1432
|
-
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
1433
|
-
const pathCopy = [...path];
|
|
1434
|
-
const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
|
|
1435
|
-
const fullPath = pathCopy.join(".");
|
|
1436
|
-
return client[procedureType](fullPath, ...args);
|
|
1437
|
-
});
|
|
1438
|
-
return createFlatProxy((key) => {
|
|
1439
|
-
if (key === untypedClientSymbol) return client;
|
|
1440
|
-
return proxy[key];
|
|
1441
|
-
});
|
|
1442
|
-
}
|
|
1443
|
-
function createTRPCClient(opts) {
|
|
1444
|
-
const client = new TRPCUntypedClient(opts);
|
|
1445
|
-
const proxy = createTRPCClientProxy(client);
|
|
1446
|
-
return proxy;
|
|
1447
|
-
}
|
|
1448
|
-
function getUntypedClient(client) {
|
|
1449
|
-
return client[untypedClientSymbol];
|
|
1450
|
-
}
|
|
1451
|
-
var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
|
1452
|
-
function httpBatchStreamLink(opts) {
|
|
1453
|
-
var _opts$maxURLLength, _opts$maxItems;
|
|
1454
|
-
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
1455
|
-
const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
|
|
1456
|
-
const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
|
|
1457
|
-
return () => {
|
|
1458
|
-
const batchLoader = (type) => {
|
|
1459
|
-
return {
|
|
1460
|
-
validate(batchOps) {
|
|
1461
|
-
if (maxURLLength === Infinity && maxItems === Infinity) return true;
|
|
1462
|
-
if (batchOps.length > maxItems) return false;
|
|
1463
|
-
const path = batchOps.map((op) => op.path).join(",");
|
|
1464
|
-
const inputs = batchOps.map((op) => op.input);
|
|
1465
|
-
const url = getUrl((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
|
1466
|
-
type,
|
|
1467
|
-
path,
|
|
1468
|
-
inputs,
|
|
1469
|
-
signal: null
|
|
1470
|
-
}));
|
|
1471
|
-
return url.length <= maxURLLength;
|
|
1472
|
-
},
|
|
1473
|
-
async fetch(batchOps) {
|
|
1474
|
-
var _opts$streamHeader;
|
|
1475
|
-
const path = batchOps.map((op) => op.path).join(",");
|
|
1476
|
-
const inputs = batchOps.map((op) => op.input);
|
|
1477
|
-
const batchSignals = allAbortSignals(...batchOps.map((op) => op.signal));
|
|
1478
|
-
const abortController = new AbortController();
|
|
1479
|
-
const responsePromise = fetchHTTPResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
|
|
1480
|
-
signal: raceAbortSignals(batchSignals, abortController.signal),
|
|
1481
|
-
type,
|
|
1482
|
-
contentTypeHeader: "application/json",
|
|
1483
|
-
trpcAcceptHeader: "application/jsonl",
|
|
1484
|
-
trpcAcceptHeaderKey: (_opts$streamHeader = opts.streamHeader) !== null && _opts$streamHeader !== void 0 ? _opts$streamHeader : "trpc-accept",
|
|
1485
|
-
getUrl,
|
|
1486
|
-
getBody,
|
|
1487
|
-
inputs,
|
|
1488
|
-
path,
|
|
1489
|
-
headers() {
|
|
1490
|
-
if (!opts.headers) return {};
|
|
1491
|
-
if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
|
|
1492
|
-
return opts.headers;
|
|
1493
|
-
}
|
|
1494
|
-
}));
|
|
1495
|
-
const res = await responsePromise;
|
|
1496
|
-
const [head] = await jsonlStreamConsumer({
|
|
1497
|
-
from: res.body,
|
|
1498
|
-
deserialize: (data) => resolvedOpts.transformer.output.deserialize(data),
|
|
1499
|
-
formatError(opts$1) {
|
|
1500
|
-
const error = opts$1.error;
|
|
1501
|
-
return TRPCClientError.from({ error });
|
|
1502
|
-
},
|
|
1503
|
-
abortController
|
|
1504
|
-
});
|
|
1505
|
-
const promises = Object.keys(batchOps).map(async (key) => {
|
|
1506
|
-
let json = await Promise.resolve(head[key]);
|
|
1507
|
-
if ("result" in json) {
|
|
1508
|
-
const result = await Promise.resolve(json.result);
|
|
1509
|
-
json = { result: { data: await Promise.resolve(result.data) } };
|
|
1510
|
-
}
|
|
1511
|
-
return {
|
|
1512
|
-
json,
|
|
1513
|
-
meta: { response: res }
|
|
1514
|
-
};
|
|
1515
|
-
});
|
|
1516
|
-
return promises;
|
|
1517
|
-
}
|
|
1518
|
-
};
|
|
1519
|
-
};
|
|
1520
|
-
const query = dataLoader(batchLoader("query"));
|
|
1521
|
-
const mutation = dataLoader(batchLoader("mutation"));
|
|
1522
|
-
const loaders = {
|
|
1523
|
-
query,
|
|
1524
|
-
mutation
|
|
1525
|
-
};
|
|
1526
|
-
return ({ op }) => {
|
|
1527
|
-
return observable6((observer) => {
|
|
1528
|
-
if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpBatchStreamLink` - use `httpSubscriptionLink` or `wsLink`");
|
|
1529
|
-
const loader = loaders[op.type];
|
|
1530
|
-
const promise = loader.load(op);
|
|
1531
|
-
let _res = void 0;
|
|
1532
|
-
promise.then((res) => {
|
|
1533
|
-
_res = res;
|
|
1534
|
-
if ("error" in res.json) {
|
|
1535
|
-
observer.error(TRPCClientError.from(res.json, { meta: res.meta }));
|
|
1536
|
-
return;
|
|
1537
|
-
} else if ("result" in res.json) {
|
|
1538
|
-
observer.next({
|
|
1539
|
-
context: res.meta,
|
|
1540
|
-
result: res.json.result
|
|
1541
|
-
});
|
|
1542
|
-
observer.complete();
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
observer.complete();
|
|
1546
|
-
}).catch((err) => {
|
|
1547
|
-
observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
|
|
1548
|
-
});
|
|
1549
|
-
return () => {
|
|
1550
|
-
};
|
|
1551
|
-
});
|
|
1552
|
-
};
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
var unstable_httpBatchStreamLink = httpBatchStreamLink;
|
|
1556
|
-
var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
|
1557
|
-
function inputWithTrackedEventId(input, lastEventId) {
|
|
1558
|
-
if (!lastEventId) return input;
|
|
1559
|
-
if (input != null && typeof input !== "object") return input;
|
|
1560
|
-
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId });
|
|
1561
|
-
}
|
|
1562
|
-
var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
|
|
1563
|
-
function _asyncIterator$1(r) {
|
|
1564
|
-
var n, t, o, e = 2;
|
|
1565
|
-
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--; ) {
|
|
1566
|
-
if (t && null != (n = r[t])) return n.call(r);
|
|
1567
|
-
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
1568
|
-
t = "@@asyncIterator", o = "@@iterator";
|
|
1569
|
-
}
|
|
1570
|
-
throw new TypeError("Object is not async iterable");
|
|
1571
|
-
}
|
|
1572
|
-
function AsyncFromSyncIterator(r) {
|
|
1573
|
-
function AsyncFromSyncIteratorContinuation(r$1) {
|
|
1574
|
-
if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
|
|
1575
|
-
var n = r$1.done;
|
|
1576
|
-
return Promise.resolve(r$1.value).then(function(r$2) {
|
|
1577
|
-
return {
|
|
1578
|
-
value: r$2,
|
|
1579
|
-
done: n
|
|
1580
|
-
};
|
|
1581
|
-
});
|
|
1582
|
-
}
|
|
1583
|
-
return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
|
|
1584
|
-
this.s = r$1, this.n = r$1.next;
|
|
1585
|
-
}, AsyncFromSyncIterator.prototype = {
|
|
1586
|
-
s: null,
|
|
1587
|
-
n: null,
|
|
1588
|
-
next: function next() {
|
|
1589
|
-
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
1590
|
-
},
|
|
1591
|
-
"return": function _return(r$1) {
|
|
1592
|
-
var n = this.s["return"];
|
|
1593
|
-
return void 0 === n ? Promise.resolve({
|
|
1594
|
-
value: r$1,
|
|
1595
|
-
done: true
|
|
1596
|
-
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1597
|
-
},
|
|
1598
|
-
"throw": function _throw(r$1) {
|
|
1599
|
-
var n = this.s["return"];
|
|
1600
|
-
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
1601
|
-
}
|
|
1602
|
-
}, new AsyncFromSyncIterator(r);
|
|
1603
|
-
}
|
|
1604
|
-
module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1605
|
-
} });
|
|
1606
|
-
var import_asyncIterator = __toESM(require_asyncIterator(), 1);
|
|
1607
|
-
async function urlWithConnectionParams(opts) {
|
|
1608
|
-
let url = await resultOf(opts.url);
|
|
1609
|
-
if (opts.connectionParams) {
|
|
1610
|
-
const params = await resultOf(opts.connectionParams);
|
|
1611
|
-
const prefix = url.includes("?") ? "&" : "?";
|
|
1612
|
-
url += prefix + "connectionParams=" + encodeURIComponent(JSON.stringify(params));
|
|
1613
|
-
}
|
|
1614
|
-
return url;
|
|
1615
|
-
}
|
|
1616
|
-
function httpSubscriptionLink(opts) {
|
|
1617
|
-
const transformer = getTransformer(opts.transformer);
|
|
1618
|
-
return () => {
|
|
1619
|
-
return ({ op }) => {
|
|
1620
|
-
return observable6((observer) => {
|
|
1621
|
-
var _opts$EventSource;
|
|
1622
|
-
const { type, path, input } = op;
|
|
1623
|
-
if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
|
|
1624
|
-
let lastEventId = void 0;
|
|
1625
|
-
const ac = new AbortController();
|
|
1626
|
-
const signal = raceAbortSignals(op.signal, ac.signal);
|
|
1627
|
-
const eventSourceStream = sseStreamConsumer({
|
|
1628
|
-
url: async () => getUrl({
|
|
1629
|
-
transformer,
|
|
1630
|
-
url: await urlWithConnectionParams(opts),
|
|
1631
|
-
input: inputWithTrackedEventId(input, lastEventId),
|
|
1632
|
-
path,
|
|
1633
|
-
type,
|
|
1634
|
-
signal: null
|
|
1635
|
-
}),
|
|
1636
|
-
init: () => resultOf(opts.eventSourceOptions, { op }),
|
|
1637
|
-
signal,
|
|
1638
|
-
deserialize: (data) => transformer.output.deserialize(data),
|
|
1639
|
-
EventSource: (_opts$EventSource = opts.EventSource) !== null && _opts$EventSource !== void 0 ? _opts$EventSource : globalThis.EventSource
|
|
1640
|
-
});
|
|
1641
|
-
const connectionState = behaviorSubject2({
|
|
1642
|
-
type: "state",
|
|
1643
|
-
state: "connecting",
|
|
1644
|
-
error: null
|
|
1645
|
-
});
|
|
1646
|
-
const connectionSub = connectionState.subscribe({ next(state) {
|
|
1647
|
-
observer.next({ result: state });
|
|
1648
|
-
} });
|
|
1649
|
-
run2(async () => {
|
|
1650
|
-
var _iteratorAbruptCompletion = false;
|
|
1651
|
-
var _didIteratorError = false;
|
|
1652
|
-
var _iteratorError;
|
|
1653
|
-
try {
|
|
1654
|
-
for (var _iterator = (0, import_asyncIterator.default)(eventSourceStream), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
|
1655
|
-
const chunk = _step.value;
|
|
1656
|
-
switch (chunk.type) {
|
|
1657
|
-
case "ping":
|
|
1658
|
-
break;
|
|
1659
|
-
case "data":
|
|
1660
|
-
const chunkData = chunk.data;
|
|
1661
|
-
let result;
|
|
1662
|
-
if (chunkData.id) {
|
|
1663
|
-
lastEventId = chunkData.id;
|
|
1664
|
-
result = {
|
|
1665
|
-
id: chunkData.id,
|
|
1666
|
-
data: chunkData
|
|
1667
|
-
};
|
|
1668
|
-
} else result = { data: chunkData.data };
|
|
1669
|
-
observer.next({
|
|
1670
|
-
result,
|
|
1671
|
-
context: { eventSource: chunk.eventSource }
|
|
1672
|
-
});
|
|
1673
|
-
break;
|
|
1674
|
-
case "connected": {
|
|
1675
|
-
observer.next({
|
|
1676
|
-
result: { type: "started" },
|
|
1677
|
-
context: { eventSource: chunk.eventSource }
|
|
1678
|
-
});
|
|
1679
|
-
connectionState.next({
|
|
1680
|
-
type: "state",
|
|
1681
|
-
state: "pending",
|
|
1682
|
-
error: null
|
|
1683
|
-
});
|
|
1684
|
-
break;
|
|
1685
|
-
}
|
|
1686
|
-
case "serialized-error": {
|
|
1687
|
-
const error = TRPCClientError.from({ error: chunk.error });
|
|
1688
|
-
if (retryableRpcCodes.includes(chunk.error.code)) {
|
|
1689
|
-
connectionState.next({
|
|
1690
|
-
type: "state",
|
|
1691
|
-
state: "connecting",
|
|
1692
|
-
error
|
|
1693
|
-
});
|
|
1694
|
-
break;
|
|
1695
|
-
}
|
|
1696
|
-
throw error;
|
|
1697
|
-
}
|
|
1698
|
-
case "connecting": {
|
|
1699
|
-
const lastState = connectionState.get();
|
|
1700
|
-
const error = chunk.event && TRPCClientError.from(chunk.event);
|
|
1701
|
-
if (!error && lastState.state === "connecting") break;
|
|
1702
|
-
connectionState.next({
|
|
1703
|
-
type: "state",
|
|
1704
|
-
state: "connecting",
|
|
1705
|
-
error
|
|
1706
|
-
});
|
|
1707
|
-
break;
|
|
1708
|
-
}
|
|
1709
|
-
case "timeout":
|
|
1710
|
-
connectionState.next({
|
|
1711
|
-
type: "state",
|
|
1712
|
-
state: "connecting",
|
|
1713
|
-
error: new TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
} catch (err) {
|
|
1718
|
-
_didIteratorError = true;
|
|
1719
|
-
_iteratorError = err;
|
|
1720
|
-
} finally {
|
|
1721
|
-
try {
|
|
1722
|
-
if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
|
|
1723
|
-
} finally {
|
|
1724
|
-
if (_didIteratorError) throw _iteratorError;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
observer.next({ result: { type: "stopped" } });
|
|
1728
|
-
connectionState.next({
|
|
1729
|
-
type: "state",
|
|
1730
|
-
state: "idle",
|
|
1731
|
-
error: null
|
|
1732
|
-
});
|
|
1733
|
-
observer.complete();
|
|
1734
|
-
}).catch((error) => {
|
|
1735
|
-
observer.error(TRPCClientError.from(error));
|
|
1736
|
-
});
|
|
1737
|
-
return () => {
|
|
1738
|
-
observer.complete();
|
|
1739
|
-
ac.abort();
|
|
1740
|
-
connectionSub.unsubscribe();
|
|
1741
|
-
};
|
|
1742
|
-
});
|
|
1743
|
-
};
|
|
1744
|
-
};
|
|
1745
|
-
}
|
|
1746
|
-
var unstable_httpSubscriptionLink = httpSubscriptionLink;
|
|
1747
|
-
var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
|
|
1748
|
-
function retryLink(opts) {
|
|
1749
|
-
return () => {
|
|
1750
|
-
return (callOpts) => {
|
|
1751
|
-
return observable6((observer) => {
|
|
1752
|
-
let next$;
|
|
1753
|
-
let callNextTimeout = void 0;
|
|
1754
|
-
let lastEventId = void 0;
|
|
1755
|
-
attempt(1);
|
|
1756
|
-
function opWithLastEventId() {
|
|
1757
|
-
const op = callOpts.op;
|
|
1758
|
-
if (!lastEventId) return op;
|
|
1759
|
-
return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) });
|
|
1760
|
-
}
|
|
1761
|
-
function attempt(attempts) {
|
|
1762
|
-
const op = opWithLastEventId();
|
|
1763
|
-
next$ = callOpts.next(op).subscribe({
|
|
1764
|
-
error(error) {
|
|
1765
|
-
var _opts$retryDelayMs, _opts$retryDelayMs2;
|
|
1766
|
-
const shouldRetry = opts.retry({
|
|
1767
|
-
op,
|
|
1768
|
-
attempts,
|
|
1769
|
-
error
|
|
1770
|
-
});
|
|
1771
|
-
if (!shouldRetry) {
|
|
1772
|
-
observer.error(error);
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0;
|
|
1776
|
-
if (delayMs <= 0) {
|
|
1777
|
-
attempt(attempts + 1);
|
|
1778
|
-
return;
|
|
1779
|
-
}
|
|
1780
|
-
callNextTimeout = setTimeout(() => attempt(attempts + 1), delayMs);
|
|
1781
|
-
},
|
|
1782
|
-
next(envelope) {
|
|
1783
|
-
if ((!envelope.result.type || envelope.result.type === "data") && envelope.result.id) lastEventId = envelope.result.id;
|
|
1784
|
-
observer.next(envelope);
|
|
1785
|
-
},
|
|
1786
|
-
complete() {
|
|
1787
|
-
observer.complete();
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
return () => {
|
|
1792
|
-
next$.unsubscribe();
|
|
1793
|
-
clearTimeout(callNextTimeout);
|
|
1794
|
-
};
|
|
1795
|
-
});
|
|
1796
|
-
};
|
|
1797
|
-
};
|
|
1798
|
-
}
|
|
1799
|
-
var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
|
1800
|
-
function _usingCtx() {
|
|
1801
|
-
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
1802
|
-
var n$1 = Error();
|
|
1803
|
-
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
|
1804
|
-
}, e = {}, n = [];
|
|
1805
|
-
function using(r$1, e$1) {
|
|
1806
|
-
if (null != e$1) {
|
|
1807
|
-
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
1808
|
-
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
1809
|
-
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
|
1810
|
-
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
1811
|
-
t && (o = function o$1() {
|
|
1812
|
-
try {
|
|
1813
|
-
t.call(e$1);
|
|
1814
|
-
} catch (r$2) {
|
|
1815
|
-
return Promise.reject(r$2);
|
|
1816
|
-
}
|
|
1817
|
-
}), n.push({
|
|
1818
|
-
v: e$1,
|
|
1819
|
-
d: o,
|
|
1820
|
-
a: r$1
|
|
1821
|
-
});
|
|
1822
|
-
} else r$1 && n.push({
|
|
1823
|
-
d: e$1,
|
|
1824
|
-
a: r$1
|
|
1825
|
-
});
|
|
1826
|
-
return e$1;
|
|
1827
|
-
}
|
|
1828
|
-
return {
|
|
1829
|
-
e,
|
|
1830
|
-
u: using.bind(null, false),
|
|
1831
|
-
a: using.bind(null, true),
|
|
1832
|
-
d: function d() {
|
|
1833
|
-
var o, t = this.e, s = 0;
|
|
1834
|
-
function next() {
|
|
1835
|
-
for (; o = n.pop(); ) try {
|
|
1836
|
-
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
1837
|
-
if (o.d) {
|
|
1838
|
-
var r$1 = o.d.call(o.v);
|
|
1839
|
-
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
|
1840
|
-
} else s |= 1;
|
|
1841
|
-
} catch (r$2) {
|
|
1842
|
-
return err(r$2);
|
|
1843
|
-
}
|
|
1844
|
-
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
1845
|
-
if (t !== e) throw t;
|
|
1846
|
-
}
|
|
1847
|
-
function err(n$1) {
|
|
1848
|
-
return t = t !== e ? new r(n$1, t) : n$1, next();
|
|
1849
|
-
}
|
|
1850
|
-
return next();
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1855
|
-
} });
|
|
1856
|
-
var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
|
|
1857
|
-
function _OverloadYield(e, d) {
|
|
1858
|
-
this.v = e, this.k = d;
|
|
1859
|
-
}
|
|
1860
|
-
module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1861
|
-
} });
|
|
1862
|
-
var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
|
|
1863
|
-
var OverloadYield$1 = require_OverloadYield();
|
|
1864
|
-
function _awaitAsyncGenerator$1(e) {
|
|
1865
|
-
return new OverloadYield$1(e, 0);
|
|
1866
|
-
}
|
|
1867
|
-
module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1868
|
-
} });
|
|
1869
|
-
var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
|
|
1870
|
-
var OverloadYield = require_OverloadYield();
|
|
1871
|
-
function _wrapAsyncGenerator$1(e) {
|
|
1872
|
-
return function() {
|
|
1873
|
-
return new AsyncGenerator(e.apply(this, arguments));
|
|
1874
|
-
};
|
|
1875
|
-
}
|
|
1876
|
-
function AsyncGenerator(e) {
|
|
1877
|
-
var r, t;
|
|
1878
|
-
function resume(r$1, t$1) {
|
|
1879
|
-
try {
|
|
1880
|
-
var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
|
|
1881
|
-
Promise.resolve(u ? o.v : o).then(function(t$2) {
|
|
1882
|
-
if (u) {
|
|
1883
|
-
var i = "return" === r$1 ? "return" : "next";
|
|
1884
|
-
if (!o.k || t$2.done) return resume(i, t$2);
|
|
1885
|
-
t$2 = e[i](t$2).value;
|
|
1886
|
-
}
|
|
1887
|
-
settle(n.done ? "return" : "normal", t$2);
|
|
1888
|
-
}, function(e$1) {
|
|
1889
|
-
resume("throw", e$1);
|
|
1890
|
-
});
|
|
1891
|
-
} catch (e$1) {
|
|
1892
|
-
settle("throw", e$1);
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
function settle(e$1, n) {
|
|
1896
|
-
switch (e$1) {
|
|
1897
|
-
case "return":
|
|
1898
|
-
r.resolve({
|
|
1899
|
-
value: n,
|
|
1900
|
-
done: true
|
|
1901
|
-
});
|
|
1902
|
-
break;
|
|
1903
|
-
case "throw":
|
|
1904
|
-
r.reject(n);
|
|
1905
|
-
break;
|
|
1906
|
-
default:
|
|
1907
|
-
r.resolve({
|
|
1908
|
-
value: n,
|
|
1909
|
-
done: false
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
(r = r.next) ? resume(r.key, r.arg) : t = null;
|
|
1913
|
-
}
|
|
1914
|
-
this._invoke = function(e$1, n) {
|
|
1915
|
-
return new Promise(function(o, u) {
|
|
1916
|
-
var i = {
|
|
1917
|
-
key: e$1,
|
|
1918
|
-
arg: n,
|
|
1919
|
-
resolve: o,
|
|
1920
|
-
reject: u,
|
|
1921
|
-
next: null
|
|
1922
|
-
};
|
|
1923
|
-
t ? t = t.next = i : (r = t = i, resume(e$1, n));
|
|
1924
|
-
});
|
|
1925
|
-
}, "function" != typeof e["return"] && (this["return"] = void 0);
|
|
1926
|
-
}
|
|
1927
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
1928
|
-
return this;
|
|
1929
|
-
}, AsyncGenerator.prototype.next = function(e) {
|
|
1930
|
-
return this._invoke("next", e);
|
|
1931
|
-
}, AsyncGenerator.prototype["throw"] = function(e) {
|
|
1932
|
-
return this._invoke("throw", e);
|
|
1933
|
-
}, AsyncGenerator.prototype["return"] = function(e) {
|
|
1934
|
-
return this._invoke("return", e);
|
|
1935
|
-
};
|
|
1936
|
-
module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1937
|
-
} });
|
|
1938
|
-
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
1939
|
-
var import_awaitAsyncGenerator = __toESM(require_awaitAsyncGenerator(), 1);
|
|
1940
|
-
var import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
|
|
1941
|
-
var import_objectSpread27 = __toESM(require_objectSpread2(), 1);
|
|
1942
|
-
function unstable_localLink(opts) {
|
|
1943
|
-
const transformer = getTransformer(opts.transformer);
|
|
1944
|
-
const transformChunk = (chunk) => {
|
|
1945
|
-
if (opts.transformer) return chunk;
|
|
1946
|
-
if (chunk === void 0) return chunk;
|
|
1947
|
-
const serialized = JSON.stringify(transformer.input.serialize(chunk));
|
|
1948
|
-
const deserialized = JSON.parse(transformer.output.deserialize(serialized));
|
|
1949
|
-
return deserialized;
|
|
1950
|
-
};
|
|
1951
|
-
return () => ({ op }) => observable6((observer) => {
|
|
1952
|
-
let ctx = void 0;
|
|
1953
|
-
const ac = new AbortController();
|
|
1954
|
-
const signal = raceAbortSignals(op.signal, ac.signal);
|
|
1955
|
-
const signalPromise = abortSignalToPromise(signal);
|
|
1956
|
-
signalPromise.catch(() => {
|
|
1957
|
-
});
|
|
1958
|
-
let input = op.input;
|
|
1959
|
-
async function runProcedure(newInput) {
|
|
1960
|
-
input = newInput;
|
|
1961
|
-
ctx = await opts.createContext();
|
|
1962
|
-
return callProcedure({
|
|
1963
|
-
router: opts.router,
|
|
1964
|
-
path: op.path,
|
|
1965
|
-
getRawInput: async () => newInput,
|
|
1966
|
-
ctx,
|
|
1967
|
-
type: op.type,
|
|
1968
|
-
signal,
|
|
1969
|
-
batchIndex: 0
|
|
1970
|
-
});
|
|
1971
|
-
}
|
|
1972
|
-
function onErrorCallback(cause) {
|
|
1973
|
-
var _opts$onError;
|
|
1974
|
-
if (isAbortError(cause)) return;
|
|
1975
|
-
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
|
1976
|
-
error: getTRPCErrorFromUnknown(cause),
|
|
1977
|
-
type: op.type,
|
|
1978
|
-
path: op.path,
|
|
1979
|
-
input,
|
|
1980
|
-
ctx
|
|
1981
|
-
});
|
|
1982
|
-
}
|
|
1983
|
-
function coerceToTRPCClientError(cause) {
|
|
1984
|
-
if (isTRPCClientError(cause)) return cause;
|
|
1985
|
-
const error = getTRPCErrorFromUnknown(cause);
|
|
1986
|
-
const shape = getTRPCErrorShape({
|
|
1987
|
-
config: opts.router._def._config,
|
|
1988
|
-
ctx,
|
|
1989
|
-
error,
|
|
1990
|
-
input,
|
|
1991
|
-
path: op.path,
|
|
1992
|
-
type: op.type
|
|
1993
|
-
});
|
|
1994
|
-
return TRPCClientError.from({ error: transformChunk(shape) }, { cause: cause instanceof Error ? cause : void 0 });
|
|
1995
|
-
}
|
|
1996
|
-
run2(async () => {
|
|
1997
|
-
switch (op.type) {
|
|
1998
|
-
case "query":
|
|
1999
|
-
case "mutation": {
|
|
2000
|
-
const result = await runProcedure(op.input);
|
|
2001
|
-
if (!isAsyncIterable(result)) {
|
|
2002
|
-
observer.next({ result: { data: transformChunk(result) } });
|
|
2003
|
-
observer.complete();
|
|
2004
|
-
break;
|
|
2005
|
-
}
|
|
2006
|
-
observer.next({ result: { data: (0, import_wrapAsyncGenerator.default)(function* () {
|
|
2007
|
-
try {
|
|
2008
|
-
var _usingCtx$1 = (0, import_usingCtx.default)();
|
|
2009
|
-
const iterator = _usingCtx$1.a(iteratorResource(result));
|
|
2010
|
-
const _finally = _usingCtx$1.u(makeResource({}, () => {
|
|
2011
|
-
observer.complete();
|
|
2012
|
-
}));
|
|
2013
|
-
try {
|
|
2014
|
-
while (true) {
|
|
2015
|
-
const res = yield (0, import_awaitAsyncGenerator.default)(Promise.race([iterator.next(), signalPromise]));
|
|
2016
|
-
if (res.done) return transformChunk(res.value);
|
|
2017
|
-
yield transformChunk(res.value);
|
|
2018
|
-
}
|
|
2019
|
-
} catch (cause) {
|
|
2020
|
-
onErrorCallback(cause);
|
|
2021
|
-
throw coerceToTRPCClientError(cause);
|
|
2022
|
-
}
|
|
2023
|
-
} catch (_) {
|
|
2024
|
-
_usingCtx$1.e = _;
|
|
2025
|
-
} finally {
|
|
2026
|
-
yield (0, import_awaitAsyncGenerator.default)(_usingCtx$1.d());
|
|
2027
|
-
}
|
|
2028
|
-
})() } });
|
|
2029
|
-
break;
|
|
2030
|
-
}
|
|
2031
|
-
case "subscription":
|
|
2032
|
-
try {
|
|
2033
|
-
var _usingCtx3 = (0, import_usingCtx.default)();
|
|
2034
|
-
const connectionState = behaviorSubject2({
|
|
2035
|
-
type: "state",
|
|
2036
|
-
state: "connecting",
|
|
2037
|
-
error: null
|
|
2038
|
-
});
|
|
2039
|
-
const connectionSub = connectionState.subscribe({ next(state) {
|
|
2040
|
-
observer.next({ result: state });
|
|
2041
|
-
} });
|
|
2042
|
-
let lastEventId = void 0;
|
|
2043
|
-
const _finally = _usingCtx3.u(makeResource({}, async () => {
|
|
2044
|
-
observer.complete();
|
|
2045
|
-
connectionState.next({
|
|
2046
|
-
type: "state",
|
|
2047
|
-
state: "idle",
|
|
2048
|
-
error: null
|
|
2049
|
-
});
|
|
2050
|
-
connectionSub.unsubscribe();
|
|
2051
|
-
}));
|
|
2052
|
-
while (true) try {
|
|
2053
|
-
var _usingCtx4 = (0, import_usingCtx.default)();
|
|
2054
|
-
const result = await runProcedure(inputWithTrackedEventId(op.input, lastEventId));
|
|
2055
|
-
if (!isAsyncIterable(result)) throw new Error("Expected an async iterable");
|
|
2056
|
-
const iterator = _usingCtx4.a(iteratorResource(result));
|
|
2057
|
-
observer.next({ result: { type: "started" } });
|
|
2058
|
-
connectionState.next({
|
|
2059
|
-
type: "state",
|
|
2060
|
-
state: "pending",
|
|
2061
|
-
error: null
|
|
2062
|
-
});
|
|
2063
|
-
while (true) {
|
|
2064
|
-
let res;
|
|
2065
|
-
try {
|
|
2066
|
-
res = await Promise.race([iterator.next(), signalPromise]);
|
|
2067
|
-
} catch (cause) {
|
|
2068
|
-
if (isAbortError(cause)) return;
|
|
2069
|
-
const error = getTRPCErrorFromUnknown(cause);
|
|
2070
|
-
if (!retryableRpcCodes.includes(TRPC_ERROR_CODES_BY_KEY[error.code])) throw coerceToTRPCClientError(error);
|
|
2071
|
-
onErrorCallback(error);
|
|
2072
|
-
connectionState.next({
|
|
2073
|
-
type: "state",
|
|
2074
|
-
state: "connecting",
|
|
2075
|
-
error: coerceToTRPCClientError(error)
|
|
2076
|
-
});
|
|
2077
|
-
break;
|
|
2078
|
-
}
|
|
2079
|
-
if (res.done) return;
|
|
2080
|
-
let chunk;
|
|
2081
|
-
if (isTrackedEnvelope(res.value)) {
|
|
2082
|
-
lastEventId = res.value[0];
|
|
2083
|
-
chunk = {
|
|
2084
|
-
id: res.value[0],
|
|
2085
|
-
data: {
|
|
2086
|
-
id: res.value[0],
|
|
2087
|
-
data: res.value[1]
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
} else chunk = { data: res.value };
|
|
2091
|
-
observer.next({ result: (0, import_objectSpread27.default)((0, import_objectSpread27.default)({}, chunk), {}, { data: transformChunk(chunk.data) }) });
|
|
2092
|
-
}
|
|
2093
|
-
} catch (_) {
|
|
2094
|
-
_usingCtx4.e = _;
|
|
2095
|
-
} finally {
|
|
2096
|
-
await _usingCtx4.d();
|
|
2097
|
-
}
|
|
2098
|
-
break;
|
|
2099
|
-
} catch (_) {
|
|
2100
|
-
_usingCtx3.e = _;
|
|
2101
|
-
} finally {
|
|
2102
|
-
_usingCtx3.d();
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}).catch((cause) => {
|
|
2106
|
-
onErrorCallback(cause);
|
|
2107
|
-
observer.error(coerceToTRPCClientError(cause));
|
|
2108
|
-
});
|
|
2109
|
-
return () => {
|
|
2110
|
-
ac.abort();
|
|
2111
|
-
};
|
|
2112
|
-
});
|
|
2113
|
-
}
|
|
2114
|
-
var experimental_localLink = unstable_localLink;
|
|
2115
|
-
export {
|
|
2116
|
-
TRPCClientError,
|
|
2117
|
-
TRPCUntypedClient,
|
|
2118
|
-
clientCallTypeToProcedureType,
|
|
2119
|
-
createTRPCClient,
|
|
2120
|
-
createTRPCClientProxy,
|
|
2121
|
-
createTRPCClient as createTRPCProxyClient,
|
|
2122
|
-
createTRPCUntypedClient,
|
|
2123
|
-
createWSClient,
|
|
2124
|
-
experimental_localLink,
|
|
2125
|
-
getFetch,
|
|
2126
|
-
getUntypedClient,
|
|
2127
|
-
httpBatchLink,
|
|
2128
|
-
httpBatchStreamLink,
|
|
2129
|
-
httpLink,
|
|
2130
|
-
httpSubscriptionLink,
|
|
2131
|
-
isFormData,
|
|
2132
|
-
isNonJsonSerializable,
|
|
2133
|
-
isOctetType,
|
|
2134
|
-
isTRPCClientError,
|
|
2135
|
-
jsonEncoder,
|
|
2136
|
-
loggerLink,
|
|
2137
|
-
retryLink,
|
|
2138
|
-
splitLink,
|
|
2139
|
-
unstable_httpBatchStreamLink,
|
|
2140
|
-
unstable_httpSubscriptionLink,
|
|
2141
|
-
unstable_localLink,
|
|
2142
|
-
wsLink
|
|
2143
|
-
};
|
|
2144
|
-
/*! Bundled license information:
|
|
2145
|
-
|
|
2146
|
-
@trpc/client/dist/httpLink-lG_6juPY.mjs:
|
|
2147
|
-
@trpc/client/dist/httpBatchLink-LhidKAPw.mjs:
|
|
2148
|
-
@trpc/client/dist/index.mjs:
|
|
2149
|
-
(* istanbul ignore if -- @preserve *)
|
|
2150
|
-
*/
|
|
2151
|
-
//# sourceMappingURL=dist-3BY63UQ5.mjs.map
|