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