@hyperweb/telescope 1.15.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.
- package/README.md +1529 -0
- package/main/build.js +183 -0
- package/main/builder.js +229 -0
- package/main/bundle.js +162 -0
- package/main/bundler.js +100 -0
- package/main/cli.js +71 -0
- package/main/cmds.js +28 -0
- package/main/commands/download.js +122 -0
- package/main/commands/generate.js +151 -0
- package/main/commands/install.js +143 -0
- package/main/commands/transpile.js +197 -0
- package/main/contracts/generate.js +31 -0
- package/main/contracts/install.js +107 -0
- package/main/contracts/message-composer.js +31 -0
- package/main/contracts/react-query.js +31 -0
- package/main/contracts/recoil.js +31 -0
- package/main/file.js +20 -0
- package/main/generators/create-aggregated-lcd-client.js +87 -0
- package/main/generators/create-all-stargate-clients.js +96 -0
- package/main/generators/create-amino-converters.js +43 -0
- package/main/generators/create-bundle.js +83 -0
- package/main/generators/create-cosmwasm-bundle.js +15 -0
- package/main/generators/create-custom-stargate-clients.js +100 -0
- package/main/generators/create-helpers.js +119 -0
- package/main/generators/create-index.js +75 -0
- package/main/generators/create-lcd-client-all.js +116 -0
- package/main/generators/create-lcd-client-scoped.js +89 -0
- package/main/generators/create-lcd-clients.js +78 -0
- package/main/generators/create-mcp-server.js +1853 -0
- package/main/generators/create-mobx-bundle.js +52 -0
- package/main/generators/create-msg-funcs.js +132 -0
- package/main/generators/create-pinia-store-bundle.js +50 -0
- package/main/generators/create-pinia-store.js +90 -0
- package/main/generators/create-query-funcs.js +133 -0
- package/main/generators/create-react-query-bundle.js +103 -0
- package/main/generators/create-registries.js +49 -0
- package/main/generators/create-root-readme.js +259 -0
- package/main/generators/create-rpc-msg-client-all.js +135 -0
- package/main/generators/create-rpc-msg-client-scoped.js +114 -0
- package/main/generators/create-rpc-msg-clients.js +116 -0
- package/main/generators/create-rpc-ops-bundle.js +119 -0
- package/main/generators/create-rpc-query-client-all.js +137 -0
- package/main/generators/create-rpc-query-client-scoped.js +110 -0
- package/main/generators/create-rpc-query-clients.js +198 -0
- package/main/generators/create-sdk-module-stargate-clients.js +95 -0
- package/main/generators/create-stargate-clients.js +96 -0
- package/main/generators/create-types.js +164 -0
- package/main/generators/customize-utils.js +50 -0
- package/main/helpers/__test__/internalTimestamp.js +49 -0
- package/main/helpers/__test__/internalTimestampBigint.js +45 -0
- package/main/helpers/binary-coder.js +535 -0
- package/main/helpers/decimals.js +111 -0
- package/main/helpers/external-comet.js +52 -0
- package/main/helpers/external-icjs.js +36 -0
- package/main/helpers/external.js +31 -0
- package/main/helpers/grpc-gateway.js +348 -0
- package/main/helpers/grpc-web.js +14 -0
- package/main/helpers/helper-func-types-interface.js +106 -0
- package/main/helpers/helper-func-types.js +93 -0
- package/main/helpers/index.js +38 -0
- package/main/helpers/internal-for-bigint.js +259 -0
- package/main/helpers/internal.js +240 -0
- package/main/helpers/json-safe.js +12 -0
- package/main/helpers/mobx.js +80 -0
- package/main/helpers/pinia-endpoint.js +20 -0
- package/main/helpers/react-query-hooks-icjs.js +223 -0
- package/main/helpers/react-query-hooks.js +258 -0
- package/main/helpers/react-query.js +93 -0
- package/main/helpers/registry-helper.js +229 -0
- package/main/helpers/types-helper.js +165 -0
- package/main/helpers/utf8-helper.js +146 -0
- package/main/helpers/varint.js +486 -0
- package/main/helpers/vue-query-hooks.js +226 -0
- package/main/imports.js +416 -0
- package/main/index.js +24 -0
- package/main/parse.js +194 -0
- package/main/prompt.js +64 -0
- package/main/protod/bufbuild.js +87 -0
- package/main/protod/config.js +30 -0
- package/main/protod/git-repo.js +58 -0
- package/main/protod/index.js +17 -0
- package/main/protod/recursive.js +134 -0
- package/main/protod/types.js +2 -0
- package/main/protod/utils.js +91 -0
- package/main/telescope.js +10 -0
- package/main/types.js +2 -0
- package/main/utils/common-create-bundle.js +29 -0
- package/main/utils/contracts.js +39 -0
- package/main/utils/files.js +138 -0
- package/main/utils/index.js +163 -0
- package/main/utils/unused.js +73 -0
- package/module/build.js +176 -0
- package/module/builder.js +222 -0
- package/module/bundle.js +128 -0
- package/module/bundler.js +96 -0
- package/module/cli.js +44 -0
- package/module/cmds.js +22 -0
- package/module/commands/download.js +94 -0
- package/module/commands/generate.js +123 -0
- package/module/commands/install.js +141 -0
- package/module/commands/transpile.js +169 -0
- package/module/contracts/generate.js +29 -0
- package/module/contracts/install.js +105 -0
- package/module/contracts/message-composer.js +29 -0
- package/module/contracts/react-query.js +29 -0
- package/module/contracts/recoil.js +29 -0
- package/module/file.js +18 -0
- package/module/generators/create-aggregated-lcd-client.js +83 -0
- package/module/generators/create-all-stargate-clients.js +92 -0
- package/module/generators/create-amino-converters.js +39 -0
- package/module/generators/create-bundle.js +79 -0
- package/module/generators/create-cosmwasm-bundle.js +11 -0
- package/module/generators/create-custom-stargate-clients.js +96 -0
- package/module/generators/create-helpers.js +112 -0
- package/module/generators/create-index.js +45 -0
- package/module/generators/create-lcd-client-all.js +89 -0
- package/module/generators/create-lcd-client-scoped.js +62 -0
- package/module/generators/create-lcd-clients.js +74 -0
- package/module/generators/create-mcp-server.js +1849 -0
- package/module/generators/create-mobx-bundle.js +25 -0
- package/module/generators/create-msg-funcs.js +128 -0
- package/module/generators/create-pinia-store-bundle.js +23 -0
- package/module/generators/create-pinia-store.js +86 -0
- package/module/generators/create-query-funcs.js +129 -0
- package/module/generators/create-react-query-bundle.js +76 -0
- package/module/generators/create-registries.js +45 -0
- package/module/generators/create-root-readme.js +255 -0
- package/module/generators/create-rpc-msg-client-all.js +108 -0
- package/module/generators/create-rpc-msg-client-scoped.js +87 -0
- package/module/generators/create-rpc-msg-clients.js +112 -0
- package/module/generators/create-rpc-ops-bundle.js +92 -0
- package/module/generators/create-rpc-query-client-all.js +110 -0
- package/module/generators/create-rpc-query-client-scoped.js +83 -0
- package/module/generators/create-rpc-query-clients.js +198 -0
- package/module/generators/create-sdk-module-stargate-clients.js +91 -0
- package/module/generators/create-stargate-clients.js +92 -0
- package/module/generators/create-types.js +137 -0
- package/module/generators/customize-utils.js +46 -0
- package/module/helpers/__test__/internalTimestamp.js +39 -0
- package/module/helpers/__test__/internalTimestampBigint.js +38 -0
- package/module/helpers/binary-coder.js +531 -0
- package/module/helpers/decimals.js +108 -0
- package/module/helpers/external-comet.js +49 -0
- package/module/helpers/external-icjs.js +33 -0
- package/module/helpers/external.js +28 -0
- package/module/helpers/grpc-gateway.js +345 -0
- package/module/helpers/grpc-web.js +11 -0
- package/module/helpers/helper-func-types-interface.js +102 -0
- package/module/helpers/helper-func-types.js +89 -0
- package/module/helpers/index.js +22 -0
- package/module/helpers/internal-for-bigint.js +255 -0
- package/module/helpers/internal.js +236 -0
- package/module/helpers/json-safe.js +9 -0
- package/module/helpers/mobx.js +77 -0
- package/module/helpers/pinia-endpoint.js +17 -0
- package/module/helpers/react-query-hooks-icjs.js +219 -0
- package/module/helpers/react-query-hooks.js +254 -0
- package/module/helpers/react-query.js +89 -0
- package/module/helpers/registry-helper.js +225 -0
- package/module/helpers/types-helper.js +161 -0
- package/module/helpers/utf8-helper.js +143 -0
- package/module/helpers/varint.js +483 -0
- package/module/helpers/vue-query-hooks.js +222 -0
- package/module/imports.js +382 -0
- package/module/index.js +8 -0
- package/module/parse.js +185 -0
- package/module/prompt.js +58 -0
- package/module/protod/bufbuild.js +76 -0
- package/module/protod/config.js +27 -0
- package/module/protod/git-repo.js +54 -0
- package/module/protod/index.js +1 -0
- package/module/protod/recursive.js +125 -0
- package/module/protod/types.js +1 -0
- package/module/protod/utils.js +77 -0
- package/module/telescope.js +8 -0
- package/module/types.js +1 -0
- package/module/utils/common-create-bundle.js +25 -0
- package/module/utils/contracts.js +33 -0
- package/module/utils/files.js +106 -0
- package/module/utils/index.js +143 -0
- package/module/utils/unused.js +47 -0
- package/package.json +115 -0
- package/src/build.ts +255 -0
- package/src/builder.ts +302 -0
- package/src/bundle.ts +160 -0
- package/src/bundler.ts +153 -0
- package/src/cli.js +51 -0
- package/src/cmds.js +25 -0
- package/src/commands/download.ts +120 -0
- package/src/commands/generate.ts +156 -0
- package/src/commands/install.ts +154 -0
- package/src/commands/transpile.ts +198 -0
- package/src/contracts/generate.ts +33 -0
- package/src/contracts/install.ts +118 -0
- package/src/contracts/message-composer.ts +34 -0
- package/src/contracts/react-query.ts +33 -0
- package/src/contracts/recoil.ts +32 -0
- package/src/file.js +20 -0
- package/src/generators/create-aggregated-lcd-client.ts +133 -0
- package/src/generators/create-all-stargate-clients.ts +121 -0
- package/src/generators/create-amino-converters.ts +62 -0
- package/src/generators/create-bundle.ts +97 -0
- package/src/generators/create-cosmwasm-bundle.ts +17 -0
- package/src/generators/create-custom-stargate-clients.ts +128 -0
- package/src/generators/create-helpers.ts +196 -0
- package/src/generators/create-index.ts +72 -0
- package/src/generators/create-lcd-client-all.ts +139 -0
- package/src/generators/create-lcd-client-scoped.ts +109 -0
- package/src/generators/create-lcd-clients.ts +108 -0
- package/src/generators/create-mcp-server.ts +1902 -0
- package/src/generators/create-mobx-bundle.ts +31 -0
- package/src/generators/create-msg-funcs.ts +219 -0
- package/src/generators/create-pinia-store-bundle.ts +35 -0
- package/src/generators/create-pinia-store.ts +121 -0
- package/src/generators/create-query-funcs.ts +224 -0
- package/src/generators/create-react-query-bundle.ts +111 -0
- package/src/generators/create-registries.ts +70 -0
- package/src/generators/create-root-readme.ts +316 -0
- package/src/generators/create-rpc-msg-client-all.ts +167 -0
- package/src/generators/create-rpc-msg-client-scoped.ts +147 -0
- package/src/generators/create-rpc-msg-clients.ts +165 -0
- package/src/generators/create-rpc-ops-bundle.ts +155 -0
- package/src/generators/create-rpc-query-client-all.ts +173 -0
- package/src/generators/create-rpc-query-client-scoped.ts +142 -0
- package/src/generators/create-rpc-query-clients.ts +304 -0
- package/src/generators/create-sdk-module-stargate-clients.ts +120 -0
- package/src/generators/create-stargate-clients.ts +123 -0
- package/src/generators/create-types.ts +236 -0
- package/src/generators/customize-utils.ts +54 -0
- package/src/helpers/__test__/internalTimestamp.test.ts +79 -0
- package/src/helpers/__test__/internalTimestamp.ts +58 -0
- package/src/helpers/__test__/internalTimestampBigint.test.ts +78 -0
- package/src/helpers/__test__/internalTimestampBigint.ts +58 -0
- package/src/helpers/binary-coder.ts +533 -0
- package/src/helpers/decimals.ts +108 -0
- package/src/helpers/external-comet.ts +49 -0
- package/src/helpers/external-icjs.ts +33 -0
- package/src/helpers/external.ts +28 -0
- package/src/helpers/grpc-gateway.ts +345 -0
- package/src/helpers/grpc-web.ts +11 -0
- package/src/helpers/helper-func-types-interface.ts +104 -0
- package/src/helpers/helper-func-types.ts +91 -0
- package/src/helpers/index.ts +22 -0
- package/src/helpers/internal-for-bigint.ts +257 -0
- package/src/helpers/internal.ts +238 -0
- package/src/helpers/json-safe.ts +11 -0
- package/src/helpers/mobx.ts +77 -0
- package/src/helpers/pinia-endpoint.ts +17 -0
- package/src/helpers/react-query-hooks-icjs.ts +223 -0
- package/src/helpers/react-query-hooks.ts +266 -0
- package/src/helpers/react-query.ts +101 -0
- package/src/helpers/registry-helper.ts +227 -0
- package/src/helpers/types-helper.ts +169 -0
- package/src/helpers/utf8-helper.ts +143 -0
- package/src/helpers/varint.ts +483 -0
- package/src/helpers/vue-query-hooks.ts +224 -0
- package/src/imports.ts +499 -0
- package/src/index.ts +12 -0
- package/src/parse.ts +243 -0
- package/src/prompt.js +65 -0
- package/src/protod/bufbuild.spec.ts +80 -0
- package/src/protod/bufbuild.ts +95 -0
- package/src/protod/config.ts +30 -0
- package/src/protod/git-repo.ts +74 -0
- package/src/protod/index.ts +1 -0
- package/src/protod/recursive.spec.ts +164 -0
- package/src/protod/recursive.ts +180 -0
- package/src/protod/test-data/.protod.config.json +42 -0
- package/src/protod/test-data/buf.lock +23 -0
- package/src/protod/test-data/buf.yaml +25 -0
- package/src/protod/test-data/buf2.yaml +20 -0
- package/src/protod/test-data/cosmos/buf.lock +23 -0
- package/src/protod/test-data/cosmos/crypto/secp256k1/keys.proto +38 -0
- package/src/protod/test-data/model.proto +101 -0
- package/src/protod/types.ts +55 -0
- package/src/protod/utils.spec.ts +68 -0
- package/src/protod/utils.ts +90 -0
- package/src/telescope.js +9 -0
- package/src/types.ts +46 -0
- package/src/utils/common-create-bundle.ts +62 -0
- package/src/utils/contracts.ts +37 -0
- package/src/utils/files.ts +145 -0
- package/src/utils/index.ts +150 -0
- package/src/utils/unused.ts +52 -0
- package/types/build.d.ts +41 -0
- package/types/builder.d.ts +50 -0
- package/types/bundle.d.ts +30 -0
- package/types/bundler.d.ts +31 -0
- package/types/cli.d.ts +1 -0
- package/types/cmds.d.ts +11 -0
- package/types/commands/download.d.ts +5 -0
- package/types/commands/generate.d.ts +2 -0
- package/types/commands/install.d.ts +2 -0
- package/types/commands/transpile.d.ts +4 -0
- package/types/contracts/generate.d.ts +2 -0
- package/types/contracts/install.d.ts +2 -0
- package/types/contracts/message-composer.d.ts +2 -0
- package/types/contracts/react-query.d.ts +2 -0
- package/types/contracts/recoil.d.ts +2 -0
- package/types/file.d.ts +2 -0
- package/types/generators/create-aggregated-lcd-client.d.ts +2 -0
- package/types/generators/create-all-stargate-clients.d.ts +3 -0
- package/types/generators/create-amino-converters.d.ts +3 -0
- package/types/generators/create-bundle.d.ts +3 -0
- package/types/generators/create-combined-stargate-clients.d.ts +3 -0
- package/types/generators/create-cosmwasm-bundle.d.ts +2 -0
- package/types/generators/create-custom-stargate-clients.d.ts +3 -0
- package/types/generators/create-helpers.d.ts +2 -0
- package/types/generators/create-index.d.ts +2 -0
- package/types/generators/create-lcd-client-all.d.ts +3 -0
- package/types/generators/create-lcd-client-scoped.d.ts +3 -0
- package/types/generators/create-lcd-clients.d.ts +3 -0
- package/types/generators/create-mcp-server.d.ts +3 -0
- package/types/generators/create-mobx-bundle.d.ts +2 -0
- package/types/generators/create-msg-funcs.d.ts +3 -0
- package/types/generators/create-pinia-store-bundle.d.ts +2 -0
- package/types/generators/create-pinia-store.d.ts +3 -0
- package/types/generators/create-query-funcs.d.ts +3 -0
- package/types/generators/create-react-query-bundle.d.ts +2 -0
- package/types/generators/create-registries.d.ts +3 -0
- package/types/generators/create-root-readme.d.ts +2 -0
- package/types/generators/create-rpc-msg-client-all.d.ts +3 -0
- package/types/generators/create-rpc-msg-client-scoped.d.ts +3 -0
- package/types/generators/create-rpc-msg-clients.d.ts +3 -0
- package/types/generators/create-rpc-ops-bundle.d.ts +2 -0
- package/types/generators/create-rpc-query-client-all.d.ts +3 -0
- package/types/generators/create-rpc-query-client-scoped.d.ts +3 -0
- package/types/generators/create-rpc-query-clients.d.ts +3 -0
- package/types/generators/create-scoped-stargate-clients.d.ts +3 -0
- package/types/generators/create-sdk-module-stargate-clients.d.ts +3 -0
- package/types/generators/create-stargate-clients.d.ts +3 -0
- package/types/generators/create-types.d.ts +3 -0
- package/types/generators/create-unified-stargate-clients.d.ts +3 -0
- package/types/generators/customize-utils.d.ts +2 -0
- package/types/helpers/__test__/internalTimestamp.d.ts +21 -0
- package/types/helpers/__test__/internalTimestampBigint.d.ts +20 -0
- package/types/helpers/binary-coder.d.ts +2 -0
- package/types/helpers/decimals.d.ts +1 -0
- package/types/helpers/external-comet.d.ts +1 -0
- package/types/helpers/external-icjs.d.ts +1 -0
- package/types/helpers/external.d.ts +1 -0
- package/types/helpers/generated-type.d.ts +1 -0
- package/types/helpers/grpc-gateway.d.ts +1 -0
- package/types/helpers/grpc-web.d.ts +1 -0
- package/types/helpers/helper-func-types-interface.d.ts +2 -0
- package/types/helpers/helper-func-types.d.ts +2 -0
- package/types/helpers/index.d.ts +22 -0
- package/types/helpers/internal-for-bigint.d.ts +2 -0
- package/types/helpers/internal.d.ts +2 -0
- package/types/helpers/internalForBigInt.d.ts +1 -0
- package/types/helpers/json-safe.d.ts +1 -0
- package/types/helpers/mobx.d.ts +1 -0
- package/types/helpers/pinia-endpoint.d.ts +1 -0
- package/types/helpers/react-query-hooks-icjs.d.ts +2 -0
- package/types/helpers/react-query-hooks.d.ts +2 -0
- package/types/helpers/react-query.d.ts +2 -0
- package/types/helpers/registry-helper.d.ts +2 -0
- package/types/helpers/types-helper.d.ts +2 -0
- package/types/helpers/types.d.ts +1 -0
- package/types/helpers/utf8-helper.d.ts +1 -0
- package/types/helpers/varint.d.ts +1 -0
- package/types/helpers/vue-query-hooks.d.ts +2 -0
- package/types/helpers/vue-query.d.ts +2 -0
- package/types/imports.d.ts +17 -0
- package/types/index.d.ts +6 -0
- package/types/parse.d.ts +15 -0
- package/types/prompt.d.ts +3 -0
- package/types/protod/bufbuild.d.ts +6 -0
- package/types/protod/config.d.ts +7 -0
- package/types/protod/git-repo.d.ts +11 -0
- package/types/protod/index.d.ts +1 -0
- package/types/protod/proto-download.d.ts +2 -0
- package/types/protod/recursive.d.ts +4 -0
- package/types/protod/types.d.ts +49 -0
- package/types/protod/utils.d.ts +11 -0
- package/types/telescope.d.ts +2 -0
- package/types/types.d.ts +43 -0
- package/types/utils/common-create-bundle.d.ts +18 -0
- package/types/utils/contracts.d.ts +6 -0
- package/types/utils/files.d.ts +5 -0
- package/types/utils/index.d.ts +16 -0
- package/types/utils/unused.d.ts +5 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findAllProtoFiles,
|
|
3
|
+
getMainBranchName,
|
|
4
|
+
isPathExist,
|
|
5
|
+
parseProtoFile,
|
|
6
|
+
} from "./utils";
|
|
7
|
+
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
|
|
10
|
+
const TEST_DATA_FOLDER = "test-data";
|
|
11
|
+
const TEST_DATA_NONE_FOLDER = "test-data-none";
|
|
12
|
+
let testData = join(__dirname, TEST_DATA_FOLDER);
|
|
13
|
+
let testDataNone = join(__dirname, TEST_DATA_NONE_FOLDER);
|
|
14
|
+
|
|
15
|
+
const testSwitch = false;
|
|
16
|
+
|
|
17
|
+
describe("Test `getMainBranchName`", () => {
|
|
18
|
+
(testSwitch ? it : it.skip)("`cosmos-proto` should return `main`", async () => {
|
|
19
|
+
const branch = await getMainBranchName(
|
|
20
|
+
"https://github.com/cosmos/cosmos-proto.git"
|
|
21
|
+
);
|
|
22
|
+
expect(branch).toBe("main");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
(testSwitch ? it : it.skip)("`ics23` should return `master`", async () => {
|
|
26
|
+
const branch = await getMainBranchName(
|
|
27
|
+
"https://github.com/cosmos/ics23.git"
|
|
28
|
+
);
|
|
29
|
+
expect(branch).toBe("master");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("Test `parseProtoFile`", () => {
|
|
34
|
+
it("should successfully parse `./test-data/model.proto`", () => {
|
|
35
|
+
const [dep1, dep2] = parseProtoFile(join(testData, "/model.proto"));
|
|
36
|
+
expect(dep1).toBe("google/api/field_behavior.proto");
|
|
37
|
+
expect(dep2).toBe("google/api/resource.proto");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("Test `isPathExist`", () => {
|
|
42
|
+
it("`./test-data/buf.lock` should exist", () => {
|
|
43
|
+
const result = isPathExist(join(testData, "/buf.lock"));
|
|
44
|
+
expect(result).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("`./test-data/fake/buf.lock` should not exist", () => {
|
|
48
|
+
const result = isPathExist(join(testData, "/fake/buf.lock"));
|
|
49
|
+
expect(result).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("`./test-data` should exist", () => {
|
|
53
|
+
const result = isPathExist(testData);
|
|
54
|
+
expect(result).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("`./test-data-none` should not exist", () => {
|
|
58
|
+
const result = isPathExist(testDataNone);
|
|
59
|
+
expect(result).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("Test `findAllProtoFiles`", () => {
|
|
64
|
+
it("`./test-data` should contain 2 proto files", () => {
|
|
65
|
+
const files = findAllProtoFiles(testData);
|
|
66
|
+
expect(files.length).toBe(2);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { exec as _exec } from "shelljs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { bufInfo } from "./config";
|
|
4
|
+
import { Repo } from "./types";
|
|
5
|
+
import { crossGlob as glob } from '@cosmology/utils';
|
|
6
|
+
|
|
7
|
+
export function exec(command: string, verbose = false) {
|
|
8
|
+
const { code, stdout, stderr } = _exec(command);
|
|
9
|
+
if (code === 0) {
|
|
10
|
+
if (verbose) {
|
|
11
|
+
console.log(stdout);
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
console.error(`Failed: ${command}`);
|
|
15
|
+
throw new Error(stderr);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return { stdout };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function getMainBranchName(url: string) {
|
|
22
|
+
console.log(`Checking main branch for ${url}`)
|
|
23
|
+
|
|
24
|
+
const { stdout } = exec(`git ls-remote -h ${url} main`);
|
|
25
|
+
if (stdout) {
|
|
26
|
+
return "main";
|
|
27
|
+
}
|
|
28
|
+
const { stdout: stdout2 } = exec(`git ls-remote -h ${url} master`);
|
|
29
|
+
if (stdout2) {
|
|
30
|
+
return "master";
|
|
31
|
+
}
|
|
32
|
+
throw new Error("Can't find `main` or `master` branch");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getCorrespondingGit(bufRepo: Repo): Repo[] {
|
|
36
|
+
const bufItem = bufInfo.find(
|
|
37
|
+
(repo) => repo.owner === bufRepo.owner && repo.repo === bufRepo.repo
|
|
38
|
+
);
|
|
39
|
+
if (bufItem) {
|
|
40
|
+
return bufItem.git;
|
|
41
|
+
} else {
|
|
42
|
+
return [bufRepo];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function parseProtoFile(filePath: string): string[] {
|
|
47
|
+
if (!isPathExist(filePath)) {
|
|
48
|
+
console.warn(`No such file ${filePath}`);
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let proto;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
proto = fs.readFileSync(filePath, "utf8");
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.log(filePath);
|
|
58
|
+
throw new Error(error);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const deps: string[] = [];
|
|
62
|
+
proto?.split("\n").forEach((line) => {
|
|
63
|
+
if (line.trim().startsWith("import ")) {
|
|
64
|
+
const dep = /import\s"(.+)";?/.exec(line)?.[1];
|
|
65
|
+
if (!dep) {
|
|
66
|
+
throw Error(`Failed to parse line: ${line}`);
|
|
67
|
+
}
|
|
68
|
+
deps.push(dep);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return deps;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function isPathExist(path: string): boolean {
|
|
75
|
+
return fs.existsSync(path);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function findAllProtoFiles(dir: string): string[] {
|
|
79
|
+
return glob(`${dir}/**/*.proto`, {
|
|
80
|
+
ignore: `${dir}/node_modules/**`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function removeFolder(dir: string) {
|
|
85
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function makeDir(dir: string) {
|
|
89
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
90
|
+
}
|
package/src/telescope.js
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ImportDeclaration } from '@babel/types';
|
|
2
|
+
import { ProtoServiceMethod, TelescopeOptions } from '@cosmology/types';
|
|
3
|
+
export interface ExportObj {
|
|
4
|
+
pkg: string;
|
|
5
|
+
localname: string;
|
|
6
|
+
relativePath: string;
|
|
7
|
+
exportedIdentifiers: string[];
|
|
8
|
+
isHelperFunc?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface Bundle {
|
|
11
|
+
bundleVariables: {};
|
|
12
|
+
bundleFile: string;
|
|
13
|
+
importPaths: ImportDeclaration[];
|
|
14
|
+
exportObjs?: ExportObj[];
|
|
15
|
+
base: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BundlerFile {
|
|
18
|
+
proto?: string;
|
|
19
|
+
package?: string;
|
|
20
|
+
localname: string;
|
|
21
|
+
filename: string;
|
|
22
|
+
isMsg?: boolean;
|
|
23
|
+
instantExportedMethods?: ProtoServiceMethod[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ImportObj {
|
|
27
|
+
type: 'import' | 'default' | 'namespace' | string;
|
|
28
|
+
name: string;
|
|
29
|
+
path: string;
|
|
30
|
+
importAs?: string;
|
|
31
|
+
protoPath?: string;
|
|
32
|
+
}
|
|
33
|
+
export type UtilValue = ImportObj | string;
|
|
34
|
+
|
|
35
|
+
export interface DerivedImportObj extends ImportObj {
|
|
36
|
+
orig: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ImportHash {
|
|
39
|
+
[key: string]: string[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface TelescopeInput {
|
|
43
|
+
protoDirs: string[];
|
|
44
|
+
outPath: string;
|
|
45
|
+
options: TelescopeOptions;
|
|
46
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { aggregateImports, getImportStatements } from '../imports';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { TelescopeBuilder } from '../builder';
|
|
4
|
+
import { GenericParseContext } from '@cosmology/ast';
|
|
5
|
+
import { ProtoRef } from '@cosmology/types';
|
|
6
|
+
import { TelescopeParseContext } from '../build';
|
|
7
|
+
import { writeAstToFile } from '../utils/files';
|
|
8
|
+
import { fixlocalpaths } from '../utils';
|
|
9
|
+
import * as t from '@babel/types';
|
|
10
|
+
import { createEmptyProtoRef } from '@cosmology/proto-parser';
|
|
11
|
+
|
|
12
|
+
export const commonBundlePlugin = (
|
|
13
|
+
builder: TelescopeBuilder,
|
|
14
|
+
bundleFilename: string,
|
|
15
|
+
packageMappings: object,
|
|
16
|
+
astFn: (
|
|
17
|
+
context: GenericParseContext,
|
|
18
|
+
obj: object
|
|
19
|
+
) => (
|
|
20
|
+
| t.ExportNamedDeclaration
|
|
21
|
+
| {
|
|
22
|
+
type: string;
|
|
23
|
+
importKind: string;
|
|
24
|
+
specifiers: {
|
|
25
|
+
type: string;
|
|
26
|
+
local: {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
}[];
|
|
31
|
+
source: {
|
|
32
|
+
type: string;
|
|
33
|
+
value: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
)[]
|
|
37
|
+
) => {
|
|
38
|
+
const localname = bundleFilename;
|
|
39
|
+
|
|
40
|
+
// create proto ref for context
|
|
41
|
+
const pkg = '@root';
|
|
42
|
+
const ref: ProtoRef = createEmptyProtoRef(pkg, localname);
|
|
43
|
+
|
|
44
|
+
// create context
|
|
45
|
+
const pCtx = new TelescopeParseContext(ref, builder.store, builder.options);
|
|
46
|
+
|
|
47
|
+
// generate code for createRpcQueryHooks and imports of related packages.
|
|
48
|
+
const ast = astFn(pCtx.proto, packageMappings);
|
|
49
|
+
|
|
50
|
+
// generate imports added by context.addUtil
|
|
51
|
+
const imports = fixlocalpaths(aggregateImports(pCtx, {}, localname));
|
|
52
|
+
const importStmts = getImportStatements(localname, imports, builder.options);
|
|
53
|
+
|
|
54
|
+
// construct the AST
|
|
55
|
+
const prog = [].concat(importStmts).concat(ast);
|
|
56
|
+
|
|
57
|
+
// write the file.
|
|
58
|
+
const filename = join(builder.outPath, localname);
|
|
59
|
+
builder.files.push(localname);
|
|
60
|
+
|
|
61
|
+
writeAstToFile(builder.outPath, builder.options, prog, filename);
|
|
62
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readSchemas } from '@cosmwasm/ts-codegen';
|
|
2
|
+
import { pascal } from 'case';
|
|
3
|
+
import { basename, dirname, join } from 'path';
|
|
4
|
+
import { readFileSync, readdirSync } from 'fs';
|
|
5
|
+
|
|
6
|
+
export const getDirectories = source =>
|
|
7
|
+
readdirSync(source, { withFileTypes: true })
|
|
8
|
+
.filter(dirent => dirent.isDirectory())
|
|
9
|
+
.map(dirent => dirent.name);
|
|
10
|
+
|
|
11
|
+
export const getContracts = () => {
|
|
12
|
+
const contracts = getDirectories('./contracts')
|
|
13
|
+
.map(contractDirname => {
|
|
14
|
+
return {
|
|
15
|
+
name: `${contractDirname}`,
|
|
16
|
+
value: `./contracts/${contractDirname}`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return contracts;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getContractSchemata = async (schemata: any[], out: string, argv) => {
|
|
23
|
+
const s = [];
|
|
24
|
+
for (let i = 0; i < schemata.length; i++) {
|
|
25
|
+
const path = schemata[i];
|
|
26
|
+
const pkg = JSON.parse(readFileSync(join(path, 'package.json'), 'utf-8'));
|
|
27
|
+
const name = basename(path);
|
|
28
|
+
const folder = basename(dirname(path));
|
|
29
|
+
const contractName = pascal(pkg.contract) || pascal(name);
|
|
30
|
+
const schemas = await readSchemas({ schemaDir: path });
|
|
31
|
+
const outPath = join(out, folder);
|
|
32
|
+
s.push({
|
|
33
|
+
contractName, schemas, outPath
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return s;
|
|
37
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { parse, ParserPlugin } from "@babel/parser";
|
|
3
|
+
import { TelescopeOptions } from "@cosmology/types";
|
|
4
|
+
import { mkdirp } from "mkdirp";
|
|
5
|
+
import { writeFileSync } from "fs";
|
|
6
|
+
import { dirname } from "path";
|
|
7
|
+
import minimatch from "minimatch";
|
|
8
|
+
import generate from "@babel/generator";
|
|
9
|
+
import { unused } from "./unused";
|
|
10
|
+
import traverse from "@babel/traverse";
|
|
11
|
+
import { toPosixPath } from "@cosmology/utils";
|
|
12
|
+
|
|
13
|
+
export function getExportedTypeNames(program: t.Statement[]): string[] {
|
|
14
|
+
const exportedNames: string[] = [];
|
|
15
|
+
const ast = t.program(program);
|
|
16
|
+
const content = generate(ast).code;
|
|
17
|
+
const plugins: ParserPlugin[] = ["typescript"];
|
|
18
|
+
const newAst = parse(content, {
|
|
19
|
+
sourceType: "module",
|
|
20
|
+
plugins,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
traverse(newAst, {
|
|
24
|
+
ExportNamedDeclaration(path) {
|
|
25
|
+
const node = path.node;
|
|
26
|
+
|
|
27
|
+
// Handle direct declarations (type aliases, interfaces, enums)
|
|
28
|
+
if (node.declaration) {
|
|
29
|
+
const decl = node.declaration;
|
|
30
|
+
const isTypeExport = node.exportKind === "type";
|
|
31
|
+
const isTypeDecl = [
|
|
32
|
+
"TSTypeAliasDeclaration",
|
|
33
|
+
"TSInterfaceDeclaration",
|
|
34
|
+
"TSEnumDeclaration",
|
|
35
|
+
].includes(decl.type);
|
|
36
|
+
|
|
37
|
+
if (isTypeExport || isTypeDecl) {
|
|
38
|
+
if ("id" in decl && decl.id?.type === "Identifier") {
|
|
39
|
+
exportedNames.push(decl.id.name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Handle const declarations that might be types (e.g., const schemas)
|
|
44
|
+
if (decl.type === "VariableDeclaration" && decl.kind === "const") {
|
|
45
|
+
decl.declarations.forEach((declarator) => {
|
|
46
|
+
if (declarator.id?.type === "Identifier") {
|
|
47
|
+
exportedNames.push(declarator.id.name);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle export specifiers (e.g., export { SomeType })
|
|
54
|
+
if (node.specifiers && node.specifiers.length > 0) {
|
|
55
|
+
const isTypeExport = node.exportKind === "type";
|
|
56
|
+
if (isTypeExport) {
|
|
57
|
+
node.specifiers.forEach((spec) => {
|
|
58
|
+
if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
|
|
59
|
+
exportedNames.push(spec.exported.name);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return exportedNames;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const writeAstToFile = (
|
|
71
|
+
outPath: string,
|
|
72
|
+
options: TelescopeOptions,
|
|
73
|
+
program: t.Statement[],
|
|
74
|
+
filename: string
|
|
75
|
+
) => {
|
|
76
|
+
const ast = t.program(program);
|
|
77
|
+
const content = generate(ast).code;
|
|
78
|
+
|
|
79
|
+
if (options.removeUnusedImports) {
|
|
80
|
+
const plugins: ParserPlugin[] = ["typescript"];
|
|
81
|
+
const newAst = parse(content, {
|
|
82
|
+
sourceType: "module",
|
|
83
|
+
plugins,
|
|
84
|
+
});
|
|
85
|
+
traverse(newAst, unused);
|
|
86
|
+
const content2 = generate(newAst).code;
|
|
87
|
+
writeContentToFile(
|
|
88
|
+
toPosixPath(outPath),
|
|
89
|
+
options,
|
|
90
|
+
content2,
|
|
91
|
+
toPosixPath(filename)
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
writeContentToFile(
|
|
95
|
+
toPosixPath(outPath),
|
|
96
|
+
options,
|
|
97
|
+
content,
|
|
98
|
+
toPosixPath(filename)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const writeContentToFile = (
|
|
104
|
+
outPath: string,
|
|
105
|
+
options: TelescopeOptions,
|
|
106
|
+
content: string,
|
|
107
|
+
filename: string
|
|
108
|
+
) => {
|
|
109
|
+
let esLintPrefix = "";
|
|
110
|
+
let tsLintPrefix = "";
|
|
111
|
+
|
|
112
|
+
let nameWithoutPath = filename.replace(outPath, "");
|
|
113
|
+
// strip off leading slash
|
|
114
|
+
if (nameWithoutPath.startsWith("/"))
|
|
115
|
+
nameWithoutPath = nameWithoutPath.replace(/^\//, "");
|
|
116
|
+
|
|
117
|
+
options.tsDisable.patterns.forEach((pattern) => {
|
|
118
|
+
if (minimatch(nameWithoutPath, pattern)) {
|
|
119
|
+
tsLintPrefix = `//@ts-nocheck\n`;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
options.eslintDisable.patterns.forEach((pattern) => {
|
|
123
|
+
if (minimatch(nameWithoutPath, pattern)) {
|
|
124
|
+
esLintPrefix = `/* eslint-disable */\n`;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (
|
|
129
|
+
options.tsDisable.files.includes(nameWithoutPath) ||
|
|
130
|
+
options.tsDisable.disableAll
|
|
131
|
+
) {
|
|
132
|
+
tsLintPrefix = `//@ts-nocheck\n`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (
|
|
136
|
+
options.eslintDisable.files.includes(nameWithoutPath) ||
|
|
137
|
+
options.eslintDisable.disableAll
|
|
138
|
+
) {
|
|
139
|
+
esLintPrefix = `/* eslint-disable */\n`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const text = tsLintPrefix + esLintPrefix + content;
|
|
143
|
+
mkdirp.sync(dirname(filename));
|
|
144
|
+
writeFileSync(filename, text);
|
|
145
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ProtoRoot, ProtoRef } from '@cosmology/types';
|
|
2
|
+
import { relative, dirname, extname } from 'path';
|
|
3
|
+
import { ImportObj, UtilValue } from '../types';
|
|
4
|
+
import { restoreExtension, toPosixPath } from '@cosmology/utils';
|
|
5
|
+
|
|
6
|
+
export const getRoot = (ref: ProtoRef): ProtoRoot => {
|
|
7
|
+
if (ref.traversed) return ref.traversed;
|
|
8
|
+
return ref.proto;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// default example:
|
|
12
|
+
// Long: { type: 'default', path: 'long', name: 'Long ' },
|
|
13
|
+
// namespaced:
|
|
14
|
+
// _m0: { type: 'namespace', path: 'protobufjs/minimal', name: '_m0' },
|
|
15
|
+
export const UTILS: { [key: string]: UtilValue } = {
|
|
16
|
+
_m0: { type: 'namespace', path: 'protobufjs/minimal', name: '_m0' },
|
|
17
|
+
AminoHeight: '__helpers__',
|
|
18
|
+
AminoMsg: '@cosmjs/amino',
|
|
19
|
+
AminoTypes: '@cosmjs/stargate',
|
|
20
|
+
base64FromBytes: '__helpers__',
|
|
21
|
+
bytesFromBase64: '__helpers__',
|
|
22
|
+
BrowserHeaders: 'browser-headers',
|
|
23
|
+
connectComet: '@cosmjs/tendermint-rpc',
|
|
24
|
+
Decimal: '@cosmjs/math',
|
|
25
|
+
padDecimal: '__helpers__',
|
|
26
|
+
createProtobufRpcClient: '@cosmjs/stargate',
|
|
27
|
+
Pubkey: '@cosmjs/amino',
|
|
28
|
+
decodeBech32Pubkey: '@cosmjs/amino',
|
|
29
|
+
DeepPartial: '__helpers__',
|
|
30
|
+
defaultRegistryTypes: '@cosmjs/stargate',
|
|
31
|
+
encodeBech32Pubkey: '@cosmjs/amino',
|
|
32
|
+
Exact: '__helpers__',
|
|
33
|
+
fm: { type: 'namespace', path: '__grpc-gateway__', name: 'fm' },
|
|
34
|
+
encodePubkey: '@cosmjs/proto-signing',
|
|
35
|
+
decodePubkey: '@cosmjs/proto-signing',
|
|
36
|
+
fromBase64: '@cosmjs/encoding',
|
|
37
|
+
fromBech32: '@cosmjs/encoding',
|
|
38
|
+
fromDuration: '__helpers__',
|
|
39
|
+
fromHex: '@cosmjs/encoding',
|
|
40
|
+
fromJsonTimestamp: '__helpers__',
|
|
41
|
+
fromTimestamp: '__helpers__',
|
|
42
|
+
fromUtf8: '@cosmjs/encoding',
|
|
43
|
+
GeneratedType: '@cosmjs/proto-signing',
|
|
44
|
+
createTm34QueryClient: '__extern__',
|
|
45
|
+
createConnectCometQueryClient: '__extern__',
|
|
46
|
+
getRpcClient: '__extern__',
|
|
47
|
+
createRpcClient: '__extern__',
|
|
48
|
+
getRpcEndpointKey: '__extern__',
|
|
49
|
+
HttpEndpoint: '@cosmjs/tendermint-rpc',
|
|
50
|
+
isObject: '__helpers__',
|
|
51
|
+
isSet: '__helpers__',
|
|
52
|
+
LCDClient: '@cosmology/lcd',
|
|
53
|
+
Long: '__helpers__',
|
|
54
|
+
OfflineSigner: '@cosmjs/proto-signing',
|
|
55
|
+
omitDefault: '__helpers__',
|
|
56
|
+
ProtobufRpcClient: '@cosmjs/stargate',
|
|
57
|
+
QueryClient: '@cosmjs/stargate',
|
|
58
|
+
Registry: '@cosmjs/proto-signing',
|
|
59
|
+
Rpc: '__helpers__',
|
|
60
|
+
StdFee: '__types__',
|
|
61
|
+
TxRpc: '__types__',
|
|
62
|
+
BroadcastTxReq: '__types__',
|
|
63
|
+
BroadcastTxRes: '__types__',
|
|
64
|
+
DeliverTxResponse: '__types__',
|
|
65
|
+
EncodeObject: '__types__',
|
|
66
|
+
SigningClientParams: '__types__',
|
|
67
|
+
grpc: '@improbable-eng/grpc-web',
|
|
68
|
+
setPaginationParams: '__helpers__',
|
|
69
|
+
SigningStargateClient: '@cosmjs/stargate',
|
|
70
|
+
Tendermint34Client: '@cosmjs/tendermint-rpc',
|
|
71
|
+
toBase64: '@cosmjs/encoding',
|
|
72
|
+
toDuration: '__helpers__',
|
|
73
|
+
toTimestamp: '__helpers__',
|
|
74
|
+
toUtf8: '@cosmjs/encoding',
|
|
75
|
+
useQuery: '@tanstack/react-query',
|
|
76
|
+
ComputedRef: 'vue',
|
|
77
|
+
computed: 'vue',
|
|
78
|
+
Ref: 'vue',
|
|
79
|
+
useRpcEndpoint: '__react-query__',
|
|
80
|
+
useRpcClient: '__react-query__',
|
|
81
|
+
useTendermintClient: '__react-query__',
|
|
82
|
+
ReactQueryParams: '__react-query__',
|
|
83
|
+
buildUseMutation:'__react-query__',
|
|
84
|
+
UseQueryParams:'__react-query__',
|
|
85
|
+
buildUseQuery:'__react-query__',
|
|
86
|
+
UseQueryOptions: '@tanstack/react-query',
|
|
87
|
+
buildUseVueMutation:'__vue-query__',
|
|
88
|
+
buildUseVueQuery:'__vue-query__',
|
|
89
|
+
QueryStore: '__mobx__',
|
|
90
|
+
MobxResponse: '__mobx__',
|
|
91
|
+
useEndpoint: '__pinia-endpoint__',
|
|
92
|
+
JsonSafe: '__json-safe__',
|
|
93
|
+
override: 'mobx',
|
|
94
|
+
makeObservable: 'mobx',
|
|
95
|
+
NodeHttpTransport: '@improbable-eng/grpc-web-node-http-transport',
|
|
96
|
+
UnaryMethodDefinitionishR: '__grpc-web__',
|
|
97
|
+
UnaryMethodDefinitionish: '__grpc-web__',
|
|
98
|
+
BinaryReader: '__binary__',
|
|
99
|
+
BinaryWriter: '__binary__',
|
|
100
|
+
TelescopeGeneratedType: '__types__',
|
|
101
|
+
GlobalDecoderRegistry: '__registry__',
|
|
102
|
+
buildTx:'__helper-func-types__',
|
|
103
|
+
ISigningClient:'__helper-func-types__',
|
|
104
|
+
buildQuery:'__helper-func-types__',
|
|
105
|
+
EndpointOrRpc:'__helper-func-types__',
|
|
106
|
+
toConverters:'@interchainjs/cosmos/utils',
|
|
107
|
+
toEncoders:'@interchainjs/cosmos/utils'
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const UTIL_HELPERS = [
|
|
111
|
+
'__helpers__',
|
|
112
|
+
'__extern__',
|
|
113
|
+
'__react-query__',
|
|
114
|
+
'__vue-query__',
|
|
115
|
+
'__mobx__',
|
|
116
|
+
'__binary__',
|
|
117
|
+
'__pinia-endpoint__',
|
|
118
|
+
'__json-safe__',
|
|
119
|
+
'__grpc-gateway__',
|
|
120
|
+
'__grpc-web__',
|
|
121
|
+
'__types__',
|
|
122
|
+
'__registry__',
|
|
123
|
+
'__decimals__',
|
|
124
|
+
'__helper-func-types__'
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
export const fixlocalpaths = (imports: ImportObj[]) => {
|
|
128
|
+
return imports.map((imp) => {
|
|
129
|
+
const fixedPath = toPosixPath(imp.path);
|
|
130
|
+
return {
|
|
131
|
+
...imp,
|
|
132
|
+
path:
|
|
133
|
+
UTIL_HELPERS.includes(imp.path) ||
|
|
134
|
+
imp.path.startsWith('.') ||
|
|
135
|
+
imp.path.startsWith('@')
|
|
136
|
+
? fixedPath
|
|
137
|
+
: `./${fixedPath}`,
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const getRelativePath = (f1: string, f2: string, ext?: string) => {
|
|
143
|
+
const rel = relative(dirname(f1), f2);
|
|
144
|
+
let importPath = rel.replace(extname(rel), '');
|
|
145
|
+
if (!/^\./.test(importPath)) importPath = `./${importPath}`;
|
|
146
|
+
importPath = toPosixPath(importPath);
|
|
147
|
+
return restoreExtension(importPath, ext);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export * from './common-create-bundle';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
|
|
3
|
+
import * as t from '@babel/types';
|
|
4
|
+
|
|
5
|
+
// https://github.com/chuyik/babel-plugin-danger-remove-unused-import
|
|
6
|
+
// https://github.com/chuyik/babel-plugin-danger-remove-unused-import/blob/c5454c21e94698a2464a12baa5590761932a71a8/License#L1
|
|
7
|
+
|
|
8
|
+
export const unused = {
|
|
9
|
+
Program: {
|
|
10
|
+
exit: (path) => {
|
|
11
|
+
const UnRefBindings = new Map()
|
|
12
|
+
for (const [name, binding] of Object.entries(path.scope.bindings)) {
|
|
13
|
+
if (!binding.path.parentPath || binding.kind !== 'module') continue
|
|
14
|
+
|
|
15
|
+
const source = binding.path.parentPath.get('source')
|
|
16
|
+
const importName = source.node.value
|
|
17
|
+
if (
|
|
18
|
+
!t.isStringLiteral(source)
|
|
19
|
+
)
|
|
20
|
+
continue
|
|
21
|
+
|
|
22
|
+
const key = `${importName}(${source.node.loc &&
|
|
23
|
+
source.node.loc.start.line})`
|
|
24
|
+
|
|
25
|
+
if (!UnRefBindings.has(key)) {
|
|
26
|
+
UnRefBindings.set(key, binding)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (binding.referenced) {
|
|
30
|
+
UnRefBindings.set(key, null)
|
|
31
|
+
} else {
|
|
32
|
+
const nodeType = binding.path.node.type
|
|
33
|
+
if (nodeType === 'ImportSpecifier') {
|
|
34
|
+
binding.path.remove()
|
|
35
|
+
} else if (nodeType === 'ImportDefaultSpecifier') {
|
|
36
|
+
binding.path.remove()
|
|
37
|
+
} else if (nodeType === 'ImportNamespaceSpecifier') {
|
|
38
|
+
binding.path.remove()
|
|
39
|
+
} else if (binding.path.parentPath) {
|
|
40
|
+
binding.path.parentPath.remove()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
UnRefBindings.forEach((binding, key) => {
|
|
46
|
+
if (binding && binding.path.parentPath) {
|
|
47
|
+
binding.path.parentPath.remove()
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|