rearrage_stuff

This commit is contained in:
Kim Ravn Hansen
2025-09-16 11:26:40 +02:00
parent 40e8c5e0ab
commit 3f11ebe6dc
4937 changed files with 1146031 additions and 134 deletions

View File

@@ -0,0 +1,10 @@
import type { DescFile } from "../descriptors.js";
import type { GenEnum } from "./types.js";
import type { JsonValue } from "../json-value.js";
export { tsEnum } from "../codegenv2/enum.js";
/**
* Hydrate an enum descriptor.
*
* @private
*/
export declare function enumDesc<Shape extends number, JsonType extends JsonValue = JsonValue>(file: DescFile, path: number, ...paths: number[]): GenEnum<Shape, JsonType>;

View File

@@ -0,0 +1,26 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export { tsEnum } from "../codegenv2/enum.js";
/**
* Hydrate an enum descriptor.
*
* @private
*/
export function enumDesc(file, path, ...paths) {
if (paths.length == 0) {
return file.enums[path];
}
const e = paths.pop(); // we checked length above
return paths.reduce((acc, cur) => acc.nestedMessages[cur], file.messages[path]).nestedEnums[e];
}

View File

@@ -0,0 +1,9 @@
import type { Message } from "../types.js";
import type { DescFile } from "../descriptors.js";
import type { GenExtension } from "./types.js";
/**
* Hydrate an extension descriptor.
*
* @private
*/
export declare function extDesc<Extendee extends Message, Value>(file: DescFile, path: number, ...paths: number[]): GenExtension<Extendee, Value>;

View File

@@ -0,0 +1,25 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Hydrate an extension descriptor.
*
* @private
*/
export function extDesc(file, path, ...paths) {
if (paths.length == 0) {
return file.extensions[path];
}
const e = paths.pop(); // we checked length above
return paths.reduce((acc, cur) => acc.nestedMessages[cur], file.messages[path]).nestedExtensions[e];
}

View File

@@ -0,0 +1 @@
export { fileDesc } from "../codegenv2/file.js";

View File

@@ -0,0 +1,14 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export { fileDesc } from "../codegenv2/file.js";

View File

@@ -0,0 +1,10 @@
export * from "../codegenv2/boot.js";
export * from "../codegenv2/embed.js";
export * from "./enum.js";
export * from "./extension.js";
export * from "./file.js";
export * from "./message.js";
export * from "./service.js";
export * from "./symbols.js";
export * from "../codegenv2/scalar.js";
export * from "./types.js";

View File

@@ -0,0 +1,23 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export * from "../codegenv2/boot.js";
export * from "../codegenv2/embed.js";
export * from "./enum.js";
export * from "./extension.js";
export * from "./file.js";
export * from "./message.js";
export * from "./service.js";
export * from "./symbols.js";
export * from "../codegenv2/scalar.js";
export * from "./types.js";

View File

@@ -0,0 +1,10 @@
import type { Message } from "../types.js";
import type { DescFile } from "../descriptors.js";
import type { GenMessage } from "./types.js";
import type { JsonValue } from "../json-value.js";
/**
* Hydrate a message descriptor.
*
* @private
*/
export declare function messageDesc<Shape extends Message, JsonType extends JsonValue = JsonValue>(file: DescFile, path: number, ...paths: number[]): GenMessage<Shape, JsonType>;

View File

@@ -0,0 +1,21 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Hydrate a message descriptor.
*
* @private
*/
export function messageDesc(file, path, ...paths) {
return paths.reduce((acc, cur) => acc.nestedMessages[cur], file.messages[path]);
}

View File

@@ -0,0 +1,8 @@
import type { GenService, GenServiceMethods } from "./types.js";
import type { DescFile } from "../descriptors.js";
/**
* Hydrate a service descriptor.
*
* @private
*/
export declare function serviceDesc<T extends GenServiceMethods>(file: DescFile, path: number, ...paths: number[]): GenService<T>;

View File

@@ -0,0 +1,24 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Hydrate a service descriptor.
*
* @private
*/
export function serviceDesc(file, path, ...paths) {
if (paths.length > 0) {
throw new Error();
}
return file.services[path];
}

View File

@@ -0,0 +1,135 @@
/**
* @private
*/
export declare const packageName = "@bufbuild/protobuf";
/**
* @private
*/
export declare const wktPublicImportPaths: Readonly<Record<string, string>>;
/**
* @private
*/
export declare const symbols: {
readonly codegen: {
readonly boot: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/boot.js";
readonly from: string;
};
readonly fileDesc: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/file.js";
readonly from: string;
};
readonly enumDesc: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/enum.js";
readonly from: string;
};
readonly extDesc: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/extension.js";
readonly from: string;
};
readonly messageDesc: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/message.js";
readonly from: string;
};
readonly serviceDesc: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/service.js";
readonly from: string;
};
readonly tsEnum: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../codegenv1/enum.js";
readonly from: string;
};
readonly GenFile: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../codegenv1/types.js";
readonly from: string;
};
readonly GenEnum: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../codegenv1/types.js";
readonly from: string;
};
readonly GenExtension: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../codegenv1/types.js";
readonly from: string;
};
readonly GenMessage: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../codegenv1/types.js";
readonly from: string;
};
readonly GenService: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../codegenv1/types.js";
readonly from: string;
};
};
readonly isMessage: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../is-message.js";
readonly from: "@bufbuild/protobuf";
};
readonly Message: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../types.js";
readonly from: "@bufbuild/protobuf";
};
readonly create: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../create.js";
readonly from: "@bufbuild/protobuf";
};
readonly fromJson: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../from-json.js";
readonly from: "@bufbuild/protobuf";
};
readonly fromJsonString: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../from-json.js";
readonly from: "@bufbuild/protobuf";
};
readonly fromBinary: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../from-binary.js";
readonly from: "@bufbuild/protobuf";
};
readonly toBinary: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../to-binary.js";
readonly from: "@bufbuild/protobuf";
};
readonly toJson: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../to-json.js";
readonly from: "@bufbuild/protobuf";
};
readonly toJsonString: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../to-json.js";
readonly from: "@bufbuild/protobuf";
};
readonly protoInt64: {
readonly typeOnly: false;
readonly bootstrapWktFrom: "../../proto-int64.js";
readonly from: "@bufbuild/protobuf";
};
readonly JsonValue: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../json-value.js";
readonly from: "@bufbuild/protobuf";
};
readonly JsonObject: {
readonly typeOnly: true;
readonly bootstrapWktFrom: "../../json-value.js";
readonly from: "@bufbuild/protobuf";
};
};

View File

@@ -0,0 +1,40 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { symbols as symbolsV2, packageName as packageNameV1, wktPublicImportPaths as wktPublicImportPathsV2, } from "../codegenv2/symbols.js";
/**
* @private
*/
export const packageName = packageNameV1;
/**
* @private
*/
export const wktPublicImportPaths = wktPublicImportPathsV2;
/**
* @private
*/
// biome-ignore format: want this to read well
export const symbols = Object.assign(Object.assign({}, symbolsV2), { codegen: {
boot: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/boot.js", from: packageName + "/codegenv1" },
fileDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/file.js", from: packageName + "/codegenv1" },
enumDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/enum.js", from: packageName + "/codegenv1" },
extDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/extension.js", from: packageName + "/codegenv1" },
messageDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/message.js", from: packageName + "/codegenv1" },
serviceDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/service.js", from: packageName + "/codegenv1" },
tsEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/enum.js", from: packageName + "/codegenv1" },
GenFile: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: packageName + "/codegenv1" },
GenEnum: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: packageName + "/codegenv1" },
GenExtension: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: packageName + "/codegenv1" },
GenMessage: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: packageName + "/codegenv1" },
GenService: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: packageName + "/codegenv1" },
} });

View File

@@ -0,0 +1,75 @@
import type { Message } from "../types.js";
import type { DescEnum, DescEnumValue, DescExtension, DescField, DescFile, DescMessage, DescMethod, DescService } from "../descriptors.js";
import type { JsonValue } from "../json-value.js";
/**
* Describes a protobuf source file.
*
* @private
*/
export type GenFile = DescFile;
/**
* Describes a message declaration in a protobuf source file.
*
* This type is identical to DescMessage, but carries additional type
* information.
*
* @private
*/
export type GenMessage<RuntimeShape extends Message, JsonType = JsonValue> = Omit<DescMessage, "field" | "typeName"> & {
field: Record<MessageFieldNames<RuntimeShape>, DescField>;
typeName: RuntimeShape["$typeName"];
} & brandv1<RuntimeShape, JsonType>;
/**
* Describes an enumeration in a protobuf source file.
*
* This type is identical to DescEnum, but carries additional type
* information.
*
* @private
*/
export type GenEnum<RuntimeShape extends number, JsonType extends JsonValue = JsonValue> = Omit<DescEnum, "value"> & {
value: Record<RuntimeShape, DescEnumValue>;
} & brandv1<RuntimeShape, JsonType>;
/**
* Describes an extension in a protobuf source file.
*
* This type is identical to DescExtension, but carries additional type
* information.
*
* @private
*/
export type GenExtension<Extendee extends Message = Message, RuntimeShape = unknown> = DescExtension & brandv1<Extendee, RuntimeShape>;
/**
* Describes a service declaration in a protobuf source file.
*
* This type is identical to DescService, but carries additional type
* information.
*
* @private
*/
export type GenService<RuntimeShape extends GenServiceMethods> = Omit<DescService, "method"> & {
method: {
[K in keyof RuntimeShape]: RuntimeShape[K] & DescMethod;
};
};
/**
* @private
*/
export type GenServiceMethods = Record<string, Pick<DescMethod, "input" | "output" | "methodKind">>;
declare class brandv1<A, B = unknown> {
protected v: "codegenv1";
protected a: A | boolean;
protected b: B | boolean;
}
/**
* Union of the property names of all fields, including oneof members.
* For an anonymous message (no generated message shape), it's simply a string.
*/
type MessageFieldNames<T extends Message> = Message extends T ? string : Exclude<keyof {
[P in keyof T as P extends ("$typeName" | "$unknown") ? never : T[P] extends Oneof<infer K> ? K : P]-?: true;
}, number | symbol>;
type Oneof<K extends string> = {
case: K | undefined;
value?: unknown;
};
export {};

View File

@@ -0,0 +1,21 @@
// Copyright 2021-2025 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
class brandv1 {
constructor() {
this.v = "codegenv1";
this.a = false;
this.b = false;
}
}
export {};