@codama/renderers-rust 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +48 -0
  3. package/dist/index.node.cjs +909 -0
  4. package/dist/index.node.cjs.map +1 -0
  5. package/dist/index.node.mjs +900 -0
  6. package/dist/index.node.mjs.map +1 -0
  7. package/dist/templates/accountsMod.njk +13 -0
  8. package/dist/templates/accountsPage.njk +160 -0
  9. package/dist/templates/definedTypesMod.njk +13 -0
  10. package/dist/templates/definedTypesPage.njk +15 -0
  11. package/dist/templates/errorsMod.njk +17 -0
  12. package/dist/templates/errorsPage.njk +23 -0
  13. package/dist/templates/instructionsCpiPage.njk +185 -0
  14. package/dist/templates/instructionsCpiPageBuilder.njk +145 -0
  15. package/dist/templates/instructionsMod.njk +13 -0
  16. package/dist/templates/instructionsPage.njk +159 -0
  17. package/dist/templates/instructionsPageBuilder.njk +128 -0
  18. package/dist/templates/layout.njk +7 -0
  19. package/dist/templates/macros.njk +6 -0
  20. package/dist/templates/programsMod.njk +13 -0
  21. package/dist/templates/rootMod.njk +26 -0
  22. package/dist/templates/sharedPage.njk +93 -0
  23. package/dist/types/ImportMap.d.ts +16 -0
  24. package/dist/types/ImportMap.d.ts.map +1 -0
  25. package/dist/types/getRenderMapVisitor.d.ts +9 -0
  26. package/dist/types/getRenderMapVisitor.d.ts.map +1 -0
  27. package/dist/types/getTypeManifestVisitor.d.ts +13 -0
  28. package/dist/types/getTypeManifestVisitor.d.ts.map +1 -0
  29. package/dist/types/index.d.ts +5 -0
  30. package/dist/types/index.d.ts.map +1 -0
  31. package/dist/types/renderValueNodeVisitor.d.ts +13 -0
  32. package/dist/types/renderValueNodeVisitor.d.ts.map +1 -0
  33. package/dist/types/renderVisitor.d.ts +9 -0
  34. package/dist/types/renderVisitor.d.ts.map +1 -0
  35. package/dist/types/utils/codecs.d.ts +3 -0
  36. package/dist/types/utils/codecs.d.ts.map +1 -0
  37. package/dist/types/utils/index.d.ts +4 -0
  38. package/dist/types/utils/index.d.ts.map +1 -0
  39. package/dist/types/utils/linkOverrides.d.ts +14 -0
  40. package/dist/types/utils/linkOverrides.d.ts.map +1 -0
  41. package/dist/types/utils/render.d.ts +4 -0
  42. package/dist/types/utils/render.d.ts.map +1 -0
  43. package/package.json +67 -0
@@ -0,0 +1,13 @@
1
+ import { RegisteredValueNode, ValueNode } from '@codama/nodes';
2
+ import { Visitor } from '@codama/visitors-core';
3
+ import { ImportMap } from './ImportMap';
4
+ import { GetImportFromFunction } from './utils';
5
+ export declare function renderValueNode(value: ValueNode, getImportFrom: GetImportFromFunction, useStr?: boolean): {
6
+ imports: ImportMap;
7
+ render: string;
8
+ };
9
+ export declare function renderValueNodeVisitor(getImportFrom: GetImportFromFunction, useStr?: boolean): Visitor<{
10
+ imports: ImportMap;
11
+ render: string;
12
+ }, RegisteredValueNode['kind']>;
13
+ //# sourceMappingURL=renderValueNodeVisitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderValueNodeVisitor.d.ts","sourceRoot":"","sources":["../../src/renderValueNodeVisitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,mBAAmB,EACnB,SAAS,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAS,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAA8B,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E,wBAAgB,eAAe,CAC3B,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,qBAAqB,EACpC,MAAM,GAAE,OAAe,GACxB;IACC,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB,CAEA;AAED,wBAAgB,sBAAsB,CAClC,aAAa,EAAE,qBAAqB,EACpC,MAAM,GAAE,OAAe,GACxB,OAAO,CACN;IACI,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB,EACD,mBAAmB,CAAC,MAAM,CAAC,CAC9B,CAiIA"}
@@ -0,0 +1,9 @@
1
+ import { GetRenderMapOptions } from './getRenderMapVisitor';
2
+ export type RenderOptions = GetRenderMapOptions & {
3
+ crateFolder?: string;
4
+ deleteFolderBeforeRendering?: boolean;
5
+ formatCode?: boolean;
6
+ toolchain?: string;
7
+ };
8
+ export declare function renderVisitor(path: string, options?: RenderOptions): import("@codama/visitors-core").Visitor<void, "rootNode">;
9
+ //# sourceMappingURL=renderVisitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderVisitor.d.ts","sourceRoot":"","sources":["../../src/renderVisitor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAuB,MAAM,uBAAuB,CAAC;AAEjF,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,6DAoBtE"}
@@ -0,0 +1,3 @@
1
+ import { BytesValueNode } from '@codama/nodes';
2
+ export declare function getBytesFromBytesValueNode(node: BytesValueNode): Uint8Array;
3
+ //# sourceMappingURL=codecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../src/utils/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CAY3E"}
@@ -0,0 +1,4 @@
1
+ export * from './codecs';
2
+ export * from './linkOverrides';
3
+ export * from './render';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { AccountLinkNode, DefinedTypeLinkNode, InstructionLinkNode, PdaLinkNode, ProgramLinkNode, ResolverValueNode } from '@codama/nodes';
2
+ export type LinkOverrides = {
3
+ accounts?: Record<string, string>;
4
+ definedTypes?: Record<string, string>;
5
+ instructions?: Record<string, string>;
6
+ pdas?: Record<string, string>;
7
+ programs?: Record<string, string>;
8
+ resolvers?: Record<string, string>;
9
+ };
10
+ type OverridableNodes = AccountLinkNode | DefinedTypeLinkNode | InstructionLinkNode | PdaLinkNode | ProgramLinkNode | ResolverValueNode;
11
+ export type GetImportFromFunction = (node: OverridableNodes, fallback?: string) => string;
12
+ export declare function getImportFromFactory(overrides: LinkOverrides): GetImportFromFunction;
13
+ export {};
14
+ //# sourceMappingURL=linkOverrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkOverrides.d.ts","sourceRoot":"","sources":["../../../src/utils/linkOverrides.ts"],"names":[],"mappings":"AACA,OAAO,EACH,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,iBAAiB,EACpB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,KAAK,gBAAgB,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,WAAW,GACX,eAAe,GACf,iBAAiB,CAAC;AAExB,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE1F,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,aAAa,GAAG,qBAAqB,CAwCpF"}
@@ -0,0 +1,4 @@
1
+ import { ConfigureOptions as NunJucksOptions } from 'nunjucks';
2
+ export declare function rustDocblock(docs: string[]): string;
3
+ export declare const render: (template: string, context?: object, options?: NunJucksOptions) => string;
4
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/utils/render.ts"],"names":[],"mappings":"AAIA,OAAiB,EAAE,gBAAgB,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAEzE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAInD;AAED,eAAO,MAAM,MAAM,aAAc,MAAM,YAAY,MAAM,YAAY,eAAe,KAAG,MAYtF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@codama/renderers-rust",
3
+ "version": "1.0.0",
4
+ "description": "Renders Rust clients for your programs",
5
+ "exports": {
6
+ "types": "./dist/types/index.d.ts",
7
+ "node": {
8
+ "import": "./dist/index.node.mjs",
9
+ "require": "./dist/index.node.cjs"
10
+ }
11
+ },
12
+ "main": "./dist/index.node.cjs",
13
+ "module": "./dist/index.node.mjs",
14
+ "types": "./dist/types/index.d.ts",
15
+ "type": "commonjs",
16
+ "files": [
17
+ "./dist/templates",
18
+ "./dist/types",
19
+ "./dist/index.*"
20
+ ],
21
+ "sideEffects": false,
22
+ "keywords": [
23
+ "solana",
24
+ "framework",
25
+ "standard",
26
+ "renderers",
27
+ "rust",
28
+ "client"
29
+ ],
30
+ "dependencies": {
31
+ "@solana/codecs-strings": "rc",
32
+ "nunjucks": "^3.2.4",
33
+ "@codama/errors": "1.0.0",
34
+ "@codama/nodes": "1.0.0",
35
+ "@codama/renderers-core": "1.0.0",
36
+ "@codama/visitors-core": "1.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/nunjucks": "^3.2.6"
40
+ },
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/codama-idl/codama"
45
+ },
46
+ "bugs": {
47
+ "url": "http://github.com/codama-idl/codama/issues"
48
+ },
49
+ "browserslist": [
50
+ "supports bigint and not dead",
51
+ "maintained node versions"
52
+ ],
53
+ "scripts": {
54
+ "build": "rimraf dist && pnpm build:src && pnpm build:types",
55
+ "build:src": "zx ../../node_modules/@codama/internals/scripts/build-src.mjs node",
56
+ "build:types": "zx ../../node_modules/@codama/internals/scripts/build-types.mjs",
57
+ "dev": "zx ../../node_modules/@codama/internals/scripts/test-unit.mjs node --watch",
58
+ "lint": "zx ../../node_modules/@codama/internals/scripts/lint.mjs",
59
+ "lint:fix": "zx ../../node_modules/@codama/internals/scripts/lint.mjs --fix",
60
+ "test": "pnpm test:types && pnpm test:treeshakability && pnpm test:node && pnpm test:e2e && pnpm test:exports",
61
+ "test:e2e": "./e2e/test.sh",
62
+ "test:exports": "node ./test/exports/module.mjs && node ./test/exports/commonjs.cjs",
63
+ "test:node": "zx ../../node_modules/@codama/internals/scripts/test-unit.mjs node",
64
+ "test:treeshakability": "zx ../../node_modules/@codama/internals/scripts/test-treeshakability.mjs",
65
+ "test:types": "zx ../../node_modules/@codama/internals/scripts/test-types.mjs"
66
+ }
67
+ }