@powerlines/plugin-nodejs 0.1.0 → 0.1.2
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.
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/components/env.cjs +188 -2
- package/dist/components/env.d.cts +9 -2
- package/dist/components/env.d.mts +9 -2
- package/dist/components/env.mjs +185 -1
- package/dist/components/index.cjs +2 -3
- package/dist/components/index.d.cts +1 -3
- package/dist/components/index.d.mts +1 -3
- package/dist/components/index.mjs +1 -2
- package/dist/deepkit/schemas/reflection.cjs +3940 -0
- package/dist/{plugin-D7kBf19k.d.cts → deepkit/schemas/reflection.d.cts} +1 -1078
- package/dist/{plugin-JL1BtFku.d.mts → deepkit/schemas/reflection.d.mts} +59 -1136
- package/dist/deepkit/schemas/reflection.mjs +3938 -0
- package/dist/deepkit/schemas/reflection2.cjs +4112 -0
- package/dist/deepkit/schemas/reflection2.mjs +4110 -0
- package/dist/deepkit/src/capnp.cjs +913 -0
- package/dist/deepkit/src/capnp.mjs +911 -0
- package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
- package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
- package/dist/deepkit/src/reflect-type.cjs +22 -0
- package/dist/deepkit/src/reflect-type.mjs +20 -0
- package/dist/deepkit/src/resolve-reflections.cjs +16 -0
- package/dist/deepkit/src/resolve-reflections.mjs +15 -0
- package/dist/deepkit/src/transformer.cjs +52 -0
- package/dist/deepkit/src/transformer.mjs +49 -0
- package/dist/deepkit/src/transpile.cjs +29 -0
- package/dist/deepkit/src/transpile.mjs +27 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/utilities.cjs +66 -0
- package/dist/deepkit/src/utilities.mjs +65 -0
- package/dist/index.cjs +14 -813
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +11 -803
- package/dist/plugin-alloy/src/core/components/output.cjs +45 -0
- package/dist/plugin-alloy/src/core/components/output.mjs +44 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +22 -0
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +21 -0
- package/dist/plugin-alloy/src/core/components/source-file.cjs +64 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.cts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.d.mts +23 -0
- package/dist/plugin-alloy/src/core/components/source-file.mjs +62 -0
- package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
- package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
- package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
- package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
- package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
- package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
- package/dist/plugin-alloy/src/index.cjs +99 -0
- package/dist/plugin-alloy/src/index.mjs +97 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
- package/dist/plugin-alloy/src/types/components.d.cts +23 -0
- package/dist/plugin-alloy/src/types/components.d.mts +24 -0
- package/dist/plugin-alloy/src/types/index.d.cts +2 -0
- package/dist/plugin-alloy/src/types/index.d.mts +2 -0
- package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
- package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +57 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.cts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.d.mts +26 -0
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +56 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +126 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +442 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.cts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.d.mts +28 -0
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +433 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +194 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.cts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.d.mts +15 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +191 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +68 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.cts +4 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.d.mts +4 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +67 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +124 -0
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +123 -0
- package/dist/plugin-automd/src/index.cjs +101 -0
- package/dist/plugin-automd/src/index.mjs +98 -0
- package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
- package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
- package/dist/plugin-automd/src/types/toc.d.cts +33 -0
- package/dist/plugin-automd/src/types/toc.d.mts +33 -0
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
- package/dist/plugin-babel/src/helpers/index.cjs +5 -0
- package/dist/plugin-babel/src/helpers/index.mjs +7 -0
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
- package/dist/plugin-babel/src/helpers/options.cjs +50 -0
- package/dist/plugin-babel/src/helpers/options.mjs +47 -0
- package/dist/plugin-babel/src/index.cjs +91 -0
- package/dist/plugin-babel/src/index.mjs +89 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
- package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
- package/dist/plugin-env/src/babel/index.cjs +1 -0
- package/dist/plugin-env/src/babel/index.mjs +3 -0
- package/dist/plugin-env/src/babel/plugin.cjs +121 -0
- package/dist/plugin-env/src/babel/plugin.mjs +119 -0
- package/dist/plugin-env/src/components/docs.cjs +9 -0
- package/dist/plugin-env/src/components/docs.mjs +11 -0
- package/dist/plugin-env/src/components/env.cjs +575 -0
- package/dist/plugin-env/src/components/env.d.cts +11 -0
- package/dist/plugin-env/src/components/env.d.mts +11 -0
- package/dist/plugin-env/src/components/env.mjs +572 -0
- package/dist/plugin-env/src/components/index.cjs +2 -0
- package/dist/plugin-env/src/components/index.mjs +4 -0
- package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
- package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
- package/dist/plugin-env/src/helpers/index.cjs +6 -0
- package/dist/plugin-env/src/helpers/index.mjs +8 -0
- package/dist/plugin-env/src/helpers/load.cjs +83 -0
- package/dist/plugin-env/src/helpers/load.mjs +80 -0
- package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
- package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
- package/dist/plugin-env/src/helpers/reflect.cjs +111 -0
- package/dist/plugin-env/src/helpers/reflect.mjs +103 -0
- package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
- package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
- package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
- package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
- package/dist/plugin-env/src/index.cjs +175 -0
- package/dist/plugin-env/src/index.mjs +173 -0
- package/dist/plugin-env/src/types/plugin.d.cts +152 -0
- package/dist/plugin-env/src/types/plugin.d.mts +153 -0
- package/dist/plugin-env/src/types/runtime.d.cts +792 -0
- package/dist/plugin-env/src/types/runtime.d.mts +792 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
- package/dist/powerlines/src/lib/entry.cjs +12 -0
- package/dist/powerlines/src/lib/entry.mjs +14 -0
- package/dist/powerlines/src/lib/logger.cjs +41 -0
- package/dist/powerlines/src/lib/logger.mjs +39 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +38 -0
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
- package/dist/powerlines/src/types/babel.d.cts +22 -0
- package/dist/powerlines/src/types/babel.d.mts +22 -0
- package/dist/powerlines/src/types/build.d.cts +145 -0
- package/dist/powerlines/src/types/build.d.mts +145 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +387 -0
- package/dist/powerlines/src/types/config.d.mts +388 -0
- package/dist/powerlines/src/types/context.d.cts +414 -0
- package/dist/powerlines/src/types/context.d.mts +416 -0
- package/dist/powerlines/src/types/fs.d.cts +486 -0
- package/dist/powerlines/src/types/fs.d.mts +486 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.d.cts +231 -0
- package/dist/powerlines/src/types/plugin.d.mts +231 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -3
- package/dist/types/index.d.mts +1 -3
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +22 -2
- package/dist/types/plugin.d.mts +22 -2
- package/dist/types/plugin.mjs +0 -2
- package/package.json +6 -6
- package/dist/components-BWLXb7a2.cjs +0 -0
- package/dist/components-CXZYcH4q.d.mts +0 -1816
- package/dist/components-kh0CpIG2.mjs +0 -1
- package/dist/env-CAhIy_H3.cjs +0 -11713
- package/dist/env-CUyFiniR.d.cts +0 -107
- package/dist/env-IF4XhMjG.mjs +0 -11570
- package/dist/env-sRb-Y8mJ.d.mts +0 -89
- package/dist/index-CUbWeWHc.d.mts +0 -1
- package/dist/index-D6CnpA_r.d.cts +0 -1
- package/dist/index-DL0uimUT.d.mts +0 -1
- package/dist/index-DWPDThxu.d.cts +0 -1
- package/dist/plugin-ifZVa20V.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/resolved-zsx09G03.d.cts +0 -1795
- package/dist/types-U3zd8PTP.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
import { ReflectionVisibility as ReflectionVisibility$1 } from "../schemas/reflection.mjs";
|
|
2
|
+
import { ReflectionKind, ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
|
|
3
|
+
import { isInteger, isSetObject, isUndefined } from "@stryke/type-checks";
|
|
4
|
+
|
|
5
|
+
//#region ../deepkit/src/capnp.ts
|
|
6
|
+
/**
|
|
7
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
8
|
+
*
|
|
9
|
+
* @param serializedTypes - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
10
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
11
|
+
*/
|
|
12
|
+
function convertToCapnp(serializedTypes, result) {
|
|
13
|
+
if (!serializedTypes || !Array.isArray(serializedTypes) || serializedTypes.length === 0) throw new Error("Invalid serialized type provided for conversion.");
|
|
14
|
+
if (serializedTypes.length !== result.length) throw new Error(`Mismatch in length of serialized types: expected ${result.length}, got ${serializedTypes.length}.`);
|
|
15
|
+
serializedTypes.filter((serializedType) => isSetObject(serializedType) && !isUndefined(serializedType.kind)).forEach((serializedType, index) => {
|
|
16
|
+
convertToCapnpBase(serializedType, result.get(index)._initType());
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
22
|
+
*
|
|
23
|
+
* @param serializedTypes - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema
|
|
24
|
+
* @returns The [Deepkit](https://deepkit.io/) {@link SerializedTypes | serialized types} converted from the Cap'n Proto serialized type
|
|
25
|
+
*/
|
|
26
|
+
function convertFromCapnp(serializedTypes) {
|
|
27
|
+
if (!serializedTypes) throw new Error("Invalid serialized type provided for conversion.");
|
|
28
|
+
const result = [];
|
|
29
|
+
serializedTypes.forEach((serializedType) => {
|
|
30
|
+
const deserializedType = convertFromCapnpBase(serializedType.type);
|
|
31
|
+
result.push(deserializedType);
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
37
|
+
*
|
|
38
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
39
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
40
|
+
*/
|
|
41
|
+
function convertToCapnpTagsReflection(result, serializedType) {
|
|
42
|
+
if (serializedType?.alias?.length) {
|
|
43
|
+
const alias = result._initAlias(serializedType.alias.length);
|
|
44
|
+
serializedType.alias.forEach((a, index) => {
|
|
45
|
+
alias.set(index, a);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
result.hidden = serializedType?.hidden ?? false;
|
|
49
|
+
result.ignore = serializedType?.ignore ?? false;
|
|
50
|
+
result.internal = serializedType?.internal ?? false;
|
|
51
|
+
result.readonly = serializedType?.readonly ?? false;
|
|
52
|
+
if (serializedType?.title) result.title = serializedType?.title;
|
|
53
|
+
if (serializedType?.domain) result.domain = serializedType?.domain;
|
|
54
|
+
if (serializedType?.permission?.length) {
|
|
55
|
+
const permission = result._initPermission(serializedType.permission.length);
|
|
56
|
+
serializedType.permission?.forEach((p, index) => {
|
|
57
|
+
permission.set(index, p);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function convertFromCapnpTagsReflection(serializedType) {
|
|
63
|
+
return serializedType._hasTags() ? {
|
|
64
|
+
alias: serializedType.tags?.alias?.length ? serializedType.tags?.alias.map((value) => value) : void 0,
|
|
65
|
+
hidden: serializedType.tags?.hidden,
|
|
66
|
+
domain: serializedType.tags?.domain ? serializedType.tags.domain : void 0,
|
|
67
|
+
title: serializedType.tags?.title ? serializedType.tags.title : void 0,
|
|
68
|
+
ignore: serializedType.tags?.ignore,
|
|
69
|
+
internal: serializedType.tags?.internal,
|
|
70
|
+
readonly: serializedType.tags?.readonly,
|
|
71
|
+
permission: serializedType.tags?.permission?.length ? serializedType.tags?.permission?.map((value) => value) : void 0
|
|
72
|
+
} : void 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
76
|
+
*
|
|
77
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
78
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
79
|
+
*/
|
|
80
|
+
function convertToCapnpIndexAccessOrigin(result, serializedType) {
|
|
81
|
+
const indexAccessOriginIndex = result._initIndex();
|
|
82
|
+
indexAccessOriginIndex.id = serializedType?.index ?? 0;
|
|
83
|
+
const indexAccessOriginContainer = result._initContainer();
|
|
84
|
+
indexAccessOriginContainer.id = serializedType?.container ?? 0;
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function convertFromCapnpIndexAccessOrigin(serializedType) {
|
|
88
|
+
return serializedType._hasIndexAccessOrigin() ? {
|
|
89
|
+
container: Number(serializedType.indexAccessOrigin?.container.id),
|
|
90
|
+
index: Number(serializedType.indexAccessOrigin?.index.id)
|
|
91
|
+
} : void 0;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
95
|
+
*
|
|
96
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
97
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
98
|
+
*/
|
|
99
|
+
function convertToCapnpBase(serializedType, result) {
|
|
100
|
+
if (serializedType.kind === ReflectionKind.objectLiteral) convertToCapnpObjectLiteral(serializedType, result._initObjectLiteral());
|
|
101
|
+
else if (serializedType.kind === ReflectionKind.class) convertToCapnpClassType(serializedType, result._initClassType());
|
|
102
|
+
else if (serializedType.kind === ReflectionKind.parameter) convertToCapnpParameter(serializedType, result._initParameter());
|
|
103
|
+
else if (serializedType.kind === ReflectionKind.function) convertToCapnpFunction(serializedType, result._initFunction());
|
|
104
|
+
else if (serializedType.kind === ReflectionKind.method) convertToCapnpMethod(serializedType, result._initMethod());
|
|
105
|
+
else if (serializedType.kind === ReflectionKind.infer) convertToCapnpInfer(serializedType, result._initInfer());
|
|
106
|
+
else if (serializedType.kind === ReflectionKind.union) convertToCapnpUnion(serializedType, result._initUnion());
|
|
107
|
+
else if (serializedType.kind === ReflectionKind.array) convertToCapnpArray(serializedType, result._initArray());
|
|
108
|
+
else if (serializedType.kind === ReflectionKind.intersection) convertToCapnpIntersection(serializedType, result._initIntersection());
|
|
109
|
+
else if (serializedType.kind === ReflectionKind.enum) convertToCapnpEnum(serializedType, result._initEnum());
|
|
110
|
+
else if (serializedType.kind === ReflectionKind.property) convertToCapnpProperty(serializedType, result._initProperty());
|
|
111
|
+
else if (serializedType.kind === ReflectionKind.tuple) convertToCapnpTuple(serializedType, result._initTuple());
|
|
112
|
+
else if (serializedType.kind === ReflectionKind.tupleMember) convertToCapnpTupleMember(serializedType, result._initTupleMember());
|
|
113
|
+
else if (serializedType.kind === ReflectionKind.propertySignature) convertToCapnpPropertySignature(serializedType, result._initPropertySignature());
|
|
114
|
+
else if (serializedType.kind === ReflectionKind.methodSignature) convertToCapnpMethodSignature(serializedType, result._initMethodSignature());
|
|
115
|
+
else if (serializedType.kind === ReflectionKind.literal) convertToCapnpLiteral(serializedType, result._initLiteral());
|
|
116
|
+
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());
|
|
117
|
+
else convertToCapnpOther(serializedType, result._initOther());
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
function convertFromCapnpBase(serializedType) {
|
|
121
|
+
if (serializedType._isObjectLiteral) return convertFromCapnpObjectLiteral(serializedType.objectLiteral);
|
|
122
|
+
else if (serializedType._isClassType) return convertFromCapnpClassType(serializedType.classType);
|
|
123
|
+
else if (serializedType._isParameter) return convertFromCapnpParameter(serializedType.parameter);
|
|
124
|
+
else if (serializedType._isFunction) return convertFromCapnpFunction(serializedType.function);
|
|
125
|
+
else if (serializedType._isInfer) return convertFromCapnpInfer(serializedType.infer);
|
|
126
|
+
else if (serializedType._isMethod) return convertFromCapnpMethod(serializedType.method);
|
|
127
|
+
else if (serializedType._isUnion) return convertFromCapnpUnion(serializedType.union);
|
|
128
|
+
else if (serializedType._isArray) return convertFromCapnpArray(serializedType.array);
|
|
129
|
+
else if (serializedType._isIntersection) return convertFromCapnpIntersection(serializedType.intersection);
|
|
130
|
+
else if (serializedType._isEnum) return convertFromCapnpEnum(serializedType.enum);
|
|
131
|
+
else if (serializedType._isProperty) return convertFromCapnpProperty(serializedType.property);
|
|
132
|
+
else if (serializedType._isTuple) return convertFromCapnpTuple(serializedType.tuple);
|
|
133
|
+
else if (serializedType._isTupleMember) return convertFromCapnpTupleMember(serializedType.tupleMember);
|
|
134
|
+
else if (serializedType._isPropertySignature) return convertFromCapnpPropertySignature(serializedType.propertySignature);
|
|
135
|
+
else if (serializedType._isMethodSignature) return convertFromCapnpMethodSignature(serializedType.methodSignature);
|
|
136
|
+
else if (serializedType._isLiteral) return convertFromCapnpLiteral(serializedType.literal);
|
|
137
|
+
else if (serializedType._isSimple) return convertFromCapnpSimple(serializedType.simple);
|
|
138
|
+
else if (serializedType._isOther) return convertFromCapnpOther(serializedType.other);
|
|
139
|
+
else throw new Error(`Unsupported serialized type kind: ${serializedType.toString()}`);
|
|
140
|
+
}
|
|
141
|
+
function convertFromCapnpOther(serializedType) {
|
|
142
|
+
return {
|
|
143
|
+
kind: serializedType.kind,
|
|
144
|
+
typeName: serializedType.typeName || void 0
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function convertFromCapnpSimple(serializedType) {
|
|
148
|
+
const result = {
|
|
149
|
+
kind: serializedType.kind,
|
|
150
|
+
typeName: serializedType.typeName || void 0,
|
|
151
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
152
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
153
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
154
|
+
};
|
|
155
|
+
if (serializedType._hasOrigin()) result.origin = Number(serializedType.origin.id);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
function convertToCapnpOther(serializedType, result) {
|
|
159
|
+
result.kind = serializedType.kind;
|
|
160
|
+
result.typeName = serializedType.typeName || "";
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
function convertToCapnpSimple(serializedType, result) {
|
|
164
|
+
result.kind = serializedType.kind;
|
|
165
|
+
result.typeName = serializedType.typeName || "";
|
|
166
|
+
if (serializedType.origin) {
|
|
167
|
+
result._initOrigin();
|
|
168
|
+
result.origin.id = serializedType.origin ?? 0;
|
|
169
|
+
}
|
|
170
|
+
if (serializedType.decorators?.length) {
|
|
171
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
172
|
+
serializedType.decorators.forEach((d, index) => {
|
|
173
|
+
const decorator = decorators.get(index);
|
|
174
|
+
decorator.id = d;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (serializedType.typeArguments?.length) {
|
|
178
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
179
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
180
|
+
const typeArgument = typeArguments.get(index);
|
|
181
|
+
typeArgument.id = t;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
function convertFromCapnpLiteral(serializedType) {
|
|
188
|
+
return {
|
|
189
|
+
kind: ReflectionKind.literal,
|
|
190
|
+
literal: serializedType.literal._isString ? serializedType.literal.string : serializedType.literal._isNumber ? serializedType.literal.number : serializedType.literal._isBoolean ? serializedType.literal.boolean : serializedType.literal._isBigint ? {
|
|
191
|
+
type: "bigint",
|
|
192
|
+
value: serializedType.literal.bigint.value
|
|
193
|
+
} : serializedType.literal._isSymbol ? {
|
|
194
|
+
type: "symbol",
|
|
195
|
+
name: serializedType.literal.symbol.name
|
|
196
|
+
} : {
|
|
197
|
+
type: "regex",
|
|
198
|
+
regex: serializedType.literal.regex.regex
|
|
199
|
+
},
|
|
200
|
+
typeName: serializedType.typeName || void 0,
|
|
201
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
202
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
203
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function convertToCapnpLiteral(serializedType, result) {
|
|
207
|
+
result.kind = serializedType.kind;
|
|
208
|
+
result.typeName = serializedType.typeName || "";
|
|
209
|
+
const literalType = result._initLiteral();
|
|
210
|
+
if (typeof serializedType.literal === "boolean") literalType.boolean = serializedType.literal;
|
|
211
|
+
else if (typeof serializedType.literal === "number") literalType.number = serializedType.literal;
|
|
212
|
+
else if (typeof serializedType.literal === "string") literalType.string = serializedType.literal;
|
|
213
|
+
else if (serializedType.literal.type === "bigint") {
|
|
214
|
+
const literalTypeBigint = literalType._initBigint();
|
|
215
|
+
literalTypeBigint.type = "bigint";
|
|
216
|
+
literalTypeBigint.value = serializedType.literal.value;
|
|
217
|
+
} else if (serializedType.literal.type === "symbol") {
|
|
218
|
+
const literalTypeSymbol = literalType._initSymbol();
|
|
219
|
+
literalTypeSymbol.type = "symbol";
|
|
220
|
+
literalTypeSymbol.name = serializedType.literal.name.toString().slice(7, -1);
|
|
221
|
+
} else if (serializedType.literal.type === "regex") {
|
|
222
|
+
const literalTypeRegex = literalType._initRegex();
|
|
223
|
+
literalTypeRegex.type = "regex";
|
|
224
|
+
literalTypeRegex.regex = serializedType.literal.regex;
|
|
225
|
+
}
|
|
226
|
+
if (serializedType.decorators?.length) {
|
|
227
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
228
|
+
serializedType.decorators.forEach((d, index) => {
|
|
229
|
+
const decorator = decorators.get(index);
|
|
230
|
+
decorator.id = d;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (serializedType.typeArguments?.length) {
|
|
234
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
235
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
236
|
+
const typeArgument = typeArguments.get(index);
|
|
237
|
+
typeArgument.id = t;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
function convertFromCapnpMethodSignature(serializedType) {
|
|
244
|
+
return {
|
|
245
|
+
kind: ReflectionKind.methodSignature,
|
|
246
|
+
name: serializedType.name,
|
|
247
|
+
typeName: serializedType.typeName || void 0,
|
|
248
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
249
|
+
parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
|
|
250
|
+
return: serializedType.return.id,
|
|
251
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function convertToCapnpMethodSignature(serializedType, result) {
|
|
255
|
+
result.kind = serializedType.kind;
|
|
256
|
+
result.name = String(serializedType.name);
|
|
257
|
+
result.typeName = serializedType.typeName || "";
|
|
258
|
+
if (serializedType.decorators?.length) {
|
|
259
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
260
|
+
serializedType.decorators.forEach((d, index) => {
|
|
261
|
+
const decorator = decorators.get(index);
|
|
262
|
+
decorator.id = d;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
if (serializedType.typeArguments?.length) {
|
|
266
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
267
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
268
|
+
const typeArgument = typeArguments.get(index);
|
|
269
|
+
typeArgument.id = t;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
273
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
function convertFromCapnpPropertySignature(serializedType) {
|
|
277
|
+
return {
|
|
278
|
+
kind: ReflectionKind.propertySignature,
|
|
279
|
+
name: serializedType.name,
|
|
280
|
+
typeName: serializedType.typeName || void 0,
|
|
281
|
+
description: serializedType.description,
|
|
282
|
+
default: convertFromCapnpDefault(serializedType.default),
|
|
283
|
+
optional: serializedType.optional ? true : void 0,
|
|
284
|
+
readonly: serializedType.readonly ? true : void 0,
|
|
285
|
+
type: serializedType.type.id,
|
|
286
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
287
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
288
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
289
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function convertToCapnpDefault(defaultValue, result) {
|
|
293
|
+
if (typeof defaultValue !== "undefined" && defaultValue !== "") {
|
|
294
|
+
result._initValue();
|
|
295
|
+
if (typeof defaultValue === "string") result.value.string = defaultValue;
|
|
296
|
+
else if (typeof defaultValue === "number") if (isInteger(defaultValue)) result.value.integer = defaultValue;
|
|
297
|
+
else result.value.float = defaultValue;
|
|
298
|
+
else if (typeof defaultValue === "boolean") result.value.boolean = defaultValue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function convertFromCapnpDefault(serializedType) {
|
|
302
|
+
if (typeof serializedType.value === "undefined") return;
|
|
303
|
+
else if (serializedType.value._isBoolean) return serializedType.value.boolean;
|
|
304
|
+
else if (serializedType.value._isInteger) return serializedType.value.integer;
|
|
305
|
+
else if (serializedType.value._isFloat) return serializedType.value.float;
|
|
306
|
+
else if (serializedType.value._isString) return serializedType.value.string;
|
|
307
|
+
}
|
|
308
|
+
function convertToCapnpPropertySignature(serializedType, result) {
|
|
309
|
+
result.kind = serializedType.kind;
|
|
310
|
+
result.name = String(serializedType.name) || "";
|
|
311
|
+
result.typeName = serializedType.typeName || "";
|
|
312
|
+
result.description = serializedType.description || "";
|
|
313
|
+
result.optional = serializedType.optional ?? false;
|
|
314
|
+
result.readonly = serializedType.readonly ?? false;
|
|
315
|
+
if (typeof serializedType.default !== "undefined") {
|
|
316
|
+
const defaultValue = result._initDefault();
|
|
317
|
+
convertToCapnpDefault(serializedType.default, defaultValue);
|
|
318
|
+
}
|
|
319
|
+
const type = result._initType();
|
|
320
|
+
type.id = serializedType.type;
|
|
321
|
+
if (serializedType.decorators?.length) {
|
|
322
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
323
|
+
serializedType.decorators.forEach((d, index) => {
|
|
324
|
+
const decorator = decorators.get(index);
|
|
325
|
+
decorator.id = d;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (serializedType.typeArguments?.length) {
|
|
329
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
330
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
331
|
+
const typeArgument = typeArguments.get(index);
|
|
332
|
+
typeArgument.id = t;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
336
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
function convertToCapnpTupleMember(serializedType, result) {
|
|
340
|
+
result.kind = serializedType.kind;
|
|
341
|
+
result.typeName = serializedType.typeName || "";
|
|
342
|
+
const type = result._initType();
|
|
343
|
+
type.id = serializedType.type;
|
|
344
|
+
if (serializedType.decorators?.length) {
|
|
345
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
346
|
+
serializedType.decorators.forEach((d, index) => {
|
|
347
|
+
const decorator = decorators.get(index);
|
|
348
|
+
decorator.id = d;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
if (serializedType.typeArguments?.length) {
|
|
352
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
353
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
354
|
+
const typeArgument = typeArguments.get(index);
|
|
355
|
+
typeArgument.id = t;
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
function convertFromCapnpTupleMember(serializedType) {
|
|
362
|
+
return {
|
|
363
|
+
kind: ReflectionKind.tupleMember,
|
|
364
|
+
type: serializedType.type.id,
|
|
365
|
+
typeName: serializedType.typeName || void 0,
|
|
366
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
367
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
368
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function convertToCapnpTuple(serializedType, result) {
|
|
372
|
+
result.kind = serializedType.kind;
|
|
373
|
+
result.typeName = serializedType.typeName || "";
|
|
374
|
+
const types = result._initTypes(serializedType.types.length);
|
|
375
|
+
serializedType.types.forEach((t, index) => {
|
|
376
|
+
convertToCapnpTupleMember(t, types.get(index));
|
|
377
|
+
});
|
|
378
|
+
if (serializedType.decorators?.length) {
|
|
379
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
380
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
381
|
+
const decorator = decorators.get(index);
|
|
382
|
+
decorator.id = d;
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (serializedType.typeArguments?.length) {
|
|
386
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
387
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
388
|
+
const typeArgument = typeArguments.get(index);
|
|
389
|
+
typeArgument.id = t;
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
function convertFromCapnpTuple(serializedType) {
|
|
396
|
+
return {
|
|
397
|
+
kind: ReflectionKind.tuple,
|
|
398
|
+
typeName: serializedType.typeName || void 0,
|
|
399
|
+
types: serializedType._hasTypes() ? serializedType.types.map((t) => convertFromCapnpTupleMember(t)) : [],
|
|
400
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
401
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
402
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function convertToCapnpProperty(serializedType, result) {
|
|
406
|
+
result.kind = serializedType.kind;
|
|
407
|
+
result.typeName = serializedType.typeName || "";
|
|
408
|
+
result.description = serializedType.description || "";
|
|
409
|
+
result.optional = serializedType.optional ?? false;
|
|
410
|
+
result.readonly = serializedType.readonly ?? false;
|
|
411
|
+
result.visibility = serializedType.visibility === ReflectionVisibility.public ? ReflectionVisibility$1.PUBLIC : serializedType.visibility === ReflectionVisibility.protected ? ReflectionVisibility$1.PROTECTED : ReflectionVisibility$1.PRIVATE;
|
|
412
|
+
result.abstract = serializedType.abstract ?? false;
|
|
413
|
+
result.name = String(serializedType.name) || "";
|
|
414
|
+
if (typeof serializedType.default !== "undefined") {
|
|
415
|
+
const defaultValue = result._initDefault();
|
|
416
|
+
convertToCapnpDefault(serializedType.default, defaultValue);
|
|
417
|
+
}
|
|
418
|
+
const type = result._initType();
|
|
419
|
+
type.id = serializedType.type;
|
|
420
|
+
if (serializedType.decorators?.length) {
|
|
421
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
422
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
423
|
+
const decorator = decorators.get(index);
|
|
424
|
+
decorator.id = d;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
if (serializedType.typeArguments?.length) {
|
|
428
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
429
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
430
|
+
const typeArgument = typeArguments.get(index);
|
|
431
|
+
typeArgument.id = t;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
435
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
function convertFromCapnpProperty(serializedType) {
|
|
439
|
+
return {
|
|
440
|
+
kind: ReflectionKind.property,
|
|
441
|
+
typeName: serializedType.typeName || void 0,
|
|
442
|
+
description: serializedType.description,
|
|
443
|
+
default: convertFromCapnpDefault(serializedType.default),
|
|
444
|
+
optional: serializedType.optional ? true : void 0,
|
|
445
|
+
readonly: serializedType.readonly ? true : void 0,
|
|
446
|
+
visibility: serializedType.visibility === ReflectionVisibility$1.PUBLIC ? ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility$1.PROTECTED ? ReflectionVisibility.protected : ReflectionVisibility.private,
|
|
447
|
+
abstract: serializedType.abstract ? true : void 0,
|
|
448
|
+
name: serializedType.name,
|
|
449
|
+
type: serializedType.type.id,
|
|
450
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
451
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
452
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
453
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function convertToCapnpEnum(serializedType, result) {
|
|
457
|
+
result.kind = serializedType.kind;
|
|
458
|
+
result.typeName = serializedType.typeName || "";
|
|
459
|
+
const indexType = result._initIndexType();
|
|
460
|
+
indexType.id = serializedType.indexType;
|
|
461
|
+
if (serializedType.decorators?.length) {
|
|
462
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
463
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
464
|
+
const decorator = decorators.get(index);
|
|
465
|
+
decorator.id = d;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
if (serializedType.typeArguments?.length) {
|
|
469
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
470
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
471
|
+
const typeArgument = typeArguments.get(index);
|
|
472
|
+
typeArgument.id = t;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
476
|
+
if (serializedType.values?.length) {
|
|
477
|
+
const values = result._initValues(serializedType.values?.length);
|
|
478
|
+
serializedType.values.forEach((value, index) => {
|
|
479
|
+
values.set(index, String(value));
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
const enumEntries = result._initEnumEntries(Object.keys(serializedType.enum).length ?? 0);
|
|
483
|
+
Object.entries(serializedType.enum).forEach(([key, value], index) => {
|
|
484
|
+
const enumEntry = enumEntries.get(index);
|
|
485
|
+
enumEntry.name = key;
|
|
486
|
+
enumEntry.value = String(value);
|
|
487
|
+
});
|
|
488
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
function convertFromCapnpEnum(serializedType) {
|
|
492
|
+
return {
|
|
493
|
+
kind: ReflectionKind.enum,
|
|
494
|
+
typeName: serializedType.typeName || void 0,
|
|
495
|
+
indexType: serializedType.indexType.id,
|
|
496
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
497
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
498
|
+
values: serializedType._hasValues() ? serializedType.values.map((value) => value) : [],
|
|
499
|
+
enum: serializedType._hasEnumEntries() ? Object.entries(serializedType.enumEntries).reduce((ret, [key, value]) => {
|
|
500
|
+
ret[key] = value.value;
|
|
501
|
+
return ret;
|
|
502
|
+
}, {}) : {},
|
|
503
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
504
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function convertToCapnpIntersection(serializedType, result) {
|
|
508
|
+
result.kind = serializedType.kind;
|
|
509
|
+
result.typeName = serializedType.typeName || "";
|
|
510
|
+
const types = result._initTypes(serializedType.types?.length ?? 0);
|
|
511
|
+
serializedType.types?.forEach((t, index) => {
|
|
512
|
+
const serializedTypeType = types.get(index);
|
|
513
|
+
serializedTypeType.id = t;
|
|
514
|
+
});
|
|
515
|
+
if (serializedType.decorators?.length) {
|
|
516
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
517
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
518
|
+
const decorator = decorators.get(index);
|
|
519
|
+
decorator.id = d;
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
if (serializedType.typeArguments?.length) {
|
|
523
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
524
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
525
|
+
const typeArgument = typeArguments.get(index);
|
|
526
|
+
typeArgument.id = t;
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
function convertFromCapnpIntersection(serializedType) {
|
|
533
|
+
return {
|
|
534
|
+
kind: ReflectionKind.intersection,
|
|
535
|
+
typeName: serializedType.typeName || void 0,
|
|
536
|
+
types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
|
|
537
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
538
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
539
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function convertToCapnpArray(serializedType, result) {
|
|
543
|
+
result.kind = serializedType.kind;
|
|
544
|
+
result.typeName = serializedType.typeName || "";
|
|
545
|
+
const type = result._initType();
|
|
546
|
+
type.id = serializedType.type;
|
|
547
|
+
if (serializedType.decorators?.length) {
|
|
548
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
549
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
550
|
+
const decorator = decorators.get(index);
|
|
551
|
+
decorator.id = d;
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
if (serializedType.typeArguments?.length) {
|
|
555
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
556
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
557
|
+
const typeArgument = typeArguments.get(index);
|
|
558
|
+
typeArgument.id = t;
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
562
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
563
|
+
return result;
|
|
564
|
+
}
|
|
565
|
+
function convertFromCapnpArray(serializedType) {
|
|
566
|
+
return {
|
|
567
|
+
kind: ReflectionKind.array,
|
|
568
|
+
typeName: serializedType.typeName || void 0,
|
|
569
|
+
type: serializedType.type.id,
|
|
570
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
571
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
572
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
573
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
578
|
+
*
|
|
579
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
580
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
581
|
+
*/
|
|
582
|
+
function convertToCapnpUnion(serializedType, result) {
|
|
583
|
+
result.kind = serializedType.kind;
|
|
584
|
+
result.typeName = serializedType.typeName || "";
|
|
585
|
+
const types = result._initTypes(serializedType.types?.length ?? 0);
|
|
586
|
+
serializedType.types?.forEach((t, index) => {
|
|
587
|
+
const serializedTypeType = types.get(index);
|
|
588
|
+
serializedTypeType.id = t;
|
|
589
|
+
});
|
|
590
|
+
if (serializedType.decorators?.length) {
|
|
591
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
592
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
593
|
+
const decorator = decorators.get(index);
|
|
594
|
+
decorator.id = d;
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
if (serializedType.typeArguments?.length) {
|
|
598
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
599
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
600
|
+
const typeArgument = typeArguments.get(index);
|
|
601
|
+
typeArgument.id = t;
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
function convertFromCapnpUnion(serializedType) {
|
|
608
|
+
return {
|
|
609
|
+
kind: ReflectionKind.union,
|
|
610
|
+
typeName: serializedType.typeName || void 0,
|
|
611
|
+
types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
|
|
612
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
613
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
614
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
619
|
+
*
|
|
620
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert.
|
|
621
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
622
|
+
*/
|
|
623
|
+
function convertToCapnpInfer(serializedType, result) {
|
|
624
|
+
result.kind = serializedType.kind;
|
|
625
|
+
result.typeName = serializedType.typeName || "";
|
|
626
|
+
if (serializedType.decorators?.length) {
|
|
627
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
628
|
+
serializedType.decorators?.forEach((d, index) => {
|
|
629
|
+
const decorator = decorators.get(index);
|
|
630
|
+
decorator.id = d;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
if (serializedType.typeArguments?.length) {
|
|
634
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments?.length ?? 0);
|
|
635
|
+
serializedType.typeArguments?.forEach((t, index) => {
|
|
636
|
+
const typeArgument = typeArguments.get(index);
|
|
637
|
+
typeArgument.id = t;
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
641
|
+
return result;
|
|
642
|
+
}
|
|
643
|
+
function convertFromCapnpInfer(serializedType) {
|
|
644
|
+
return {
|
|
645
|
+
kind: ReflectionKind.infer,
|
|
646
|
+
typeName: serializedType.typeName || void 0,
|
|
647
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
648
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
649
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
654
|
+
*
|
|
655
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
656
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
657
|
+
*/
|
|
658
|
+
function convertToCapnpFunction(serializedType, result) {
|
|
659
|
+
result.name = String(serializedType.name) || "";
|
|
660
|
+
result.kind = serializedType.kind;
|
|
661
|
+
result.typeName = serializedType.typeName || "";
|
|
662
|
+
if (serializedType.decorators?.length) {
|
|
663
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
664
|
+
serializedType.decorators.forEach((d, index) => {
|
|
665
|
+
const decorator = decorators.get(index);
|
|
666
|
+
decorator.id = d;
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
if (serializedType.typeArguments?.length) {
|
|
670
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
671
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
672
|
+
const typeArgument = typeArguments.get(index);
|
|
673
|
+
typeArgument.id = t;
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
if (serializedType.parameters?.length) {
|
|
677
|
+
const parameters = result._initParameters(serializedType.parameters.length);
|
|
678
|
+
serializedType.parameters.forEach((p, index) => {
|
|
679
|
+
convertToCapnpParameter(p, parameters.get(index));
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const returnType = result._initReturn();
|
|
683
|
+
returnType.id = serializedType.return;
|
|
684
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
685
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
690
|
+
*
|
|
691
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
692
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
693
|
+
*/
|
|
694
|
+
function convertToCapnpMethod(serializedType, result) {
|
|
695
|
+
result.name = String(serializedType.name) || "";
|
|
696
|
+
result.kind = serializedType.kind;
|
|
697
|
+
result.typeName = serializedType.typeName || "";
|
|
698
|
+
result.abstract = serializedType.abstract ?? false;
|
|
699
|
+
result.visibility = serializedType.visibility === ReflectionVisibility.public ? ReflectionVisibility$1.PUBLIC : serializedType.visibility === ReflectionVisibility.protected ? ReflectionVisibility$1.PROTECTED : ReflectionVisibility$1.PRIVATE;
|
|
700
|
+
if (serializedType.decorators?.length) {
|
|
701
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
702
|
+
serializedType.decorators.forEach((d, index) => {
|
|
703
|
+
const decorator = decorators.get(index);
|
|
704
|
+
decorator.id = d;
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
if (serializedType.typeArguments?.length) {
|
|
708
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
709
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
710
|
+
const typeArgument = typeArguments.get(index);
|
|
711
|
+
typeArgument.id = t;
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
if (serializedType.parameters?.length) {
|
|
715
|
+
const parameters = result._initParameters(serializedType.parameters.length);
|
|
716
|
+
serializedType.parameters.forEach((p, index) => {
|
|
717
|
+
convertToCapnpParameter(p, parameters.get(index));
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
const returnType = result._initReturn();
|
|
721
|
+
returnType.id = serializedType.return;
|
|
722
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
723
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
726
|
+
function convertFromCapnpFunction(serializedType) {
|
|
727
|
+
return {
|
|
728
|
+
kind: ReflectionKind.function,
|
|
729
|
+
name: serializedType.name,
|
|
730
|
+
typeName: serializedType.typeName || void 0,
|
|
731
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
732
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
733
|
+
parameters: serializedType._hasParameters() ? serializedType.parameters.map((p) => convertFromCapnpParameter(p)) : [],
|
|
734
|
+
return: serializedType.return.id,
|
|
735
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
736
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function convertFromCapnpMethod(serializedType) {
|
|
740
|
+
return {
|
|
741
|
+
kind: ReflectionKind.method,
|
|
742
|
+
name: serializedType.name,
|
|
743
|
+
typeName: serializedType.typeName || void 0,
|
|
744
|
+
abstract: serializedType.abstract ? true : void 0,
|
|
745
|
+
return: serializedType.return.id,
|
|
746
|
+
visibility: serializedType.visibility === ReflectionVisibility$1.PUBLIC ? ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility$1.PROTECTED ? ReflectionVisibility.protected : ReflectionVisibility.private,
|
|
747
|
+
parameters: serializedType._hasParameters() ? serializedType.parameters.map((parameter) => convertFromCapnpParameter(parameter)) : []
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
752
|
+
*
|
|
753
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
754
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
755
|
+
*/
|
|
756
|
+
function convertToCapnpClassType(serializedType, result) {
|
|
757
|
+
result.kind = serializedType.kind;
|
|
758
|
+
result.typeName = serializedType.typeName || "";
|
|
759
|
+
result.classType = serializedType.classType || "";
|
|
760
|
+
result.globalObject = serializedType.globalObject ?? false;
|
|
761
|
+
if (serializedType.arguments?.length) {
|
|
762
|
+
const _arguments = result._initArguments(serializedType.arguments.length);
|
|
763
|
+
serializedType.arguments.forEach((t, index) => {
|
|
764
|
+
const serializedTypeArguments = _arguments.get(index);
|
|
765
|
+
serializedTypeArguments.id = t;
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
if (serializedType.extendsArguments?.length) {
|
|
769
|
+
const extendsArguments = result._initArguments(serializedType.extendsArguments.length);
|
|
770
|
+
serializedType.extendsArguments.forEach((t, index) => {
|
|
771
|
+
const serializedTypeExtendsArguments = extendsArguments.get(index);
|
|
772
|
+
serializedTypeExtendsArguments.id = t;
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
if (serializedType.decorators?.length) {
|
|
776
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
777
|
+
serializedType.decorators.forEach((d, index) => {
|
|
778
|
+
const decorator = decorators.get(index);
|
|
779
|
+
decorator.id = d;
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
if (serializedType.typeArguments?.length) {
|
|
783
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
784
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
785
|
+
const typeArgument = typeArguments.get(index);
|
|
786
|
+
typeArgument.id = t;
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
if (serializedType.superClass) {
|
|
790
|
+
const superClass = result._initSuperClass();
|
|
791
|
+
superClass.id = serializedType.superClass;
|
|
792
|
+
}
|
|
793
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
794
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
function convertFromCapnpClassType(serializedType) {
|
|
798
|
+
return {
|
|
799
|
+
kind: ReflectionKind.class,
|
|
800
|
+
typeName: serializedType.typeName || void 0,
|
|
801
|
+
classType: serializedType.classType,
|
|
802
|
+
globalObject: serializedType.globalObject ? true : void 0,
|
|
803
|
+
arguments: serializedType._hasArguments() ? serializedType.arguments.map((t) => t.id) : void 0,
|
|
804
|
+
extendsArguments: serializedType._hasExtendsArguments() ? serializedType.extendsArguments.map((t) => t.id) : void 0,
|
|
805
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
806
|
+
types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
|
|
807
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
808
|
+
superClass: serializedType._hasSuperClass() ? serializedType.superClass.id : void 0,
|
|
809
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
810
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
815
|
+
*
|
|
816
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
817
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
818
|
+
*/
|
|
819
|
+
function convertToCapnpObjectLiteral(serializedType, result) {
|
|
820
|
+
if (serializedType.decorators?.length) {
|
|
821
|
+
const decorators = result._initDecorators(serializedType.decorators?.length ?? 0);
|
|
822
|
+
serializedType.decorators.forEach((d, index) => {
|
|
823
|
+
const decorator = decorators.get(index);
|
|
824
|
+
decorator.id = d;
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
if (serializedType.types?.length) {
|
|
828
|
+
const types = result._initTypes(serializedType.types.length);
|
|
829
|
+
serializedType.types.forEach((t, index) => {
|
|
830
|
+
const serializedTypeType = types.get(index);
|
|
831
|
+
serializedTypeType.id = t;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
if (serializedType.typeArguments?.length) {
|
|
835
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
836
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
837
|
+
const serializedTypeTypeArguments = typeArguments.get(index);
|
|
838
|
+
serializedTypeTypeArguments.id = t;
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
842
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
843
|
+
return result;
|
|
844
|
+
}
|
|
845
|
+
function convertFromCapnpObjectLiteral(serializedType) {
|
|
846
|
+
return {
|
|
847
|
+
kind: ReflectionKind.objectLiteral,
|
|
848
|
+
typeName: serializedType.typeName || void 0,
|
|
849
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
850
|
+
types: serializedType._hasTypes() ? serializedType.types.map((t) => t.id) : [],
|
|
851
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
852
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
853
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Converts a Deepkit serialized type to a Cap'n Proto serialized type.
|
|
858
|
+
*
|
|
859
|
+
* @param serializedType - The [Deepkit](https://deepkit.io/) {@link SerializedType | serialized type} to convert
|
|
860
|
+
* @param result - The {@link capnp.List | list} object defined in a [Cap'n Proto](https://capnproto.org/) schema to write the converted type to
|
|
861
|
+
*/
|
|
862
|
+
function convertToCapnpParameter(serializedType, result) {
|
|
863
|
+
result.kind = serializedType.kind;
|
|
864
|
+
result.typeName = serializedType.typeName || "";
|
|
865
|
+
result.name = serializedType.name || "";
|
|
866
|
+
result.optional = serializedType.optional ?? false;
|
|
867
|
+
result.readonly = serializedType.readonly ?? false;
|
|
868
|
+
result.visibility = serializedType.visibility === ReflectionVisibility.public ? ReflectionVisibility$1.PUBLIC : serializedType.visibility === ReflectionVisibility.protected ? ReflectionVisibility$1.PROTECTED : ReflectionVisibility$1.PRIVATE;
|
|
869
|
+
if (typeof serializedType.default !== "undefined") {
|
|
870
|
+
const defaultValue = result._initDefault();
|
|
871
|
+
convertToCapnpDefault(serializedType.default, defaultValue);
|
|
872
|
+
}
|
|
873
|
+
const parameterType = result._initType();
|
|
874
|
+
parameterType.id = serializedType.type;
|
|
875
|
+
if (serializedType.decorators?.length) {
|
|
876
|
+
const decorators = result._initDecorators(serializedType.decorators.length);
|
|
877
|
+
serializedType.decorators.forEach((d, index) => {
|
|
878
|
+
const decorator = decorators.get(index);
|
|
879
|
+
decorator.id = d;
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
if (serializedType.typeArguments?.length) {
|
|
883
|
+
const typeArguments = result._initTypeArguments(serializedType.typeArguments.length);
|
|
884
|
+
serializedType.typeArguments.forEach((t, index) => {
|
|
885
|
+
const typeArgument = typeArguments.get(index);
|
|
886
|
+
typeArgument.id = t;
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
if (serializedType.indexAccessOrigin) convertToCapnpIndexAccessOrigin(result._initIndexAccessOrigin(), serializedType.indexAccessOrigin);
|
|
890
|
+
if (serializedType.tags) convertToCapnpTagsReflection(result._initTags(), serializedType.tags);
|
|
891
|
+
return result;
|
|
892
|
+
}
|
|
893
|
+
function convertFromCapnpParameter(serializedType) {
|
|
894
|
+
return {
|
|
895
|
+
kind: ReflectionKind.parameter,
|
|
896
|
+
typeName: serializedType.typeName || void 0,
|
|
897
|
+
name: serializedType.name,
|
|
898
|
+
default: convertFromCapnpDefault(serializedType.default),
|
|
899
|
+
optional: serializedType.optional ? true : void 0,
|
|
900
|
+
readonly: serializedType.readonly ? true : void 0,
|
|
901
|
+
visibility: serializedType.visibility === ReflectionVisibility$1.PUBLIC ? ReflectionVisibility.public : serializedType.visibility === ReflectionVisibility$1.PROTECTED ? ReflectionVisibility.protected : ReflectionVisibility.private,
|
|
902
|
+
type: serializedType.type.id,
|
|
903
|
+
decorators: serializedType._hasDecorators() ? serializedType.decorators.map((d) => d.id) : void 0,
|
|
904
|
+
typeArguments: serializedType._hasTypeArguments() ? serializedType.typeArguments.map((t) => t.id) : void 0,
|
|
905
|
+
indexAccessOrigin: convertFromCapnpIndexAccessOrigin(serializedType),
|
|
906
|
+
tags: convertFromCapnpTagsReflection(serializedType)
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
//#endregion
|
|
911
|
+
export { convertFromCapnp, convertToCapnp };
|