vibedgames 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +14 -6
  2. package/dist/THIRD_PARTY_NOTICES.txt +58 -6
  3. package/dist/{chunk-FNYBZNW2.js → chunk-25BAMW5X.js} +3 -1
  4. package/dist/{chunk-GCX5KQ6A.js → chunk-2VUUMXAQ.js} +2 -2
  5. package/dist/{chunk-7MKUR7Y3.js → chunk-355VG7EO.js} +13 -12
  6. package/dist/{chunk-I6O4HIDY.js → chunk-3HUWAJQH.js} +76 -61
  7. package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
  8. package/dist/chunk-56OY4TEP.js +20125 -0
  9. package/dist/{chunk-PHEDW6C7.js → chunk-6EWHKL7Z.js} +13 -5
  10. package/dist/{chunk-6FZPPUQH.js → chunk-7CXMMC5S.js} +1 -1
  11. package/dist/{chunk-QJZ72MSY.js → chunk-7QZSDU52.js} +5 -5
  12. package/dist/{chunk-MGIASPED.js → chunk-AXTLPJ2F.js} +5 -5
  13. package/dist/{chunk-RAUJA3OY.js → chunk-BMTHAVMS.js} +5 -5
  14. package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
  15. package/dist/chunk-FC233UKH.js +170 -0
  16. package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
  17. package/dist/{chunk-HCMTSR7E.js → chunk-H3IPLBXQ.js} +8 -7
  18. package/dist/{chunk-QGEITHUP.js → chunk-HNRVSBRK.js} +5 -5
  19. package/dist/chunk-K2U7L4RU.js +183 -0
  20. package/dist/{chunk-PQDBCZRT.js → chunk-KZBZNTM4.js} +203 -153
  21. package/dist/{chunk-QIVCBUYD.js → chunk-LXS3NJYD.js} +7 -6
  22. package/dist/{chunk-HKA5LBYW.js → chunk-LY2GQ32S.js} +9 -8
  23. package/dist/{chunk-2GL2WJZX.js → chunk-NDHXM4PL.js} +4 -4
  24. package/dist/{chunk-PM5UOIKR.js → chunk-OD2MNYXD.js} +16 -16
  25. package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
  26. package/dist/{chunk-RYFO3ZPO.js → chunk-RXHTGX7C.js} +9 -2
  27. package/dist/chunk-ST5FC2W3.js +95 -0
  28. package/dist/{chunk-AYJQVZXY.js → chunk-TBQ5BU3Q.js} +4 -4
  29. package/dist/{chunk-N3XAUFKH.js → chunk-UFR6G6BL.js} +38 -63
  30. package/dist/{chunk-4BGCA3W7.js → chunk-US6QZICZ.js} +8 -8
  31. package/dist/{chunk-TLRL6FHW.js → chunk-UXCWSWWX.js} +7 -7
  32. package/dist/chunk-UZM6OSW5.js +113 -0
  33. package/dist/{chunk-NC5XCGYU.js → chunk-WSRIF6K4.js} +4 -4
  34. package/dist/chunk-X75Y7LUW.js +126 -0
  35. package/dist/chunk-Z5TFZQ5U.js +2478 -0
  36. package/dist/{chunk-C2IRIRAA.js → chunk-ZCYWDKYP.js} +2 -2
  37. package/dist/index.js +30 -19
  38. package/package.json +6 -5
  39. package/dist/chunk-MJQSHP3Y.js +0 -415
  40. package/dist/chunk-MYFLYNPO.js +0 -68
@@ -4,18 +4,19 @@ import { fileURLToPath as __fileURLToPath } from "node:url";
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
+ import {
8
+ CLI_VERSION_HEADER,
9
+ getAccessToken
10
+ } from "./chunk-K2U7L4RU.js";
7
11
  import {
8
12
  PACKAGE_VERSION
9
13
  } from "./chunk-Z4Z24FWO.js";
10
14
  import {
11
15
  getBaseUrl,
12
16
  getToken
13
- } from "./chunk-RYFO3ZPO.js";
14
-
15
- // ../../packages/contract/src/cli.ts
16
- var CLI_VERSION_HEADER = "x-vg-cli";
17
+ } from "./chunk-RXHTGX7C.js";
17
18
 
18
- // ../../node_modules/.pnpm/@standard-server+shared@0.10.1/node_modules/@standard-server/shared/dist/index.mjs
19
+ // ../../node_modules/.pnpm/@standard-server+shared@0.11.0/node_modules/@standard-server/shared/dist/index.mjs
19
20
  function toArray(value2) {
20
21
  return Array.isArray(value2) ? value2 : value2 === void 0 || value2 === null ? [] : [value2];
21
22
  }
@@ -34,7 +35,7 @@ function isAsyncIteratorObject(maybe) {
34
35
  }
35
36
  return "next" in maybe && typeof maybe.next === "function" && Symbol.asyncIterator in maybe && typeof maybe[Symbol.asyncIterator] === "function";
36
37
  }
37
- var fallbackAsyncDisposeSymbol = /* @__PURE__ */ Symbol.for("asyncDispose");
38
+ var fallbackAsyncDisposeSymbol = /* @__PURE__ */ Symbol.for("Symbol.asyncDispose");
38
39
  var asyncDisposeSymbol = Symbol.asyncDispose ?? fallbackAsyncDisposeSymbol;
39
40
  var AsyncIteratorClass = class {
40
41
  isDone = false;
@@ -91,7 +92,7 @@ var AsyncIteratorClass = class {
91
92
  throw error;
92
93
  }
93
94
  /**
94
- * asyncDispose symbol only available in esnext, we should fallback to Symbol.for('asyncDispose')
95
+ * Uses the native Symbol.asyncDispose, or Symbol.for('Symbol.asyncDispose') on runtimes without it
95
96
  */
96
97
  async [asyncDisposeSymbol]() {
97
98
  this.isDone = true;
@@ -136,8 +137,7 @@ function getOrBind(target, property, { bind = true } = {}) {
136
137
  }
137
138
  return bound;
138
139
  }
139
- var LONE_SURROGATE_REGEX = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
140
- var PERCENT_ESCAPES_REGEX = /(?:%[0-9A-F]{2})+/gi;
140
+ var LONE_SURROGATE_REGEX = /[\uD800-\uDFFF]/gu;
141
141
  function safeEncodeURIComponent(value2) {
142
142
  try {
143
143
  return encodeURIComponent(value2);
@@ -152,20 +152,77 @@ function safeDecodeURIComponent(value2) {
152
152
  try {
153
153
  return decodeURIComponent(value2);
154
154
  } catch {
155
- return value2.replace(PERCENT_ESCAPES_REGEX, (escapes) => {
156
- try {
157
- return decodeURIComponent(escapes);
158
- } catch {
159
- return escapes;
160
- }
161
- });
155
+ return value2;
162
156
  }
163
157
  }
164
158
 
165
- // ../../node_modules/.pnpm/@orpc+shared@2.0.0-beta.42/node_modules/@orpc/shared/dist/index.mjs
159
+ // ../../node_modules/.pnpm/@orpc+shared@2.0.0-beta.45/node_modules/@orpc/shared/dist/index.mjs
166
160
  function resolveMaybeOptionalOptions(rest) {
167
161
  return rest[0] ?? {};
168
162
  }
163
+ var DEFAULT_MAX_BIGINT_DIGITS = 4300;
164
+ var BIGINT_PATTERN = /^-?(?:0|[1-9]\d*)$/;
165
+ function parseBigIntString(value2, maxDigits) {
166
+ const digits = value2.startsWith("-") ? value2.length - 1 : value2.length;
167
+ if (digits > maxDigits || !BIGINT_PATTERN.test(value2)) {
168
+ return void 0;
169
+ }
170
+ return BigInt(value2);
171
+ }
172
+ function* getConstructors(value2) {
173
+ if (!isTypescriptObject(value2)) {
174
+ return;
175
+ }
176
+ let proto = Object.getPrototypeOf(value2);
177
+ while (proto != null) {
178
+ if (proto.constructor) {
179
+ yield proto.constructor;
180
+ }
181
+ proto = Object.getPrototypeOf(proto);
182
+ }
183
+ }
184
+ function isPlainObject(value2) {
185
+ if (!value2 || typeof value2 !== "object") {
186
+ return false;
187
+ }
188
+ const proto = Object.getPrototypeOf(value2);
189
+ return proto === Object.prototype || !proto || !proto.constructor;
190
+ }
191
+ function setOwn(object, key, value2) {
192
+ if (key === "__proto__") {
193
+ Object.defineProperty(object, key, {
194
+ value: value2,
195
+ writable: true,
196
+ enumerable: true,
197
+ configurable: true
198
+ });
199
+ } else {
200
+ object[key] = value2;
201
+ }
202
+ }
203
+ function copyOnWrite(parent, key, original) {
204
+ const value2 = parent[key];
205
+ if (value2 !== original) {
206
+ return value2;
207
+ }
208
+ let copy;
209
+ if (Array.isArray(value2)) {
210
+ copy = value2.slice();
211
+ } else if (isPlainObject(value2)) {
212
+ copy = { ...value2 };
213
+ } else {
214
+ return value2;
215
+ }
216
+ setOwn(parent, key, copy);
217
+ return copy;
218
+ }
219
+ var NullProtoObj = /* @__PURE__ */ (() => {
220
+ const e = function() {
221
+ };
222
+ e.prototype = /* @__PURE__ */ Object.create(null);
223
+ Object.freeze(e.prototype);
224
+ return e;
225
+ })();
169
226
  var ORPC_NAME = "orpc";
170
227
  function isAbortError(error) {
171
228
  return error instanceof Error && error.name.includes("Abort");
@@ -312,60 +369,6 @@ function override(target, partial) {
312
369
  });
313
370
  return proxy;
314
371
  }
315
- function* getConstructors(value2) {
316
- if (!isTypescriptObject(value2)) {
317
- return;
318
- }
319
- let proto = Object.getPrototypeOf(value2);
320
- while (proto != null) {
321
- if (proto.constructor) {
322
- yield proto.constructor;
323
- }
324
- proto = Object.getPrototypeOf(proto);
325
- }
326
- }
327
- function isPlainObject(value2) {
328
- if (!value2 || typeof value2 !== "object") {
329
- return false;
330
- }
331
- const proto = Object.getPrototypeOf(value2);
332
- return proto === Object.prototype || !proto || !proto.constructor;
333
- }
334
- function setOwn(object, key, value2) {
335
- if (key === "__proto__") {
336
- Object.defineProperty(object, key, {
337
- value: value2,
338
- writable: true,
339
- enumerable: true,
340
- configurable: true
341
- });
342
- } else {
343
- object[key] = value2;
344
- }
345
- }
346
- function copyOnWrite(parent, key, original) {
347
- const value2 = parent[key];
348
- if (value2 !== original) {
349
- return value2;
350
- }
351
- let copy;
352
- if (Array.isArray(value2)) {
353
- copy = value2.slice();
354
- } else if (isPlainObject(value2)) {
355
- copy = { ...value2 };
356
- } else {
357
- return value2;
358
- }
359
- setOwn(parent, key, copy);
360
- return copy;
361
- }
362
- var NullProtoObj = /* @__PURE__ */ (() => {
363
- const e = function() {
364
- };
365
- e.prototype = /* @__PURE__ */ Object.create(null);
366
- Object.freeze(e.prototype);
367
- return e;
368
- })();
369
372
  function wrapReadableStream(stream, { runWith, mapResult, mapError, onError, onFinish }) {
370
373
  runWith ??= (run) => run();
371
374
  const reader = once(() => stream.getReader());
@@ -496,7 +499,7 @@ function findCyclicPlugin(plugins, dependencies, placed) {
496
499
  return plugins[current];
497
500
  }
498
501
 
499
- // ../../node_modules/.pnpm/@standard-server+core@0.10.1/node_modules/@standard-server/core/dist/index.mjs
502
+ // ../../node_modules/.pnpm/@standard-server+core@0.11.0/node_modules/@standard-server/core/dist/index.mjs
500
503
  var EventStreamEncoderError = class extends TypeError {
501
504
  };
502
505
  var EventStreamDecoderError = class extends TypeError {
@@ -822,8 +825,6 @@ function resolveStandardBodyHint(headers) {
822
825
  }
823
826
  const mimeType = flattenStandardHeader(headers["content-type"])?.split(";")[0]?.trim().toLowerCase();
824
827
  const contentLength = flattenStandardHeader(headers["content-length"]);
825
- const contentDisposition = flattenStandardHeader(headers["content-disposition"]);
826
- const fileName = contentDisposition !== void 0 ? getFilenameFromContentDisposition(contentDisposition) : void 0;
827
828
  if (mimeType === void 0 && (contentLength === void 0 || contentLength === "0")) {
828
829
  return "none";
829
830
  }
@@ -839,7 +840,11 @@ function resolveStandardBodyHint(headers) {
839
840
  if (mimeType === "text/event-stream") {
840
841
  return "event-stream";
841
842
  }
842
- if (fileName !== void 0 || contentLength !== void 0) {
843
+ if (contentLength !== void 0) {
844
+ return "file";
845
+ }
846
+ const contentDisposition = flattenStandardHeader(headers["content-disposition"]);
847
+ if (contentDisposition !== void 0 && getFilenameFromContentDisposition(contentDisposition) !== void 0) {
843
848
  return "file";
844
849
  }
845
850
  return "octet-stream";
@@ -868,7 +873,7 @@ function parseStandardUrl(url) {
868
873
  return [pathname, search, hash];
869
874
  }
870
875
 
871
- // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.42/node_modules/@orpc/client/dist/shared/client.DD2eNne_.mjs
876
+ // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.45/node_modules/@orpc/client/dist/shared/client.LF04eOvL.mjs
872
877
  var COMMON_ERROR_STATUS_MAP = {
873
878
  BAD_REQUEST: 400,
874
879
  UNAUTHORIZED: 401,
@@ -917,7 +922,7 @@ var ORPCError = class _ORPCError extends Error {
917
922
  data;
918
923
  constructor(code, ...rest) {
919
924
  const options = resolveMaybeOptionalOptions(rest);
920
- const message = options.message ?? code.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
925
+ const message = options.message ?? codeToMessage(code);
921
926
  super(message, options);
922
927
  this.code = code;
923
928
  this.data = options.data;
@@ -954,16 +959,34 @@ var ORPCError = class _ORPCError extends Error {
954
959
  return false;
955
960
  }
956
961
  };
957
- var MalformedResponseError = class extends Error {
958
- name = "MalformedResponseError";
962
+ var ResponseError = class extends Error {
963
+ name = "ResponseError";
959
964
  response;
960
965
  constructor(options) {
961
- super(options.message, options);
966
+ super(options.message ?? `Received a ${options.response.status} response.`, options);
962
967
  this.response = options.response;
963
968
  }
964
969
  };
970
+ var MalformedResponseError = class extends ResponseError {
971
+ name = "MalformedResponseError";
972
+ constructor(options) {
973
+ super({ ...options, message: options.message ?? inferMalformedResponseMessage(options.response) });
974
+ }
975
+ };
976
+ var INFERRED_MESSAGE_MAX_LENGTH = 256;
977
+ function inferMalformedResponseMessage(response) {
978
+ const candidate = isPlainObject(response.body) ? response.body.message : response.body;
979
+ if (typeof candidate === "string" && candidate.length > 0 && candidate.length <= INFERRED_MESSAGE_MAX_LENGTH) {
980
+ return candidate;
981
+ }
982
+ const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
983
+ return commonCode ? codeToMessage(commonCode) : "Malformed oRPC Response";
984
+ }
985
+ function codeToMessage(code) {
986
+ return code.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
987
+ }
965
988
 
966
- // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.42/node_modules/@orpc/client/dist/shared/client.DpkGsZt-.mjs
989
+ // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.45/node_modules/@orpc/client/dist/shared/client._wG5INmC.mjs
967
990
  function toORPCError(error) {
968
991
  return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", { cause: error });
969
992
  }
@@ -985,29 +1008,6 @@ function createORPCErrorFromJson(json, options = {}) {
985
1008
  error.defined = json.defined;
986
1009
  return error;
987
1010
  }
988
- function createORPCErrorFromMalformedResponse(options) {
989
- const error = new ORPCError("MALFORMED_ORPC_RESPONSE", {
990
- message: options.message ?? inferMalformedResponseMessage(options.response),
991
- data: options.response
992
- });
993
- error.cause = new MalformedResponseError({ ...options, message: error.message });
994
- return error;
995
- }
996
- var INFERRED_MESSAGE_MIN_LENGTH = 1;
997
- var INFERRED_MESSAGE_MAX_LENGTH = 256;
998
- function isInferableMessage(text) {
999
- return text.length >= INFERRED_MESSAGE_MIN_LENGTH && text.length <= INFERRED_MESSAGE_MAX_LENGTH;
1000
- }
1001
- function inferMalformedResponseMessage(response) {
1002
- if (typeof response.body === "string" && isInferableMessage(response.body)) {
1003
- return response.body;
1004
- }
1005
- if (isPlainObject(response.body) && typeof response.body.message === "string" && isInferableMessage(response.body.message)) {
1006
- return response.body.message;
1007
- }
1008
- const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
1009
- return commonCode?.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1010
- }
1011
1011
  function wrapAsyncIteratorPreservingEventMeta(iterator, { mapResult, mapError, ...rest }) {
1012
1012
  return wrapAsyncIterator(iterator, {
1013
1013
  ...rest,
@@ -1041,6 +1041,16 @@ function assertSerializedType(ok, type, expected) {
1041
1041
  throw invalidSerializedData(`type "${type}" expects ${expected}.`);
1042
1042
  }
1043
1043
  }
1044
+ function isWalkable(value2) {
1045
+ return Array.isArray(value2) || isPlainObject(value2);
1046
+ }
1047
+ function walkInto(parent, key, original, restored) {
1048
+ const value2 = parent[key];
1049
+ if (!isWalkable(value2) || restored?.has(value2)) {
1050
+ throw invalidSerializedData(`segment "${key}" cannot be walked into.`);
1051
+ }
1052
+ return value2 === original ? copyOnWrite(parent, key, original) : value2;
1053
+ }
1044
1054
  var DEFAULT_RPC_JSON_SERIALIZER_HANDLERS = {
1045
1055
  undefined: {
1046
1056
  condition(data) {
@@ -1064,7 +1074,11 @@ var DEFAULT_RPC_JSON_SERIALIZER_HANDLERS = {
1064
1074
  },
1065
1075
  deserialize(serialized) {
1066
1076
  assertSerializedType(typeof serialized === "string", "bigint", "a string");
1067
- return BigInt(serialized);
1077
+ const value2 = parseBigIntString(serialized, DEFAULT_MAX_BIGINT_DIGITS);
1078
+ if (value2 === void 0) {
1079
+ throw invalidSerializedData(`type "bigint" expects a decimal integer string of at most ${DEFAULT_MAX_BIGINT_DIGITS} digits.`);
1080
+ }
1081
+ return value2;
1068
1082
  },
1069
1083
  isTerminal: true
1070
1084
  },
@@ -1185,7 +1199,7 @@ var RPCJsonSerializer = class {
1185
1199
  this.inlineBuiltInHandlers = inlineBuiltInHandlers;
1186
1200
  this.handlerEntries = handlerEntries;
1187
1201
  }
1188
- serialize(data) {
1202
+ serializeJson(data) {
1189
1203
  let meta = [];
1190
1204
  const maps = [];
1191
1205
  const blobs = [];
@@ -1300,7 +1314,7 @@ var RPCJsonSerializer = class {
1300
1314
  }
1301
1315
  return data;
1302
1316
  }
1303
- deserialize(serialized) {
1317
+ deserializeJson(serialized) {
1304
1318
  const ref = { json: serialized.json };
1305
1319
  if (serialized.blobs?.length) {
1306
1320
  for (let i = 0; i < serialized.maps.length; i++) {
@@ -1314,7 +1328,7 @@ var RPCJsonSerializer = class {
1314
1328
  let preSegment = "json";
1315
1329
  for (let j = 0; j < segments.length; j++) {
1316
1330
  original = original[preSegment];
1317
- currentRef = copyOnWrite(currentRef, preSegment, original);
1331
+ currentRef = walkInto(currentRef, preSegment, original);
1318
1332
  preSegment = segments[j];
1319
1333
  if (!Object.hasOwn(currentRef, preSegment)) {
1320
1334
  throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
@@ -1323,35 +1337,63 @@ var RPCJsonSerializer = class {
1323
1337
  currentRef[preSegment] = blob;
1324
1338
  }
1325
1339
  }
1326
- if (serialized.meta) {
1327
- for (const item of serialized.meta) {
1340
+ const meta = serialized.meta;
1341
+ if (meta) {
1342
+ let restored;
1343
+ const chain = meta.length === 1 ? void 0 : [];
1344
+ let chainDepth = 0;
1345
+ for (const item of meta) {
1328
1346
  const type = item[0];
1329
1347
  const handler = this.handlers[type];
1330
1348
  if (handler === void 0) {
1331
1349
  throw invalidSerializedData(`type "${type}" is not supported.`);
1332
1350
  }
1351
+ const depth = item.length - 1;
1352
+ const shared = Math.min(depth, chainDepth);
1353
+ let d = 0;
1333
1354
  let original = serialized;
1334
1355
  let currentRef = ref;
1335
1356
  let preSegment = "json";
1336
- for (let i = 1; i < item.length; i++) {
1357
+ if (chain !== void 0 && shared > 0) {
1358
+ d = 1;
1359
+ while (d < shared && chain[3 * d] === item[d]) {
1360
+ d++;
1361
+ }
1362
+ currentRef = chain[3 * d - 2];
1363
+ original = chain[3 * d - 1];
1364
+ preSegment = item[d];
1365
+ if (!Object.hasOwn(currentRef, preSegment)) {
1366
+ throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
1367
+ }
1368
+ }
1369
+ while (d < depth) {
1337
1370
  original = original[preSegment];
1338
- currentRef = copyOnWrite(currentRef, preSegment, original);
1339
- preSegment = item[i];
1371
+ currentRef = walkInto(currentRef, preSegment, original, restored);
1372
+ if (chain !== void 0) {
1373
+ chain[3 * d] = preSegment;
1374
+ chain[3 * d + 1] = currentRef;
1375
+ chain[3 * d + 2] = original;
1376
+ }
1377
+ preSegment = item[++d];
1340
1378
  if (!Object.hasOwn(currentRef, preSegment)) {
1341
1379
  throw invalidSerializedData(`segment "${preSegment}" does not exist.`);
1342
1380
  }
1343
1381
  }
1344
- currentRef[preSegment] = handler.deserialize(currentRef[preSegment]);
1382
+ chainDepth = depth;
1383
+ const value2 = handler.deserialize(currentRef[preSegment]);
1384
+ currentRef[preSegment] = value2;
1385
+ if (isWalkable(value2)) {
1386
+ (restored ??= /* @__PURE__ */ new Set()).add(value2);
1387
+ }
1345
1388
  }
1346
1389
  }
1347
1390
  return ref.json;
1348
1391
  }
1349
1392
  };
1350
- var RPCSerializer = class {
1351
- jsonSerializer;
1393
+ var RPCSerializer = class extends RPCJsonSerializer {
1352
1394
  defaultSerializeOptions;
1353
1395
  constructor(options = {}) {
1354
- this.jsonSerializer = new RPCJsonSerializer(options);
1396
+ super(options);
1355
1397
  this.defaultSerializeOptions = options.serialize;
1356
1398
  }
1357
1399
  serialize(data, options = {}) {
@@ -1364,19 +1406,19 @@ var RPCSerializer = class {
1364
1406
  if (result.value === void 0) {
1365
1407
  return result;
1366
1408
  }
1367
- return { done: result.done, value: this.serializeValue(result.value, false) };
1409
+ return { done: result.done, value: this.serializePayload(result.value, false) };
1368
1410
  },
1369
1411
  mapError: (e) => new ErrorEvent(
1370
- this.serializeValue(toORPCError(e).toJSON(), false),
1412
+ this.serializePayload(toORPCError(e).toJSON(), false),
1371
1413
  { cause: e }
1372
1414
  )
1373
1415
  });
1374
1416
  }
1375
1417
  const useFormDataForBlobs = options.useFormDataForBlobFields ?? this.defaultSerializeOptions?.useFormDataForBlobFields ?? true;
1376
- return this.serializeValue(data, useFormDataForBlobs);
1418
+ return this.serializePayload(data, useFormDataForBlobs);
1377
1419
  }
1378
- serializeValue(data, useFormDataForBlobs) {
1379
- const { json, meta, maps, blobs } = this.jsonSerializer.serialize(data);
1420
+ serializePayload(data, useFormDataForBlobs) {
1421
+ const { json, meta, maps, blobs } = this.serializeJson(data);
1380
1422
  if (!useFormDataForBlobs || !blobs?.length) {
1381
1423
  return { json, meta };
1382
1424
  }
@@ -1397,13 +1439,13 @@ var RPCSerializer = class {
1397
1439
  if (result.value === void 0) {
1398
1440
  return result;
1399
1441
  }
1400
- return { done: result.done, value: this.deserializeValue(result.value) };
1442
+ return { done: result.done, value: this.deserializePayload(result.value) };
1401
1443
  },
1402
1444
  mapError: (e) => {
1403
1445
  if (!(e instanceof ErrorEvent)) {
1404
1446
  return e;
1405
1447
  }
1406
- const deserialized = this.deserializeValue(e.data);
1448
+ const deserialized = this.deserializePayload(e.data);
1407
1449
  if (isORPCErrorJson(deserialized)) {
1408
1450
  return createORPCErrorFromJson(deserialized, { cause: e });
1409
1451
  }
@@ -1411,11 +1453,11 @@ var RPCSerializer = class {
1411
1453
  }
1412
1454
  });
1413
1455
  }
1414
- return this.deserializeValue(data);
1456
+ return this.deserializePayload(data);
1415
1457
  }
1416
- deserializeValue(data) {
1458
+ deserializePayload(data) {
1417
1459
  if (!(data instanceof FormData)) {
1418
- return this.jsonSerializer.deserialize(data);
1460
+ return this.deserializeJson(data);
1419
1461
  }
1420
1462
  const serialized = JSON.parse(data.get("data"));
1421
1463
  const blobs = [];
@@ -1424,11 +1466,11 @@ var RPCSerializer = class {
1424
1466
  blobs[Number(key)] = value2;
1425
1467
  }
1426
1468
  }
1427
- return this.jsonSerializer.deserialize({ ...serialized, blobs });
1469
+ return this.deserializeJson({ ...serialized, blobs });
1428
1470
  }
1429
1471
  };
1430
1472
 
1431
- // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.42/node_modules/@orpc/client/dist/index.mjs
1473
+ // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.45/node_modules/@orpc/client/dist/index.mjs
1432
1474
  var RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
1433
1475
  /**
1434
1476
  * Prevents the client from being treated as a thenable when users
@@ -1512,20 +1554,18 @@ function createORPCClient(link, { path = [], ...options } = {}) {
1512
1554
  return recursive;
1513
1555
  }
1514
1556
 
1515
- // ../../node_modules/.pnpm/@standard-server+fetch@0.10.1/node_modules/@standard-server/fetch/dist/index.mjs
1557
+ // ../../node_modules/.pnpm/@standard-server+fetch@0.11.0/node_modules/@standard-server/fetch/dist/index.mjs
1516
1558
  function toAsyncIteratorObject(stream) {
1517
1559
  const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventStreamDecoderStream());
1518
1560
  const reader = eventStream?.getReader();
1519
1561
  return new AsyncIteratorClass(
1520
1562
  async () => {
1521
1563
  while (true) {
1522
- if (reader === void 0) {
1523
- return { done: true, value: void 0 };
1524
- }
1525
- const { done, value: value2 } = await reader.read();
1526
- if (done) {
1527
- return { done: true, value: void 0 };
1564
+ const result = await reader?.read();
1565
+ if (result === void 0 || result.done) {
1566
+ throw new EventStreamDecoderError("Event Stream ended before complete");
1528
1567
  }
1568
+ const { value: value2 } = result;
1529
1569
  switch (value2.event) {
1530
1570
  case "message": {
1531
1571
  let message = parseEmptyableJSON(value2.data);
@@ -1765,7 +1805,7 @@ function toStandardLazyResponse(response) {
1765
1805
  };
1766
1806
  }
1767
1807
 
1768
- // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.42/node_modules/@orpc/client/dist/shared/client.Bstqyaro.mjs
1808
+ // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.45/node_modules/@orpc/client/dist/shared/client.Bpyj1NM2.mjs
1769
1809
  var CompositeStandardLinkPlugin = class {
1770
1810
  name = "~composite";
1771
1811
  plugins;
@@ -1792,7 +1832,7 @@ var StandardLink = class {
1792
1832
  interceptors;
1793
1833
  transportInterceptors;
1794
1834
  /**
1795
- * @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
1835
+ * @throws ORPCError, MalformedResponseError, transport-level errors (network failures, timeouts, etc.)
1796
1836
  */
1797
1837
  call(path, input, options) {
1798
1838
  return runWithSpan(`${ORPC_NAME}.${path.join("/")}`, (span) => {
@@ -1901,7 +1941,7 @@ var RPCLinkCodec = class {
1901
1941
  try {
1902
1942
  return this.serializer.deserialize(body);
1903
1943
  } catch (cause) {
1904
- throw createORPCErrorFromMalformedResponse({
1944
+ throw new MalformedResponseError({
1905
1945
  message: "Invalid RPC response format.",
1906
1946
  response: { status: response.status, headers: response.headers, body },
1907
1947
  cause
@@ -1910,12 +1950,14 @@ var RPCLinkCodec = class {
1910
1950
  })();
1911
1951
  if (!isOk) {
1912
1952
  if (isORPCErrorJson(deserialized)) {
1913
- return { kind: "error", error: createORPCErrorFromJson(deserialized) };
1953
+ return {
1954
+ kind: "error",
1955
+ error: createORPCErrorFromJson(deserialized, {
1956
+ cause: new ResponseError({ response: { status: response.status, headers: response.headers, body } })
1957
+ })
1958
+ };
1914
1959
  }
1915
- return {
1916
- kind: "error",
1917
- error: createORPCErrorFromMalformedResponse({ response: { headers: response.headers, status: response.status, body } })
1918
- };
1960
+ throw new MalformedResponseError({ response: { headers: response.headers, status: response.status, body } });
1919
1961
  }
1920
1962
  return { kind: "output", output: deserialized };
1921
1963
  }
@@ -1927,7 +1969,7 @@ function toResolvedStandardHeaders(headers) {
1927
1969
  return headers;
1928
1970
  }
1929
1971
 
1930
- // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.42/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
1972
+ // ../../node_modules/.pnpm/@orpc+client@2.0.0-beta.45/node_modules/@orpc/client/dist/adapters/fetch/index.mjs
1931
1973
  var GET_SUPPORTED_DUPLEX_MODE = once(() => {
1932
1974
  try {
1933
1975
  let duplex;
@@ -1978,6 +2020,12 @@ var FetchLinkTransport = class {
1978
2020
  }
1979
2021
  const fetch = this.fetch;
1980
2022
  const response = await fetch(url, init, options, path);
2023
+ if (response.type === "opaqueredirect") {
2024
+ throw new TypeError("Unexpected redirect response: redirects are not followed.");
2025
+ }
2026
+ if (response.type === "opaque") {
2027
+ throw new TypeError("Unexpected opaque response: the response is unreadable, likely due to a no-cors request.");
2028
+ }
1981
2029
  const standardResponse = toStandardLazyResponse(response);
1982
2030
  return standardResponse;
1983
2031
  }
@@ -1991,27 +2039,29 @@ var RPCLink = class extends StandardLink {
1991
2039
  };
1992
2040
 
1993
2041
  // src/lib/api.ts
1994
- var makeClient = (baseUrl, token) => createORPCClient(
2042
+ var makeClient = (baseUrl) => createORPCClient(
1995
2043
  new RPCLink({
1996
- headers: () => token ? { Authorization: `Bearer ${token}`, [CLI_VERSION_HEADER]: PACKAGE_VERSION } : { [CLI_VERSION_HEADER]: PACKAGE_VERSION },
2044
+ // Read per request, so a login's access token is refreshed before the
2045
+ // call that would find it expired.
2046
+ headers: async () => {
2047
+ const token = await getAccessToken();
2048
+ return token ? { Authorization: `Bearer ${token}`, [CLI_VERSION_HEADER]: PACKAGE_VERSION } : { [CLI_VERSION_HEADER]: PACKAGE_VERSION };
2049
+ },
1997
2050
  origin: baseUrl,
1998
2051
  url: "/api/orpc"
1999
2052
  })
2000
2053
  );
2001
2054
  var createClient = () => {
2002
- const token = getToken();
2003
- if (!token) {
2055
+ if (!getToken()) {
2004
2056
  throw new Error("Not logged in. Run `vg login` to authenticate.");
2005
2057
  }
2006
- return makeClient(getBaseUrl(), token);
2058
+ return makeClient(getBaseUrl());
2007
2059
  };
2008
2060
  var authErrorCode = (cause) => cause instanceof ORPCError ? cause.code : null;
2009
2061
  var forwardJson = async (client, input) => await client.generate.forward(input);
2010
- var createPublicClient = (baseUrl) => makeClient(baseUrl);
2011
2062
 
2012
2063
  export {
2013
2064
  createClient,
2014
2065
  authErrorCode,
2015
- forwardJson,
2016
- createPublicClient
2066
+ forwardJson
2017
2067
  };
@@ -7,9 +7,13 @@ var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  authErrorCode,
9
9
  createClient
10
- } from "./chunk-PQDBCZRT.js";
10
+ } from "./chunk-KZBZNTM4.js";
11
+ import "./chunk-K2U7L4RU.js";
11
12
  import "./chunk-Z4Z24FWO.js";
12
13
  import "./chunk-PEUP4MZR.js";
14
+ import {
15
+ getToken
16
+ } from "./chunk-RXHTGX7C.js";
13
17
  import {
14
18
  outputArgs,
15
19
  writeStructured
@@ -17,17 +21,14 @@ import {
17
21
  import {
18
22
  assertKnownFlags
19
23
  } from "./chunk-RZ4DIJQW.js";
20
- import {
21
- getToken
22
- } from "./chunk-RYFO3ZPO.js";
23
24
  import {
24
25
  consola
25
- } from "./chunk-CU7UY5YJ.js";
26
+ } from "./chunk-D2RF35HJ.js";
26
27
  import "./chunk-J6PKNPI2.js";
27
28
  import {
28
29
  defineCommand
29
30
  } from "./chunk-MBXCVCC4.js";
30
- import "./chunk-CAKBGDCY.js";
31
+ import "./chunk-GKDUYJ7R.js";
31
32
 
32
33
  // src/commands/credits.ts
33
34
  var creditsArgs = { ...outputArgs };