@bufbuild/protoplugin
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -51,3 +51,3 @@ "use strict"; | ||
if (tsNoCheck) { | ||
builder.push("/* @ts-nocheck */\n"); | ||
builder.push("// @ts-nocheck\n"); | ||
} | ||
@@ -54,0 +54,0 @@ builder.push("\n"); |
@@ -27,4 +27,17 @@ "use strict"; | ||
}, | ||
print(...any) { | ||
printableToEl(any, el, createTypeImport, runtimeImports); | ||
print(printableOrFragments, ...rest) { | ||
let printables; | ||
if (printableOrFragments != null && | ||
Object.prototype.hasOwnProperty.call(printableOrFragments, "raw")) { | ||
// If called with a tagged template literal | ||
printables = buildPrintablesFromFragments(printableOrFragments, rest); | ||
} | ||
else { | ||
// If called with just an array of Printables | ||
printables = | ||
printableOrFragments != null | ||
? [printableOrFragments, ...rest] | ||
: rest; | ||
} | ||
printableToEl(printables, el, createTypeImport, runtimeImports); | ||
el.push("\n"); | ||
@@ -60,3 +73,3 @@ }, | ||
const p = names.map(({ name, alias }) => alias == undefined ? name : `${name} as ${alias}`); | ||
const what = `{${p.join(", ")}}`; | ||
const what = `{ ${p.join(", ")} }`; | ||
if (typeOnly) { | ||
@@ -124,2 +137,12 @@ c.push(`import type ${what} from ${(0, gencommon_js_1.literalString)(from)};\n`); | ||
} | ||
function buildPrintablesFromFragments(fragments, values) { | ||
const printables = []; | ||
fragments.forEach((fragment, i) => { | ||
printables.push(fragment); | ||
if (fragments.length - 1 !== i) { | ||
printables.push(values[i]); | ||
} | ||
}); | ||
return printables; | ||
} | ||
function processImports(el, importerPath, makeImportStatement) { | ||
@@ -126,0 +149,0 @@ // identifiers to use in the output |
@@ -39,2 +39,3 @@ "use strict"; | ||
MethodIdempotency: infoToSymbol("MethodIdempotency", bootstrapWkt), | ||
IMessageTypeRegistry: infoToSymbol("IMessageTypeRegistry", bootstrapWkt), | ||
}; | ||
@@ -41,0 +42,0 @@ } |
@@ -48,3 +48,3 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
if (tsNoCheck) { | ||
builder.push("/* @ts-nocheck */\n"); | ||
builder.push("// @ts-nocheck\n"); | ||
} | ||
@@ -51,0 +51,0 @@ builder.push("\n"); |
@@ -24,4 +24,17 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
}, | ||
print(...any) { | ||
printableToEl(any, el, createTypeImport, runtimeImports); | ||
print(printableOrFragments, ...rest) { | ||
let printables; | ||
if (printableOrFragments != null && | ||
Object.prototype.hasOwnProperty.call(printableOrFragments, "raw")) { | ||
// If called with a tagged template literal | ||
printables = buildPrintablesFromFragments(printableOrFragments, rest); | ||
} | ||
else { | ||
// If called with just an array of Printables | ||
printables = | ||
printableOrFragments != null | ||
? [printableOrFragments, ...rest] | ||
: rest; | ||
} | ||
printableToEl(printables, el, createTypeImport, runtimeImports); | ||
el.push("\n"); | ||
@@ -56,3 +69,3 @@ }, | ||
const p = names.map(({ name, alias }) => alias == undefined ? name : `${name} as ${alias}`); | ||
const what = `{${p.join(", ")}}`; | ||
const what = `{ ${p.join(", ")} }`; | ||
if (typeOnly) { | ||
@@ -120,2 +133,12 @@ c.push(`import type ${what} from ${literalString(from)};\n`); | ||
} | ||
function buildPrintablesFromFragments(fragments, values) { | ||
const printables = []; | ||
fragments.forEach((fragment, i) => { | ||
printables.push(fragment); | ||
if (fragments.length - 1 !== i) { | ||
printables.push(values[i]); | ||
} | ||
}); | ||
return printables; | ||
} | ||
function processImports(el, importerPath, makeImportStatement) { | ||
@@ -122,0 +145,0 @@ // identifiers to use in the output |
@@ -36,2 +36,3 @@ // Copyright 2021-2022 Buf Technologies, Inc. | ||
MethodIdempotency: infoToSymbol("MethodIdempotency", bootstrapWkt), | ||
IMessageTypeRegistry: infoToSymbol("IMessageTypeRegistry", bootstrapWkt), | ||
}; | ||
@@ -38,0 +39,0 @@ } |
@@ -39,4 +39,10 @@ import type { DescEnum, DescFile, DescMessage } from "@bufbuild/protobuf"; | ||
*/ | ||
print(...any: Printable[]): void; | ||
print(...printables: Printable[]): void; | ||
/** | ||
* Add a line of code to the file with tagged template literal and | ||
* an optional array of Printables. | ||
* See print(Printable[]) for behavior when printing Printable items. | ||
*/ | ||
print(fragments: TemplateStringsArray, ...printables: Printable[]): void; | ||
/** | ||
* Reserves an identifier in this file. | ||
@@ -43,0 +49,0 @@ */ |
@@ -20,3 +20,4 @@ import type { ImportSymbol } from "./import-symbol.js"; | ||
MethodIdempotency: ImportSymbol; | ||
IMessageTypeRegistry: ImportSymbol; | ||
} | ||
export declare function createRuntimeImports(bootstrapWkt: boolean): RuntimeImports; |
{ | ||
"name": "@bufbuild/protoplugin", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"license": "(Apache-2.0 AND BSD-3-Clause)", | ||
@@ -38,3 +38,3 @@ "description": "Helps to create your own Protocol Buffers code generators.", | ||
"dependencies": { | ||
"@bufbuild/protobuf": "0.2.1", | ||
"@bufbuild/protobuf": "0.3.0", | ||
"@typescript/vfs": "^1.4.0", | ||
@@ -41,0 +41,0 @@ "typescript": "4.5.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136815
3470
+ Added@bufbuild/protobuf@0.3.0(transitive)
- Removed@bufbuild/protobuf@0.2.1(transitive)
Updated@bufbuild/protobuf@0.3.0