@codama/renderers-js 2.0.2 → 2.1.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/dist/index.browser.cjs +51 -12
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +51 -13
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +51 -12
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +51 -13
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +51 -13
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/fragments/programPlugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.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/package.json +1 -1
package/dist/index.browser.mjs
CHANGED
|
@@ -307,6 +307,8 @@ var DEFAULT_NAME_TRANSFORMERS = {
|
|
|
307
307
|
programPluginInstructionKey: (name) => `${camelCase(name)}`,
|
|
308
308
|
programPluginInstructionsType: (name) => `${pascalCase(name)}PluginInstructions`,
|
|
309
309
|
programPluginKey: (name) => `${camelCase(name)}`,
|
|
310
|
+
programPluginPdaKey: (name) => `${camelCase(name)}`,
|
|
311
|
+
programPluginPdasType: (name) => `${pascalCase(name)}PluginPdas`,
|
|
310
312
|
programPluginRequirementsType: (name) => `${pascalCase(name)}PluginRequirements`,
|
|
311
313
|
programPluginType: (name) => `${pascalCase(name)}Plugin`,
|
|
312
314
|
resolverFunction: (name) => `${camelCase(name)}`
|
|
@@ -2241,7 +2243,8 @@ function getProgramInstructionsParseFunctionFragment(scope) {
|
|
|
2241
2243
|
}`;
|
|
2242
2244
|
}
|
|
2243
2245
|
function getProgramPluginFragment(scope) {
|
|
2244
|
-
if (scope.programNode.accounts.length === 0 && scope.programNode.instructions.length === 0)
|
|
2246
|
+
if (scope.programNode.accounts.length === 0 && scope.programNode.instructions.length === 0 && scope.programNode.pdas.length === 0)
|
|
2247
|
+
return;
|
|
2245
2248
|
const resolvedInstructionInputVisitor = getResolvedInstructionInputsVisitor();
|
|
2246
2249
|
const asyncInstructions = scope.programNode.instructions.filter(
|
|
2247
2250
|
(instruction) => hasAsyncFunction(instruction, visit(instruction, resolvedInstructionInputVisitor), scope.asyncResolvers)
|
|
@@ -2251,6 +2254,7 @@ function getProgramPluginFragment(scope) {
|
|
|
2251
2254
|
getProgramPluginTypeFragment(scope),
|
|
2252
2255
|
getProgramPluginAccountsTypeFragment(scope),
|
|
2253
2256
|
getProgramPluginInstructionsTypeFragment({ ...scope, asyncInstructions }),
|
|
2257
|
+
getProgramPluginPdasTypeFragment(scope),
|
|
2254
2258
|
getProgramPluginRequirementsTypeFragment(scope),
|
|
2255
2259
|
getProgramPluginFunctionFragment({ ...scope, asyncInstructions }),
|
|
2256
2260
|
getMakeOptionalHelperTypeFragment(scope)
|
|
@@ -2263,10 +2267,12 @@ function getProgramPluginTypeFragment(scope) {
|
|
|
2263
2267
|
const programPluginType = nameApi.programPluginType(programNode.name);
|
|
2264
2268
|
const programPluginAccountsType = nameApi.programPluginAccountsType(programNode.name);
|
|
2265
2269
|
const programPluginInstructionsType = nameApi.programPluginInstructionsType(programNode.name);
|
|
2270
|
+
const programPluginPdasType = nameApi.programPluginPdasType(programNode.name);
|
|
2266
2271
|
const fields = mergeFragments(
|
|
2267
2272
|
[
|
|
2268
2273
|
programNode.accounts.length > 0 ? fragment`accounts: ${programPluginAccountsType};` : void 0,
|
|
2269
|
-
programNode.instructions.length > 0 ? fragment`instructions: ${programPluginInstructionsType};` : void 0
|
|
2274
|
+
programNode.instructions.length > 0 ? fragment`instructions: ${programPluginInstructionsType};` : void 0,
|
|
2275
|
+
programNode.pdas.length > 0 ? fragment`pdas: ${programPluginPdasType};` : void 0
|
|
2270
2276
|
],
|
|
2271
2277
|
(c) => c.join(" ")
|
|
2272
2278
|
);
|
|
@@ -2311,6 +2317,33 @@ function getProgramPluginInstructionsTypeFragment(scope) {
|
|
|
2311
2317
|
);
|
|
2312
2318
|
return fragment`export type ${programPluginInstructionsType} = { ${fields} }`;
|
|
2313
2319
|
}
|
|
2320
|
+
function getProgramPluginPdasTypeFragment(scope) {
|
|
2321
|
+
const { programNode, nameApi } = scope;
|
|
2322
|
+
if (programNode.pdas.length === 0) return;
|
|
2323
|
+
const programPluginPdasType = nameApi.programPluginPdasType(programNode.name);
|
|
2324
|
+
const fields = mergeFragments(
|
|
2325
|
+
programNode.pdas.map((pda) => {
|
|
2326
|
+
const name = nameApi.programPluginPdaKey(pda.name);
|
|
2327
|
+
const pdaFindFunction = use("type " + nameApi.pdaFindFunction(pda.name), "generatedPdas");
|
|
2328
|
+
return fragment`${name}: typeof ${pdaFindFunction};`;
|
|
2329
|
+
}),
|
|
2330
|
+
(c) => c.join(" ")
|
|
2331
|
+
);
|
|
2332
|
+
return fragment`export type ${programPluginPdasType} = { ${fields} }`;
|
|
2333
|
+
}
|
|
2334
|
+
function getProgramPluginPdasObjectFragment(scope) {
|
|
2335
|
+
const { programNode, nameApi } = scope;
|
|
2336
|
+
if (programNode.pdas.length === 0) return;
|
|
2337
|
+
const fields = mergeFragments(
|
|
2338
|
+
programNode.pdas.map((pda) => {
|
|
2339
|
+
const name = nameApi.programPluginPdaKey(pda.name);
|
|
2340
|
+
const pdaFindFunction = use(nameApi.pdaFindFunction(pda.name), "generatedPdas");
|
|
2341
|
+
return fragment`${name}: ${pdaFindFunction}`;
|
|
2342
|
+
}),
|
|
2343
|
+
(c) => c.join(", ")
|
|
2344
|
+
);
|
|
2345
|
+
return fragment`pdas: { ${fields} }`;
|
|
2346
|
+
}
|
|
2314
2347
|
function getProgramPluginRequirementsTypeFragment(scope) {
|
|
2315
2348
|
const { programNode, nameApi } = scope;
|
|
2316
2349
|
const programRequirementsType = nameApi.programPluginRequirementsType(programNode.name);
|
|
@@ -2320,15 +2353,16 @@ function getProgramPluginRequirementsTypeFragment(scope) {
|
|
|
2320
2353
|
const clientWithTransactionSending = use("type ClientWithTransactionSending", "solanaPluginInterfaces");
|
|
2321
2354
|
const hasAccounts = programNode.accounts.length > 0;
|
|
2322
2355
|
const hasInstructions = programNode.instructions.length > 0;
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2356
|
+
const requirementList = [
|
|
2357
|
+
hasAccounts ? clientWithRpc : void 0,
|
|
2358
|
+
hasPayerDefaultValues(programNode) ? clientWithPayer : void 0,
|
|
2359
|
+
hasInstructions ? clientWithTransactionPlanning : void 0,
|
|
2360
|
+
hasInstructions ? clientWithTransactionSending : void 0
|
|
2361
|
+
].filter((r) => r !== void 0);
|
|
2362
|
+
if (requirementList.length === 0) {
|
|
2363
|
+
return fragment`export type ${programRequirementsType} = object`;
|
|
2364
|
+
}
|
|
2365
|
+
const requirements = mergeFragments(requirementList, (c) => c.join(" & "));
|
|
2332
2366
|
return fragment`export type ${programRequirementsType} = ${requirements}`;
|
|
2333
2367
|
}
|
|
2334
2368
|
function getProgramPluginFunctionFragment(scope) {
|
|
@@ -2338,7 +2372,11 @@ function getProgramPluginFunctionFragment(scope) {
|
|
|
2338
2372
|
const programPluginRequirementsType = nameApi.programPluginRequirementsType(programNode.name);
|
|
2339
2373
|
const programPluginKey = nameApi.programPluginKey(programNode.name);
|
|
2340
2374
|
const fields = mergeFragments(
|
|
2341
|
-
[
|
|
2375
|
+
[
|
|
2376
|
+
getProgramPluginAccountsObjectFragment(scope),
|
|
2377
|
+
getProgramPluginInstructionsObjectFragment(scope),
|
|
2378
|
+
getProgramPluginPdasObjectFragment(scope)
|
|
2379
|
+
],
|
|
2342
2380
|
(c) => c.join(", ")
|
|
2343
2381
|
);
|
|
2344
2382
|
return fragment`export function ${programPluginFunction}() {
|
|
@@ -3348,6 +3386,6 @@ function renderVisitor(packageFolder, options = {}) {
|
|
|
3348
3386
|
});
|
|
3349
3387
|
}
|
|
3350
3388
|
|
|
3351
|
-
export { DEFAULT_NAME_TRANSFORMERS, addToImportMap, createImportMap, renderVisitor as default, getExternalDependencies, getNameApi, getRenderMapVisitor, getTypeManifestVisitor, importMapToString, mergeImportMaps, mergeTypeManifests, parseImportInput, removeFromImportMap, renderVisitor, typeManifest };
|
|
3389
|
+
export { DEFAULT_KIT_IMPORT_STRATEGY, DEFAULT_NAME_TRANSFORMERS, addToImportMap, createImportMap, renderVisitor as default, getExternalDependencies, getNameApi, getRenderMapVisitor, getTypeManifestVisitor, importMapToString, mergeImportMaps, mergeTypeManifests, parseImportInput, removeFromImportMap, renderVisitor, typeManifest };
|
|
3352
3390
|
//# sourceMappingURL=index.browser.mjs.map
|
|
3353
3391
|
//# sourceMappingURL=index.browser.mjs.map
|