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,31 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsEnum = void 0;
exports.enumDesc = enumDesc;
var enum_js_1 = require("../codegenv2/enum.js");
Object.defineProperty(exports, "tsEnum", { enumerable: true, get: function () { return enum_js_1.tsEnum; } });
/**
* Hydrate an enum descriptor.
*
* @private
*/
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,28 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.extDesc = extDesc;
/**
* Hydrate an extension descriptor.
*
* @private
*/
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,18 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.fileDesc = void 0;
var file_js_1 = require("../codegenv2/file.js");
Object.defineProperty(exports, "fileDesc", { enumerable: true, get: function () { return file_js_1.fileDesc; } });

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,39 @@
"use strict";
// 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.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("../codegenv2/boot.js"), exports);
__exportStar(require("../codegenv2/embed.js"), exports);
__exportStar(require("./enum.js"), exports);
__exportStar(require("./extension.js"), exports);
__exportStar(require("./file.js"), exports);
__exportStar(require("./message.js"), exports);
__exportStar(require("./service.js"), exports);
__exportStar(require("./symbols.js"), exports);
__exportStar(require("../codegenv2/scalar.js"), exports);
__exportStar(require("./types.js"), exports);

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,24 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageDesc = messageDesc;
/**
* Hydrate a message descriptor.
*
* @private
*/
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,27 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.serviceDesc = serviceDesc;
/**
* Hydrate a service descriptor.
*
* @private
*/
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,43 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.symbols = exports.wktPublicImportPaths = exports.packageName = void 0;
const symbols_js_1 = require("../codegenv2/symbols.js");
/**
* @private
*/
exports.packageName = symbols_js_1.packageName;
/**
* @private
*/
exports.wktPublicImportPaths = symbols_js_1.wktPublicImportPaths;
/**
* @private
*/
// biome-ignore format: want this to read well
exports.symbols = Object.assign(Object.assign({}, symbols_js_1.symbols), { codegen: {
boot: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/boot.js", from: exports.packageName + "/codegenv1" },
fileDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/file.js", from: exports.packageName + "/codegenv1" },
enumDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/enum.js", from: exports.packageName + "/codegenv1" },
extDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/extension.js", from: exports.packageName + "/codegenv1" },
messageDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/message.js", from: exports.packageName + "/codegenv1" },
serviceDesc: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/service.js", from: exports.packageName + "/codegenv1" },
tsEnum: { typeOnly: false, bootstrapWktFrom: "../../codegenv1/enum.js", from: exports.packageName + "/codegenv1" },
GenFile: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: exports.packageName + "/codegenv1" },
GenEnum: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: exports.packageName + "/codegenv1" },
GenExtension: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: exports.packageName + "/codegenv1" },
GenMessage: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: exports.packageName + "/codegenv1" },
GenService: { typeOnly: true, bootstrapWktFrom: "../../codegenv1/types.js", from: exports.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,22 @@
"use strict";
// 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.
Object.defineProperty(exports, "__esModule", { value: true });
class brandv1 {
constructor() {
this.v = "codegenv1";
this.a = false;
this.b = false;
}
}