@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,8 +1,6 @@
1
- const require_chunk = require('./chunk-BmvPcxpV.cjs');
2
- const require_type = require('./type-C7UXbXfx.cjs');
3
- let _stryke_type_checks = require("@stryke/type-checks");
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
4
2
  let _stryke_capnp = require("@stryke/capnp");
5
- _stryke_capnp = require_chunk.__toESM(_stryke_capnp);
3
+ _stryke_capnp = require_runtime.__toESM(_stryke_capnp);
6
4
 
7
5
  //#region schemas/reflection.ts
8
6
  const ReflectionVisibility = {
@@ -3997,1179 +3995,4 @@ SerializedTypeTemplateLiteral._Types = _stryke_capnp.CompositeList(SerializedTyp
3997
3995
  SerializedTypes._Types = _stryke_capnp.CompositeList(SerializedType);
3998
3996
 
3999
3997
  //#endregion
4000
- //#region src/capnp.ts
4001
- /**
4002
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4003
- *
4004
- * @param serializedTypes - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4005
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4006
- */
4007
- function convertToCapnp(serializedTypes, result) {
4008
- if (!serializedTypes || !Array.isArray(serializedTypes) || serializedTypes.length === 0) throw new Error("Invalid serialized type provided for conversion.");
4009
- if (serializedTypes.length !== result.length) throw new Error(`Mismatch in length of serialized types: expected ${result.length}, got ${serializedTypes.length}.`);
4010
- serializedTypes.filter((serializedType) => (0, _stryke_type_checks.isSetObject)(serializedType) && !(0, _stryke_type_checks.isUndefined)(serializedType.kind)).forEach((serializedType, index) => {
4011
- convertToCapnpBase(serializedType, result.get(index)._initType());
4012
- });
4013
- return result;
4014
- }
4015
- /**
4016
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4017
- *
4018
- * @param serializedTypes - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema
4019
- * @returns The [Deepkit](https://deepkit.io/) {@link SerializedTypes | serialized types} converted from the Cap'n Proto serialized type
4020
- */
4021
- function convertFromCapnp(serializedTypes) {
4022
- if (!serializedTypes) throw new Error("Invalid serialized type provided for conversion.");
4023
- const result = [];
4024
- serializedTypes.forEach((serializedType) => {
4025
- const deserializedType = convertFromCapnpBase(serializedType.type);
4026
- result.push(deserializedType);
4027
- });
4028
- return result;
4029
- }
4030
- /**
4031
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4032
- *
4033
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4034
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4035
- */
4036
- function convertToCapnpTagsReflection(result, serializedType) {
4037
- if (serializedType?.alias?.length) {
4038
- const alias = result._initAlias(serializedType.alias.length);
4039
- serializedType.alias.forEach((a, index) => {
4040
- alias.set(index, a);
4041
- });
4042
- }
4043
- result.hidden = serializedType?.hidden ?? false;
4044
- result.ignore = serializedType?.ignore ?? false;
4045
- result.internal = serializedType?.internal ?? false;
4046
- result.readonly = serializedType?.readonly ?? false;
4047
- if (serializedType?.title) result.title = serializedType?.title;
4048
- if (serializedType?.domain) result.domain = serializedType?.domain;
4049
- if (serializedType?.permission?.length) {
4050
- const permission = result._initPermission(serializedType.permission.length);
4051
- serializedType.permission?.forEach((p, index) => {
4052
- permission.set(index, p);
4053
- });
4054
- }
4055
- return result;
4056
- }
4057
- function convertFromCapnpTagsReflection(serializedType) {
4058
- return serializedType._hasTags() ? {
4059
- alias: serializedType.tags?.alias?.length ? serializedType.tags?.alias.map((value) => value) : void 0,
4060
- hidden: serializedType.tags?.hidden,
4061
- domain: serializedType.tags?.domain ? serializedType.tags.domain : void 0,
4062
- title: serializedType.tags?.title ? serializedType.tags.title : void 0,
4063
- ignore: serializedType.tags?.ignore,
4064
- internal: serializedType.tags?.internal,
4065
- readonly: serializedType.tags?.readonly,
4066
- permission: serializedType.tags?.permission?.length ? serializedType.tags?.permission?.map((value) => value) : void 0
4067
- } : void 0;
4068
- }
4069
- /**
4070
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4071
- *
4072
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4073
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4074
- */
4075
- function convertToCapnpIndexAccessOrigin(result, serializedType) {
4076
- const indexAccessOriginIndex = result._initIndex();
4077
- indexAccessOriginIndex.id = serializedType?.index ?? 0;
4078
- const indexAccessOriginContainer = result._initContainer();
4079
- indexAccessOriginContainer.id = serializedType?.container ?? 0;
4080
- return result;
4081
- }
4082
- function convertFromCapnpIndexAccessOrigin(serializedType) {
4083
- return serializedType._hasIndexAccessOrigin() ? {
4084
- container: Number(serializedType.indexAccessOrigin?.container.id),
4085
- index: Number(serializedType.indexAccessOrigin?.index.id)
4086
- } : void 0;
4087
- }
4088
- /**
4089
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4090
- *
4091
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4092
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4093
- */
4094
- function convertToCapnpBase(serializedType, result) {
4095
- if (serializedType.kind === require_type.ReflectionKind.objectLiteral) convertToCapnpObjectLiteral(serializedType, result._initObjectLiteral());
4096
- else if (serializedType.kind === require_type.ReflectionKind.class) convertToCapnpClassType(serializedType, result._initClassType());
4097
- else if (serializedType.kind === require_type.ReflectionKind.parameter) convertToCapnpParameter(serializedType, result._initParameter());
4098
- else if (serializedType.kind === require_type.ReflectionKind.function) convertToCapnpFunction(serializedType, result._initFunction());
4099
- else if (serializedType.kind === require_type.ReflectionKind.method) convertToCapnpMethod(serializedType, result._initMethod());
4100
- else if (serializedType.kind === require_type.ReflectionKind.infer) convertToCapnpInfer(serializedType, result._initInfer());
4101
- else if (serializedType.kind === require_type.ReflectionKind.union) convertToCapnpUnion(serializedType, result._initUnion());
4102
- else if (serializedType.kind === require_type.ReflectionKind.array) convertToCapnpArray(serializedType, result._initArray());
4103
- else if (serializedType.kind === require_type.ReflectionKind.intersection) convertToCapnpIntersection(serializedType, result._initIntersection());
4104
- else if (serializedType.kind === require_type.ReflectionKind.enum) convertToCapnpEnum(serializedType, result._initEnum());
4105
- else if (serializedType.kind === require_type.ReflectionKind.property) convertToCapnpProperty(serializedType, result._initProperty());
4106
- else if (serializedType.kind === require_type.ReflectionKind.tuple) convertToCapnpTuple(serializedType, result._initTuple());
4107
- else if (serializedType.kind === require_type.ReflectionKind.tupleMember) convertToCapnpTupleMember(serializedType, result._initTupleMember());
4108
- else if (serializedType.kind === require_type.ReflectionKind.propertySignature) convertToCapnpPropertySignature(serializedType, result._initPropertySignature());
4109
- else if (serializedType.kind === require_type.ReflectionKind.methodSignature) convertToCapnpMethodSignature(serializedType, result._initMethodSignature());
4110
- else if (serializedType.kind === require_type.ReflectionKind.literal) convertToCapnpLiteral(serializedType, result._initLiteral());
4111
- else if (serializedType.kind === require_type.ReflectionKind.never || serializedType.kind === require_type.ReflectionKind.any || serializedType.kind === require_type.ReflectionKind.unknown || serializedType.kind === require_type.ReflectionKind.void || serializedType.kind === require_type.ReflectionKind.object || serializedType.kind === require_type.ReflectionKind.string || serializedType.kind === require_type.ReflectionKind.number || serializedType.kind === require_type.ReflectionKind.boolean || serializedType.kind === require_type.ReflectionKind.symbol || serializedType.kind === require_type.ReflectionKind.bigint || serializedType.kind === require_type.ReflectionKind.null || serializedType.kind === require_type.ReflectionKind.undefined || serializedType.kind === require_type.ReflectionKind.regexp) convertToCapnpSimple(serializedType, result._initSimple());
4112
- else convertToCapnpOther(serializedType, result._initOther());
4113
- return result;
4114
- }
4115
- function convertFromCapnpBase(serializedType) {
4116
- if (serializedType._isObjectLiteral) return convertFromCapnpObjectLiteral(serializedType.objectLiteral);
4117
- else if (serializedType._isClassType) return convertFromCapnpClassType(serializedType.classType);
4118
- else if (serializedType._isParameter) return convertFromCapnpParameter(serializedType.parameter);
4119
- else if (serializedType._isFunction) return convertFromCapnpFunction(serializedType.function);
4120
- else if (serializedType._isInfer) return convertFromCapnpInfer(serializedType.infer);
4121
- else if (serializedType._isMethod) return convertFromCapnpMethod(serializedType.method);
4122
- else if (serializedType._isUnion) return convertFromCapnpUnion(serializedType.union);
4123
- else if (serializedType._isArray) return convertFromCapnpArray(serializedType.array);
4124
- else if (serializedType._isIntersection) return convertFromCapnpIntersection(serializedType.intersection);
4125
- else if (serializedType._isEnum) return convertFromCapnpEnum(serializedType.enum);
4126
- else if (serializedType._isProperty) return convertFromCapnpProperty(serializedType.property);
4127
- else if (serializedType._isTuple) return convertFromCapnpTuple(serializedType.tuple);
4128
- else if (serializedType._isTupleMember) return convertFromCapnpTupleMember(serializedType.tupleMember);
4129
- else if (serializedType._isPropertySignature) return convertFromCapnpPropertySignature(serializedType.propertySignature);
4130
- else if (serializedType._isMethodSignature) return convertFromCapnpMethodSignature(serializedType.methodSignature);
4131
- else if (serializedType._isLiteral) return convertFromCapnpLiteral(serializedType.literal);
4132
- else if (serializedType._isSimple) return convertFromCapnpSimple(serializedType.simple);
4133
- else if (serializedType._isOther) return convertFromCapnpOther(serializedType.other);
4134
- else throw new Error(`Unsupported serialized type kind: ${serializedType.toString()}`);
4135
- }
4136
- function convertFromCapnpOther(serializedType) {
4137
- return {
4138
- kind: serializedType.kind,
4139
- typeName: serializedType.typeName || void 0
4140
- };
4141
- }
4142
- function convertFromCapnpSimple(serializedType) {
4143
- const result = {
4144
- kind: serializedType.kind,
4145
- typeName: serializedType.typeName || void 0,
4146
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4147
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4148
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4149
- };
4150
- if (serializedType._hasOrigin()) result.origin = Number(serializedType.origin.id);
4151
- return result;
4152
- }
4153
- function convertToCapnpOther(serializedType, result) {
4154
- result.kind = serializedType.kind;
4155
- result.typeName = serializedType.typeName || "";
4156
- return result;
4157
- }
4158
- function convertToCapnpSimple(serializedType, result) {
4159
- result.kind = serializedType.kind;
4160
- result.typeName = serializedType.typeName || "";
4161
- if (serializedType.origin) {
4162
- result._initOrigin();
4163
- result.origin.id = serializedType.origin ?? 0;
4164
- }
4165
- if (serializedType.decorators?.length) {
4166
- const decorators = result._initDecorators(serializedType.decorators.length);
4167
- serializedType.decorators.forEach((d, index) => {
4168
- const decorator = decorators.get(index);
4169
- decorator.id = d;
4170
- });
4171
- }
4172
- if (serializedType.typeArguments?.length) {
4173
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4174
- serializedType.typeArguments.forEach((t, index) => {
4175
- const typeArgument = typeArguments.get(index);
4176
- typeArgument.id = t;
4177
- });
4178
- }
4179
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4180
- return result;
4181
- }
4182
- function convertFromCapnpLiteral(serializedType) {
4183
- return {
4184
- kind: require_type.ReflectionKind.literal,
4185
- literal: serializedType.literal._isString ? serializedType.literal.string : serializedType.literal._isNumber ? serializedType.literal.number : serializedType.literal._isBoolean ? serializedType.literal.boolean : serializedType.literal._isBigint ? {
4186
- type: "bigint",
4187
- value: serializedType.literal.bigint.value
4188
- } : serializedType.literal._isSymbol ? {
4189
- type: "symbol",
4190
- name: serializedType.literal.symbol.name
4191
- } : {
4192
- type: "regex",
4193
- regex: serializedType.literal.regex.regex
4194
- },
4195
- typeName: serializedType.typeName || void 0,
4196
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4197
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4198
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4199
- };
4200
- }
4201
- function convertToCapnpLiteral(serializedType, result) {
4202
- result.kind = serializedType.kind;
4203
- result.typeName = serializedType.typeName || "";
4204
- const literalType = result._initLiteral();
4205
- if (typeof serializedType.literal === "boolean") literalType.boolean = serializedType.literal;
4206
- else if (typeof serializedType.literal === "number") literalType.number = serializedType.literal;
4207
- else if (typeof serializedType.literal === "string") literalType.string = serializedType.literal;
4208
- else if (serializedType.literal.type === "bigint") {
4209
- const literalTypeBigint = literalType._initBigint();
4210
- literalTypeBigint.type = "bigint";
4211
- literalTypeBigint.value = serializedType.literal.value;
4212
- } else if (serializedType.literal.type === "symbol") {
4213
- const literalTypeSymbol = literalType._initSymbol();
4214
- literalTypeSymbol.type = "symbol";
4215
- literalTypeSymbol.name = serializedType.literal.name.toString().slice(7, -1);
4216
- } else if (serializedType.literal.type === "regex") {
4217
- const literalTypeRegex = literalType._initRegex();
4218
- literalTypeRegex.type = "regex";
4219
- literalTypeRegex.regex = serializedType.literal.regex;
4220
- }
4221
- if (serializedType.decorators?.length) {
4222
- const decorators = result._initDecorators(serializedType.decorators.length);
4223
- serializedType.decorators.forEach((d, index) => {
4224
- const decorator = decorators.get(index);
4225
- decorator.id = d;
4226
- });
4227
- }
4228
- if (serializedType.typeArguments?.length) {
4229
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4230
- serializedType.typeArguments.forEach((t, index) => {
4231
- const typeArgument = typeArguments.get(index);
4232
- typeArgument.id = t;
4233
- });
4234
- }
4235
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4236
- return result;
4237
- }
4238
- function convertFromCapnpMethodSignature(serializedType) {
4239
- return {
4240
- kind: require_type.ReflectionKind.methodSignature,
4241
- name: serializedType.name,
4242
- typeName: serializedType.typeName || void 0,
4243
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4244
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
4245
- return: serializedType.return.id,
4246
- tags: convertFromCapnpTagsReflection(serializedType)
4247
- };
4248
- }
4249
- function convertToCapnpMethodSignature(serializedType, result) {
4250
- result.kind = serializedType.kind;
4251
- result.name = String(serializedType.name);
4252
- result.typeName = serializedType.typeName || "";
4253
- if (serializedType.decorators?.length) {
4254
- const decorators = result._initDecorators(serializedType.decorators.length);
4255
- serializedType.decorators.forEach((d, index) => {
4256
- const decorator = decorators.get(index);
4257
- decorator.id = d;
4258
- });
4259
- }
4260
- if (serializedType.typeArguments?.length) {
4261
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4262
- serializedType.typeArguments.forEach((t, index) => {
4263
- const typeArgument = typeArguments.get(index);
4264
- typeArgument.id = t;
4265
- });
4266
- }
4267
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4268
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4269
- return result;
4270
- }
4271
- function convertFromCapnpPropertySignature(serializedType) {
4272
- return {
4273
- kind: require_type.ReflectionKind.propertySignature,
4274
- name: serializedType.name,
4275
- typeName: serializedType.typeName || void 0,
4276
- description: serializedType.description,
4277
- default: convertFromCapnpDefault(serializedType.default),
4278
- optional: serializedType.optional ? true : void 0,
4279
- readonly: serializedType.readonly ? true : void 0,
4280
- type: serializedType.type.id,
4281
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4282
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4283
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4284
- tags: convertFromCapnpTagsReflection(serializedType)
4285
- };
4286
- }
4287
- function convertToCapnpDefault(defaultValue, result) {
4288
- if (typeof defaultValue !== "undefined" && defaultValue !== "") {
4289
- result._initValue();
4290
- if (typeof defaultValue === "string") result.value.string = defaultValue;
4291
- else if (typeof defaultValue === "number") if ((0, _stryke_type_checks.isInteger)(defaultValue)) result.value.integer = defaultValue;
4292
- else result.value.float = defaultValue;
4293
- else if (typeof defaultValue === "boolean") result.value.boolean = defaultValue;
4294
- }
4295
- }
4296
- function convertFromCapnpDefault(serializedType) {
4297
- if (typeof serializedType.value === "undefined") return;
4298
- else if (serializedType.value._isBoolean) return serializedType.value.boolean;
4299
- else if (serializedType.value._isInteger) return serializedType.value.integer;
4300
- else if (serializedType.value._isFloat) return serializedType.value.float;
4301
- else if (serializedType.value._isString) return serializedType.value.string;
4302
- }
4303
- function convertToCapnpPropertySignature(serializedType, result) {
4304
- result.kind = serializedType.kind;
4305
- result.name = String(serializedType.name) || "";
4306
- result.typeName = serializedType.typeName || "";
4307
- result.description = serializedType.description || "";
4308
- result.optional = serializedType.optional ?? false;
4309
- result.readonly = serializedType.readonly ?? false;
4310
- if (typeof serializedType.default !== "undefined") {
4311
- const defaultValue = result._initDefault();
4312
- convertToCapnpDefault(serializedType.default, defaultValue);
4313
- }
4314
- const type = result._initType();
4315
- type.id = serializedType.type;
4316
- if (serializedType.decorators?.length) {
4317
- const decorators = result._initDecorators(serializedType.decorators.length);
4318
- serializedType.decorators.forEach((d, index) => {
4319
- const decorator = decorators.get(index);
4320
- decorator.id = d;
4321
- });
4322
- }
4323
- if (serializedType.typeArguments?.length) {
4324
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4325
- serializedType.typeArguments.forEach((t, index) => {
4326
- const typeArgument = typeArguments.get(index);
4327
- typeArgument.id = t;
4328
- });
4329
- }
4330
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4331
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4332
- return result;
4333
- }
4334
- function convertToCapnpTupleMember(serializedType, result) {
4335
- result.kind = serializedType.kind;
4336
- result.typeName = serializedType.typeName || "";
4337
- const type = result._initType();
4338
- type.id = serializedType.type;
4339
- if (serializedType.decorators?.length) {
4340
- const decorators = result._initDecorators(serializedType.decorators.length);
4341
- serializedType.decorators.forEach((d, index) => {
4342
- const decorator = decorators.get(index);
4343
- decorator.id = d;
4344
- });
4345
- }
4346
- if (serializedType.typeArguments?.length) {
4347
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4348
- serializedType.typeArguments.forEach((t, index) => {
4349
- const typeArgument = typeArguments.get(index);
4350
- typeArgument.id = t;
4351
- });
4352
- }
4353
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4354
- return result;
4355
- }
4356
- function convertFromCapnpTupleMember(serializedType) {
4357
- return {
4358
- kind: require_type.ReflectionKind.tupleMember,
4359
- type: serializedType.type.id,
4360
- typeName: serializedType.typeName || void 0,
4361
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4362
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4363
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4364
- };
4365
- }
4366
- function convertToCapnpTuple(serializedType, result) {
4367
- result.kind = serializedType.kind;
4368
- result.typeName = serializedType.typeName || "";
4369
- const types = result._initTypes(serializedType.types.length);
4370
- serializedType.types.forEach((t, index) => {
4371
- convertToCapnpTupleMember(t, types.get(index));
4372
- });
4373
- if (serializedType.decorators?.length) {
4374
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4375
- serializedType.decorators?.forEach((d, index) => {
4376
- const decorator = decorators.get(index);
4377
- decorator.id = d;
4378
- });
4379
- }
4380
- if (serializedType.typeArguments?.length) {
4381
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4382
- serializedType.typeArguments?.forEach((t, index) => {
4383
- const typeArgument = typeArguments.get(index);
4384
- typeArgument.id = t;
4385
- });
4386
- }
4387
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4388
- return result;
4389
- }
4390
- function convertFromCapnpTuple(serializedType) {
4391
- return {
4392
- kind: require_type.ReflectionKind.tuple,
4393
- typeName: serializedType.typeName || void 0,
4394
- types: serializedType._hasTypes() ? serializedType.types.map((t) => convertFromCapnpTupleMember(t)) : [],
4395
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4396
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4397
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4398
- };
4399
- }
4400
- function convertToCapnpProperty(serializedType, result) {
4401
- result.kind = serializedType.kind;
4402
- result.typeName = serializedType.typeName || "";
4403
- result.description = serializedType.description || "";
4404
- result.optional = serializedType.optional ?? false;
4405
- result.readonly = serializedType.readonly ?? false;
4406
- result.visibility = serializedType.visibility === require_type.ReflectionVisibility.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === require_type.ReflectionVisibility.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4407
- result.abstract = serializedType.abstract ?? false;
4408
- result.name = String(serializedType.name) || "";
4409
- if (typeof serializedType.default !== "undefined") {
4410
- const defaultValue = result._initDefault();
4411
- convertToCapnpDefault(serializedType.default, defaultValue);
4412
- }
4413
- const type = result._initType();
4414
- type.id = serializedType.type;
4415
- if (serializedType.decorators?.length) {
4416
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4417
- serializedType.decorators?.forEach((d, index) => {
4418
- const decorator = decorators.get(index);
4419
- decorator.id = d;
4420
- });
4421
- }
4422
- if (serializedType.typeArguments?.length) {
4423
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4424
- serializedType.typeArguments?.forEach((t, index) => {
4425
- const typeArgument = typeArguments.get(index);
4426
- typeArgument.id = t;
4427
- });
4428
- }
4429
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4430
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4431
- return result;
4432
- }
4433
- function convertFromCapnpProperty(serializedType) {
4434
- return {
4435
- kind: require_type.ReflectionKind.property,
4436
- typeName: serializedType.typeName || void 0,
4437
- description: serializedType.description,
4438
- default: convertFromCapnpDefault(serializedType.default),
4439
- optional: serializedType.optional ? true : void 0,
4440
- readonly: serializedType.readonly ? true : void 0,
4441
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? require_type.ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? require_type.ReflectionVisibility.protected : require_type.ReflectionVisibility.private,
4442
- abstract: serializedType.abstract ? true : void 0,
4443
- name: serializedType.name,
4444
- type: serializedType.type.id,
4445
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4446
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4447
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4448
- tags: convertFromCapnpTagsReflection(serializedType)
4449
- };
4450
- }
4451
- function convertToCapnpEnum(serializedType, result) {
4452
- result.kind = serializedType.kind;
4453
- result.typeName = serializedType.typeName || "";
4454
- const indexType = result._initIndexType();
4455
- indexType.id = serializedType.indexType;
4456
- if (serializedType.decorators?.length) {
4457
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4458
- serializedType.decorators?.forEach((d, index) => {
4459
- const decorator = decorators.get(index);
4460
- decorator.id = d;
4461
- });
4462
- }
4463
- if (serializedType.typeArguments?.length) {
4464
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4465
- serializedType.typeArguments?.forEach((t, index) => {
4466
- const typeArgument = typeArguments.get(index);
4467
- typeArgument.id = t;
4468
- });
4469
- }
4470
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4471
- if (serializedType.values?.length) {
4472
- const values = result._initValues(serializedType.values?.length);
4473
- serializedType.values.forEach((value, index) => {
4474
- values.set(index, String(value));
4475
- });
4476
- }
4477
- const enumEntries = result._initEnumEntries(Object.keys(serializedType.enum).length ?? 0);
4478
- Object.entries(serializedType.enum).forEach(([key, value], index) => {
4479
- const enumEntry = enumEntries.get(index);
4480
- enumEntry.name = key;
4481
- enumEntry.value = String(value);
4482
- });
4483
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4484
- return result;
4485
- }
4486
- function convertFromCapnpEnum(serializedType) {
4487
- return {
4488
- kind: require_type.ReflectionKind.enum,
4489
- typeName: serializedType.typeName || void 0,
4490
- indexType: serializedType.indexType.id,
4491
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4492
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4493
- values: serializedType._hasValues() ? serializedType.values.map((value) => value) : [],
4494
- enum: serializedType._hasEnumEntries() ? Object.entries(serializedType.enumEntries).reduce((ret, [key, value]) => {
4495
- ret[key] = value.value;
4496
- return ret;
4497
- }, {}) : {},
4498
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4499
- tags: convertFromCapnpTagsReflection(serializedType)
4500
- };
4501
- }
4502
- function convertToCapnpIntersection(serializedType, result) {
4503
- result.kind = serializedType.kind;
4504
- result.typeName = serializedType.typeName || "";
4505
- const types = result._initTypes(serializedType.types?.length ?? 0);
4506
- serializedType.types?.forEach((t, index) => {
4507
- const serializedTypeType = types.get(index);
4508
- serializedTypeType.id = t;
4509
- });
4510
- if (serializedType.decorators?.length) {
4511
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4512
- serializedType.decorators?.forEach((d, index) => {
4513
- const decorator = decorators.get(index);
4514
- decorator.id = d;
4515
- });
4516
- }
4517
- if (serializedType.typeArguments?.length) {
4518
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4519
- serializedType.typeArguments?.forEach((t, index) => {
4520
- const typeArgument = typeArguments.get(index);
4521
- typeArgument.id = t;
4522
- });
4523
- }
4524
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4525
- return result;
4526
- }
4527
- function convertFromCapnpIntersection(serializedType) {
4528
- return {
4529
- kind: require_type.ReflectionKind.intersection,
4530
- typeName: serializedType.typeName || void 0,
4531
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4532
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4533
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4534
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4535
- };
4536
- }
4537
- function convertToCapnpArray(serializedType, result) {
4538
- result.kind = serializedType.kind;
4539
- result.typeName = serializedType.typeName || "";
4540
- const type = result._initType();
4541
- type.id = serializedType.type;
4542
- if (serializedType.decorators?.length) {
4543
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4544
- serializedType.decorators?.forEach((d, index) => {
4545
- const decorator = decorators.get(index);
4546
- decorator.id = d;
4547
- });
4548
- }
4549
- if (serializedType.typeArguments?.length) {
4550
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4551
- serializedType.typeArguments?.forEach((t, index) => {
4552
- const typeArgument = typeArguments.get(index);
4553
- typeArgument.id = t;
4554
- });
4555
- }
4556
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4557
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4558
- return result;
4559
- }
4560
- function convertFromCapnpArray(serializedType) {
4561
- return {
4562
- kind: require_type.ReflectionKind.array,
4563
- typeName: serializedType.typeName || void 0,
4564
- type: serializedType.type.id,
4565
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4566
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4567
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4568
- tags: convertFromCapnpTagsReflection(serializedType)
4569
- };
4570
- }
4571
- /**
4572
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4573
- *
4574
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4575
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4576
- */
4577
- function convertToCapnpUnion(serializedType, result) {
4578
- result.kind = serializedType.kind;
4579
- result.typeName = serializedType.typeName || "";
4580
- const types = result._initTypes(serializedType.types?.length ?? 0);
4581
- serializedType.types?.forEach((t, index) => {
4582
- const serializedTypeType = types.get(index);
4583
- serializedTypeType.id = t;
4584
- });
4585
- if (serializedType.decorators?.length) {
4586
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4587
- serializedType.decorators?.forEach((d, index) => {
4588
- const decorator = decorators.get(index);
4589
- decorator.id = d;
4590
- });
4591
- }
4592
- if (serializedType.typeArguments?.length) {
4593
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4594
- serializedType.typeArguments?.forEach((t, index) => {
4595
- const typeArgument = typeArguments.get(index);
4596
- typeArgument.id = t;
4597
- });
4598
- }
4599
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4600
- return result;
4601
- }
4602
- function convertFromCapnpUnion(serializedType) {
4603
- return {
4604
- kind: require_type.ReflectionKind.union,
4605
- typeName: serializedType.typeName || void 0,
4606
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4607
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4608
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4609
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4610
- };
4611
- }
4612
- /**
4613
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4614
- *
4615
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert.
4616
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4617
- */
4618
- function convertToCapnpInfer(serializedType, result) {
4619
- result.kind = serializedType.kind;
4620
- result.typeName = serializedType.typeName || "";
4621
- if (serializedType.decorators?.length) {
4622
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4623
- serializedType.decorators?.forEach((d, index) => {
4624
- const decorator = decorators.get(index);
4625
- decorator.id = d;
4626
- });
4627
- }
4628
- if (serializedType.typeArguments?.length) {
4629
- const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
4630
- serializedType.typeArguments?.forEach((t, index) => {
4631
- const typeArgument = typeArguments.get(index);
4632
- typeArgument.id = t;
4633
- });
4634
- }
4635
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4636
- return result;
4637
- }
4638
- function convertFromCapnpInfer(serializedType) {
4639
- return {
4640
- kind: require_type.ReflectionKind.infer,
4641
- typeName: serializedType.typeName || void 0,
4642
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4643
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4644
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
4645
- };
4646
- }
4647
- /**
4648
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4649
- *
4650
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4651
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4652
- */
4653
- function convertToCapnpFunction(serializedType, result) {
4654
- result.name = String(serializedType.name) || "";
4655
- result.kind = serializedType.kind;
4656
- result.typeName = serializedType.typeName || "";
4657
- if (serializedType.decorators?.length) {
4658
- const decorators = result._initDecorators(serializedType.decorators.length);
4659
- serializedType.decorators.forEach((d, index) => {
4660
- const decorator = decorators.get(index);
4661
- decorator.id = d;
4662
- });
4663
- }
4664
- if (serializedType.typeArguments?.length) {
4665
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4666
- serializedType.typeArguments.forEach((t, index) => {
4667
- const typeArgument = typeArguments.get(index);
4668
- typeArgument.id = t;
4669
- });
4670
- }
4671
- if (serializedType.parameters?.length) {
4672
- const parameters = result._initParameters(serializedType.parameters.length);
4673
- serializedType.parameters.forEach((p, index) => {
4674
- convertToCapnpParameter(p, parameters.get(index));
4675
- });
4676
- }
4677
- const returnType = result._initReturn();
4678
- returnType.id = serializedType.return;
4679
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4680
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4681
- return result;
4682
- }
4683
- /**
4684
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4685
- *
4686
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4687
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4688
- */
4689
- function convertToCapnpMethod(serializedType, result) {
4690
- result.name = String(serializedType.name) || "";
4691
- result.kind = serializedType.kind;
4692
- result.typeName = serializedType.typeName || "";
4693
- result.abstract = serializedType.abstract ?? false;
4694
- result.visibility = serializedType.visibility === require_type.ReflectionVisibility.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === require_type.ReflectionVisibility.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4695
- if (serializedType.decorators?.length) {
4696
- const decorators = result._initDecorators(serializedType.decorators.length);
4697
- serializedType.decorators.forEach((d, index) => {
4698
- const decorator = decorators.get(index);
4699
- decorator.id = d;
4700
- });
4701
- }
4702
- if (serializedType.typeArguments?.length) {
4703
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4704
- serializedType.typeArguments.forEach((t, index) => {
4705
- const typeArgument = typeArguments.get(index);
4706
- typeArgument.id = t;
4707
- });
4708
- }
4709
- if (serializedType.parameters?.length) {
4710
- const parameters = result._initParameters(serializedType.parameters.length);
4711
- serializedType.parameters.forEach((p, index) => {
4712
- convertToCapnpParameter(p, parameters.get(index));
4713
- });
4714
- }
4715
- const returnType = result._initReturn();
4716
- returnType.id = serializedType.return;
4717
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4718
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4719
- return result;
4720
- }
4721
- function convertFromCapnpFunction(serializedType) {
4722
- return {
4723
- kind: require_type.ReflectionKind.function,
4724
- name: serializedType.name,
4725
- typeName: serializedType.typeName || void 0,
4726
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4727
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4728
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
4729
- return: serializedType.return.id,
4730
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4731
- tags: convertFromCapnpTagsReflection(serializedType)
4732
- };
4733
- }
4734
- function convertFromCapnpMethod(serializedType) {
4735
- return {
4736
- kind: require_type.ReflectionKind.method,
4737
- name: serializedType.name,
4738
- typeName: serializedType.typeName || void 0,
4739
- abstract: serializedType.abstract ? true : void 0,
4740
- return: serializedType.return.id,
4741
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? require_type.ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? require_type.ReflectionVisibility.protected : require_type.ReflectionVisibility.private,
4742
- parameters: serializedType._hasParameters() ? serializedType.parameters.map((parameter) => convertFromCapnpParameter(parameter)) : []
4743
- };
4744
- }
4745
- /**
4746
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4747
- *
4748
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4749
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4750
- */
4751
- function convertToCapnpClassType(serializedType, result) {
4752
- result.kind = serializedType.kind;
4753
- result.typeName = serializedType.typeName || "";
4754
- result.classType = serializedType.classType || "";
4755
- result.globalObject = serializedType.globalObject ?? false;
4756
- if (serializedType.arguments?.length) {
4757
- const _arguments = result._initArguments(serializedType.arguments.length);
4758
- serializedType.arguments.forEach((t, index) => {
4759
- const serializedTypeArguments = _arguments.get(index);
4760
- serializedTypeArguments.id = t;
4761
- });
4762
- }
4763
- if (serializedType.extendsArguments?.length) {
4764
- const extendsArguments = result._initArguments(serializedType.extendsArguments.length);
4765
- serializedType.extendsArguments.forEach((t, index) => {
4766
- const serializedTypeExtendsArguments = extendsArguments.get(index);
4767
- serializedTypeExtendsArguments.id = t;
4768
- });
4769
- }
4770
- if (serializedType.decorators?.length) {
4771
- const decorators = result._initDecorators(serializedType.decorators.length);
4772
- serializedType.decorators.forEach((d, index) => {
4773
- const decorator = decorators.get(index);
4774
- decorator.id = d;
4775
- });
4776
- }
4777
- if (serializedType.typeArguments?.length) {
4778
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4779
- serializedType.typeArguments.forEach((t, index) => {
4780
- const typeArgument = typeArguments.get(index);
4781
- typeArgument.id = t;
4782
- });
4783
- }
4784
- if (serializedType.superClass) {
4785
- const superClass = result._initSuperClass();
4786
- superClass.id = serializedType.superClass;
4787
- }
4788
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4789
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4790
- return result;
4791
- }
4792
- function convertFromCapnpClassType(serializedType) {
4793
- return {
4794
- kind: require_type.ReflectionKind.class,
4795
- typeName: serializedType.typeName || void 0,
4796
- classType: serializedType.classType,
4797
- globalObject: serializedType.globalObject ? true : void 0,
4798
- arguments: serializedType._hasArguments() ? serializedType.arguments.map((t) => t.id) : void 0,
4799
- extendsArguments: serializedType._hasExtendsArguments() ? serializedType.extendsArguments.map((t) => t.id) : void 0,
4800
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4801
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4802
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4803
- superClass: serializedType._hasSuperClass() ? serializedType.superClass.id : void 0,
4804
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4805
- tags: convertFromCapnpTagsReflection(serializedType)
4806
- };
4807
- }
4808
- /**
4809
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4810
- *
4811
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4812
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4813
- */
4814
- function convertToCapnpObjectLiteral(serializedType, result) {
4815
- if (serializedType.decorators?.length) {
4816
- const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
4817
- serializedType.decorators.forEach((d, index) => {
4818
- const decorator = decorators.get(index);
4819
- decorator.id = d;
4820
- });
4821
- }
4822
- if (serializedType.types?.length) {
4823
- const types = result._initTypes(serializedType.types.length);
4824
- serializedType.types.forEach((t, index) => {
4825
- const serializedTypeType = types.get(index);
4826
- serializedTypeType.id = t;
4827
- });
4828
- }
4829
- if (serializedType.typeArguments?.length) {
4830
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4831
- serializedType.typeArguments.forEach((t, index) => {
4832
- const serializedTypeTypeArguments = typeArguments.get(index);
4833
- serializedTypeTypeArguments.id = t;
4834
- });
4835
- }
4836
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4837
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4838
- return result;
4839
- }
4840
- function convertFromCapnpObjectLiteral(serializedType) {
4841
- return {
4842
- kind: require_type.ReflectionKind.objectLiteral,
4843
- typeName: serializedType.typeName || void 0,
4844
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4845
- types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
4846
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4847
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4848
- tags: convertFromCapnpTagsReflection(serializedType)
4849
- };
4850
- }
4851
- /**
4852
- * Converts a Deepkit serialized type to a Cap'n Proto serialized type.
4853
- *
4854
- * @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
4855
- * @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
4856
- */
4857
- function convertToCapnpParameter(serializedType, result) {
4858
- result.kind = serializedType.kind;
4859
- result.typeName = serializedType.typeName || "";
4860
- result.name = serializedType.name || "";
4861
- result.optional = serializedType.optional ?? false;
4862
- result.readonly = serializedType.readonly ?? false;
4863
- result.visibility = serializedType.visibility === require_type.ReflectionVisibility.public ? ReflectionVisibility.PUBLIC : serializedType.visibility === require_type.ReflectionVisibility.protected ? ReflectionVisibility.PROTECTED : ReflectionVisibility.PRIVATE;
4864
- if (typeof serializedType.default !== "undefined") {
4865
- const defaultValue = result._initDefault();
4866
- convertToCapnpDefault(serializedType.default, defaultValue);
4867
- }
4868
- const parameterType = result._initType();
4869
- parameterType.id = serializedType.type;
4870
- if (serializedType.decorators?.length) {
4871
- const decorators = result._initDecorators(serializedType.decorators.length);
4872
- serializedType.decorators.forEach((d, index) => {
4873
- const decorator = decorators.get(index);
4874
- decorator.id = d;
4875
- });
4876
- }
4877
- if (serializedType.typeArguments?.length) {
4878
- const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
4879
- serializedType.typeArguments.forEach((t, index) => {
4880
- const typeArgument = typeArguments.get(index);
4881
- typeArgument.id = t;
4882
- });
4883
- }
4884
- if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
4885
- if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
4886
- return result;
4887
- }
4888
- function convertFromCapnpParameter(serializedType) {
4889
- return {
4890
- kind: require_type.ReflectionKind.parameter,
4891
- typeName: serializedType.typeName || void 0,
4892
- name: serializedType.name,
4893
- default: convertFromCapnpDefault(serializedType.default),
4894
- optional: serializedType.optional ? true : void 0,
4895
- readonly: serializedType.readonly ? true : void 0,
4896
- visibility: serializedType.visibility === ReflectionVisibility.PUBLIC ? require_type.ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility.PROTECTED ? require_type.ReflectionVisibility.protected : require_type.ReflectionVisibility.private,
4897
- type: serializedType.type.id,
4898
- decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
4899
- typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
4900
- indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
4901
- tags: convertFromCapnpTagsReflection(serializedType)
4902
- };
4903
- }
4904
-
4905
- //#endregion
4906
- Object.defineProperty(exports, 'convertFromCapnp', {
4907
- enumerable: true,
4908
- get: function () {
4909
- return convertFromCapnp;
4910
- }
4911
- });
4912
- Object.defineProperty(exports, 'convertFromCapnpArray', {
4913
- enumerable: true,
4914
- get: function () {
4915
- return convertFromCapnpArray;
4916
- }
4917
- });
4918
- Object.defineProperty(exports, 'convertFromCapnpBase', {
4919
- enumerable: true,
4920
- get: function () {
4921
- return convertFromCapnpBase;
4922
- }
4923
- });
4924
- Object.defineProperty(exports, 'convertFromCapnpClassType', {
4925
- enumerable: true,
4926
- get: function () {
4927
- return convertFromCapnpClassType;
4928
- }
4929
- });
4930
- Object.defineProperty(exports, 'convertFromCapnpDefault', {
4931
- enumerable: true,
4932
- get: function () {
4933
- return convertFromCapnpDefault;
4934
- }
4935
- });
4936
- Object.defineProperty(exports, 'convertFromCapnpEnum', {
4937
- enumerable: true,
4938
- get: function () {
4939
- return convertFromCapnpEnum;
4940
- }
4941
- });
4942
- Object.defineProperty(exports, 'convertFromCapnpFunction', {
4943
- enumerable: true,
4944
- get: function () {
4945
- return convertFromCapnpFunction;
4946
- }
4947
- });
4948
- Object.defineProperty(exports, 'convertFromCapnpIndexAccessOrigin', {
4949
- enumerable: true,
4950
- get: function () {
4951
- return convertFromCapnpIndexAccessOrigin;
4952
- }
4953
- });
4954
- Object.defineProperty(exports, 'convertFromCapnpInfer', {
4955
- enumerable: true,
4956
- get: function () {
4957
- return convertFromCapnpInfer;
4958
- }
4959
- });
4960
- Object.defineProperty(exports, 'convertFromCapnpIntersection', {
4961
- enumerable: true,
4962
- get: function () {
4963
- return convertFromCapnpIntersection;
4964
- }
4965
- });
4966
- Object.defineProperty(exports, 'convertFromCapnpLiteral', {
4967
- enumerable: true,
4968
- get: function () {
4969
- return convertFromCapnpLiteral;
4970
- }
4971
- });
4972
- Object.defineProperty(exports, 'convertFromCapnpMethodSignature', {
4973
- enumerable: true,
4974
- get: function () {
4975
- return convertFromCapnpMethodSignature;
4976
- }
4977
- });
4978
- Object.defineProperty(exports, 'convertFromCapnpObjectLiteral', {
4979
- enumerable: true,
4980
- get: function () {
4981
- return convertFromCapnpObjectLiteral;
4982
- }
4983
- });
4984
- Object.defineProperty(exports, 'convertFromCapnpOther', {
4985
- enumerable: true,
4986
- get: function () {
4987
- return convertFromCapnpOther;
4988
- }
4989
- });
4990
- Object.defineProperty(exports, 'convertFromCapnpParameter', {
4991
- enumerable: true,
4992
- get: function () {
4993
- return convertFromCapnpParameter;
4994
- }
4995
- });
4996
- Object.defineProperty(exports, 'convertFromCapnpProperty', {
4997
- enumerable: true,
4998
- get: function () {
4999
- return convertFromCapnpProperty;
5000
- }
5001
- });
5002
- Object.defineProperty(exports, 'convertFromCapnpPropertySignature', {
5003
- enumerable: true,
5004
- get: function () {
5005
- return convertFromCapnpPropertySignature;
5006
- }
5007
- });
5008
- Object.defineProperty(exports, 'convertFromCapnpSimple', {
5009
- enumerable: true,
5010
- get: function () {
5011
- return convertFromCapnpSimple;
5012
- }
5013
- });
5014
- Object.defineProperty(exports, 'convertFromCapnpTagsReflection', {
5015
- enumerable: true,
5016
- get: function () {
5017
- return convertFromCapnpTagsReflection;
5018
- }
5019
- });
5020
- Object.defineProperty(exports, 'convertFromCapnpTuple', {
5021
- enumerable: true,
5022
- get: function () {
5023
- return convertFromCapnpTuple;
5024
- }
5025
- });
5026
- Object.defineProperty(exports, 'convertFromCapnpTupleMember', {
5027
- enumerable: true,
5028
- get: function () {
5029
- return convertFromCapnpTupleMember;
5030
- }
5031
- });
5032
- Object.defineProperty(exports, 'convertFromCapnpUnion', {
5033
- enumerable: true,
5034
- get: function () {
5035
- return convertFromCapnpUnion;
5036
- }
5037
- });
5038
- Object.defineProperty(exports, 'convertToCapnp', {
5039
- enumerable: true,
5040
- get: function () {
5041
- return convertToCapnp;
5042
- }
5043
- });
5044
- Object.defineProperty(exports, 'convertToCapnpArray', {
5045
- enumerable: true,
5046
- get: function () {
5047
- return convertToCapnpArray;
5048
- }
5049
- });
5050
- Object.defineProperty(exports, 'convertToCapnpBase', {
5051
- enumerable: true,
5052
- get: function () {
5053
- return convertToCapnpBase;
5054
- }
5055
- });
5056
- Object.defineProperty(exports, 'convertToCapnpClassType', {
5057
- enumerable: true,
5058
- get: function () {
5059
- return convertToCapnpClassType;
5060
- }
5061
- });
5062
- Object.defineProperty(exports, 'convertToCapnpDefault', {
5063
- enumerable: true,
5064
- get: function () {
5065
- return convertToCapnpDefault;
5066
- }
5067
- });
5068
- Object.defineProperty(exports, 'convertToCapnpEnum', {
5069
- enumerable: true,
5070
- get: function () {
5071
- return convertToCapnpEnum;
5072
- }
5073
- });
5074
- Object.defineProperty(exports, 'convertToCapnpFunction', {
5075
- enumerable: true,
5076
- get: function () {
5077
- return convertToCapnpFunction;
5078
- }
5079
- });
5080
- Object.defineProperty(exports, 'convertToCapnpIndexAccessOrigin', {
5081
- enumerable: true,
5082
- get: function () {
5083
- return convertToCapnpIndexAccessOrigin;
5084
- }
5085
- });
5086
- Object.defineProperty(exports, 'convertToCapnpInfer', {
5087
- enumerable: true,
5088
- get: function () {
5089
- return convertToCapnpInfer;
5090
- }
5091
- });
5092
- Object.defineProperty(exports, 'convertToCapnpIntersection', {
5093
- enumerable: true,
5094
- get: function () {
5095
- return convertToCapnpIntersection;
5096
- }
5097
- });
5098
- Object.defineProperty(exports, 'convertToCapnpLiteral', {
5099
- enumerable: true,
5100
- get: function () {
5101
- return convertToCapnpLiteral;
5102
- }
5103
- });
5104
- Object.defineProperty(exports, 'convertToCapnpMethod', {
5105
- enumerable: true,
5106
- get: function () {
5107
- return convertToCapnpMethod;
5108
- }
5109
- });
5110
- Object.defineProperty(exports, 'convertToCapnpMethodSignature', {
5111
- enumerable: true,
5112
- get: function () {
5113
- return convertToCapnpMethodSignature;
5114
- }
5115
- });
5116
- Object.defineProperty(exports, 'convertToCapnpObjectLiteral', {
5117
- enumerable: true,
5118
- get: function () {
5119
- return convertToCapnpObjectLiteral;
5120
- }
5121
- });
5122
- Object.defineProperty(exports, 'convertToCapnpOther', {
5123
- enumerable: true,
5124
- get: function () {
5125
- return convertToCapnpOther;
5126
- }
5127
- });
5128
- Object.defineProperty(exports, 'convertToCapnpParameter', {
5129
- enumerable: true,
5130
- get: function () {
5131
- return convertToCapnpParameter;
5132
- }
5133
- });
5134
- Object.defineProperty(exports, 'convertToCapnpProperty', {
5135
- enumerable: true,
5136
- get: function () {
5137
- return convertToCapnpProperty;
5138
- }
5139
- });
5140
- Object.defineProperty(exports, 'convertToCapnpPropertySignature', {
5141
- enumerable: true,
5142
- get: function () {
5143
- return convertToCapnpPropertySignature;
5144
- }
5145
- });
5146
- Object.defineProperty(exports, 'convertToCapnpSimple', {
5147
- enumerable: true,
5148
- get: function () {
5149
- return convertToCapnpSimple;
5150
- }
5151
- });
5152
- Object.defineProperty(exports, 'convertToCapnpTagsReflection', {
5153
- enumerable: true,
5154
- get: function () {
5155
- return convertToCapnpTagsReflection;
5156
- }
5157
- });
5158
- Object.defineProperty(exports, 'convertToCapnpTuple', {
5159
- enumerable: true,
5160
- get: function () {
5161
- return convertToCapnpTuple;
5162
- }
5163
- });
5164
- Object.defineProperty(exports, 'convertToCapnpTupleMember', {
5165
- enumerable: true,
5166
- get: function () {
5167
- return convertToCapnpTupleMember;
5168
- }
5169
- });
5170
- Object.defineProperty(exports, 'convertToCapnpUnion', {
5171
- enumerable: true,
5172
- get: function () {
5173
- return convertToCapnpUnion;
5174
- }
5175
- });
3998
+ exports.ReflectionVisibility = ReflectionVisibility;