@zachacious/protoc-gen-connect-vue 1.0.19 → 1.0.21

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/README.md CHANGED
@@ -16,6 +16,17 @@ Protoc-gen-connect-vue attempts to create the full SDK - The client and API Wrap
16
16
  - **Message Initializers:** A createEmpty utility to generate default objects for any Protobuf message type.
17
17
  - **Query Key Factory:** Centralized query keys to simplify manual cache invalidation.
18
18
 
19
+ ## **Compatibility**
20
+
21
+ | Dependency | Supported versions |
22
+ | --- | --- |
23
+ | `@connectrpc/connect` / `@connectrpc/connect-web` | v1.6+ and v2 |
24
+ | `@bufbuild/protobuf` / `protoc-gen-es` codegen | v2 |
25
+ | `@tanstack/vue-query` | v5 |
26
+ | Vue | 3 |
27
+
28
+ The generated client configures credentials through a `fetch` override rather than the version-specific `credentials` transport option, so the same generated code type-checks against both connect-web v1.6+ and v2. See the [CHANGELOG](CHANGELOG.md) for the 1.0.21 upgrade notes.
29
+
19
30
  ## **Installation**
20
31
 
21
32
  ```bash
@@ -93,6 +104,22 @@ setSDKErrorCallback((err, url) => {
93
104
  });
94
105
  ```
95
106
 
107
+ ### **3. Credentials / Cookies**
108
+
109
+ The generated transport sends cookies cross-origin by default (`credentials: "include"`), applied through a `fetch` override so it works with both `@connectrpc/connect-web` v1 (>= 1.6) and v2 — v2 removed the `credentials` transport option, and the `fetch` override is the recommended replacement.
110
+
111
+ If your backend's CORS configuration doesn't allow credentials, change the mode at runtime:
112
+
113
+ ```TypeScript
114
+
115
+ import { setFetchCredentials } from '@/api/generated';
116
+
117
+ // "include" (default) | "same-origin" | "omit"
118
+ setFetchCredentials('same-origin');
119
+ ```
120
+
121
+ > **Upgrading from 1.0.20 or earlier:** previous releases passed a `fetchOptions` option that connect-web silently ignored, so credentials were never actually applied. From 1.0.21 the `"include"` default genuinely takes effect — if a cross-origin backend's CORS isn't configured for credentials, set `"same-origin"` at startup to keep the old behavior. Details in the [CHANGELOG](CHANGELOG.md).
122
+
96
123
  ## **Usage**
97
124
 
98
125
  ### **Using Hooks and Manual Wrappers**
package/dist/generator.js CHANGED
@@ -5,15 +5,29 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
@@ -42,7 +56,7 @@ var require_typescript = __commonJS((exports, module) => {
42
56
  var __esm = (fn, res) => function __init() {
43
57
  return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
44
58
  };
45
- var __commonJS2 = (cb, mod) => function __require() {
59
+ var __commonJS2 = (cb, mod) => function __require2() {
46
60
  return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
47
61
  };
48
62
  var __export = (target, all) => {
@@ -6274,7 +6288,7 @@ ${lanes.join(`
6274
6288
  function pathIsBareSpecifier(path) {
6275
6289
  return !pathIsAbsolute(path) && !pathIsRelative(path);
6276
6290
  }
6277
- function hasExtension(fileName) {
6291
+ function hasExtension2(fileName) {
6278
6292
  return getBaseFileName(fileName).includes(".");
6279
6293
  }
6280
6294
  function fileExtensionIs(path, extension) {
@@ -17247,7 +17261,7 @@ ${lanes.join(`
17247
17261
  function getIncludeBasePath(absolute) {
17248
17262
  const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
17249
17263
  if (wildcardOffset < 0) {
17250
- return !hasExtension(absolute) ? absolute : removeTrailingDirectorySeparator(getDirectoryPath(absolute));
17264
+ return !hasExtension2(absolute) ? absolute : removeTrailingDirectorySeparator(getDirectoryPath(absolute));
17251
17265
  }
17252
17266
  return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
17253
17267
  }
@@ -17306,8 +17320,8 @@ ${lanes.join(`
17306
17320
  function hasTSFileExtension(fileName) {
17307
17321
  return some(supportedTSExtensionsFlat, (extension) => fileExtensionIs(fileName, extension));
17308
17322
  }
17309
- function usesExtensionsOnImports({ imports }, hasExtension2 = or(hasJSFileExtension, hasTSFileExtension)) {
17310
- return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension2(text) : undefined) || false;
17323
+ function usesExtensionsOnImports({ imports }, hasExtension22 = or(hasJSFileExtension, hasTSFileExtension)) {
17324
+ return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension22(text) : undefined) || false;
17311
17325
  }
17312
17326
  function getModuleSpecifierEndingPreference(preference, resolutionMode, compilerOptions, sourceFile) {
17313
17327
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
@@ -34570,7 +34584,7 @@ ${lanes.join(`
34570
34584
  return false;
34571
34585
  if (excludeRegex.test(pathToCheck))
34572
34586
  return true;
34573
- return !hasExtension(pathToCheck) && excludeRegex.test(ensureTrailingDirectorySeparator(pathToCheck));
34587
+ return !hasExtension2(pathToCheck) && excludeRegex.test(ensureTrailingDirectorySeparator(pathToCheck));
34574
34588
  }
34575
34589
  function validateSpecs(specs, errors, disallowTrailingRecursion, jsonSourceFile, specKey) {
34576
34590
  return specs.filter((spec) => {
@@ -44733,7 +44747,7 @@ ${lanes.join(`
44733
44747
  if (resolutionDiagnostic) {
44734
44748
  error2(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
44735
44749
  } else {
44736
- const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
44750
+ const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension2(moduleReference);
44737
44751
  const resolutionIsNode16OrNext = moduleResolutionKind === 3 || moduleResolutionKind === 99;
44738
44752
  if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json") && moduleResolutionKind !== 1 && hasJsonModuleEmitEnabled(compilerOptions)) {
44739
44753
  error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
@@ -77262,7 +77276,7 @@ ${lanes.join(`
77262
77276
  if (!links2.hasReportedStatementInAmbientContext) {
77263
77277
  return links2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
77264
77278
  }
77265
- } else {}
77279
+ }
77266
77280
  }
77267
77281
  return false;
77268
77282
  }
@@ -86912,7 +86926,7 @@ ${lanes.join(`
86912
86926
  ], 2));
86913
86927
  setParentRecursive(requireStatement, false);
86914
86928
  statements = insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
86915
- } else {}
86929
+ }
86916
86930
  }
86917
86931
  }
86918
86932
  if (statements !== visited.statements) {
@@ -93940,7 +93954,7 @@ ${lanes.join(`
93940
93954
  return;
93941
93955
  }
93942
93956
  let fileName = getRelativePathToDirectoryOrUrl(outputFilePath2, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
93943
- if (startsWith(fileName, "./") && hasExtension(fileName)) {
93957
+ if (startsWith(fileName, "./") && hasExtension2(fileName)) {
93944
93958
  fileName = fileName.substring(2);
93945
93959
  }
93946
93960
  if (startsWith(fileName, "node_modules/") || pathContainsNodeModules(fileName)) {
@@ -100388,7 +100402,7 @@ ${lanes.join(`
100388
100402
  fileOrDirectoryPath = newPath;
100389
100403
  if (fileOrDirectoryPath === watchedDirPath)
100390
100404
  return false;
100391
- if (hasExtension(fileOrDirectoryPath) && !(isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions) || isSupportedScriptKind())) {
100405
+ if (hasExtension2(fileOrDirectoryPath) && !(isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions) || isSupportedScriptKind())) {
100392
100406
  writeLog(`Project: ${configFileName} Detected file add/remove of non supported extension: ${fileOrDirectory}`);
100393
100407
  return true;
100394
100408
  }
@@ -102559,7 +102573,7 @@ ${lanes.join(`
102559
102573
  return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), getSourceFile);
102560
102574
  }
102561
102575
  function getSourceFileFromReferenceWorker(fileName, getSourceFile2, fail, reason) {
102562
- if (hasExtension(fileName)) {
102576
+ if (hasExtension2(fileName)) {
102563
102577
  const canonicalFileName = host.getCanonicalFileName(fileName);
102564
102578
  if (!options.allowNonTsExtensions && !forEach(flatten(supportedExtensionsWithJsonIfResolveJsonModule), (extension) => fileExtensionIs(canonicalFileName, extension))) {
102565
102579
  if (fail) {
@@ -152395,7 +152409,7 @@ All files are: ${JSON.stringify(names)}`, "Err");
152395
152409
  if (isScriptInfoWatchedFromNodeModules(info)) {
152396
152410
  this.refreshScriptInfo(info);
152397
152411
  }
152398
- } else if (!hasExtension(fileOrDirectoryPath)) {
152412
+ } else if (!hasExtension2(fileOrDirectoryPath)) {
152399
152413
  this.refreshScriptInfosInDirectory(fileOrDirectoryPath);
152400
152414
  }
152401
152415
  }
@@ -158503,7 +158517,7 @@ ${e.message}`;
158503
158517
  hasEffectiveModifier: () => hasEffectiveModifier,
158504
158518
  hasEffectiveModifiers: () => hasEffectiveModifiers,
158505
158519
  hasEffectiveReadonlyModifier: () => hasEffectiveReadonlyModifier,
158506
- hasExtension: () => hasExtension,
158520
+ hasExtension: () => hasExtension2,
158507
158521
  hasIndexSignature: () => hasIndexSignature,
158508
158522
  hasInitializer: () => hasInitializer,
158509
158523
  hasInvalidEscape: () => hasInvalidEscape,
@@ -160918,7 +160932,7 @@ ${e.message}`;
160918
160932
  hasEffectiveModifier: () => hasEffectiveModifier,
160919
160933
  hasEffectiveModifiers: () => hasEffectiveModifiers,
160920
160934
  hasEffectiveReadonlyModifier: () => hasEffectiveReadonlyModifier,
160921
- hasExtension: () => hasExtension,
160935
+ hasExtension: () => hasExtension2,
160922
160936
  hasIndexSignature: () => hasIndexSignature,
160923
160937
  hasInitializer: () => hasInitializer,
160924
160938
  hasInvalidEscape: () => hasInvalidEscape,
@@ -163274,7 +163288,7 @@ var require_typescript2 = __commonJS((exports, module) => {
163274
163288
  hasEffectiveModifier: () => hasEffectiveModifier,
163275
163289
  hasEffectiveModifiers: () => hasEffectiveModifiers,
163276
163290
  hasEffectiveReadonlyModifier: () => hasEffectiveReadonlyModifier,
163277
- hasExtension: () => hasExtension,
163291
+ hasExtension: () => hasExtension2,
163278
163292
  hasImplementationTSFileExtension: () => hasImplementationTSFileExtension,
163279
163293
  hasIndexSignature: () => hasIndexSignature,
163280
163294
  hasInferredType: () => hasInferredType,
@@ -170618,7 +170632,7 @@ ${lanes.join(`
170618
170632
  function pathIsBareSpecifier(path) {
170619
170633
  return !pathIsAbsolute(path) && !pathIsRelative(path);
170620
170634
  }
170621
- function hasExtension(fileName) {
170635
+ function hasExtension2(fileName) {
170622
170636
  return getBaseFileName(fileName).includes(".");
170623
170637
  }
170624
170638
  function fileExtensionIs(path, extension) {
@@ -183787,7 +183801,7 @@ ${lanes.join(`
183787
183801
  function getIncludeBasePath(absolute) {
183788
183802
  const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
183789
183803
  if (wildcardOffset < 0) {
183790
- return !hasExtension(absolute) ? absolute : removeTrailingDirectorySeparator(getDirectoryPath(absolute));
183804
+ return !hasExtension2(absolute) ? absolute : removeTrailingDirectorySeparator(getDirectoryPath(absolute));
183791
183805
  }
183792
183806
  return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
183793
183807
  }
@@ -183867,8 +183881,8 @@ ${lanes.join(`
183867
183881
  ModuleSpecifierEnding2[ModuleSpecifierEnding2["TsExtension"] = 3] = "TsExtension";
183868
183882
  return ModuleSpecifierEnding2;
183869
183883
  })(ModuleSpecifierEnding || {});
183870
- function usesExtensionsOnImports({ imports }, hasExtension2 = or(hasJSFileExtension, hasTSFileExtension)) {
183871
- return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension2(text) : undefined) || false;
183884
+ function usesExtensionsOnImports({ imports }, hasExtension22 = or(hasJSFileExtension, hasTSFileExtension)) {
183885
+ return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension22(text) : undefined) || false;
183872
183886
  }
183873
183887
  function getModuleSpecifierEndingPreference(preference, resolutionMode, compilerOptions, sourceFile) {
183874
183888
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
@@ -202769,7 +202783,7 @@ ${lanes.join(`
202769
202783
  return false;
202770
202784
  if (excludeRegex.test(pathToCheck))
202771
202785
  return true;
202772
- return !hasExtension(pathToCheck) && excludeRegex.test(ensureTrailingDirectorySeparator(pathToCheck));
202786
+ return !hasExtension2(pathToCheck) && excludeRegex.test(ensureTrailingDirectorySeparator(pathToCheck));
202773
202787
  }
202774
202788
  function validateSpecs(specs, errors, disallowTrailingRecursion, jsonSourceFile, specKey) {
202775
202789
  return specs.filter((spec) => {
@@ -211513,7 +211527,7 @@ ${lanes.join(`
211513
211527
  if (resolutionDiagnostic) {
211514
211528
  error2(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
211515
211529
  } else {
211516
- const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
211530
+ const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension2(moduleReference);
211517
211531
  const resolutionIsNode16OrNext = moduleResolutionKind === 3 || moduleResolutionKind === 99;
211518
211532
  if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json") && moduleResolutionKind !== 1 && hasJsonModuleEmitEnabled(compilerOptions)) {
211519
211533
  error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
@@ -246187,7 +246201,7 @@ ${lanes.join(`
246187
246201
  if (!links2.hasReportedStatementInAmbientContext) {
246188
246202
  return links2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
246189
246203
  }
246190
- } else {}
246204
+ }
246191
246205
  }
246192
246206
  return false;
246193
246207
  }
@@ -255651,7 +255665,7 @@ ${lanes.join(`
255651
255665
  ], 2));
255652
255666
  setParentRecursive(requireStatement, false);
255653
255667
  statements = insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
255654
- } else {}
255668
+ }
255655
255669
  }
255656
255670
  }
255657
255671
  if (statements !== visited.statements) {
@@ -268855,7 +268869,7 @@ ${lanes.join(`
268855
268869
  fileOrDirectoryPath = newPath;
268856
268870
  if (fileOrDirectoryPath === watchedDirPath)
268857
268871
  return false;
268858
- if (hasExtension(fileOrDirectoryPath) && !(isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions) || isSupportedScriptKind())) {
268872
+ if (hasExtension2(fileOrDirectoryPath) && !(isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions) || isSupportedScriptKind())) {
268859
268873
  writeLog(`Project: ${configFileName} Detected file add/remove of non supported extension: ${fileOrDirectory}`);
268860
268874
  return true;
268861
268875
  }
@@ -271041,7 +271055,7 @@ ${lanes.join(`
271041
271055
  return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), getSourceFile);
271042
271056
  }
271043
271057
  function getSourceFileFromReferenceWorker(fileName, getSourceFile2, fail, reason) {
271044
- if (hasExtension(fileName)) {
271058
+ if (hasExtension2(fileName)) {
271045
271059
  const canonicalFileName = host.getCanonicalFileName(fileName);
271046
271060
  if (!options.allowNonTsExtensions && !forEach(flatten(supportedExtensionsWithJsonIfResolveJsonModule), (extension) => fileExtensionIs(canonicalFileName, extension))) {
271047
271061
  if (fail) {
@@ -319274,7 +319288,7 @@ ${options.prefix}` : `
319274
319288
  hasEffectiveModifier: () => hasEffectiveModifier,
319275
319289
  hasEffectiveModifiers: () => hasEffectiveModifiers,
319276
319290
  hasEffectiveReadonlyModifier: () => hasEffectiveReadonlyModifier,
319277
- hasExtension: () => hasExtension,
319291
+ hasExtension: () => hasExtension2,
319278
319292
  hasImplementationTSFileExtension: () => hasImplementationTSFileExtension,
319279
319293
  hasIndexSignature: () => hasIndexSignature,
319280
319294
  hasInferredType: () => hasInferredType,
@@ -325606,7 +325620,7 @@ All files are: ${JSON.stringify(names)}`, "Err");
325606
325620
  if (isScriptInfoWatchedFromNodeModules(info)) {
325607
325621
  this.refreshScriptInfo(info);
325608
325622
  }
325609
- } else if (!hasExtension(fileOrDirectoryPath)) {
325623
+ } else if (!hasExtension2(fileOrDirectoryPath)) {
325610
325624
  this.refreshScriptInfosInDirectory(fileOrDirectoryPath);
325611
325625
  }
325612
325626
  }
@@ -330969,7 +330983,7 @@ var require_vfs_cjs_development = __commonJS((exports) => {
330969
330983
  }
330970
330984
  };
330971
330985
  }
330972
- var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions(compilerOptions, ts) {
330986
+ var knownLibFilesForCompilerOptions = function knownLibFilesForCompilerOptions2(compilerOptions, ts) {
330973
330987
  var target = compilerOptions.target || ts.ScriptTarget.ES5;
330974
330988
  var lib = compilerOptions.lib || [];
330975
330989
  var files = ["lib.d.ts", "lib.core.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts", "lib.dom.asynciterable.d.ts", "lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.webworker.asynciterable.d.ts", "lib.webworker.d.ts", "lib.webworker.importscripts.d.ts", "lib.webworker.iterable.d.ts", "lib.scripthost.d.ts", "lib.es5.d.ts", "lib.es6.d.ts", "lib.es7.d.ts", "lib.core.es6.d.ts", "lib.core.es7.d.ts", "lib.es2015.collection.d.ts", "lib.es2015.core.d.ts", "lib.es2015.d.ts", "lib.es2015.generator.d.ts", "lib.es2015.iterable.d.ts", "lib.es2015.promise.d.ts", "lib.es2015.proxy.d.ts", "lib.es2015.reflect.d.ts", "lib.es2015.symbol.d.ts", "lib.es2015.symbol.wellknown.d.ts", "lib.es2016.array.include.d.ts", "lib.es2016.d.ts", "lib.es2016.full.d.ts", "lib.es2016.intl.d.ts", "lib.es2017.arraybuffer.d.ts", "lib.es2017.d.ts", "lib.es2017.date.d.ts", "lib.es2017.full.d.ts", "lib.es2017.intl.d.ts", "lib.es2017.object.d.ts", "lib.es2017.sharedmemory.d.ts", "lib.es2017.string.d.ts", "lib.es2017.typedarrays.d.ts", "lib.es2018.asyncgenerator.d.ts", "lib.es2018.asynciterable.d.ts", "lib.es2018.d.ts", "lib.es2018.full.d.ts", "lib.es2018.intl.d.ts", "lib.es2018.promise.d.ts", "lib.es2018.regexp.d.ts", "lib.es2019.array.d.ts", "lib.es2019.d.ts", "lib.es2019.full.d.ts", "lib.es2019.intl.d.ts", "lib.es2019.object.d.ts", "lib.es2019.string.d.ts", "lib.es2019.symbol.d.ts", "lib.es2020.bigint.d.ts", "lib.es2020.d.ts", "lib.es2020.date.d.ts", "lib.es2020.full.d.ts", "lib.es2020.intl.d.ts", "lib.es2020.number.d.ts", "lib.es2020.promise.d.ts", "lib.es2020.sharedmemory.d.ts", "lib.es2020.string.d.ts", "lib.es2020.symbol.wellknown.d.ts", "lib.es2021.d.ts", "lib.es2021.full.d.ts", "lib.es2021.intl.d.ts", "lib.es2021.promise.d.ts", "lib.es2021.string.d.ts", "lib.es2021.weakref.d.ts", "lib.es2022.array.d.ts", "lib.es2022.d.ts", "lib.es2022.error.d.ts", "lib.es2022.full.d.ts", "lib.es2022.intl.d.ts", "lib.es2022.object.d.ts", "lib.es2022.regexp.d.ts", "lib.es2022.sharedmemory.d.ts", "lib.es2022.string.d.ts", "lib.es2023.array.d.ts", "lib.es2023.collection.d.ts", "lib.es2023.d.ts", "lib.es2023.full.d.ts", "lib.es2023.intl.d.ts", "lib.es2024.arraybuffer.d.ts", "lib.es2024.collection.d.ts", "lib.es2024.d.ts", "lib.es2024.full.d.ts", "lib.es2024.object.d.ts", "lib.es2024.promise.d.ts", "lib.es2024.regexp.d.ts", "lib.es2024.sharedmemory.d.ts", "lib.es2024.string.d.ts", "lib.esnext.array.d.ts", "lib.esnext.asynciterable.d.ts", "lib.esnext.bigint.d.ts", "lib.esnext.collection.d.ts", "lib.esnext.d.ts", "lib.esnext.decorators.d.ts", "lib.esnext.disposable.d.ts", "lib.esnext.float16.d.ts", "lib.esnext.full.d.ts", "lib.esnext.intl.d.ts", "lib.esnext.iterator.d.ts", "lib.esnext.object.d.ts", "lib.esnext.promise.d.ts", "lib.esnext.regexp.d.ts", "lib.esnext.string.d.ts", "lib.esnext.symbol.d.ts", "lib.esnext.weakref.d.ts"];
@@ -330978,7 +330992,7 @@ var require_vfs_cjs_development = __commonJS((exports) => {
330978
330992
  return f.startsWith("lib." + targetToCut.toLowerCase());
330979
330993
  });
330980
330994
  var targetCutIndex = files.indexOf(matches.pop());
330981
- var getMax = function getMax(array) {
330995
+ var getMax = function getMax2(array) {
330982
330996
  return array && array.length ? array.reduce(function(max, current) {
330983
330997
  return current > max ? current : max;
330984
330998
  }) : undefined;
@@ -330996,14 +331010,14 @@ var require_vfs_cjs_development = __commonJS((exports) => {
330996
331010
  var finalCutIndex = Math.max(targetCutIndex, libCutIndex);
330997
331011
  return files.slice(0, finalCutIndex + 1);
330998
331012
  };
330999
- var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules(_compilerOptions, _ts, tsLibDirectory) {
331013
+ var createDefaultMapFromNodeModules = function createDefaultMapFromNodeModules2(_compilerOptions, _ts, tsLibDirectory) {
331000
331014
  var path = requirePath();
331001
331015
  var fs = requireFS();
331002
- var getLib = function getLib(name) {
331016
+ var getLib = function getLib2(name) {
331003
331017
  var lib = tsLibDirectory || path.dirname(__require.resolve("/home/zach/src/protoc-gen-connect-vue/node_modules/typescript/lib/typescript.js"));
331004
331018
  return fs.readFileSync(path.join(lib, name), "utf8");
331005
331019
  };
331006
- var isDtsFile = function isDtsFile(file) {
331020
+ var isDtsFile = function isDtsFile2(file) {
331007
331021
  return /\.d\.([^\.]+\.)?[cm]?ts$/i.test(file);
331008
331022
  };
331009
331023
  var libFiles = fs.readdirSync(tsLibDirectory || path.dirname(__require.resolve("/home/zach/src/protoc-gen-connect-vue/node_modules/typescript/lib/typescript.js")));
@@ -331016,17 +331030,17 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331016
331030
  });
331017
331031
  return fsMap;
331018
331032
  };
331019
- var addAllFilesFromFolder = function addAllFilesFromFolder(map, workingDir) {
331033
+ var addAllFilesFromFolder = function addAllFilesFromFolder2(map, workingDir) {
331020
331034
  var path = requirePath();
331021
331035
  var fs = requireFS();
331022
- var walk = function walk(dir) {
331036
+ var walk = function walk2(dir) {
331023
331037
  var results = [];
331024
331038
  var list = fs.readdirSync(dir);
331025
331039
  list.forEach(function(file) {
331026
331040
  file = path.join(dir, file);
331027
331041
  var stat = fs.statSync(file);
331028
331042
  if (stat && stat.isDirectory()) {
331029
- results = results.concat(walk(file));
331043
+ results = results.concat(walk2(file));
331030
331044
  } else {
331031
331045
  results.push(file);
331032
331046
  }
@@ -331043,10 +331057,10 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331043
331057
  }
331044
331058
  });
331045
331059
  };
331046
- var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder(map) {
331060
+ var addFilesForTypesIntoFolder = function addFilesForTypesIntoFolder2(map) {
331047
331061
  return addAllFilesFromFolder(map, "node_modules/@types");
331048
331062
  };
331049
- var createDefaultMapFromCDN = function createDefaultMapFromCDN(options, version, cache2, ts, lzstring, fetcher, storer) {
331063
+ var createDefaultMapFromCDN = function createDefaultMapFromCDN2(options, version, cache2, ts, lzstring, fetcher, storer) {
331050
331064
  var fetchlike = fetcher || fetch;
331051
331065
  var fsMap = new Map;
331052
331066
  var files = knownLibFilesForCompilerOptions(options, ts);
@@ -331118,7 +331132,7 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331118
331132
  return res;
331119
331133
  };
331120
331134
  }
331121
- var defaultCompilerOptions = function defaultCompilerOptions(ts) {
331135
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
331122
331136
  return _extends({}, ts.getDefaultCompilerOptions(), {
331123
331137
  jsx: ts.JsxEmit.React,
331124
331138
  strict: true,
@@ -331130,7 +331144,7 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331130
331144
  moduleResolution: ts.ModuleResolutionKind.NodeJs
331131
331145
  });
331132
331146
  };
331133
- var libize = function libize(path) {
331147
+ var libize = function libize2(path) {
331134
331148
  return path.replace("/", "/lib.").toLowerCase();
331135
331149
  };
331136
331150
  function createSystem(files) {
@@ -331262,7 +331276,7 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331262
331276
  }
331263
331277
  function createVirtualCompilerHost(sys, compilerOptions, ts) {
331264
331278
  var sourceFiles = new Map;
331265
- var save = function save(sourceFile) {
331279
+ var save = function save2(sourceFile) {
331266
331280
  sourceFiles.set(sourceFile.fileName, sourceFile);
331267
331281
  return sourceFile;
331268
331282
  };
@@ -331352,10 +331366,10 @@ var require_vfs_cjs_development = __commonJS((exports) => {
331352
331366
  };
331353
331367
  return lsHost;
331354
331368
  }
331355
- var requirePath = function requirePath() {
331369
+ var requirePath = function requirePath2() {
331356
331370
  return __require(String.fromCharCode(112, 97, 116, 104));
331357
331371
  };
331358
- var requireFS = function requireFS() {
331372
+ var requireFS = function requireFS2() {
331359
331373
  return __require(String.fromCharCode(102, 115));
331360
331374
  };
331361
331375
  exports.addAllFilesFromFolder = addAllFilesFromFolder;
@@ -336799,6 +336813,7 @@ var KNOWN_WKT = [
336799
336813
  ];
336800
336814
  var currentDir = new URL(".", import.meta.url).pathname;
336801
336815
  var templateDir = path.join(currentDir, "..", "templates");
336816
+ var pkg = JSON.parse(fs.readFileSync(path.join(currentDir, "..", "package.json"), "utf-8"));
336802
336817
  var templates = {
336803
336818
  client: fs.readFileSync(path.join(templateDir, "client.ts.mustache"), "utf-8"),
336804
336819
  api: fs.readFileSync(path.join(templateDir, "api.ts.mustache"), "utf-8"),
@@ -336908,7 +336923,7 @@ function processService(service) {
336908
336923
  }
336909
336924
  var plugin = createEcmaScriptPlugin({
336910
336925
  name: "protoc-gen-connect-vue",
336911
- version: "v1.10.0",
336926
+ version: `v${pkg.version}`,
336912
336927
  generateTs: (schema) => {
336913
336928
  const service = schema.files.flatMap((f) => f.services)[0];
336914
336929
  if (!service)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zachacious/protoc-gen-connect-vue",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Smart TanStack Query & ConnectRPC SDK generator for Vue.js",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,23 @@ export type ErrorCallback = (error: ConnectError, url: string) => void;
32
32
  let onError: ErrorCallback = () => {};
33
33
  export const setSDKErrorCallback = (cb: ErrorCallback) => { onError = cb; };
34
34
 
35
+ // --- FETCH CREDENTIALS ---
36
+ // connect-web v1 exposed a `credentials` option on the transport; v2 removed it
37
+ // in favor of overriding `fetch`. Wrapping fetch works on both major versions.
38
+ const credentialsMode = ref<RequestCredentials>("include");
39
+
40
+ /**
41
+ * Set the fetch credentials mode ("include" | "same-origin" | "omit").
42
+ * Defaults to "include" so cookie-based auth works cross-origin.
43
+ * Takes effect on the next request; no transport rebuild required.
44
+ */
45
+ export const setFetchCredentials = (mode: RequestCredentials) => {
46
+ credentialsMode.value = mode;
47
+ };
48
+
49
+ const fetchWithCredentials: typeof globalThis.fetch = (input, init) =>
50
+ globalThis.fetch(input, { ...init, credentials: credentialsMode.value });
51
+
35
52
  const transportInterceptor: Interceptor = (next) => async (req) => {
36
53
  const token = await resolveToken();
37
54
  if (token) req.header.set("x-api-key", token);
@@ -54,6 +71,7 @@ export const useGrpcClient = () => {
54
71
  const transport = computed(() => createConnectTransport({
55
72
  baseUrl: baseUrl.value,
56
73
  interceptors: [transportInterceptor],
74
+ fetch: fetchWithCredentials,
57
75
  }));
58
76
 
59
77
  const client = computed(() => createClient({{serviceName}}, transport.value));
@@ -102,6 +120,11 @@ async function handleUpdate() {
102
120
  <p>{{ manualResult }}</p>
103
121
  </template>
104
122
 
123
+ // Cookies are sent cross-origin by default (credentials: "include").
124
+ // If your backend's CORS config doesn't allow credentials, opt out with:
125
+ // import { setFetchCredentials } from '@/api';
126
+ // setFetchCredentials("same-origin");
127
+
105
128
  // use this to set the error interceptor - for instance to log to sentry or something
106
129
  import { setAuthResolver, setSDKErrorCallback } from '@/api';
107
130
  import { useAuthStore } from '@/stores/auth';