Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bufbuild/protoplugin

Package Overview
Dependencies
Maintainers
10
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufbuild/protoplugin - npm Package Compare versions

Comparing version 1.7.2 to 1.8.0

dist/cjs/ecmascript/file-preamble.d.ts

6

dist/cjs/ecmascript/generated-file.d.ts

@@ -1,10 +0,10 @@

import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage } from "@bufbuild/protobuf";
import { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage } from "@bufbuild/protobuf";
import type { ImportSymbol } from "./import-symbol.js";
import type { RuntimeImports } from "./runtime-imports.js";
import type { ExportDeclaration } from "./export-declaration.js";
import type { JSDocBlock } from "./jsdoc.js";
import { ExportDeclaration, LiteralProtoInt64, LiteralString, RefDescEnum, RefDescMessage } from "./opaque-printables.js";
/**
* All types that can be passed to GeneratedFile.print()
*/
export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | DescMessage | DescEnum | DescExtension | Printable[];
export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | LiteralString | LiteralProtoInt64 | RefDescMessage | RefDescEnum | DescMessage | DescEnum | DescExtension | Printable[];
/**

@@ -11,0 +11,0 @@ * FileInfo represents an intermediate type using for transpiling TypeScript internally.

@@ -17,6 +17,5 @@ "use strict";

exports.createGeneratedFile = void 0;
const protobuf_1 = require("@bufbuild/protobuf");
const import_symbol_js_1 = require("./import-symbol.js");
const gencommon_js_1 = require("./gencommon.js");
const import_path_js_1 = require("./import-path.js");
const export_declaration_js_1 = require("./export-declaration.js");
const jsdoc_js_1 = require("./jsdoc.js");

@@ -51,6 +50,11 @@ function createGeneratedFile(name, importPath, jsImportStyle, rewriteImportPath, createTypeImport, runtimeImports, createPreamble) {

exportDecl(declaration, name) {
return (0, export_declaration_js_1.createExportDeclaration)(declaration, name);
return {
kind: "es_export_decl",
declaration,
name,
};
},
string(string) {
return (0, gencommon_js_1.literalString)(string);
// We do not use LiteralString, which was added later, to maintain backwards compatibility
return escapeString(string);
},

@@ -92,3 +96,3 @@ jsDoc(textOrDesc, indentation) {

const what = `{ ${p.join(", ")} }`;
c.push(`const ${what} = require(${(0, gencommon_js_1.literalString)(from)});\n`);
c.push(`const ${what} = require(${escapeString(from)});\n`);
}

@@ -99,6 +103,6 @@ else {

if (typeOnly) {
c.push(`import type ${what} from ${(0, gencommon_js_1.literalString)(from)};\n`);
c.push(`import type ${what} from ${escapeString(from)};\n`);
}
else {
c.push(`import ${what} from ${(0, gencommon_js_1.literalString)(from)};\n`);
c.push(`import ${what} from ${escapeString(from)};\n`);
}

@@ -160,3 +164,3 @@ }

case "number":
el.push(...literalNumber(p, runtimeImports));
elNumber(el, p, runtimeImports);
break;

@@ -167,7 +171,7 @@ case "boolean":

case "bigint":
el.push(...literalBigint(p, runtimeImports));
elBigint(el, p, runtimeImports);
break;
case "object":
if (p instanceof Uint8Array) {
el.push(literalUint8Array(p));
elUint8Array(el, p);
break;

@@ -182,2 +186,8 @@ }

break;
case "es_string":
el.push(escapeString(p.value));
break;
case "es_proto_int64":
elProtoInt64(el, p, runtimeImports);
break;
case "es_export_decl":

@@ -192,2 +202,8 @@ el.push({

break;
case "es_ref_message":
case "es_ref_enum":
el.push(p.typeOnly
? createTypeImport(p.type).toTypeOnly()
: createTypeImport(p.type));
break;
case "message":

@@ -322,30 +338,31 @@ case "extension":

}
function literalNumber(value, runtimeImports) {
function elBigint(el, value, runtimeImports) {
if (value == protobuf_1.protoInt64.zero) {
// Loose comparison will match between 0n and 0.
el.push(runtimeImports.protoInt64, ".zero");
}
else {
el.push(runtimeImports.protoInt64, value > 0 ? ".uParse(" : ".parse(", escapeString(value.toString()), ")");
}
}
function elNumber(el, value, runtimeImports) {
if (Number.isNaN(value)) {
return [runtimeImports.protoDouble, ".NaN"];
el.push(runtimeImports.protoDouble, ".NaN");
}
if (value === Number.POSITIVE_INFINITY) {
return [runtimeImports.protoDouble, ".POSITIVE_INFINITY"];
else if (value === Number.POSITIVE_INFINITY) {
el.push(runtimeImports.protoDouble, ".POSITIVE_INFINITY");
}
if (value === Number.NEGATIVE_INFINITY) {
return [runtimeImports.protoDouble, ".NEGATIVE_INFINITY"];
else if (value === Number.NEGATIVE_INFINITY) {
el.push(runtimeImports.protoDouble, ".NEGATIVE_INFINITY");
}
return value.toString(10);
}
function literalBigint(value, runtimeImports) {
// Loose comparison will match between 0n and 0.
if (value == 0) {
return [runtimeImports.protoInt64, ".zero"];
else {
el.push(value.toString(10));
}
return [
runtimeImports.protoInt64,
value > 0 ? ".uParse(" : ".parse(",
(0, gencommon_js_1.literalString)(value.toString()),
")",
];
}
function literalUint8Array(value) {
function elUint8Array(el, value) {
if (value.length === 0) {
return "new Uint8Array(0)";
el.push("new Uint8Array(0)");
return;
}
el.push("new Uint8Array([");
const strings = [];

@@ -355,3 +372,45 @@ for (const n of value) {

}
return `new Uint8Array([${strings.join(", ")}])`;
el.push(strings.join(", "));
el.push("])");
}
function elProtoInt64(el, literal, runtimeImports) {
switch (literal.longType) {
case protobuf_1.LongType.STRING:
el.push(escapeString(literal.value.toString()));
break;
case protobuf_1.LongType.BIGINT:
if (literal.value == protobuf_1.protoInt64.zero) {
// Loose comparison will match between 0n and 0.
el.push(runtimeImports.protoInt64, ".zero");
break;
}
switch (literal.type) {
case protobuf_1.ScalarType.UINT64:
case protobuf_1.ScalarType.FIXED64:
el.push(runtimeImports.protoInt64);
el.push(".uParse(");
el.push(escapeString(literal.value.toString()));
el.push(")");
break;
default:
el.push(runtimeImports.protoInt64);
el.push(".parse(");
el.push(escapeString(literal.value.toString()));
el.push(")");
break;
}
}
}
function escapeString(value) {
return ('"' +
value
.split("\\")
.join("\\\\")
.split('"')
.join('\\"')
.split("\r")
.join("\\r")
.split("\n")
.join("\\n") +
'"');
}

@@ -11,9 +11,5 @@ import { AnyDesc, DescExtension, DescFile } from "@bufbuild/protobuf";

export declare const localName: (desc: import("@bufbuild/protobuf").DescEnum | import("@bufbuild/protobuf").DescMessage | import("@bufbuild/protobuf").DescService | DescExtension | import("@bufbuild/protobuf").DescEnumValue | import("@bufbuild/protobuf").DescField | import("@bufbuild/protobuf").DescOneof | import("@bufbuild/protobuf").DescMethod) => string;
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, } from "./gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, literalString, } from "./legacy-gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./legacy-custom-options.js";
/**
* @deprecated Please use GeneratedFile.string() instead
*/
export declare function literalString(value: string): string;
/**
* @deprecated Please use GeneratedFile.jsDoc() instead

@@ -20,0 +16,0 @@ */

@@ -16,6 +16,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createJsDocBlock = exports.makeJsDoc = exports.literalString = exports.findCustomEnumOption = exports.findCustomMessageOption = exports.findCustomScalarOption = exports.getFieldTyping = exports.getFieldIntrinsicDefaultValue = exports.getFieldExplicitDefaultValue = exports.localName = exports.createImportSymbol = exports.reifyWkt = void 0;
exports.createJsDocBlock = exports.makeJsDoc = exports.findCustomEnumOption = exports.findCustomMessageOption = exports.findCustomScalarOption = exports.literalString = exports.getFieldTyping = exports.getFieldIntrinsicDefaultValue = exports.getFieldExplicitDefaultValue = exports.localName = exports.createImportSymbol = exports.reifyWkt = void 0;
const protobuf_1 = require("@bufbuild/protobuf");
const jsdoc_js_1 = require("./jsdoc.js");
const gencommon_js_1 = require("./gencommon.js");
var reify_wkt_js_1 = require("./reify-wkt.js");

@@ -26,18 +25,12 @@ Object.defineProperty(exports, "reifyWkt", { enumerable: true, get: function () { return reify_wkt_js_1.reifyWkt; } });

exports.localName = protobuf_1.codegenInfo.localName;
var gencommon_js_2 = require("./gencommon.js");
Object.defineProperty(exports, "getFieldExplicitDefaultValue", { enumerable: true, get: function () { return gencommon_js_2.getFieldExplicitDefaultValue; } });
Object.defineProperty(exports, "getFieldIntrinsicDefaultValue", { enumerable: true, get: function () { return gencommon_js_2.getFieldIntrinsicDefaultValue; } });
Object.defineProperty(exports, "getFieldTyping", { enumerable: true, get: function () { return gencommon_js_2.getFieldTyping; } });
var custom_options_js_1 = require("./custom-options.js");
Object.defineProperty(exports, "findCustomScalarOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomScalarOption; } });
Object.defineProperty(exports, "findCustomMessageOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomMessageOption; } });
Object.defineProperty(exports, "findCustomEnumOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomEnumOption; } });
var legacy_gencommon_js_1 = require("./legacy-gencommon.js");
Object.defineProperty(exports, "getFieldExplicitDefaultValue", { enumerable: true, get: function () { return legacy_gencommon_js_1.getFieldExplicitDefaultValue; } });
Object.defineProperty(exports, "getFieldIntrinsicDefaultValue", { enumerable: true, get: function () { return legacy_gencommon_js_1.getFieldIntrinsicDefaultValue; } });
Object.defineProperty(exports, "getFieldTyping", { enumerable: true, get: function () { return legacy_gencommon_js_1.getFieldTyping; } });
Object.defineProperty(exports, "literalString", { enumerable: true, get: function () { return legacy_gencommon_js_1.literalString; } });
var legacy_custom_options_js_1 = require("./legacy-custom-options.js");
Object.defineProperty(exports, "findCustomScalarOption", { enumerable: true, get: function () { return legacy_custom_options_js_1.findCustomScalarOption; } });
Object.defineProperty(exports, "findCustomMessageOption", { enumerable: true, get: function () { return legacy_custom_options_js_1.findCustomMessageOption; } });
Object.defineProperty(exports, "findCustomEnumOption", { enumerable: true, get: function () { return legacy_custom_options_js_1.findCustomEnumOption; } });
/**
* @deprecated Please use GeneratedFile.string() instead
*/
function literalString(value) {
return (0, gencommon_js_1.literalString)(value);
}
exports.literalString = literalString;
/**
* @deprecated Please use GeneratedFile.jsDoc() instead

@@ -44,0 +37,0 @@ */

import type { AnyDesc, DescFile } from "@bufbuild/protobuf";
export type JSDocBlock = {
readonly kind: "es_jsdoc";
/**
* @deprecated In a future release, we will make this property optional.
*/
text: string;
indentation?: string;
/**
* @deprecated In a future release, we will remove this method.
*/
toString(): string;
};
export declare function createJsDocBlock(textOrDesc: string | Exclude<AnyDesc, DescFile>, indentation?: string): JSDocBlock;

@@ -17,2 +17,3 @@ "use strict";

exports.createJsDocBlock = void 0;
// TODO simplify type JSDocBlock to bring it in line with others in opaque-printables.ts
function createJsDocBlock(textOrDesc, indentation) {

@@ -19,0 +20,0 @@ const text = typeof textOrDesc == "string" ? textOrDesc : createTextForDesc(textOrDesc);

@@ -6,3 +6,3 @@ import type { CodeGeneratorRequest, DescFile } from "@bufbuild/protobuf";

import type { Target } from "./target.js";
import { ParsedParameter } from "./parameter";
import { ParsedParameter } from "./parameter.js";
/**

@@ -9,0 +9,0 @@ * Schema describes the files and types that the plugin is requested to

@@ -22,3 +22,3 @@ "use strict";

const import_path_js_1 = require("./import-path.js");
const gencommon_1 = require("./gencommon");
const file_preamble_js_1 = require("./file-preamble.js");
function createSchema(request, parameter, pluginName, pluginVersion, featureSetDefaults) {

@@ -35,3 +35,3 @@ const descriptorSet = (0, protobuf_1.createDescriptorSet)(request.protoFile, {

};
const createPreamble = (descFile) => (0, gencommon_1.makeFilePreamble)(descFile, pluginName, pluginVersion, parameter.sanitizedParameter, parameter.tsNocheck);
const createPreamble = (descFile) => (0, file_preamble_js_1.makeFilePreamble)(descFile, pluginName, pluginVersion, parameter.sanitizedParameter, parameter.tsNocheck);
let target;

@@ -38,0 +38,0 @@ const generatedFiles = [];

export declare class PluginOptionError extends Error {
name: string;
constructor(option: string, reason?: unknown);
}
export declare function reasonToString(reason: unknown): string;
export declare function isPluginOptionError(arg: unknown): arg is PluginOptionError;

@@ -16,3 +16,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.reasonToString = exports.PluginOptionError = void 0;
exports.isPluginOptionError = exports.reasonToString = exports.PluginOptionError = void 0;
class PluginOptionError extends Error {

@@ -24,2 +24,3 @@ constructor(option, reason) {

: `invalid option "${option}"`);
this.name = "PluginOptionError";
}

@@ -38,1 +39,8 @@ }

exports.reasonToString = reasonToString;
function isPluginOptionError(arg) {
if (!(arg instanceof Error)) {
return false;
}
return arg.name === "PluginOptionError";
}
exports.isPluginOptionError = isPluginOptionError;

@@ -49,3 +49,3 @@ "use strict";

.catch((reason) => {
const message = reason instanceof error_js_1.PluginOptionError
const message = (0, error_js_1.isPluginOptionError)(reason)
? reason.message

@@ -52,0 +52,0 @@ : (0, error_js_1.reasonToString)(reason);

@@ -1,10 +0,10 @@

import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage } from "@bufbuild/protobuf";
import { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage } from "@bufbuild/protobuf";
import type { ImportSymbol } from "./import-symbol.js";
import type { RuntimeImports } from "./runtime-imports.js";
import type { ExportDeclaration } from "./export-declaration.js";
import type { JSDocBlock } from "./jsdoc.js";
import { ExportDeclaration, LiteralProtoInt64, LiteralString, RefDescEnum, RefDescMessage } from "./opaque-printables.js";
/**
* All types that can be passed to GeneratedFile.print()
*/
export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | DescMessage | DescEnum | DescExtension | Printable[];
export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | LiteralString | LiteralProtoInt64 | RefDescMessage | RefDescEnum | DescMessage | DescEnum | DescExtension | Printable[];
/**

@@ -11,0 +11,0 @@ * FileInfo represents an intermediate type using for transpiling TypeScript internally.

@@ -14,6 +14,5 @@ // Copyright 2021-2024 Buf Technologies, Inc.

// limitations under the License.
import { LongType, protoInt64, ScalarType, } from "@bufbuild/protobuf";
import { createImportSymbol } from "./import-symbol.js";
import { literalString } from "./gencommon.js";
import { makeImportPathRelative } from "./import-path.js";
import { createExportDeclaration } from "./export-declaration.js";
import { createJsDocBlock } from "./jsdoc.js";

@@ -48,6 +47,11 @@ export function createGeneratedFile(name, importPath, jsImportStyle, rewriteImportPath, createTypeImport, runtimeImports, createPreamble) {

exportDecl(declaration, name) {
return createExportDeclaration(declaration, name);
return {
kind: "es_export_decl",
declaration,
name,
};
},
string(string) {
return literalString(string);
// We do not use LiteralString, which was added later, to maintain backwards compatibility
return escapeString(string);
},

@@ -88,3 +92,3 @@ jsDoc(textOrDesc, indentation) {

const what = `{ ${p.join(", ")} }`;
c.push(`const ${what} = require(${literalString(from)});\n`);
c.push(`const ${what} = require(${escapeString(from)});\n`);
}

@@ -95,6 +99,6 @@ else {

if (typeOnly) {
c.push(`import type ${what} from ${literalString(from)};\n`);
c.push(`import type ${what} from ${escapeString(from)};\n`);
}
else {
c.push(`import ${what} from ${literalString(from)};\n`);
c.push(`import ${what} from ${escapeString(from)};\n`);
}

@@ -156,3 +160,3 @@ }

case "number":
el.push(...literalNumber(p, runtimeImports));
elNumber(el, p, runtimeImports);
break;

@@ -163,7 +167,7 @@ case "boolean":

case "bigint":
el.push(...literalBigint(p, runtimeImports));
elBigint(el, p, runtimeImports);
break;
case "object":
if (p instanceof Uint8Array) {
el.push(literalUint8Array(p));
elUint8Array(el, p);
break;

@@ -178,2 +182,8 @@ }

break;
case "es_string":
el.push(escapeString(p.value));
break;
case "es_proto_int64":
elProtoInt64(el, p, runtimeImports);
break;
case "es_export_decl":

@@ -188,2 +198,8 @@ el.push({

break;
case "es_ref_message":
case "es_ref_enum":
el.push(p.typeOnly
? createTypeImport(p.type).toTypeOnly()
: createTypeImport(p.type));
break;
case "message":

@@ -318,30 +334,31 @@ case "extension":

}
function literalNumber(value, runtimeImports) {
function elBigint(el, value, runtimeImports) {
if (value == protoInt64.zero) {
// Loose comparison will match between 0n and 0.
el.push(runtimeImports.protoInt64, ".zero");
}
else {
el.push(runtimeImports.protoInt64, value > 0 ? ".uParse(" : ".parse(", escapeString(value.toString()), ")");
}
}
function elNumber(el, value, runtimeImports) {
if (Number.isNaN(value)) {
return [runtimeImports.protoDouble, ".NaN"];
el.push(runtimeImports.protoDouble, ".NaN");
}
if (value === Number.POSITIVE_INFINITY) {
return [runtimeImports.protoDouble, ".POSITIVE_INFINITY"];
else if (value === Number.POSITIVE_INFINITY) {
el.push(runtimeImports.protoDouble, ".POSITIVE_INFINITY");
}
if (value === Number.NEGATIVE_INFINITY) {
return [runtimeImports.protoDouble, ".NEGATIVE_INFINITY"];
else if (value === Number.NEGATIVE_INFINITY) {
el.push(runtimeImports.protoDouble, ".NEGATIVE_INFINITY");
}
return value.toString(10);
}
function literalBigint(value, runtimeImports) {
// Loose comparison will match between 0n and 0.
if (value == 0) {
return [runtimeImports.protoInt64, ".zero"];
else {
el.push(value.toString(10));
}
return [
runtimeImports.protoInt64,
value > 0 ? ".uParse(" : ".parse(",
literalString(value.toString()),
")",
];
}
function literalUint8Array(value) {
function elUint8Array(el, value) {
if (value.length === 0) {
return "new Uint8Array(0)";
el.push("new Uint8Array(0)");
return;
}
el.push("new Uint8Array([");
const strings = [];

@@ -351,3 +368,45 @@ for (const n of value) {

}
return `new Uint8Array([${strings.join(", ")}])`;
el.push(strings.join(", "));
el.push("])");
}
function elProtoInt64(el, literal, runtimeImports) {
switch (literal.longType) {
case LongType.STRING:
el.push(escapeString(literal.value.toString()));
break;
case LongType.BIGINT:
if (literal.value == protoInt64.zero) {
// Loose comparison will match between 0n and 0.
el.push(runtimeImports.protoInt64, ".zero");
break;
}
switch (literal.type) {
case ScalarType.UINT64:
case ScalarType.FIXED64:
el.push(runtimeImports.protoInt64);
el.push(".uParse(");
el.push(escapeString(literal.value.toString()));
el.push(")");
break;
default:
el.push(runtimeImports.protoInt64);
el.push(".parse(");
el.push(escapeString(literal.value.toString()));
el.push(")");
break;
}
}
}
function escapeString(value) {
return ('"' +
value
.split("\\")
.join("\\\\")
.split('"')
.join('\\"')
.split("\r")
.join("\\r")
.split("\n")
.join("\\n") +
'"');
}

@@ -11,9 +11,5 @@ import { AnyDesc, DescExtension, DescFile } from "@bufbuild/protobuf";

export declare const localName: (desc: import("@bufbuild/protobuf").DescEnum | import("@bufbuild/protobuf").DescMessage | import("@bufbuild/protobuf").DescService | DescExtension | import("@bufbuild/protobuf").DescEnumValue | import("@bufbuild/protobuf").DescField | import("@bufbuild/protobuf").DescOneof | import("@bufbuild/protobuf").DescMethod) => string;
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, } from "./gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, literalString, } from "./legacy-gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./legacy-custom-options.js";
/**
* @deprecated Please use GeneratedFile.string() instead
*/
export declare function literalString(value: string): string;
/**
* @deprecated Please use GeneratedFile.jsDoc() instead

@@ -20,0 +16,0 @@ */

@@ -16,15 +16,8 @@ // Copyright 2021-2024 Buf Technologies, Inc.

import { createJsDocBlock as createJsDocBlockInternal } from "./jsdoc.js";
import { literalString as literalStringInternal } from "./gencommon.js";
export { reifyWkt } from "./reify-wkt.js";
export { createImportSymbol } from "./import-symbol.js";
export const { localName } = codegenInfo;
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, } from "./gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, literalString, } from "./legacy-gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./legacy-custom-options.js";
/**
* @deprecated Please use GeneratedFile.string() instead
*/
export function literalString(value) {
return literalStringInternal(value);
}
/**
* @deprecated Please use GeneratedFile.jsDoc() instead

@@ -31,0 +24,0 @@ */

import type { AnyDesc, DescFile } from "@bufbuild/protobuf";
export type JSDocBlock = {
readonly kind: "es_jsdoc";
/**
* @deprecated In a future release, we will make this property optional.
*/
text: string;
indentation?: string;
/**
* @deprecated In a future release, we will remove this method.
*/
toString(): string;
};
export declare function createJsDocBlock(textOrDesc: string | Exclude<AnyDesc, DescFile>, indentation?: string): JSDocBlock;

@@ -14,2 +14,3 @@ // Copyright 2021-2024 Buf Technologies, Inc.

// limitations under the License.
// TODO simplify type JSDocBlock to bring it in line with others in opaque-printables.ts
export function createJsDocBlock(textOrDesc, indentation) {

@@ -16,0 +17,0 @@ const text = typeof textOrDesc == "string" ? textOrDesc : createTextForDesc(textOrDesc);

@@ -6,3 +6,3 @@ import type { CodeGeneratorRequest, DescFile } from "@bufbuild/protobuf";

import type { Target } from "./target.js";
import { ParsedParameter } from "./parameter";
import { ParsedParameter } from "./parameter.js";
/**

@@ -9,0 +9,0 @@ * Schema describes the files and types that the plugin is requested to

@@ -19,3 +19,3 @@ // Copyright 2021-2024 Buf Technologies, Inc.

import { deriveImportPath, makeImportPath, rewriteImportPath, } from "./import-path.js";
import { makeFilePreamble } from "./gencommon";
import { makeFilePreamble } from "./file-preamble.js";
export function createSchema(request, parameter, pluginName, pluginVersion, featureSetDefaults) {

@@ -22,0 +22,0 @@ const descriptorSet = createDescriptorSet(request.protoFile, {

export declare class PluginOptionError extends Error {
name: string;
constructor(option: string, reason?: unknown);
}
export declare function reasonToString(reason: unknown): string;
export declare function isPluginOptionError(arg: unknown): arg is PluginOptionError;

@@ -20,2 +20,3 @@ // Copyright 2021-2024 Buf Technologies, Inc.

: `invalid option "${option}"`);
this.name = "PluginOptionError";
}

@@ -32,1 +33,7 @@ }

}
export function isPluginOptionError(arg) {
if (!(arg instanceof Error)) {
return false;
}
return arg.name === "PluginOptionError";
}

@@ -15,3 +15,3 @@ // Copyright 2021-2024 Buf Technologies, Inc.

import { CodeGeneratorRequest } from "@bufbuild/protobuf";
import { PluginOptionError, reasonToString } from "./error.js";
import { isPluginOptionError, reasonToString } from "./error.js";
/**

@@ -47,3 +47,3 @@ * Run a plugin with Node.js.

.catch((reason) => {
const message = reason instanceof PluginOptionError
const message = isPluginOptionError(reason)
? reason.message

@@ -50,0 +50,0 @@ : reasonToString(reason);

{
"name": "@bufbuild/protoplugin",
"version": "1.7.2",
"version": "1.8.0",
"license": "(Apache-2.0 AND BSD-3-Clause)",

@@ -13,6 +13,5 @@ "description": "Helps to create your own Protocol Buffers code generators.",

"clean": "rm -rf ./dist/*",
"build": "npm run build:cjs && npm run build:esm && npm run build:proxy",
"build": "npm run build:cjs && npm run build:esm",
"build:cjs": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs --declaration --declarationDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm": "../../node_modules/typescript/bin/tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/esm",
"build:proxy": "node ../../scripts/gen-esm-proxy.mjs . ecmascript",
"attw": "attw --pack"

@@ -25,7 +24,2 @@ },

".": {
"node": {
"import": "./dist/proxy/index.js",
"require": "./dist/cjs/index.js"
},
"module": "./dist/esm/index.js",
"import": "./dist/esm/index.js",

@@ -35,7 +29,2 @@ "require": "./dist/cjs/index.js"

"./ecmascript": {
"node": {
"import": "./dist/proxy/ecmascript/index.js",
"require": "./dist/cjs/ecmascript/index.js"
},
"module": "./dist/esm/ecmascript/index.js",
"import": "./dist/esm/ecmascript/index.js",

@@ -53,3 +42,3 @@ "require": "./dist/cjs/ecmascript/index.js"

"dependencies": {
"@bufbuild/protobuf": "1.7.2",
"@bufbuild/protobuf": "1.8.0",
"@typescript/vfs": "^1.4.0",

@@ -56,0 +45,0 @@ "typescript": "4.5.2"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc