protoscript
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -648,3 +648,3 @@ import { processTypes } from "../utils.js"; | ||
IMPORT_TRACKER = { ...DEFAULT_IMPORT_TRACKER }; | ||
const { imports, types } = processTypes(fileDescriptorProto, identifierTable, config.isTS); | ||
const { imports, types } = processTypes(fileDescriptorProto, identifierTable); | ||
const sourceFile = fileDescriptorProto.getName(); | ||
@@ -651,0 +651,0 @@ if (!sourceFile) { |
@@ -95,3 +95,3 @@ import type { CodeGeneratorRequest } from "google-protobuf/google/protobuf/compiler/plugin_pb.js"; | ||
} | ||
export declare function processTypes(fileDescriptorProto: FileDescriptorProto, identifierTable: IdentifierTable, isTypescript: boolean): TypeFile; | ||
export declare function processTypes(fileDescriptorProto: FileDescriptorProto, identifierTable: IdentifierTable): TypeFile; | ||
export {}; |
@@ -277,8 +277,2 @@ import { dirname, relative } from "path"; | ||
} | ||
function stripTSExtension(filename) { | ||
return filename.replace(".ts", ""); | ||
} | ||
function stripJSExtension(filename) { | ||
return filename.replace(".js", ""); | ||
} | ||
export function getProtobufTSFileName(protoFileName) { | ||
@@ -392,9 +386,7 @@ return stripProtoExtension(protoFileName) + ".pb.ts"; | ||
} | ||
function getImportForIdentifier(identifier, identifiers, fileDescriptorProto, isTypescript) { | ||
function getImportForIdentifier(identifier, identifiers, fileDescriptorProto) { | ||
const dep = getIdentifierEntryFromTable(identifier, identifiers, fileDescriptorProto); | ||
const sourceFile = fileDescriptorProto.getName() ?? ""; | ||
const dependencyImportPath = dep.publicImport ?? dep.file; | ||
const importPath = isTypescript | ||
? stripTSExtension(relative(dirname(sourceFile), getProtobufTSFileName(dependencyImportPath))) | ||
: stripJSExtension(relative(dirname(sourceFile), getProtobufJSFileName(dependencyImportPath))); | ||
const importPath = relative(dirname(sourceFile), getProtobufJSFileName(dependencyImportPath)); | ||
const path = getImportPath(importPath); | ||
@@ -423,3 +415,3 @@ const dependencyIdentifier = identifier.split(".").pop() ?? ""; | ||
} | ||
export function processTypes(fileDescriptorProto, identifierTable, isTypescript) { | ||
export function processTypes(fileDescriptorProto, identifierTable) { | ||
const typeFile = { | ||
@@ -432,3 +424,3 @@ packageName: fileDescriptorProto.getPackage(), | ||
function addIdentiferToImports(identifier) { | ||
const _import = getImportForIdentifier(identifier, identifierTable, fileDescriptorProto, isTypescript); | ||
const _import = getImportForIdentifier(identifier, identifierTable, fileDescriptorProto); | ||
const exisitingImport = typeFile.imports.find(({ path }) => path === _import.path); | ||
@@ -435,0 +427,0 @@ if (exisitingImport) { |
{ | ||
"name": "protoscript", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A Protobuf runtime and code generation tool for JavaScript and TypeScript", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -34,3 +34,3 @@ # ProtoScript | ||
2. Code generation. This a replacement of `protoc`'s JavaScript generation that generates idiomatic JavaScript code, JSON serializers/deserializers, and includes TSDoc comments. | ||
2. Code generation. This is a replacement of `protoc`'s JavaScript generation that generates idiomatic JavaScript code, JSON serializers/deserializers, and includes TSDoc comments. | ||
@@ -37,0 +37,0 @@ If you're looking for an RPC framework, you may be interested in [TwirpScript](https://github.com/tatethurston/TwirpScript). |
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
397624
10751