@powerlines/deepkit 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +31 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  3. package/dist/capnp.cjs +955 -46
  4. package/dist/capnp.d.cts +41 -41
  5. package/dist/capnp.d.mts +41 -41
  6. package/dist/capnp.mjs +911 -2
  7. package/dist/esbuild-plugin.cjs +47 -2
  8. package/dist/esbuild-plugin.d.cts +1 -1
  9. package/dist/esbuild-plugin.d.mts +1 -1
  10. package/dist/esbuild-plugin.mjs +47 -2
  11. package/dist/index.cjs +3 -4
  12. package/dist/index.mjs +3 -4
  13. package/dist/{capnp-BLCHrDSY.cjs → packages/deepkit/schemas/reflection.cjs} +3 -1180
  14. package/dist/{reflection-Bhe75GyI.d.mts → packages/deepkit/schemas/reflection.d.cts} +2 -2
  15. package/dist/{reflection-DGOuMF8F.d.cts → packages/deepkit/schemas/reflection.d.mts} +2 -2
  16. package/dist/{capnp-BqAglxrS.mjs → packages/deepkit/schemas/reflection.mjs} +2 -910
  17. package/dist/reflect-type.cjs +5 -5
  18. package/dist/reflect-type.d.cts +1 -1
  19. package/dist/reflect-type.d.mts +1 -1
  20. package/dist/reflect-type.mjs +2 -2
  21. package/dist/resolve-reflections.cjs +1 -1
  22. package/dist/rolldown-plugin.cjs +1 -1
  23. package/dist/transformer.cjs +6 -5
  24. package/dist/transformer.d.cts +1 -1
  25. package/dist/transformer.d.mts +1 -1
  26. package/dist/transformer.mjs +2 -1
  27. package/dist/transpile.cjs +2 -2
  28. package/dist/transpile.d.cts +1 -1
  29. package/dist/transpile.d.mts +1 -1
  30. package/dist/types.d.cts +3 -3
  31. package/dist/types.d.mts +3 -3
  32. package/dist/utilities.cjs +116 -8
  33. package/dist/utilities.d.cts +1 -1
  34. package/dist/utilities.d.mts +1 -1
  35. package/dist/utilities.mjs +110 -2
  36. package/dist/{compiler-B-zwyGQf.d.cts → vendor/compiler-BYhFaVxE.d.mts} +3 -3
  37. package/dist/{compiler-DTp8Jvav.cjs → vendor/compiler-Ci5aO9pY.cjs} +2 -2
  38. package/dist/{compiler-BUUdv7wG.mjs → vendor/compiler-CqkzeoNX.mjs} +3 -3
  39. package/dist/{compiler-BzOZmhWO.d.mts → vendor/compiler-Dz2b4nOM.d.cts} +3 -3
  40. package/dist/{config-B2hS4_tR.d.mts → vendor/config-BTErH18l.d.mts} +1 -1
  41. package/dist/{config-DCmu3CV2.d.cts → vendor/config-Cc2qE8fH.d.cts} +1 -1
  42. package/dist/{config-CuXC21KA.mjs → vendor/config-eSNKiBGB.mjs} +1 -1
  43. package/dist/vendor/core.cjs +1 -1
  44. package/dist/vendor/core.d.cts +1 -1
  45. package/dist/vendor/core.d.mts +1 -1
  46. package/dist/vendor/core.mjs +1 -1
  47. package/dist/{string-CjkshhTG.mjs → vendor/string-DoT35ViA.mjs} +1 -1
  48. package/dist/{type-DfwJ6GTs.d.mts → vendor/type-2yMJb9Mw.d.cts} +1 -1
  49. package/dist/{type-DR66Hepn.d.cts → vendor/type-BoBEcrg7.d.mts} +1 -1
  50. package/dist/vendor/type-compiler/compiler.cjs +1 -1
  51. package/dist/vendor/type-compiler/compiler.d.cts +1 -1
  52. package/dist/vendor/type-compiler/compiler.d.mts +1 -1
  53. package/dist/vendor/type-compiler/compiler.mjs +1 -1
  54. package/dist/vendor/type-compiler/config.cjs +1 -1
  55. package/dist/vendor/type-compiler/config.d.cts +1 -1
  56. package/dist/vendor/type-compiler/config.d.mts +1 -1
  57. package/dist/vendor/type-compiler/config.mjs +1 -1
  58. package/dist/vendor/type-compiler/index.cjs +3 -3
  59. package/dist/vendor/type-compiler/index.d.cts +2 -2
  60. package/dist/vendor/type-compiler/index.d.mts +2 -2
  61. package/dist/vendor/type-compiler/index.mjs +2 -2
  62. package/dist/vendor/type-spec.cjs +1 -1
  63. package/dist/vendor/type-spec.d.cts +1 -1
  64. package/dist/vendor/type-spec.d.mts +1 -1
  65. package/dist/vendor/type-spec.mjs +1 -1
  66. package/dist/{type-BWm74eaQ.mjs → vendor/type-wscUl8NW.mjs} +1 -1
  67. package/dist/vendor/type.cjs +9375 -268
  68. package/dist/vendor/type.d.cts +2969 -3
  69. package/dist/vendor/type.d.mts +2969 -3
  70. package/dist/vendor/type.mjs +9109 -3
  71. package/dist/{types-BO3PJV5p.d.mts → vendor/types-BwPWMe3m.d.mts} +1 -1
  72. package/dist/{types-Bb6lL3KL.d.cts → vendor/types-exLGvFgG.d.cts} +1 -1
  73. package/package.json +13 -21
  74. package/dist/config-C0OHvihx.d.mts +0 -1
  75. package/dist/config-GPeRZeGl.d.cts +0 -1
  76. package/dist/esbuild-plugin-BUYqx8_5.cjs +0 -80
  77. package/dist/esbuild-plugin-CRQUmm86.mjs +0 -75
  78. package/dist/type-8AL5U7vn.d.cts +0 -2969
  79. package/dist/type-BDuj5wg2.d.mts +0 -2969
  80. package/dist/type-C7UXbXfx.cjs +0 -10688
  81. package/dist/type-ma8o4dJG.mjs +0 -9110
  82. package/dist/utilities-CT_jcB5h.mjs +0 -1483
  83. package/dist/utilities-Dr3TzxMb.cjs +0 -1523
  84. /package/dist/{chunk-BmvPcxpV.cjs → vendor/chunk-BmvPcxpV.cjs} +0 -0
  85. /package/dist/{chunk-CgI6uo-e.mjs → vendor/chunk-CgI6uo-e.mjs} +0 -0
  86. /package/dist/{config-GVyELKY1.cjs → vendor/config-BbFVGRVh.cjs} +0 -0
  87. /package/dist/{string-CpVz34Gv.cjs → vendor/string-LTCnMzW_.cjs} +0 -0
  88. /package/dist/{type-DhqntM0q.cjs → vendor/type-fEQrgtBF.cjs} +0 -0
@@ -1,5 +1,3 @@
1
- import { vn as ReflectionKind, yn as ReflectionVisibility$1 } from "./type-ma8o4dJG.mjs";
2
- import { isInteger, isSetObject, isUndefined } from "@stryke/type-checks";
3
1
  import * as $ from "@stryke/capnp";
4
2
 
5
3
  //#region schemas/reflection.ts
@@ -3995,911 +3993,5 @@ SerializedTypeTemplateLiteral._Types = $.CompositeList(SerializedTypeReference);
3995
3993
  SerializedTypes._Types = $.CompositeList(SerializedType);
3996
3994
 
3997
3995
  //#endregion
3998
- //#region src/capnp.ts
3999
- /**
4000
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4001
- *
4002
- * @param serializedTypes - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4003
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4004
- */
4005
- function convertToCapnp(serializedTypes, result) {
4006
- if (!serializedTypes || !Array.isArray(serializedTypes) || serializedTypes.length === 0) throw new Error("Invalid serialized type provided for conversion.");
4007
- if (serializedTypes.length !== result.length) throw new Error(`Mismatch in length of serialized types: expected ${result.length}, got ${serializedTypes.length}.`);
4008
- serializedTypes.filter((serializedType) => isSetObject(serializedType) && !isUndefined(serializedType.kind)).forEach((serializedType, index) => {
4009
- convertToCapnpBase(serializedType, result.get(index)._initType());
4010
- });
4011
- return result;
4012
- }
4013
- /**
4014
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4015
- *
4016
- * @param serializedTypes - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema
4017
- * @returns The [Deepkit](https://deepkit.io/) {@link SerializedTypes | serialized types} converted from the Cap'n Proto serialized type
4018
- */
4019
- function convertFromCapnp(serializedTypes) {
4020
- if (!serializedTypes) throw new Error("Invalid serialized type provided for conversion.");
4021
- const result = [];
4022
- serializedTypes.forEach((serializedType) => {
4023
- const deserializedType = convertFromCapnpBase(serializedType.type);
4024
- result.push(deserializedType);
4025
- });
4026
- return result;
4027
- }
4028
- /**
4029
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4030
- *
4031
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4032
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4033
- */
4034
- function convertToCapnpTagsReflection(result, serializedType) {
4035
- if (serializedType?.alias?.length) {
4036
- const alias = result._initAlias(serializedType.alias.length);
4037
- serializedType.alias.forEach((a, index) => {
4038
- alias.set(index, a);
4039
- });
4040
- }
4041
- result.hidden = serializedType?.hidden ?? false;
4042
- result.ignore = serializedType?.ignore ?? false;
4043
- result.internal = serializedType?.internal ?? false;
4044
- result.readonly = serializedType?.readonly ?? false;
4045
- if (serializedType?.title) result.title = serializedType?.title;
4046
- if (serializedType?.domain) result.domain = serializedType?.domain;
4047
- if (serializedType?.permission?.length) {
4048
- const permission = result._initPermission(serializedType.permission.length);
4049
- serializedType.permission?.forEach((p, index) => {
4050
- permission.set(index, p);
4051
- });
4052
- }
4053
- return result;
4054
- }
4055
- function convertFromCapnpTagsReflection(serializedType) {
4056
- return serializedType._hasTags() ? {
4057
- alias: serializedType.tags?.alias?.length ? serializedType.tags?.alias.map((value) => value) : void 0,
4058
- hidden: serializedType.tags?.hidden,
4059
- domain: serializedType.tags?.domain ? serializedType.tags.domain : void 0,
4060
- title: serializedType.tags?.title ? serializedType.tags.title : void 0,
4061
- ignore: serializedType.tags?.ignore,
4062
- internal: serializedType.tags?.internal,
4063
- readonly: serializedType.tags?.readonly,
4064
- permission: serializedType.tags?.permission?.length ? serializedType.tags?.permission?.map((value) => value) : void 0
4065
- } : void 0;
4066
- }
4067
- /**
4068
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4069
- *
4070
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4071
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4072
- */
4073
- function convertToCapnpIndexAccessOrigin(result, serializedType) {
4074
- const indexAccessOriginIndex = result._initIndex();
4075
- indexAccessOriginIndex.id = serializedType?.index ?? 0;
4076
- const indexAccessOriginContainer = result._initContainer();
4077
- indexAccessOriginContainer.id = serializedType?.container ?? 0;
4078
- return result;
4079
- }
4080
- function convertFromCapnpIndexAccessOrigin(serializedType) {
4081
- return serializedType._hasIndexAccessOrigin() ? {
4082
- container: Number(serializedType.indexAccessOrigin?.container.id),
4083
- index: Number(serializedType.indexAccessOrigin?.index.id)
4084
- } : void 0;
4085
- }
4086
- /**
4087
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4088
- *
4089
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4090
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4091
- */
4092
- function convertToCapnpBase(serializedType, result) {
4093
- if (serializedType.kind === ReflectionKind.objectLiteral) convertToCapnpObjectLiteral(serializedType, result._initObjectLiteral());
4094
- else if (serializedType.kind === ReflectionKind.class) convertToCapnpClassType(serializedType, result._initClassType());
4095
- else if (serializedType.kind === ReflectionKind.parameter) convertToCapnpParameter(serializedType, result._initParameter());
4096
- else if (serializedType.kind === ReflectionKind.function) convertToCapnpFunction(serializedType, result._initFunction());
4097
- else if (serializedType.kind === ReflectionKind.method) convertToCapnpMethod(serializedType, result._initMethod());
4098
- else if (serializedType.kind === ReflectionKind.infer) convertToCapnpInfer(serializedType, result._initInfer());
4099
- else if (serializedType.kind === ReflectionKind.union) convertToCapnpUnion(serializedType, result._initUnion());
4100
- else if (serializedType.kind === ReflectionKind.array) convertToCapnpArray(serializedType, result._initArray());
4101
- else if (serializedType.kind === ReflectionKind.intersection) convertToCapnpIntersection(serializedType, result._initIntersection());
4102
- else if (serializedType.kind === ReflectionKind.enum) convertToCapnpEnum(serializedType, result._initEnum());
4103
- else if (serializedType.kind === ReflectionKind.property) convertToCapnpProperty(serializedType, result._initProperty());
4104
- else if (serializedType.kind === ReflectionKind.tuple) convertToCapnpTuple(serializedType, result._initTuple());
4105
- else if (serializedType.kind === ReflectionKind.tupleMember) convertToCapnpTupleMember(serializedType, result._initTupleMember());
4106
- else if (serializedType.kind === ReflectionKind.propertySignature) convertToCapnpPropertySignature(serializedType, result._initPropertySignature());
4107
- else if (serializedType.kind === ReflectionKind.methodSignature) convertToCapnpMethodSignature(serializedType, result._initMethodSignature());
4108
- else if (serializedType.kind === ReflectionKind.literal) convertToCapnpLiteral(serializedType, result._initLiteral());
4109
- else if (serializedType.kind === ReflectionKind.never || serializedType.kind === ReflectionKind.any || serializedType.kind === ReflectionKind.unknown || serializedType.kind === ReflectionKind.void || serializedType.kind === ReflectionKind.object || serializedType.kind === ReflectionKind.string || serializedType.kind === ReflectionKind.number || serializedType.kind === ReflectionKind.boolean || serializedType.kind === ReflectionKind.symbol || serializedType.kind === ReflectionKind.bigint || serializedType.kind === ReflectionKind.null || serializedType.kind === ReflectionKind.undefined || serializedType.kind === ReflectionKind.regexp) convertToCapnpSimple(serializedType, result._initSimple());
4110
- else convertToCapnpOther(serializedType, result._initOther());
4111
- return result;
4112
- }
4113
- function convertFromCapnpBase(serializedType) {
4114
- if (serializedType._isObjectLiteral) return convertFromCapnpObjectLiteral(serializedType.objectLiteral);
4115
- else if (serializedType._isClassType) return convertFromCapnpClassType(serializedType.classType);
4116
- else if (serializedType._isParameter) return convertFromCapnpParameter(serializedType.parameter);
4117
- else if (serializedType._isFunction) return convertFromCapnpFunction(serializedType.function);
4118
- else if (serializedType._isInfer) return convertFromCapnpInfer(serializedType.infer);
4119
- else if (serializedType._isMethod) return convertFromCapnpMethod(serializedType.method);
4120
- else if (serializedType._isUnion) return convertFromCapnpUnion(serializedType.union);
4121
- else if (serializedType._isArray) return convertFromCapnpArray(serializedType.array);
4122
- else if (serializedType._isIntersection) return convertFromCapnpIntersection(serializedType.intersection);
4123
- else if (serializedType._isEnum) return convertFromCapnpEnum(serializedType.enum);
4124
- else if (serializedType._isProperty) return convertFromCapnpProperty(serializedType.property);
4125
- else if (serializedType._isTuple) return convertFromCapnpTuple(serializedType.tuple);
4126
- else if (serializedType._isTupleMember) return convertFromCapnpTupleMember(serializedType.tupleMember);
4127
- else if (serializedType._isPropertySignature) return convertFromCapnpPropertySignature(serializedType.propertySignature);
4128
- else if (serializedType._isMethodSignature) return convertFromCapnpMethodSignature(serializedType.methodSignature);
4129
- else if (serializedType._isLiteral) return convertFromCapnpLiteral(serializedType.literal);
4130
- else if (serializedType._isSimple) return convertFromCapnpSimple(serializedType.simple);
4131
- else if (serializedType._isOther) return convertFromCapnpOther(serializedType.other);
4132
- else throw new Error(`Unsupported serialized type kind: ${serializedType.toString()}`);
4133
- }
4134
- function convertFromCapnpOther(serializedType) {
4135
- return {
4136
- kind: serializedType.kind,
4137
- typeName: serializedType.typeName || void 0
4138
- };
4139
- }
4140
- function convertFromCapnpSimple(serializedType) {
4141
- const result = {
4142
- kind: serializedType.kind,
4143
- typeName: serializedType.typeName || void 0,
4144
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4145
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4146
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4147
- };
4148
- if (serializedType._hasOrigin()) result.origin = Number(serializedType.origin.id);
4149
- return result;
4150
- }
4151
- function convertToCapnpOther(serializedType, result) {
4152
- result.kind = serializedType.kind;
4153
- result.typeName = serializedType.typeName || "";
4154
- return result;
4155
- }
4156
- function convertToCapnpSimple(serializedType, result) {
4157
- result.kind = serializedType.kind;
4158
- result.typeName = serializedType.typeName || "";
4159
- if (serializedType.origin) {
4160
- result._initOrigin();
4161
- result.origin.id = serializedType.origin ?? 0;
4162
- }
4163
- if (serializedType.decorators?.length) {
4164
- const decorators = result._initDecorators(serializedType.decorators.length);
4165
- serializedType.decorators.forEach((d, index) => {
4166
- const decorator = decorators.get(index);
4167
- decorator.id = d;
4168
- });
4169
- }
4170
- if (serializedType.typeArguments?.length) {
4171
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4172
- serializedType.typeArguments.forEach((t, index) => {
4173
- const typeArgument = typeArguments.get(index);
4174
- typeArgument.id = t;
4175
- });
4176
- }
4177
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4178
- return result;
4179
- }
4180
- function convertFromCapnpLiteral(serializedType) {
4181
- return {
4182
- kind: ReflectionKind.literal,
4183
- literal: serializedType.literal._isString ? serializedType.literal.string : serializedType.literal._isNumber ? serializedType.literal.number : serializedType.literal._isBoolean ? serializedType.literal.boolean : serializedType.literal._isBigint ? {
4184
- type: "bigint",
4185
- value: serializedType.literal.bigint.value
4186
- } : serializedType.literal._isSymbol ? {
4187
- type: "symbol",
4188
- name: serializedType.literal.symbol.name
4189
- } : {
4190
- type: "regex",
4191
- regex: serializedType.literal.regex.regex
4192
- },
4193
- typeName: serializedType.typeName || void 0,
4194
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4195
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4196
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4197
- };
4198
- }
4199
- function convertToCapnpLiteral(serializedType, result) {
4200
- result.kind = serializedType.kind;
4201
- result.typeName = serializedType.typeName || "";
4202
- const literalType = result._initLiteral();
4203
- if (typeof serializedType.literal === "boolean") literalType.boolean = serializedType.literal;
4204
- else if (typeof serializedType.literal === "number") literalType.number = serializedType.literal;
4205
- else if (typeof serializedType.literal === "string") literalType.string = serializedType.literal;
4206
- else if (serializedType.literal.type === "bigint") {
4207
- const literalTypeBigint = literalType._initBigint();
4208
- literalTypeBigint.type = "bigint";
4209
- literalTypeBigint.value = serializedType.literal.value;
4210
- } else if (serializedType.literal.type === "symbol") {
4211
- const literalTypeSymbol = literalType._initSymbol();
4212
- literalTypeSymbol.type = "symbol";
4213
- literalTypeSymbol.name = serializedType.literal.name.toString().slice(7, -1);
4214
- } else if (serializedType.literal.type === "regex") {
4215
- const literalTypeRegex = literalType._initRegex();
4216
- literalTypeRegex.type = "regex";
4217
- literalTypeRegex.regex = serializedType.literal.regex;
4218
- }
4219
- if (serializedType.decorators?.length) {
4220
- const decorators = result._initDecorators(serializedType.decorators.length);
4221
- serializedType.decorators.forEach((d, index) => {
4222
- const decorator = decorators.get(index);
4223
- decorator.id = d;
4224
- });
4225
- }
4226
- if (serializedType.typeArguments?.length) {
4227
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4228
- serializedType.typeArguments.forEach((t, index) => {
4229
- const typeArgument = typeArguments.get(index);
4230
- typeArgument.id = t;
4231
- });
4232
- }
4233
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4234
- return result;
4235
- }
4236
- function convertFromCapnpMethodSignature(serializedType) {
4237
- return {
4238
- kind: ReflectionKind.methodSignature,
4239
- name: serializedType.name,
4240
- typeName: serializedType.typeName || void 0,
4241
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4242
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
4243
- return: serializedType.return.id,
4244
- tags: convertFromCapnpTagsReflection(serializedType)
4245
- };
4246
- }
4247
- function convertToCapnpMethodSignature(serializedType, result) {
4248
- result.kind = serializedType.kind;
4249
- result.name = String(serializedType.name);
4250
- result.typeName = serializedType.typeName || "";
4251
- if (serializedType.decorators?.length) {
4252
- const decorators = result._initDecorators(serializedType.decorators.length);
4253
- serializedType.decorators.forEach((d, index) => {
4254
- const decorator = decorators.get(index);
4255
- decorator.id = d;
4256
- });
4257
- }
4258
- if (serializedType.typeArguments?.length) {
4259
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4260
- serializedType.typeArguments.forEach((t, index) => {
4261
- const typeArgument = typeArguments.get(index);
4262
- typeArgument.id = t;
4263
- });
4264
- }
4265
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4266
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4267
- return result;
4268
- }
4269
- function convertFromCapnpPropertySignature(serializedType) {
4270
- return {
4271
- kind: ReflectionKind.propertySignature,
4272
- name: serializedType.name,
4273
- typeName: serializedType.typeName || void 0,
4274
- description: serializedType.description,
4275
- default: convertFromCapnpDefault(serializedType.default),
4276
- optional: serializedType.optional ? true : void 0,
4277
- readonly: serializedType.readonly ? true : void 0,
4278
- type: serializedType.type.id,
4279
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4280
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4281
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4282
- tags: convertFromCapnpTagsReflection(serializedType)
4283
- };
4284
- }
4285
- function convertToCapnpDefault(defaultValue, result) {
4286
- if (typeof defaultValue !== "undefined" && defaultValue !== "") {
4287
- result._initValue();
4288
- if (typeof defaultValue === "string") result.value.string = defaultValue;
4289
- else if (typeof defaultValue === "number") if (isInteger(defaultValue)) result.value.integer = defaultValue;
4290
- else result.value.float = defaultValue;
4291
- else if (typeof defaultValue === "boolean") result.value.boolean = defaultValue;
4292
- }
4293
- }
4294
- function convertFromCapnpDefault(serializedType) {
4295
- if (typeof serializedType.value === "undefined") return;
4296
- else if (serializedType.value._isBoolean) return serializedType.value.boolean;
4297
- else if (serializedType.value._isInteger) return serializedType.value.integer;
4298
- else if (serializedType.value._isFloat) return serializedType.value.float;
4299
- else if (serializedType.value._isString) return serializedType.value.string;
4300
- }
4301
- function convertToCapnpPropertySignature(serializedType, result) {
4302
- result.kind = serializedType.kind;
4303
- result.name = String(serializedType.name) || "";
4304
- result.typeName = serializedType.typeName || "";
4305
- result.description = serializedType.description || "";
4306
- result.optional = serializedType.optional ?? false;
4307
- result.readonly = serializedType.readonly ?? false;
4308
- if (typeof serializedType.default !== "undefined") {
4309
- const defaultValue = result._initDefault();
4310
- convertToCapnpDefault(serializedType.default, defaultValue);
4311
- }
4312
- const type = result._initType();
4313
- type.id = serializedType.type;
4314
- if (serializedType.decorators?.length) {
4315
- const decorators = result._initDecorators(serializedType.decorators.length);
4316
- serializedType.decorators.forEach((d, index) => {
4317
- const decorator = decorators.get(index);
4318
- decorator.id = d;
4319
- });
4320
- }
4321
- if (serializedType.typeArguments?.length) {
4322
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4323
- serializedType.typeArguments.forEach((t, index) => {
4324
- const typeArgument = typeArguments.get(index);
4325
- typeArgument.id = t;
4326
- });
4327
- }
4328
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4329
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4330
- return result;
4331
- }
4332
- function convertToCapnpTupleMember(serializedType, result) {
4333
- result.kind = serializedType.kind;
4334
- result.typeName = serializedType.typeName || "";
4335
- const type = result._initType();
4336
- type.id = serializedType.type;
4337
- if (serializedType.decorators?.length) {
4338
- const decorators = result._initDecorators(serializedType.decorators.length);
4339
- serializedType.decorators.forEach((d, index) => {
4340
- const decorator = decorators.get(index);
4341
- decorator.id = d;
4342
- });
4343
- }
4344
- if (serializedType.typeArguments?.length) {
4345
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4346
- serializedType.typeArguments.forEach((t, index) => {
4347
- const typeArgument = typeArguments.get(index);
4348
- typeArgument.id = t;
4349
- });
4350
- }
4351
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4352
- return result;
4353
- }
4354
- function convertFromCapnpTupleMember(serializedType) {
4355
- return {
4356
- kind: ReflectionKind.tupleMember,
4357
- type: serializedType.type.id,
4358
- typeName: serializedType.typeName || void 0,
4359
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4360
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4361
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4362
- };
4363
- }
4364
- function convertToCapnpTuple(serializedType, result) {
4365
- result.kind = serializedType.kind;
4366
- result.typeName = serializedType.typeName || "";
4367
- const types = result._initTypes(serializedType.types.length);
4368
- serializedType.types.forEach((t, index) => {
4369
- convertToCapnpTupleMember(t, types.get(index));
4370
- });
4371
- if (serializedType.decorators?.length) {
4372
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4373
- serializedType.decorators?.forEach((d, index) => {
4374
- const decorator = decorators.get(index);
4375
- decorator.id = d;
4376
- });
4377
- }
4378
- if (serializedType.typeArguments?.length) {
4379
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4380
- serializedType.typeArguments?.forEach((t, index) => {
4381
- const typeArgument = typeArguments.get(index);
4382
- typeArgument.id = t;
4383
- });
4384
- }
4385
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4386
- return result;
4387
- }
4388
- function convertFromCapnpTuple(serializedType) {
4389
- return {
4390
- kind: ReflectionKind.tuple,
4391
- typeName: serializedType.typeName || void 0,
4392
- types: serializedType._hasTypes() ? serializedType.types.map((t) => convertFromCapnpTupleMember(t)) : [],
4393
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4394
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4395
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4396
- };
4397
- }
4398
- function convertToCapnpProperty(serializedType, result) {
4399
- result.kind = serializedType.kind;
4400
- result.typeName = serializedType.typeName || "";
4401
- result.description = serializedType.description || "";
4402
- result.optional = serializedType.optional ?? false;
4403
- result.readonly = serializedType.readonly ?? false;
4404
- result.visibility = serializedType.visibility === ReflectionVisibility$1.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === ReflectionVisibility$1.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4405
- result.abstract = serializedType.abstract ?? false;
4406
- result.name = String(serializedType.name) || "";
4407
- if (typeof serializedType.default !== "undefined") {
4408
- const defaultValue = result._initDefault();
4409
- convertToCapnpDefault(serializedType.default, defaultValue);
4410
- }
4411
- const type = result._initType();
4412
- type.id = serializedType.type;
4413
- if (serializedType.decorators?.length) {
4414
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4415
- serializedType.decorators?.forEach((d, index) => {
4416
- const decorator = decorators.get(index);
4417
- decorator.id = d;
4418
- });
4419
- }
4420
- if (serializedType.typeArguments?.length) {
4421
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4422
- serializedType.typeArguments?.forEach((t, index) => {
4423
- const typeArgument = typeArguments.get(index);
4424
- typeArgument.id = t;
4425
- });
4426
- }
4427
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4428
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4429
- return result;
4430
- }
4431
- function convertFromCapnpProperty(serializedType) {
4432
- return {
4433
- kind: ReflectionKind.property,
4434
- typeName: serializedType.typeName || void 0,
4435
- description: serializedType.description,
4436
- default: convertFromCapnpDefault(serializedType.default),
4437
- optional: serializedType.optional ? true : void 0,
4438
- readonly: serializedType.readonly ? true : void 0,
4439
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? ReflectionVisibility$1.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? ReflectionVisibility$1.protected : ReflectionVisibility$1.private,
4440
- abstract: serializedType.abstract ? true : void 0,
4441
- name: serializedType.name,
4442
- type: serializedType.type.id,
4443
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4444
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4445
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4446
- tags: convertFromCapnpTagsReflection(serializedType)
4447
- };
4448
- }
4449
- function convertToCapnpEnum(serializedType, result) {
4450
- result.kind = serializedType.kind;
4451
- result.typeName = serializedType.typeName || "";
4452
- const indexType = result._initIndexType();
4453
- indexType.id = serializedType.indexType;
4454
- if (serializedType.decorators?.length) {
4455
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4456
- serializedType.decorators?.forEach((d, index) => {
4457
- const decorator = decorators.get(index);
4458
- decorator.id = d;
4459
- });
4460
- }
4461
- if (serializedType.typeArguments?.length) {
4462
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4463
- serializedType.typeArguments?.forEach((t, index) => {
4464
- const typeArgument = typeArguments.get(index);
4465
- typeArgument.id = t;
4466
- });
4467
- }
4468
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4469
- if (serializedType.values?.length) {
4470
- const values = result._initValues(serializedType.values?.length);
4471
- serializedType.values.forEach((value, index) => {
4472
- values.set(index, String(value));
4473
- });
4474
- }
4475
- const enumEntries = result._initEnumEntries(Object.keys(serializedType.enum).length ?? 0);
4476
- Object.entries(serializedType.enum).forEach(([key, value], index) => {
4477
- const enumEntry = enumEntries.get(index);
4478
- enumEntry.name = key;
4479
- enumEntry.value = String(value);
4480
- });
4481
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4482
- return result;
4483
- }
4484
- function convertFromCapnpEnum(serializedType) {
4485
- return {
4486
- kind: ReflectionKind.enum,
4487
- typeName: serializedType.typeName || void 0,
4488
- indexType: serializedType.indexType.id,
4489
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4490
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4491
- values: serializedType._hasValues() ? serializedType.values.map((value) => value) : [],
4492
- enum: serializedType._hasEnumEntries() ? Object.entries(serializedType.enumEntries).reduce((ret, [key, value]) => {
4493
- ret[key] = value.value;
4494
- return ret;
4495
- }, {}) : {},
4496
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4497
- tags: convertFromCapnpTagsReflection(serializedType)
4498
- };
4499
- }
4500
- function convertToCapnpIntersection(serializedType, result) {
4501
- result.kind = serializedType.kind;
4502
- result.typeName = serializedType.typeName || "";
4503
- const types = result._initTypes(serializedType.types?.length ?? 0);
4504
- serializedType.types?.forEach((t, index) => {
4505
- const serializedTypeType = types.get(index);
4506
- serializedTypeType.id = t;
4507
- });
4508
- if (serializedType.decorators?.length) {
4509
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4510
- serializedType.decorators?.forEach((d, index) => {
4511
- const decorator = decorators.get(index);
4512
- decorator.id = d;
4513
- });
4514
- }
4515
- if (serializedType.typeArguments?.length) {
4516
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4517
- serializedType.typeArguments?.forEach((t, index) => {
4518
- const typeArgument = typeArguments.get(index);
4519
- typeArgument.id = t;
4520
- });
4521
- }
4522
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4523
- return result;
4524
- }
4525
- function convertFromCapnpIntersection(serializedType) {
4526
- return {
4527
- kind: ReflectionKind.intersection,
4528
- typeName: serializedType.typeName || void 0,
4529
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4530
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4531
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4532
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4533
- };
4534
- }
4535
- function convertToCapnpArray(serializedType, result) {
4536
- result.kind = serializedType.kind;
4537
- result.typeName = serializedType.typeName || "";
4538
- const type = result._initType();
4539
- type.id = serializedType.type;
4540
- if (serializedType.decorators?.length) {
4541
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4542
- serializedType.decorators?.forEach((d, index) => {
4543
- const decorator = decorators.get(index);
4544
- decorator.id = d;
4545
- });
4546
- }
4547
- if (serializedType.typeArguments?.length) {
4548
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4549
- serializedType.typeArguments?.forEach((t, index) => {
4550
- const typeArgument = typeArguments.get(index);
4551
- typeArgument.id = t;
4552
- });
4553
- }
4554
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4555
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4556
- return result;
4557
- }
4558
- function convertFromCapnpArray(serializedType) {
4559
- return {
4560
- kind: ReflectionKind.array,
4561
- typeName: serializedType.typeName || void 0,
4562
- type: serializedType.type.id,
4563
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4564
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4565
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4566
- tags: convertFromCapnpTagsReflection(serializedType)
4567
- };
4568
- }
4569
- /**
4570
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4571
- *
4572
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4573
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4574
- */
4575
- function convertToCapnpUnion(serializedType, result) {
4576
- result.kind = serializedType.kind;
4577
- result.typeName = serializedType.typeName || "";
4578
- const types = result._initTypes(serializedType.types?.length ?? 0);
4579
- serializedType.types?.forEach((t, index) => {
4580
- const serializedTypeType = types.get(index);
4581
- serializedTypeType.id = t;
4582
- });
4583
- if (serializedType.decorators?.length) {
4584
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4585
- serializedType.decorators?.forEach((d, index) => {
4586
- const decorator = decorators.get(index);
4587
- decorator.id = d;
4588
- });
4589
- }
4590
- if (serializedType.typeArguments?.length) {
4591
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4592
- serializedType.typeArguments?.forEach((t, index) => {
4593
- const typeArgument = typeArguments.get(index);
4594
- typeArgument.id = t;
4595
- });
4596
- }
4597
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4598
- return result;
4599
- }
4600
- function convertFromCapnpUnion(serializedType) {
4601
- return {
4602
- kind: ReflectionKind.union,
4603
- typeName: serializedType.typeName || void 0,
4604
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4605
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4606
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4607
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4608
- };
4609
- }
4610
- /**
4611
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4612
- *
4613
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert.
4614
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4615
- */
4616
- function convertToCapnpInfer(serializedType, result) {
4617
- result.kind = serializedType.kind;
4618
- result.typeName = serializedType.typeName || "";
4619
- if (serializedType.decorators?.length) {
4620
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4621
- serializedType.decorators?.forEach((d, index) => {
4622
- const decorator = decorators.get(index);
4623
- decorator.id = d;
4624
- });
4625
- }
4626
- if (serializedType.typeArguments?.length) {
4627
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4628
- serializedType.typeArguments?.forEach((t, index) => {
4629
- const typeArgument = typeArguments.get(index);
4630
- typeArgument.id = t;
4631
- });
4632
- }
4633
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4634
- return result;
4635
- }
4636
- function convertFromCapnpInfer(serializedType) {
4637
- return {
4638
- kind: ReflectionKind.infer,
4639
- typeName: serializedType.typeName || void 0,
4640
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4641
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4642
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4643
- };
4644
- }
4645
- /**
4646
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4647
- *
4648
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4649
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4650
- */
4651
- function convertToCapnpFunction(serializedType, result) {
4652
- result.name = String(serializedType.name) || "";
4653
- result.kind = serializedType.kind;
4654
- result.typeName = serializedType.typeName || "";
4655
- if (serializedType.decorators?.length) {
4656
- const decorators = result._initDecorators(serializedType.decorators.length);
4657
- serializedType.decorators.forEach((d, index) => {
4658
- const decorator = decorators.get(index);
4659
- decorator.id = d;
4660
- });
4661
- }
4662
- if (serializedType.typeArguments?.length) {
4663
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4664
- serializedType.typeArguments.forEach((t, index) => {
4665
- const typeArgument = typeArguments.get(index);
4666
- typeArgument.id = t;
4667
- });
4668
- }
4669
- if (serializedType.parameters?.length) {
4670
- const parameters = result._initParameters(serializedType.parameters.length);
4671
- serializedType.parameters.forEach((p, index) => {
4672
- convertToCapnpParameter(p, parameters.get(index));
4673
- });
4674
- }
4675
- const returnType = result._initReturn();
4676
- returnType.id = serializedType.return;
4677
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4678
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4679
- return result;
4680
- }
4681
- /**
4682
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4683
- *
4684
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4685
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4686
- */
4687
- function convertToCapnpMethod(serializedType, result) {
4688
- result.name = String(serializedType.name) || "";
4689
- result.kind = serializedType.kind;
4690
- result.typeName = serializedType.typeName || "";
4691
- result.abstract = serializedType.abstract ?? false;
4692
- result.visibility = serializedType.visibility === ReflectionVisibility$1.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === ReflectionVisibility$1.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4693
- if (serializedType.decorators?.length) {
4694
- const decorators = result._initDecorators(serializedType.decorators.length);
4695
- serializedType.decorators.forEach((d, index) => {
4696
- const decorator = decorators.get(index);
4697
- decorator.id = d;
4698
- });
4699
- }
4700
- if (serializedType.typeArguments?.length) {
4701
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4702
- serializedType.typeArguments.forEach((t, index) => {
4703
- const typeArgument = typeArguments.get(index);
4704
- typeArgument.id = t;
4705
- });
4706
- }
4707
- if (serializedType.parameters?.length) {
4708
- const parameters = result._initParameters(serializedType.parameters.length);
4709
- serializedType.parameters.forEach((p, index) => {
4710
- convertToCapnpParameter(p, parameters.get(index));
4711
- });
4712
- }
4713
- const returnType = result._initReturn();
4714
- returnType.id = serializedType.return;
4715
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4716
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4717
- return result;
4718
- }
4719
- function convertFromCapnpFunction(serializedType) {
4720
- return {
4721
- kind: ReflectionKind.function,
4722
- name: serializedType.name,
4723
- typeName: serializedType.typeName || void 0,
4724
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4725
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4726
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
4727
- return: serializedType.return.id,
4728
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4729
- tags: convertFromCapnpTagsReflection(serializedType)
4730
- };
4731
- }
4732
- function convertFromCapnpMethod(serializedType) {
4733
- return {
4734
- kind: ReflectionKind.method,
4735
- name: serializedType.name,
4736
- typeName: serializedType.typeName || void 0,
4737
- abstract: serializedType.abstract ? true : void 0,
4738
- return: serializedType.return.id,
4739
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? ReflectionVisibility$1.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? ReflectionVisibility$1.protected : ReflectionVisibility$1.private,
4740
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((parameter) => convertFromCapnpParameter(parameter)) : []
4741
- };
4742
- }
4743
- /**
4744
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4745
- *
4746
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4747
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4748
- */
4749
- function convertToCapnpClassType(serializedType, result) {
4750
- result.kind = serializedType.kind;
4751
- result.typeName = serializedType.typeName || "";
4752
- result.classType = serializedType.classType || "";
4753
- result.globalObject = serializedType.globalObject ?? false;
4754
- if (serializedType.arguments?.length) {
4755
- const _arguments = result._initArguments(serializedType.arguments.length);
4756
- serializedType.arguments.forEach((t, index) => {
4757
- const serializedTypeArguments = _arguments.get(index);
4758
- serializedTypeArguments.id = t;
4759
- });
4760
- }
4761
- if (serializedType.extendsArguments?.length) {
4762
- const extendsArguments = result._initArguments(serializedType.extendsArguments.length);
4763
- serializedType.extendsArguments.forEach((t, index) => {
4764
- const serializedTypeExtendsArguments = extendsArguments.get(index);
4765
- serializedTypeExtendsArguments.id = t;
4766
- });
4767
- }
4768
- if (serializedType.decorators?.length) {
4769
- const decorators = result._initDecorators(serializedType.decorators.length);
4770
- serializedType.decorators.forEach((d, index) => {
4771
- const decorator = decorators.get(index);
4772
- decorator.id = d;
4773
- });
4774
- }
4775
- if (serializedType.typeArguments?.length) {
4776
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4777
- serializedType.typeArguments.forEach((t, index) => {
4778
- const typeArgument = typeArguments.get(index);
4779
- typeArgument.id = t;
4780
- });
4781
- }
4782
- if (serializedType.superClass) {
4783
- const superClass = result._initSuperClass();
4784
- superClass.id = serializedType.superClass;
4785
- }
4786
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4787
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4788
- return result;
4789
- }
4790
- function convertFromCapnpClassType(serializedType) {
4791
- return {
4792
- kind: ReflectionKind.class,
4793
- typeName: serializedType.typeName || void 0,
4794
- classType: serializedType.classType,
4795
- globalObject: serializedType.globalObject ? true : void 0,
4796
- arguments: serializedType._hasArguments() ? serializedType.arguments.map((t) => t.id) : void 0,
4797
- extendsArguments: serializedType._hasExtendsArguments() ? serializedType.extendsArguments.map((t) => t.id) : void 0,
4798
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4799
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4800
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4801
- superClass: serializedType._hasSuperClass() ? serializedType.superClass.id : void 0,
4802
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4803
- tags: convertFromCapnpTagsReflection(serializedType)
4804
- };
4805
- }
4806
- /**
4807
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4808
- *
4809
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4810
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4811
- */
4812
- function convertToCapnpObjectLiteral(serializedType, result) {
4813
- if (serializedType.decorators?.length) {
4814
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4815
- serializedType.decorators.forEach((d, index) => {
4816
- const decorator = decorators.get(index);
4817
- decorator.id = d;
4818
- });
4819
- }
4820
- if (serializedType.types?.length) {
4821
- const types = result._initTypes(serializedType.types.length);
4822
- serializedType.types.forEach((t, index) => {
4823
- const serializedTypeType = types.get(index);
4824
- serializedTypeType.id = t;
4825
- });
4826
- }
4827
- if (serializedType.typeArguments?.length) {
4828
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4829
- serializedType.typeArguments.forEach((t, index) => {
4830
- const serializedTypeTypeArguments = typeArguments.get(index);
4831
- serializedTypeTypeArguments.id = t;
4832
- });
4833
- }
4834
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4835
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4836
- return result;
4837
- }
4838
- function convertFromCapnpObjectLiteral(serializedType) {
4839
- return {
4840
- kind: ReflectionKind.objectLiteral,
4841
- typeName: serializedType.typeName || void 0,
4842
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4843
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4844
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4845
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4846
- tags: convertFromCapnpTagsReflection(serializedType)
4847
- };
4848
- }
4849
- /**
4850
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4851
- *
4852
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4853
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4854
- */
4855
- function convertToCapnpParameter(serializedType, result) {
4856
- result.kind = serializedType.kind;
4857
- result.typeName = serializedType.typeName || "";
4858
- result.name = serializedType.name || "";
4859
- result.optional = serializedType.optional ?? false;
4860
- result.readonly = serializedType.readonly ?? false;
4861
- result.visibility = serializedType.visibility === ReflectionVisibility$1.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === ReflectionVisibility$1.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4862
- if (typeof serializedType.default !== "undefined") {
4863
- const defaultValue = result._initDefault();
4864
- convertToCapnpDefault(serializedType.default, defaultValue);
4865
- }
4866
- const parameterType = result._initType();
4867
- parameterType.id = serializedType.type;
4868
- if (serializedType.decorators?.length) {
4869
- const decorators = result._initDecorators(serializedType.decorators.length);
4870
- serializedType.decorators.forEach((d, index) => {
4871
- const decorator = decorators.get(index);
4872
- decorator.id = d;
4873
- });
4874
- }
4875
- if (serializedType.typeArguments?.length) {
4876
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4877
- serializedType.typeArguments.forEach((t, index) => {
4878
- const typeArgument = typeArguments.get(index);
4879
- typeArgument.id = t;
4880
- });
4881
- }
4882
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4883
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4884
- return result;
4885
- }
4886
- function convertFromCapnpParameter(serializedType) {
4887
- return {
4888
- kind: ReflectionKind.parameter,
4889
- typeName: serializedType.typeName || void 0,
4890
- name: serializedType.name,
4891
- default: convertFromCapnpDefault(serializedType.default),
4892
- optional: serializedType.optional ? true : void 0,
4893
- readonly: serializedType.readonly ? true : void 0,
4894
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? ReflectionVisibility$1.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? ReflectionVisibility$1.protected : ReflectionVisibility$1.private,
4895
- type: serializedType.type.id,
4896
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4897
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4898
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4899
- tags: convertFromCapnpTagsReflection(serializedType)
4900
- };
4901
- }
4902
-
4903
- //#endregion
4904
- export { convertToCapnpIndexAccessOrigin as A, convertToCapnpPropertySignature as B, convertToCapnp as C, convertToCapnpDefault as D, convertToCapnpClassType as E, convertToCapnpMethodSignature as F, convertToCapnpUnion as G, convertToCapnpTagsReflection as H, convertToCapnpObjectLiteral as I, convertToCapnpOther as L, convertToCapnpIntersection as M, convertToCapnpLiteral as N, convertToCapnpEnum as O, convertToCapnpMethod as P, convertToCapnpParameter as R, convertFromCapnpUnion as S, convertToCapnpBase as T, convertToCapnpTuple as U, convertToCapnpSimple as V, convertToCapnpTupleMember as W, convertFromCapnpPropertySignature as _, convertFromCapnpDefault as a, convertFromCapnpTuple as b, convertFromCapnpIndexAccessOrigin as c, convertFromCapnpLiteral as d, convertFromCapnpMethodSignature as f, convertFromCapnpProperty as g, convertFromCapnpParameter as h, convertFromCapnpClassType as i, convertToCapnpInfer as j, convertToCapnpFunction as k, convertFromCapnpInfer as l, convertFromCapnpOther as m, convertFromCapnpArray as n, convertFromCapnpEnum as o, convertFromCapnpObjectLiteral as p, convertFromCapnpBase as r, convertFromCapnpFunction as s, convertFromCapnp as t, convertFromCapnpIntersection as u, convertFromCapnpSimple as v, convertToCapnpArray as w, convertFromCapnpTupleMember as x, convertFromCapnpTagsReflection as y, convertToCapnpProperty as z };
4905
- //# sourceMappingURL=capnp-BqAglxrS.mjs.map
3996
+ export { ReflectionVisibility };
3997
+ //# sourceMappingURL=reflection.mjs.map