@codama/renderers-js 1.7.0 → 2.0.1
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 +21 -19
- package/dist/index.browser.cjs +565 -465
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +565 -465
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +565 -465
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +565 -465
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +565 -465
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/fragments/index.d.ts +1 -1
- package/dist/types/fragments/index.d.ts.map +1 -1
- package/dist/types/fragments/instructionInputDefault.d.ts.map +1 -1
- package/dist/types/fragments/instructionPage.d.ts +1 -0
- package/dist/types/fragments/instructionPage.d.ts.map +1 -1
- package/dist/types/fragments/programAccounts.d.ts.map +1 -1
- package/dist/types/fragments/programInstructions.d.ts.map +1 -1
- package/dist/types/fragments/programPage.d.ts +1 -1
- package/dist/types/fragments/programPage.d.ts.map +1 -1
- package/dist/types/fragments/programPlugin.d.ts +6 -0
- package/dist/types/fragments/programPlugin.d.ts.map +1 -0
- package/dist/types/utils/formatCode.d.ts +1 -1
- package/dist/types/utils/formatCode.d.ts.map +1 -1
- package/dist/types/utils/fragment.d.ts +1 -1
- package/dist/types/utils/fragment.d.ts.map +1 -1
- package/dist/types/utils/importMap.d.ts +3 -2
- package/dist/types/utils/importMap.d.ts.map +1 -1
- package/dist/types/utils/nameTransformers.d.ts +1 -1
- package/dist/types/utils/nameTransformers.d.ts.map +1 -1
- package/dist/types/utils/options.d.ts +28 -3
- package/dist/types/utils/options.d.ts.map +1 -1
- package/dist/types/utils/packageJson.d.ts +3 -3
- package/dist/types/utils/packageJson.d.ts.map +1 -1
- package/dist/types/visitors/getRenderMapVisitor.d.ts.map +1 -1
- package/dist/types/visitors/renderVisitor.d.ts +1 -1
- package/dist/types/visitors/renderVisitor.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/fragments/sharedPage.d.ts +0 -3
- package/dist/types/fragments/sharedPage.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -24,33 +24,35 @@ Add the following script to your Codama configuration file.
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"js": {
|
|
26
26
|
"from": "@codama/renderers-js",
|
|
27
|
-
"args": ["clients/js
|
|
27
|
+
"args": ["clients/js"]
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
The first argument is the package folder — i.e. where the `package.json` lives. The generated files will be written to `src/generated` within that folder by default.
|
|
34
|
+
|
|
33
35
|
An object can be passed as a second argument to further configure the renderer. See the [Options](#options) section below for more details.
|
|
34
36
|
|
|
35
37
|
## Options
|
|
36
38
|
|
|
37
39
|
The `renderVisitor` accepts the following options.
|
|
38
40
|
|
|
39
|
-
| Name | Type | Default
|
|
40
|
-
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
-
| `deleteFolderBeforeRendering` | `boolean` | `true`
|
|
42
|
-
| `formatCode` | `boolean` | `true`
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
41
|
+
| Name | Type | Default | Description |
|
|
42
|
+
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `deleteFolderBeforeRendering` | `boolean` | `true` | Whether the base directory should be cleaned before generating new files. |
|
|
44
|
+
| `formatCode` | `boolean` | `true` | Whether we should use Prettier to format the generated code. |
|
|
45
|
+
| `generatedFolder` | `string` | `'src/generated'` | The path to the generated folder relative to the package folder. |
|
|
46
|
+
| `prettierOptions` | `PrettierOptions` | `{}` | The options to use when formatting the code using Prettier. |
|
|
47
|
+
| `asyncResolvers` | `string[]` | `[]` | The exhaustive list of `ResolverValueNode`'s names whose implementation is asynchronous in JavaScript. |
|
|
48
|
+
| `customAccountData` | `string[]` | `[]` | The names of all `AccountNodes` whose data should be manually written in JavaScript. |
|
|
49
|
+
| `customInstructionData` | `string[]` | `[]` | The names of all `InstructionNodes` whose data should be manually written in JavaScript. |
|
|
50
|
+
| `linkOverrides` | `Record<'accounts' \| 'definedTypes' \| 'instructions' \| 'pdas' \| 'programs' \| 'resolvers', Record<string, string>>` | `{}` | A object that overrides the import path of link nodes. For instance, `{ definedTypes: { counter: 'hooked' } }` uses the `hooked` folder to import any link node referring to the `counter` type. |
|
|
51
|
+
| `dependencyMap` | `Record<string, string>` | `{}` | A mapping between import aliases and their actual package name or path in JavaScript. |
|
|
52
|
+
| `dependencyVersions` | `Record<string, string>` | `{}` | A mapping between external package names — e.g. `@solana/kit` — and the version range we should use for them — e.g. `^6.0.0`. The renderer offers default values for all external dependencies it relies on but this option may be used to override some of these values or add new ones. |
|
|
53
|
+
| `internalNodes` | `string[]` | `[]` | The names of all nodes that should be generated but not exported by the `index.ts` files. |
|
|
54
|
+
| `nameTransformers` | `Partial<NameTransformers>` | `{}` | An object that enables us to override the names of any generated type, constant or function. |
|
|
55
|
+
| `nonScalarEnums` | `string[]` | `[]` | The names of enum variants with no data that should be treated as a data union instead of a native `enum` type. This is only useful if you are referencing an enum value in your Codama IDL. |
|
|
56
|
+
| `renderParentInstructions` | `boolean` | `false` | When using nested instructions, whether the parent instructions should also be rendered. When set to `false` (default), only the instruction leaves are being rendered. |
|
|
57
|
+
| `kitImportStrategy` | `'granular' \| 'preferRoot' \| 'rootOnly'` | `'preferRoot'` | Whether to generate imports from granular packages (e.g. `@solana/addresses`, `@solana/codecs-strings`) or from the `@solana/kit` package. `'granular'`: always use granular packages when available. `'preferRoot'` (default): use `@solana/kit` when the symbol is exported from it; otherwise fall back to granular packages. `'rootOnly'`: only import from the `@solana/kit` package. This may use `@solana/kit` subpath exports (e.g. `@solana/kit/program-client-core`). This is useful when installing `@solana/kit` as a peerDependency, but may require TypeScript `moduleResolution: "bundler"`. |
|
|
58
|
+
| `syncPackageJson` | `boolean` | `true` | Whether to update the dependencies of the existing `package.json` — or create a new `package.json` when missing — inside the package folder. |
|