@hyperweb/telescope 1.17.2 → 1.17.4
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 +0 -1
- package/main/generators/create-bundle.js +38 -12
- package/main/generators/create-root-readme.js +58 -43
- package/main/helpers/helper-func-types-interface.js +2 -2
- package/main/helpers/helper-func-types.js +2 -2
- package/main/helpers/internal-for-bigint.js +1 -1
- package/main/helpers/internal.js +1 -1
- package/main/helpers/react-query-hooks-icjs.js +1 -1
- package/module/generators/create-bundle.js +39 -13
- package/module/generators/create-root-readme.js +58 -43
- package/module/helpers/helper-func-types-interface.js +2 -2
- package/module/helpers/helper-func-types.js +2 -2
- package/module/helpers/internal-for-bigint.js +1 -1
- package/module/helpers/internal.js +1 -1
- package/module/helpers/react-query-hooks-icjs.js +1 -1
- package/package.json +6 -6
- package/src/generators/create-bundle.ts +66 -20
- package/src/generators/create-root-readme.ts +358 -271
- package/src/helpers/helper-func-types-interface.ts +2 -2
- package/src/helpers/helper-func-types.ts +2 -2
- package/src/helpers/internal-for-bigint.ts +1 -1
- package/src/helpers/internal.ts +1 -1
- package/src/helpers/react-query-hooks-icjs.ts +1 -1
package/README.md
CHANGED
|
@@ -747,7 +747,6 @@ See [Helper Functions Configuration](#helper-functions-configuration) for more i
|
|
|
747
747
|
| ------------------------------ | -------------------------------------------------------------- | ---------- |
|
|
748
748
|
| `bundle.enabled` | Bundle all files into a scoped index file | `true` |
|
|
749
749
|
| `bundle.type` | Bundle type: "namespace" or "module" | `"namespace"` |
|
|
750
|
-
> **Warning:** This option is not recommended. It will generate a bundle file that exports all the types and functions under one namespace. This will make the bundle file very large and hard to maintain. e.g. using `cosmos.bank.v1beta1.MsgSend` might be intuitive, but it will also include `cosmos.gov.v1beta1.*` and other types in the final bundle file. So use this option with caution.
|
|
751
750
|
|
|
752
751
|
### MCP Server
|
|
753
752
|
|
|
@@ -3,11 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.plugin = void 0;
|
|
4
4
|
const ast_1 = require("@cosmology/ast");
|
|
5
5
|
const utils_1 = require("@cosmology/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Process noAlias configuration to create a map of names to their first package
|
|
8
|
+
* This ensures that only the first occurrence of a name skips aliasing
|
|
9
|
+
*/
|
|
10
|
+
const processNoAliasConfig = (noAlias) => {
|
|
11
|
+
if (!noAlias || noAlias.length === 0) {
|
|
12
|
+
return new Map();
|
|
13
|
+
}
|
|
14
|
+
const nameToFirstPackage = new Map();
|
|
15
|
+
for (const entry of noAlias) {
|
|
16
|
+
if (!nameToFirstPackage.has(entry.name)) {
|
|
17
|
+
nameToFirstPackage.set(entry.name, entry.package);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return nameToFirstPackage;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Check if a package/name combination should skip aliasing
|
|
24
|
+
*/
|
|
25
|
+
const shouldSkipAlias = (pkg, name, nameToFirstPackage) => {
|
|
26
|
+
const firstPackage = nameToFirstPackage.get(name);
|
|
27
|
+
return firstPackage === pkg;
|
|
28
|
+
};
|
|
6
29
|
const plugin = (builder, bundler) => {
|
|
7
30
|
if (!builder.options.bundle.enabled) {
|
|
8
31
|
return;
|
|
9
32
|
}
|
|
10
33
|
let prog = [];
|
|
34
|
+
// Process noAlias configuration once at the beginning
|
|
35
|
+
const nameToFirstPackage = processNoAliasConfig(builder.options.bundle.noAlias);
|
|
11
36
|
if (builder.options.bundle.type === "namespace") {
|
|
12
37
|
const importPaths = (0, utils_1.duplicateImportPathsWithExt)(bundler.bundle.importPaths, builder.options.restoreImportExtension);
|
|
13
38
|
// [x] bundle
|
|
@@ -44,22 +69,23 @@ const plugin = (builder, bundler) => {
|
|
|
44
69
|
const duplicatedType = duplicatedTypeNames.find((type) => type === identifier);
|
|
45
70
|
if (duplicatedType) {
|
|
46
71
|
let alias;
|
|
47
|
-
if
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
alias = (0, utils_1.makeAliasNameWithPackageAtEnd)({ package: exportObj.pkg, name: identifier });
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
alias = identifier;
|
|
54
|
-
}
|
|
72
|
+
// Check if this package/name combination should skip aliasing
|
|
73
|
+
if (shouldSkipAlias(exportObj.pkg, identifier, nameToFirstPackage)) {
|
|
74
|
+
alias = identifier; // Use original name, no alias
|
|
55
75
|
}
|
|
56
76
|
else {
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
alias = (0, utils_1.
|
|
77
|
+
// Generate alias as usual
|
|
78
|
+
if (exportObj.isHelperFunc) {
|
|
79
|
+
alias = (0, utils_1.makeAliasNameWithPackageAtEnd)({
|
|
80
|
+
package: exportObj.pkg,
|
|
81
|
+
name: identifier,
|
|
82
|
+
});
|
|
60
83
|
}
|
|
61
84
|
else {
|
|
62
|
-
alias =
|
|
85
|
+
alias = (0, utils_1.makeAliasName)({
|
|
86
|
+
package: exportObj.pkg,
|
|
87
|
+
name: identifier,
|
|
88
|
+
});
|
|
63
89
|
}
|
|
64
90
|
}
|
|
65
91
|
return { name: identifier, alias: alias };
|
|
@@ -11,10 +11,10 @@ function getAliasedFunctionName(builder, functionName, packageName) {
|
|
|
11
11
|
const duplicatedHelperFuncs = builder.store.getHelperFuncsInMultipleFiles();
|
|
12
12
|
const isDuplicated = duplicatedHelperFuncs.includes(functionName);
|
|
13
13
|
if (isDuplicated) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
return (0, utils_1.makeAliasNameWithPackageAtEnd)({
|
|
15
|
+
package: packageName,
|
|
16
|
+
name: functionName,
|
|
17
|
+
});
|
|
18
18
|
}
|
|
19
19
|
return functionName;
|
|
20
20
|
}
|
|
@@ -27,15 +27,15 @@ function cleanComment(comment) {
|
|
|
27
27
|
// Remove lint directives and technical annotations
|
|
28
28
|
const cleanedComment = comment
|
|
29
29
|
// Remove buf:lint:ignore directives
|
|
30
|
-
.replace(/buf:lint:ignore\s+[A-Z_]+/gi,
|
|
30
|
+
.replace(/buf:lint:ignore\s+[A-Z_]+/gi, "")
|
|
31
31
|
// Remove other common lint directives
|
|
32
|
-
.replace(/lint:ignore[:\s]+[A-Z_]+/gi,
|
|
32
|
+
.replace(/lint:ignore[:\s]+[A-Z_]+/gi, "")
|
|
33
33
|
// Remove protolint directives
|
|
34
|
-
.replace(/protolint:disable[:\s]+[A-Z_]+/gi,
|
|
34
|
+
.replace(/protolint:disable[:\s]+[A-Z_]+/gi, "")
|
|
35
35
|
// Remove eslint directives
|
|
36
|
-
.replace(/eslint-disable[:\s-]+[a-z-]+/gi,
|
|
36
|
+
.replace(/eslint-disable[:\s-]+[a-z-]+/gi, "")
|
|
37
37
|
// Remove multiple consecutive spaces
|
|
38
|
-
.replace(/\s+/g,
|
|
38
|
+
.replace(/\s+/g, " ")
|
|
39
39
|
// Remove leading/trailing whitespace
|
|
40
40
|
.trim();
|
|
41
41
|
return cleanedComment;
|
|
@@ -58,7 +58,7 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
|
|
|
58
58
|
const aliasedName = getAliasedFunctionName(builder, functionName, packageName);
|
|
59
59
|
if (aliasedName !== functionName) {
|
|
60
60
|
// Extract the top-level package name (e.g., 'akash' from 'akash.audit.v1beta2')
|
|
61
|
-
const topLevelPackage = packageName.split(
|
|
61
|
+
const topLevelPackage = packageName.split(".")[0];
|
|
62
62
|
// Function is aliased and should be available in bundle
|
|
63
63
|
return `${projectName}/${topLevelPackage}/bundle`;
|
|
64
64
|
}
|
|
@@ -67,11 +67,11 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
|
|
|
67
67
|
// This handles all functions with specific file locations
|
|
68
68
|
if (sourceFilename) {
|
|
69
69
|
// Remove .ts extension and convert to proper import path
|
|
70
|
-
const filePath = sourceFilename.replace(/\.ts$/,
|
|
70
|
+
const filePath = sourceFilename.replace(/\.ts$/, "");
|
|
71
71
|
return `${projectName}/${filePath}`;
|
|
72
72
|
}
|
|
73
73
|
// Fallback: import from the specific package path
|
|
74
|
-
return `${projectName}/${packageName.replace(/\./g,
|
|
74
|
+
return `${projectName}/${packageName.replace(/\./g, "/")}`;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Gets all types for a package by looking at export objects and filtering out extended forms
|
|
@@ -79,18 +79,18 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
|
|
|
79
79
|
function getTypesForPackage(builder, packageName) {
|
|
80
80
|
const types = [];
|
|
81
81
|
// Get all contexts for this package
|
|
82
|
-
const packageContexts = builder.contexts.filter(ctx => ctx.ref.proto.package === packageName);
|
|
83
|
-
packageContexts.forEach(context => {
|
|
82
|
+
const packageContexts = builder.contexts.filter((ctx) => ctx.ref.proto.package === packageName);
|
|
83
|
+
packageContexts.forEach((context) => {
|
|
84
84
|
// Get types from this context
|
|
85
|
-
const contextTypes = context.types.filter(type => !type.isNested);
|
|
86
|
-
contextTypes.forEach(typeInfo => {
|
|
85
|
+
const contextTypes = context.types.filter((type) => !type.isNested);
|
|
86
|
+
contextTypes.forEach((typeInfo) => {
|
|
87
87
|
const typeName = typeInfo.name;
|
|
88
88
|
// Filter out extended forms (these are created during code generation but not in the types array)
|
|
89
|
-
if (!typeName.endsWith(
|
|
90
|
-
!typeName.endsWith(
|
|
91
|
-
!typeName.endsWith(
|
|
92
|
-
!typeName.endsWith(
|
|
93
|
-
!typeName.endsWith(
|
|
89
|
+
if (!typeName.endsWith("ProtoMsg") &&
|
|
90
|
+
!typeName.endsWith("Amino") &&
|
|
91
|
+
!typeName.endsWith("AminoMsg") &&
|
|
92
|
+
!typeName.endsWith("Encoded") &&
|
|
93
|
+
!typeName.endsWith("SDKType")) {
|
|
94
94
|
// Get the actual source file from the store mapping
|
|
95
95
|
const typeFiles = builder.store.getTypeFilesMapping(typeName);
|
|
96
96
|
let sourceFile;
|
|
@@ -100,21 +100,22 @@ function getTypesForPackage(builder, packageName) {
|
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
102
|
// Fallback to context ref filename if not in mapping
|
|
103
|
-
sourceFile = context.ref.filename.replace(/\.proto$/,
|
|
103
|
+
sourceFile = context.ref.filename.replace(/\.proto$/, ".ts");
|
|
104
104
|
}
|
|
105
105
|
types.push({
|
|
106
106
|
name: typeName,
|
|
107
|
-
sourceFile
|
|
107
|
+
sourceFile,
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
// Remove duplicates and sort
|
|
113
|
-
const uniqueTypes = types.filter((type, index, self) => index === self.findIndex(t => t.name === type.name));
|
|
113
|
+
const uniqueTypes = types.filter((type, index, self) => index === self.findIndex((t) => t.name === type.name));
|
|
114
114
|
return uniqueTypes.sort((a, b) => a.name.localeCompare(b.name));
|
|
115
115
|
}
|
|
116
116
|
const plugin = (builder) => {
|
|
117
|
-
if (!builder.options?.readme?.enabled &&
|
|
117
|
+
if (!builder.options?.readme?.enabled &&
|
|
118
|
+
!builder.options?.mcpServer?.enabled) {
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
121
|
const readmePath = (0, path_1.join)(builder.outPath, "README.md");
|
|
@@ -123,7 +124,9 @@ const plugin = (builder) => {
|
|
|
123
124
|
const functionMappings = builder.getFunctionMappings();
|
|
124
125
|
// Generate package documentation
|
|
125
126
|
let packageDocs = "";
|
|
126
|
-
Object.keys(functionMappings)
|
|
127
|
+
Object.keys(functionMappings)
|
|
128
|
+
.sort()
|
|
129
|
+
.forEach((packageName) => {
|
|
127
130
|
const packageServices = functionMappings[packageName];
|
|
128
131
|
// Check if package has any methods before adding it
|
|
129
132
|
const hasQueryMethods = packageServices.Query && Object.keys(packageServices.Query).length > 0;
|
|
@@ -138,10 +141,10 @@ const plugin = (builder) => {
|
|
|
138
141
|
packageDocs += `### Types\n\n`;
|
|
139
142
|
packageDocs += `| Type | Name | Source |\n`;
|
|
140
143
|
packageDocs += `| --- | --- | --- |\n`;
|
|
141
|
-
types.forEach(type => {
|
|
144
|
+
types.forEach((type) => {
|
|
142
145
|
packageDocs += `| Type | \`${type.name}\` | [View source ↗](${type.sourceFile}) |\n`;
|
|
143
146
|
});
|
|
144
|
-
packageDocs +=
|
|
147
|
+
packageDocs += "\n";
|
|
145
148
|
}
|
|
146
149
|
// Query section
|
|
147
150
|
if (packageServices.Query) {
|
|
@@ -159,7 +162,9 @@ const plugin = (builder) => {
|
|
|
159
162
|
}
|
|
160
163
|
// Add import code block
|
|
161
164
|
const functionImportPath = getImportPath(builder, method.functionName, packageName, projectName, method.sourceFilename);
|
|
162
|
-
const hookImportPath = method.hookName
|
|
165
|
+
const hookImportPath = method.hookName
|
|
166
|
+
? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename)
|
|
167
|
+
: functionImportPath;
|
|
163
168
|
packageDocs += `\`\`\`ts\n`;
|
|
164
169
|
packageDocs += `import { ${aliasedFunctionName} } from '${functionImportPath}'\n`;
|
|
165
170
|
if (method.hookName && aliasedHookName !== aliasedFunctionName) {
|
|
@@ -170,29 +175,33 @@ const plugin = (builder) => {
|
|
|
170
175
|
packageDocs += `| Field | Value | Source |\n`;
|
|
171
176
|
packageDocs += `| --- | --- | --- |\n`;
|
|
172
177
|
// Function source
|
|
173
|
-
const functionSourcePath = method.sourceFilename ||
|
|
178
|
+
const functionSourcePath = method.sourceFilename ||
|
|
179
|
+
`${packageName.replace(/\./g, "/")}/query.rpc.func.ts`;
|
|
174
180
|
packageDocs += `| Function | \`${aliasedFunctionName}\` | [View source ↗](${functionSourcePath}) |\n`;
|
|
175
181
|
// Hook source (React)
|
|
176
182
|
if (method.hookName && aliasedHookName !== aliasedFunctionName) {
|
|
177
|
-
const hookSourcePath = method.hookSourceFilename ||
|
|
183
|
+
const hookSourcePath = method.hookSourceFilename ||
|
|
184
|
+
`${packageName.replace(/\./g, "/")}/query.rpc.react.ts`;
|
|
178
185
|
packageDocs += `| Hook | \`${aliasedHookName}\` | [View source ↗](${hookSourcePath}) |\n`;
|
|
179
186
|
}
|
|
180
187
|
// Request type source
|
|
181
188
|
if (method.requestType) {
|
|
182
|
-
const requestSourcePath = method.typeSourceFilename ||
|
|
189
|
+
const requestSourcePath = method.typeSourceFilename ||
|
|
190
|
+
`${packageName.replace(/\./g, "/")}/query.ts`;
|
|
183
191
|
packageDocs += `| Request | \`${method.requestType}\` | [View source ↗](${requestSourcePath}) |\n`;
|
|
184
192
|
}
|
|
185
193
|
// Response type source
|
|
186
194
|
if (method.responseType) {
|
|
187
|
-
const responseSourcePath = method.typeSourceFilename ||
|
|
195
|
+
const responseSourcePath = method.typeSourceFilename ||
|
|
196
|
+
`${packageName.replace(/\./g, "/")}/query.ts`;
|
|
188
197
|
packageDocs += `| Response | \`${method.responseType}\` | [View source ↗](${responseSourcePath}) |\n`;
|
|
189
198
|
}
|
|
190
199
|
// Add spacing between methods (but not after the last one)
|
|
191
200
|
if (index < queryMethods.length - 1) {
|
|
192
|
-
packageDocs +=
|
|
201
|
+
packageDocs += "\n---\n\n";
|
|
193
202
|
}
|
|
194
203
|
else {
|
|
195
|
-
packageDocs +=
|
|
204
|
+
packageDocs += "\n";
|
|
196
205
|
}
|
|
197
206
|
});
|
|
198
207
|
}
|
|
@@ -212,7 +221,9 @@ const plugin = (builder) => {
|
|
|
212
221
|
}
|
|
213
222
|
// Add import code block
|
|
214
223
|
const functionImportPath = getImportPath(builder, method.functionName, packageName, projectName, method.sourceFilename);
|
|
215
|
-
const hookImportPath = method.hookName
|
|
224
|
+
const hookImportPath = method.hookName
|
|
225
|
+
? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename)
|
|
226
|
+
: functionImportPath;
|
|
216
227
|
packageDocs += `\`\`\`ts\n`;
|
|
217
228
|
packageDocs += `import { ${aliasedFunctionName} } from '${functionImportPath}'\n`;
|
|
218
229
|
if (method.hookName && aliasedHookName !== aliasedFunctionName) {
|
|
@@ -223,34 +234,38 @@ const plugin = (builder) => {
|
|
|
223
234
|
packageDocs += `| Field | Value | Source |\n`;
|
|
224
235
|
packageDocs += `| --- | --- | --- |\n`;
|
|
225
236
|
// Function source
|
|
226
|
-
const functionSourcePath = method.sourceFilename ||
|
|
237
|
+
const functionSourcePath = method.sourceFilename ||
|
|
238
|
+
`${packageName.replace(/\./g, "/")}/tx.rpc.func.ts`;
|
|
227
239
|
packageDocs += `| Function | \`${aliasedFunctionName}\` | [View source ↗](${functionSourcePath}) |\n`;
|
|
228
240
|
// Hook source (React)
|
|
229
241
|
if (method.hookName && aliasedHookName !== aliasedFunctionName) {
|
|
230
|
-
const hookSourcePath = method.hookSourceFilename ||
|
|
242
|
+
const hookSourcePath = method.hookSourceFilename ||
|
|
243
|
+
`${packageName.replace(/\./g, "/")}/tx.rpc.react.ts`;
|
|
231
244
|
packageDocs += `| Hook | \`${aliasedHookName}\` | [View source ↗](${hookSourcePath}) |\n`;
|
|
232
245
|
}
|
|
233
246
|
// Request type source
|
|
234
247
|
if (method.requestType) {
|
|
235
|
-
const requestSourcePath = method.typeSourceFilename ||
|
|
248
|
+
const requestSourcePath = method.typeSourceFilename ||
|
|
249
|
+
`${packageName.replace(/\./g, "/")}/tx.ts`;
|
|
236
250
|
packageDocs += `| Request | \`${method.requestType}\` | [View source ↗](${requestSourcePath}) |\n`;
|
|
237
251
|
}
|
|
238
252
|
// Response type source
|
|
239
253
|
if (method.responseType) {
|
|
240
|
-
const responseSourcePath = method.typeSourceFilename ||
|
|
254
|
+
const responseSourcePath = method.typeSourceFilename ||
|
|
255
|
+
`${packageName.replace(/\./g, "/")}/tx.ts`;
|
|
241
256
|
packageDocs += `| Response | \`${method.responseType}\` | [View source ↗](${responseSourcePath}) |\n`;
|
|
242
257
|
}
|
|
243
258
|
// Add spacing between methods (but not after the last one)
|
|
244
259
|
if (index < msgMethods.length - 1) {
|
|
245
|
-
packageDocs +=
|
|
260
|
+
packageDocs += "\n---\n\n";
|
|
246
261
|
}
|
|
247
262
|
else {
|
|
248
|
-
packageDocs +=
|
|
263
|
+
packageDocs += "\n";
|
|
249
264
|
}
|
|
250
265
|
});
|
|
251
266
|
}
|
|
252
267
|
// Add spacing between packages
|
|
253
|
-
packageDocs +=
|
|
268
|
+
packageDocs += "\n";
|
|
254
269
|
});
|
|
255
270
|
const readmeContent = `# Package Documentation
|
|
256
271
|
${packageDocs}`;
|
|
@@ -8,8 +8,8 @@ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExten
|
|
|
8
8
|
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
|
|
9
9
|
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
10
10
|
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
|
|
11
|
-
import { toConverters, toEncoders } from "@interchainjs/cosmos
|
|
12
|
-
import { ISigningClient } from "@interchainjs/cosmos
|
|
11
|
+
import { toConverters, toEncoders } from "@interchainjs/cosmos";
|
|
12
|
+
import { ISigningClient } from "@interchainjs/cosmos";` : ''}
|
|
13
13
|
|
|
14
14
|
export interface QueryBuilderOptions<TReq, TRes> {
|
|
15
15
|
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
|
|
@@ -8,8 +8,8 @@ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExten
|
|
|
8
8
|
import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
|
|
9
9
|
import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
|
|
10
10
|
import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
|
|
11
|
-
import { toConverters, toEncoders } from "@interchainjs/cosmos
|
|
12
|
-
import { ISigningClient } from "@interchainjs/cosmos
|
|
11
|
+
import { toConverters, toEncoders } from "@interchainjs/cosmos";
|
|
12
|
+
import { ISigningClient } from "@interchainjs/cosmos";` : ''}
|
|
13
13
|
|
|
14
14
|
export interface QueryBuilderOptions<TReq, TRes> {
|
|
15
15
|
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getHelperForBigint = void 0;
|
|
4
4
|
const getHelperForBigint = (options) => {
|
|
5
5
|
return `${options.useInterchainJs ?
|
|
6
|
-
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding
|
|
6
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding\';' :
|
|
7
7
|
`declare var self: any | undefined;
|
|
8
8
|
declare var window: any | undefined;
|
|
9
9
|
declare var global: any | undefined;
|
package/main/helpers/internal.js
CHANGED
|
@@ -15,7 +15,7 @@ if (_m0.util.Long !== Long) {
|
|
|
15
15
|
export { Long };
|
|
16
16
|
|
|
17
17
|
${options.useInterchainJs ?
|
|
18
|
-
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding
|
|
18
|
+
'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding\';' :
|
|
19
19
|
`declare var self: any | undefined;
|
|
20
20
|
declare var window: any | undefined;
|
|
21
21
|
declare var global: any | undefined;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ITxArgs,
|
|
13
13
|
EndpointOrRpc,
|
|
14
14
|
} from './helper-func-types${options.restoreImportExtension ?? ""}'
|
|
15
|
-
import { ISigningClient, isISigningClient } from "@interchainjs/cosmos
|
|
15
|
+
import { ISigningClient, isISigningClient } from "@interchainjs/cosmos";
|
|
16
16
|
import {
|
|
17
17
|
StdFee,
|
|
18
18
|
DeliverTxResponse,
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import { exportAllFromRelPath, exportTypesWithAlias, recursiveModuleBundle, } from "@cosmology/ast";
|
|
2
|
-
import { duplicateImportPathsWithExt, makeAliasName, makeAliasNameWithPackageAtEnd } from "@cosmology/utils";
|
|
2
|
+
import { duplicateImportPathsWithExt, makeAliasName, makeAliasNameWithPackageAtEnd, } from "@cosmology/utils";
|
|
3
|
+
/**
|
|
4
|
+
* Process noAlias configuration to create a map of names to their first package
|
|
5
|
+
* This ensures that only the first occurrence of a name skips aliasing
|
|
6
|
+
*/
|
|
7
|
+
const processNoAliasConfig = (noAlias) => {
|
|
8
|
+
if (!noAlias || noAlias.length === 0) {
|
|
9
|
+
return new Map();
|
|
10
|
+
}
|
|
11
|
+
const nameToFirstPackage = new Map();
|
|
12
|
+
for (const entry of noAlias) {
|
|
13
|
+
if (!nameToFirstPackage.has(entry.name)) {
|
|
14
|
+
nameToFirstPackage.set(entry.name, entry.package);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return nameToFirstPackage;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Check if a package/name combination should skip aliasing
|
|
21
|
+
*/
|
|
22
|
+
const shouldSkipAlias = (pkg, name, nameToFirstPackage) => {
|
|
23
|
+
const firstPackage = nameToFirstPackage.get(name);
|
|
24
|
+
return firstPackage === pkg;
|
|
25
|
+
};
|
|
3
26
|
export const plugin = (builder, bundler) => {
|
|
4
27
|
if (!builder.options.bundle.enabled) {
|
|
5
28
|
return;
|
|
6
29
|
}
|
|
7
30
|
let prog = [];
|
|
31
|
+
// Process noAlias configuration once at the beginning
|
|
32
|
+
const nameToFirstPackage = processNoAliasConfig(builder.options.bundle.noAlias);
|
|
8
33
|
if (builder.options.bundle.type === "namespace") {
|
|
9
34
|
const importPaths = duplicateImportPathsWithExt(bundler.bundle.importPaths, builder.options.restoreImportExtension);
|
|
10
35
|
// [x] bundle
|
|
@@ -41,22 +66,23 @@ export const plugin = (builder, bundler) => {
|
|
|
41
66
|
const duplicatedType = duplicatedTypeNames.find((type) => type === identifier);
|
|
42
67
|
if (duplicatedType) {
|
|
43
68
|
let alias;
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
alias = makeAliasNameWithPackageAtEnd({ package: exportObj.pkg, name: identifier });
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
alias = identifier;
|
|
51
|
-
}
|
|
69
|
+
// Check if this package/name combination should skip aliasing
|
|
70
|
+
if (shouldSkipAlias(exportObj.pkg, identifier, nameToFirstPackage)) {
|
|
71
|
+
alias = identifier; // Use original name, no alias
|
|
52
72
|
}
|
|
53
73
|
else {
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
alias =
|
|
74
|
+
// Generate alias as usual
|
|
75
|
+
if (exportObj.isHelperFunc) {
|
|
76
|
+
alias = makeAliasNameWithPackageAtEnd({
|
|
77
|
+
package: exportObj.pkg,
|
|
78
|
+
name: identifier,
|
|
79
|
+
});
|
|
57
80
|
}
|
|
58
81
|
else {
|
|
59
|
-
alias =
|
|
82
|
+
alias = makeAliasName({
|
|
83
|
+
package: exportObj.pkg,
|
|
84
|
+
name: identifier,
|
|
85
|
+
});
|
|
60
86
|
}
|
|
61
87
|
}
|
|
62
88
|
return { name: identifier, alias: alias };
|