@snap/camera-kit
Version:
Camera Kit Web
254 lines • 10.7 kB
JavaScript
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "google.api";
function createBaseHttp() {
return { rules: [], fullyDecodeReservedExpansion: false };
}
export const Http = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.rules) {
HttpRule.encode(v, writer.uint32(10).fork()).join();
}
if (message.fullyDecodeReservedExpansion !== false) {
writer.uint32(16).bool(message.fullyDecodeReservedExpansion);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseHttp();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.rules.push(HttpRule.decode(reader, reader.uint32()));
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.fullyDecodeReservedExpansion = reader.bool();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
create(base) {
return Http.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseHttp();
message.rules = ((_a = object.rules) === null || _a === void 0 ? void 0 : _a.map((e) => HttpRule.fromPartial(e))) || [];
message.fullyDecodeReservedExpansion = (_b = object.fullyDecodeReservedExpansion) !== null && _b !== void 0 ? _b : false;
return message;
},
};
function createBaseHttpRule() {
return { selector: "", pattern: undefined, body: "", additionalBindings: [] };
}
export const HttpRule = {
encode(message, writer = new BinaryWriter()) {
var _a;
if (message.selector !== "") {
writer.uint32(10).string(message.selector);
}
switch ((_a = message.pattern) === null || _a === void 0 ? void 0 : _a.$case) {
case "get":
writer.uint32(18).string(message.pattern.get);
break;
case "put":
writer.uint32(26).string(message.pattern.put);
break;
case "post":
writer.uint32(34).string(message.pattern.post);
break;
case "delete":
writer.uint32(42).string(message.pattern.delete);
break;
case "patch":
writer.uint32(50).string(message.pattern.patch);
break;
case "custom":
CustomHttpPattern.encode(message.pattern.custom, writer.uint32(66).fork()).join();
break;
}
if (message.body !== "") {
writer.uint32(58).string(message.body);
}
for (const v of message.additionalBindings) {
HttpRule.encode(v, writer.uint32(90).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseHttpRule();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.selector = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.pattern = { $case: "get", get: reader.string() };
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.pattern = { $case: "put", put: reader.string() };
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.pattern = { $case: "post", post: reader.string() };
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.pattern = { $case: "delete", delete: reader.string() };
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.pattern = { $case: "patch", patch: reader.string() };
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.pattern = { $case: "custom", custom: CustomHttpPattern.decode(reader, reader.uint32()) };
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.body = reader.string();
continue;
}
case 11: {
if (tag !== 90) {
break;
}
message.additionalBindings.push(HttpRule.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
create(base) {
return HttpRule.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
const message = createBaseHttpRule();
message.selector = (_a = object.selector) !== null && _a !== void 0 ? _a : "";
if (((_b = object.pattern) === null || _b === void 0 ? void 0 : _b.$case) === "get" && ((_c = object.pattern) === null || _c === void 0 ? void 0 : _c.get) !== undefined && ((_d = object.pattern) === null || _d === void 0 ? void 0 : _d.get) !== null) {
message.pattern = { $case: "get", get: object.pattern.get };
}
if (((_e = object.pattern) === null || _e === void 0 ? void 0 : _e.$case) === "put" && ((_f = object.pattern) === null || _f === void 0 ? void 0 : _f.put) !== undefined && ((_g = object.pattern) === null || _g === void 0 ? void 0 : _g.put) !== null) {
message.pattern = { $case: "put", put: object.pattern.put };
}
if (((_h = object.pattern) === null || _h === void 0 ? void 0 : _h.$case) === "post" && ((_j = object.pattern) === null || _j === void 0 ? void 0 : _j.post) !== undefined && ((_k = object.pattern) === null || _k === void 0 ? void 0 : _k.post) !== null) {
message.pattern = { $case: "post", post: object.pattern.post };
}
if (((_l = object.pattern) === null || _l === void 0 ? void 0 : _l.$case) === "delete" && ((_m = object.pattern) === null || _m === void 0 ? void 0 : _m.delete) !== undefined && ((_o = object.pattern) === null || _o === void 0 ? void 0 : _o.delete) !== null) {
message.pattern = { $case: "delete", delete: object.pattern.delete };
}
if (((_p = object.pattern) === null || _p === void 0 ? void 0 : _p.$case) === "patch" && ((_q = object.pattern) === null || _q === void 0 ? void 0 : _q.patch) !== undefined && ((_r = object.pattern) === null || _r === void 0 ? void 0 : _r.patch) !== null) {
message.pattern = { $case: "patch", patch: object.pattern.patch };
}
if (((_s = object.pattern) === null || _s === void 0 ? void 0 : _s.$case) === "custom" && ((_t = object.pattern) === null || _t === void 0 ? void 0 : _t.custom) !== undefined && ((_u = object.pattern) === null || _u === void 0 ? void 0 : _u.custom) !== null) {
message.pattern = { $case: "custom", custom: CustomHttpPattern.fromPartial(object.pattern.custom) };
}
message.body = (_v = object.body) !== null && _v !== void 0 ? _v : "";
message.additionalBindings = ((_w = object.additionalBindings) === null || _w === void 0 ? void 0 : _w.map((e) => HttpRule.fromPartial(e))) || [];
return message;
},
};
function createBaseCustomHttpPattern() {
return { kind: "", path: "" };
}
export const CustomHttpPattern = {
encode(message, writer = new BinaryWriter()) {
if (message.kind !== "") {
writer.uint32(10).string(message.kind);
}
if (message.path !== "") {
writer.uint32(18).string(message.path);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCustomHttpPattern();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.kind = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.path = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
create(base) {
return CustomHttpPattern.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseCustomHttpPattern();
message.kind = (_a = object.kind) !== null && _a !== void 0 ? _a : "";
message.path = (_b = object.path) !== null && _b !== void 0 ? _b : "";
return message;
},
};
//# sourceMappingURL=http.js.map